You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
# app/models.py
|
|
|
|
from sqlalchemy import Column, Integer, String, Text, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from .database import Base
|
|
|
|
class ToolModel(Base):
|
|
__tablename__ = "tools"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, unique=True, index=True, nullable=False)
|
|
description = Column(Text, nullable=False)
|
|
function_code = Column(Text, nullable=False) # Store function as code (for simplicity)
|
|
|
|
class QuestionModel(Base):
|
|
__tablename__ = "questions"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
query = Column(Text, nullable=False)
|
|
answer = Column(Text, nullable=False)
|
|
timestamp = Column(String, nullable=False)
|
|
|
|
class AnswerModel(Base):
|
|
__tablename__ = "answers"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
question_id = Column(Integer, ForeignKey("questions.id"))
|
|
content = Column(Text, nullable=False)
|
|
timestamp = Column(String, nullable=False)
|
|
|
|
question = relationship("QuestionModel", back_populates="answers")
|
|
|
|
QuestionModel.answers = relationship("AnswerModel", back_populates="question")
|