mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-20 09:25:34 +00:00
Merge branch 'main' into 0.2.77
This commit is contained in:
commit
e64cea1caa
2 changed files with 48 additions and 1 deletions
|
|
@ -0,0 +1,36 @@
|
|||
"""modify_chat_history_add_project_id
|
||||
|
||||
Revision ID: eec7242b3a9b
|
||||
Revises: d74ab2a44600
|
||||
Create Date: 2025-10-15 14:46:47.904254
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "eec7242b3a9b"
|
||||
down_revision: Union[str, None] = "d74ab2a44600"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column("chat_history", sa.Column("project_id", sqlmodel.sql.sqltypes.AutoString(), nullable=True))
|
||||
op.create_index(op.f("ix_chat_history_project_id"), "chat_history", ["project_id"], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f("ix_chat_history_project_id"), table_name="chat_history")
|
||||
op.drop_column("chat_history", "project_id")
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -4,7 +4,7 @@ from typing import Optional
|
|||
from enum import IntEnum
|
||||
from sqlalchemy_utils import ChoiceType
|
||||
from app.model.abstract.model import AbstractModel, DefaultTimes
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, model_validator
|
||||
|
||||
|
||||
class ChatStatus(IntEnum):
|
||||
|
|
@ -16,6 +16,7 @@ class ChatHistory(AbstractModel, DefaultTimes, table=True):
|
|||
id: int = Field(default=None, primary_key=True)
|
||||
user_id: int = Field(index=True)
|
||||
task_id: str = Field(index=True, unique=True)
|
||||
project_id: str = Field(index=True, unique=False, nullable=True)
|
||||
question: str
|
||||
language: str
|
||||
model_platform: str
|
||||
|
|
@ -34,6 +35,7 @@ class ChatHistory(AbstractModel, DefaultTimes, table=True):
|
|||
|
||||
class ChatHistoryIn(BaseModel):
|
||||
task_id: str
|
||||
project_id: str | None = None
|
||||
user_id: int | None = None
|
||||
question: str
|
||||
language: str
|
||||
|
|
@ -54,6 +56,7 @@ class ChatHistoryIn(BaseModel):
|
|||
class ChatHistoryOut(BaseModel):
|
||||
id: int
|
||||
task_id: str
|
||||
project_id: str | None = None
|
||||
question: str
|
||||
language: str
|
||||
model_platform: str
|
||||
|
|
@ -68,9 +71,17 @@ class ChatHistoryOut(BaseModel):
|
|||
tokens: int
|
||||
status: int
|
||||
|
||||
@model_validator(mode="after")
|
||||
def fill_project_id_from_task_id(self):
|
||||
"""fill by task_id when project_id is None"""
|
||||
if self.project_id is None:
|
||||
self.project_id = self.task_id
|
||||
return self
|
||||
|
||||
|
||||
class ChatHistoryUpdate(BaseModel):
|
||||
project_name: str | None = None
|
||||
summary: str | None = None
|
||||
tokens: int | None = None
|
||||
status: int | None = None
|
||||
project_id: str | None = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue