Initial commit: AI Video Assistant fullstack platform.
Add pipecat-based backend with WebRTC/WS voice routes, Next.js frontend, and Docker Compose orchestration. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
55
backend/models.py
Normal file
55
backend/models.py
Normal file
@@ -0,0 +1,55 @@
|
||||
"""请求/配置数据模型。
|
||||
|
||||
分两层(重要):
|
||||
- AssistantConfig:**运行时**配置,含真 key,只在后端内部流转,绝不返回前端。
|
||||
由 config_resolver 从 DB 组装(或信令内联传入)。
|
||||
- schemas.py 里的 *Request/*Response:面向前端的 DTO(key 打码)。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
RuntimeMode = Literal["pipeline", "realtime"]
|
||||
|
||||
|
||||
class AssistantConfig(BaseModel):
|
||||
"""运行时配置:前端可见部分(name/prompt/...) + 服务端注入部分(*_api_key/*_base_url)。"""
|
||||
|
||||
name: str = "未命名助手"
|
||||
greeting: str = "您好,我是 AI 视频助手,请问有什么可以帮您?"
|
||||
prompt: str = "你是一个有帮助的助手。"
|
||||
runtimeMode: RuntimeMode = "pipeline"
|
||||
|
||||
# 模型/音色选项
|
||||
model: str = "" # LLM
|
||||
asr: str = "" # STT
|
||||
voice: str = "" # TTS 音色
|
||||
realtimeModel: str = ""
|
||||
|
||||
enableInterrupt: bool = True
|
||||
|
||||
# ---- 运行时连接信息(服务端注入,不来自浏览器) ----
|
||||
# 为空时,service_factory 会回退到 config.py 的 .env 默认值。
|
||||
llm_api_key: str = ""
|
||||
llm_base_url: str = ""
|
||||
stt_api_key: str = ""
|
||||
stt_base_url: str = ""
|
||||
tts_api_key: str = ""
|
||||
tts_base_url: str = ""
|
||||
|
||||
|
||||
class SignalingOffer(BaseModel):
|
||||
"""WS 信令里 offer 消息的 payload。
|
||||
|
||||
推荐用 assistant_id(浏览器只传 id,key 在服务端解析);
|
||||
inline_config 仅用于调试/无库场景。
|
||||
"""
|
||||
|
||||
pc_id: str | None = None
|
||||
sdp: str
|
||||
type: str
|
||||
assistant_id: str | None = None
|
||||
inline_config: AssistantConfig | None = None
|
||||
Reference in New Issue
Block a user