46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
# [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, 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] |