llm_model.py 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. from datetime import datetime
  2. from enum import IntEnum
  3. from typing import Optional
  4. from sqlalchemy import Column, Integer, String, DateTime, Enum, Index, Table, ForeignKey
  5. from pydantic import BaseModel
  6. from sqlalchemy.orm import relationship, backref
  7. from app.models.base_model import Base
  8. class CommonLlmModel(Base):
  9. __tablename__ = 'common_llm'
  10. __mapper_args__ = {
  11. # "order_by": 'SEQ'
  12. }
  13. id = Column(String(36), primary_key=True, nullable=False)
  14. llm_factory = Column(String(128), nullable=False)
  15. model_type = Column(String(128), nullable=False)
  16. llm_name = Column(String(128), nullable=False)
  17. api_key = Column(String(1024), nullable=True)
  18. api_base = Column(String(255), nullable=True)
  19. def to_json(self):
  20. json = {
  21. 'id': self.ID,
  22. 'llm_factory': self.llm_factory,
  23. 'model_type': self.model_type,
  24. 'llm_name': self.llm_name,
  25. 'api_key': self.api_key,
  26. 'api_base': self.api_base,
  27. }
  28. return json