Вроде работает
This commit is contained in:
46
backend/src/models/llm.py
Normal file
46
backend/src/models/llm.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# [DEF:backend.src.models.llm:Module]
|
||||
# @TIER: STANDARD
|
||||
# @SEMANTICS: llm, models, sqlalchemy, persistence
|
||||
# @PURPOSE: SQLAlchemy models for LLM provider configuration and validation results.
|
||||
# @LAYER: Domain
|
||||
# @RELATION: INHERITS_FROM -> backend.src.models.mapping.Base
|
||||
|
||||
from sqlalchemy import Column, String, Boolean, DateTime, JSON, Enum, Text
|
||||
from datetime import datetime
|
||||
import uuid
|
||||
from .mapping import Base
|
||||
|
||||
def generate_uuid():
|
||||
return str(uuid.uuid4())
|
||||
|
||||
# [DEF:LLMProvider:Class]
|
||||
# @PURPOSE: SQLAlchemy model for LLM provider configuration.
|
||||
class LLMProvider(Base):
|
||||
__tablename__ = "llm_providers"
|
||||
|
||||
id = Column(String, primary_key=True, default=generate_uuid)
|
||||
provider_type = Column(String, nullable=False) # openai, openrouter, kilo
|
||||
name = Column(String, nullable=False)
|
||||
base_url = Column(String, nullable=False)
|
||||
api_key = Column(String, nullable=False) # Should be encrypted
|
||||
default_model = Column(String, nullable=False)
|
||||
is_active = Column(Boolean, default=True)
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
# [/DEF:LLMProvider:Class]
|
||||
|
||||
# [DEF:ValidationRecord:Class]
|
||||
# @PURPOSE: SQLAlchemy model for dashboard validation history.
|
||||
class ValidationRecord(Base):
|
||||
__tablename__ = "llm_validation_results"
|
||||
|
||||
id = Column(String, primary_key=True, default=generate_uuid)
|
||||
dashboard_id = Column(String, nullable=False, index=True)
|
||||
timestamp = Column(DateTime, default=datetime.utcnow)
|
||||
status = Column(String, nullable=False) # PASS, WARN, FAIL
|
||||
screenshot_path = Column(String, nullable=True)
|
||||
issues = Column(JSON, nullable=False)
|
||||
summary = Column(Text, nullable=False)
|
||||
raw_response = Column(Text, nullable=True)
|
||||
# [/DEF:ValidationRecord:Class]
|
||||
|
||||
# [/DEF:backend.src.models.llm:Module]
|
||||
Reference in New Issue
Block a user