wip: 客服Agent + RAG + 画像收尾(基于 6516ccb)

This commit is contained in:
2026-09-11 14:46:40 +08:00
parent 870fd0d44e
commit e4c4099aaa
82 changed files with 13901 additions and 2426 deletions
+56
View File
@@ -0,0 +1,56 @@
"""知识库表的 ORM 映射。
按 docs/00 基线与 docs/02 建表设计逐列对齐现库;milvus_collection 是基线自带字段,
不需要新增迁移。本模块只做映射,读写由 Repository/Service 负责。
"""
from datetime import date, datetime
from typing import Any
from sqlalchemy import JSON, BigInteger, Date, DateTime, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.model.base import Base
class KnowledgeMeta(Base):
__tablename__ = "fin_knowledge_meta"
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
knowledge_type: Mapped[str] = mapped_column(String(32), nullable=False)
title: Mapped[str] = mapped_column(String(256), nullable=False)
source_file: Mapped[str | None] = mapped_column(String(256))
minio_path: Mapped[str | None] = mapped_column(String(512))
milvus_collection: Mapped[str] = mapped_column(String(64), nullable=False)
version: Mapped[str | None] = mapped_column(String(16))
effective_date: Mapped[date | None] = mapped_column(Date)
expire_date: Mapped[date | None] = mapped_column(Date)
content_text: Mapped[str] = mapped_column(Text, nullable=False)
tags: Mapped[dict[str, Any] | None] = mapped_column(JSON)
reviewer_id: Mapped[int | None] = mapped_column(BigInteger)
review_status: Mapped[str] = mapped_column(
String(16), nullable=False, default="pending")
status: Mapped[str] = mapped_column(String(16), nullable=False)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
class FaqSynonym(Base):
__tablename__ = "agent_faq_synonym"
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
knowledge_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
phrase: Mapped[str] = mapped_column(String(500), nullable=False)
normalized_phrase: Mapped[str] = mapped_column(String(500), nullable=False)
phrase_hash: Mapped[str] = mapped_column(String(64), nullable=False)
language_code: Mapped[str] = mapped_column(
String(16), nullable=False, default="zh-CN")
source_type: Mapped[str] = mapped_column(
String(24), nullable=False, default="manual")
hit_count: Mapped[int] = mapped_column(BigInteger, nullable=False, default=0)
status: Mapped[str] = mapped_column(String(16), nullable=False, default="pending")
created_by: Mapped[int] = mapped_column(BigInteger, nullable=False)
reviewer_id: Mapped[int | None] = mapped_column(BigInteger)
reviewed_at: Mapped[datetime | None] = mapped_column(DateTime)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)