Add conversation history management and API endpoints

- Introduce new database models for conversation sessions, messages, and artifacts to support conversation history tracking.
- Implement API routes for listing conversations and retrieving detailed conversation data, enhancing user interaction with historical records.
- Add a conversation recorder service to persist conversation messages in real-time without disrupting ongoing calls.
- Update the frontend to display conversation history, including filtering and sorting options, improving user experience.
- Enhance the pipeline to integrate conversation history recording seamlessly during interactions.
This commit is contained in:
Xin Wang
2026-07-10 16:25:06 +08:00
parent 5705726cfb
commit 059ad8162e
13 changed files with 1096 additions and 43 deletions

View File

@@ -7,6 +7,7 @@ JSON 用 camelCase(modelId/interfaceType/apiUrl/apiKey),Python 内部用 snake_c
from __future__ import annotations
from datetime import datetime
from typing import Annotated, Any, Literal, Union
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
@@ -199,3 +200,37 @@ class ModelResourceTestResult(CamelModel):
latency_ms: int | None = None
message: str
detail: str = ""
# ---------- 对话历史 ----------
class ConversationMessageOut(CamelModel):
id: str
sequence: int
role: Literal["user", "assistant"]
content_type: str
content: str
occurred_at: datetime
extra: dict[str, Any] = Field(default_factory=dict)
class ConversationOut(CamelModel):
id: str
assistant_id: str | None
assistant_name: str
channel: str
runtime_mode: str
status: str
message_count: int
started_at: datetime
ended_at: datetime | None
class ConversationDetailOut(ConversationOut):
messages: list[ConversationMessageOut] = Field(default_factory=list)
class ConversationListOut(CamelModel):
items: list[ConversationOut]
total: int
page: int
page_size: int