45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
"""问答路由记忆样本。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Optional
|
|
|
|
from sqlalchemy import BigInteger, ForeignKey, Integer, Text, UniqueConstraint, VARCHAR
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from .base import Base
|
|
from .types import JSONB
|
|
|
|
|
|
class QueryRouteMemory(Base):
|
|
__tablename__ = "query_route_memories"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
qa_record_id: Mapped[int] = mapped_column(
|
|
Integer,
|
|
ForeignKey("qa_records.id", ondelete="CASCADE"),
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
project_id: Mapped[Optional[int]] = mapped_column(BigInteger, nullable=True, index=True)
|
|
question_text: Mapped[str] = mapped_column(Text, nullable=False)
|
|
route_mode_predicted: Mapped[str] = mapped_column(VARCHAR(32), nullable=False, index=True)
|
|
route_mode_effective: Mapped[str] = mapped_column(VARCHAR(32), nullable=False, index=True)
|
|
decision_origin: Mapped[Optional[str]] = mapped_column(VARCHAR(64), nullable=True, index=True)
|
|
reply_contract: Mapped[Optional[Any]] = mapped_column(JSONB, nullable=True)
|
|
probe_snapshot: Mapped[Optional[Any]] = mapped_column(JSONB, nullable=True)
|
|
query_profile: Mapped[Optional[Any]] = mapped_column(JSONB, nullable=True)
|
|
feedback_outcome: Mapped[Optional[Any]] = mapped_column(JSONB, nullable=True)
|
|
question_embedding: Mapped[Optional[Any]] = mapped_column(JSONB, nullable=True)
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint(
|
|
"tenant_id",
|
|
"qa_record_id",
|
|
name="uq_query_route_memories_tenant_qa_record",
|
|
),
|
|
)
|
|
|
|
|
|
__all__ = ["QueryRouteMemory"]
|