更新接口

codex/dev
AlanPaine 2026-03-30 08:22:09 +00:00
parent 423e768c3c
commit a69dd645ca
4 changed files with 29 additions and 8 deletions

View File

@ -517,6 +517,7 @@ async def upload_audio(
meeting_id: int = Form(...),
auto_summarize: str = Form("true"),
prompt_id: Optional[int] = Form(None), # 可选的提示词模版ID
model_code: Optional[str] = Form(None), # 可选的总结模型编码
background_tasks: BackgroundTasks = None,
current_user: dict = Depends(get_current_user)
):
@ -530,6 +531,7 @@ async def upload_audio(
meeting_id: 会议ID
auto_summarize: 是否自动生成总结"true"/"false"默认"true"
prompt_id: 提示词模版ID可选如果不指定则使用默认模版
model_code: 总结模型编码可选如果不指定则使用默认模型
background_tasks: FastAPI后台任务
current_user: 当前登录用户
@ -539,6 +541,8 @@ async def upload_audio(
"""
auto_summarize_bool = auto_summarize.lower() in ("true", "1", "yes")
model_code = model_code.strip() if model_code else None
# 0. 如果没有传入 prompt_id尝试获取默认模版ID
if prompt_id is None:
with get_db_connection() as connection:
@ -599,6 +603,7 @@ async def upload_audio(
auto_summarize=auto_summarize_bool,
background_tasks=background_tasks,
prompt_id=prompt_id,
model_code=model_code,
duration=audio_duration # 传递时长参数
)
@ -632,6 +637,7 @@ async def upload_audio(
"task_id": transcription_task_id,
"transcription_started": transcription_task_id is not None,
"auto_summarize": auto_summarize_bool,
"model_code": model_code,
"replaced_existing": result["replaced_existing"],
"previous_transcription_cleared": result["replaced_existing"] and result["has_transcription"]
}
@ -942,7 +948,7 @@ def list_active_llm_models(current_user: dict = Depends(get_current_user)):
"SELECT model_code, model_name, provider, is_default FROM llm_model_config WHERE is_active = 1 ORDER BY is_default DESC, model_code ASC"
)
models = cursor.fetchall()
return create_api_response(code="200", message="获取模型列表成功", data={"models": models})
return create_api_response(code="200", message="获取模型列表成功", data=models)
except Exception as e:
return create_api_response(code="500", message=f"获取模型列表失败: {str(e)}")
@router.get("/meetings/{meeting_id}/navigation")

View File

@ -127,7 +127,13 @@ class AsyncMeetingService:
self._update_task_in_db(task_id, 'failed', 0, error_message=error_msg)
self._update_task_status_in_redis(task_id, 'failed', 0, error_message=error_msg)
def monitor_and_auto_summarize(self, meeting_id: int, transcription_task_id: str, prompt_id: Optional[int] = None):
def monitor_and_auto_summarize(
self,
meeting_id: int,
transcription_task_id: str,
prompt_id: Optional[int] = None,
model_code: Optional[str] = None
):
"""
监控转录任务完成后自动生成总结
此方法设计为由BackgroundTasks调用在后台运行
@ -136,13 +142,14 @@ class AsyncMeetingService:
meeting_id: 会议ID
transcription_task_id: 转录任务ID
prompt_id: 提示词模版ID可选如果不指定则使用默认模版
model_code: 总结模型编码可选如果不指定则使用默认模型
流程:
1. 循环轮询转录任务状态
2. 转录成功后自动启动总结任务
3. 转录失败或超时则停止轮询并记录日志
"""
print(f"[Monitor] Started monitoring transcription task {transcription_task_id} for meeting {meeting_id}, prompt_id: {prompt_id}")
print(f"[Monitor] Started monitoring transcription task {transcription_task_id} for meeting {meeting_id}, prompt_id: {prompt_id}, model_code: {model_code}")
# 获取配置参数
poll_interval = TRANSCRIPTION_POLL_CONFIG['poll_interval']
@ -178,7 +185,12 @@ class AsyncMeetingService:
else:
# 启动总结任务
try:
summary_task_id = self.start_summary_generation(meeting_id, user_prompt="", prompt_id=prompt_id)
summary_task_id = self.start_summary_generation(
meeting_id,
user_prompt="",
prompt_id=prompt_id,
model_code=model_code
)
print(f"[Monitor] Summary task {summary_task_id} started for meeting {meeting_id}")
# 在后台执行总结任务

View File

@ -25,6 +25,7 @@ def handle_audio_upload(
auto_summarize: bool = True,
background_tasks: BackgroundTasks = None,
prompt_id: int = None,
model_code: str = None,
duration: int = 0
) -> dict:
"""
@ -46,6 +47,7 @@ def handle_audio_upload(
auto_summarize: 是否自动生成总结默认True
background_tasks: FastAPI 后台任务对象
prompt_id: 提示词模版ID可选如果不指定则使用默认模版
model_code: 总结模型编码可选如果不指定则使用默认模型
duration: 音频时长
Returns:
@ -58,7 +60,7 @@ def handle_audio_upload(
"has_transcription": bool # 原来是否有转录记录 (成功时)
}
"""
print(f"[Audio Service] handle_audio_upload called - Meeting ID: {meeting_id}, Auto-summarize: {auto_summarize}, Received prompt_id: {prompt_id}, Type: {type(prompt_id)}")
print(f"[Audio Service] handle_audio_upload called - Meeting ID: {meeting_id}, Auto-summarize: {auto_summarize}, Received prompt_id: {prompt_id}, model_code: {model_code}")
# 1. 权限和已有文件检查
try:
@ -145,9 +147,10 @@ def handle_audio_upload(
async_meeting_service.monitor_and_auto_summarize,
meeting_id,
transcription_task_id,
prompt_id # 传递 prompt_id 给自动总结监控任务
prompt_id,
model_code
)
print(f"[audio_service] Auto-summarize enabled, monitor task added for meeting {meeting_id}, prompt_id: {prompt_id}")
print(f"[audio_service] Auto-summarize enabled, monitor task added for meeting {meeting_id}, prompt_id: {prompt_id}, model_code: {model_code}")
except Exception as e:
print(f"Failed to start transcription: {e}")

View File

@ -179,7 +179,7 @@ const MeetingDetails = ({ user }) => {
const fetchLlmModels = async () => {
try {
const res = await apiClient.get(buildApiUrl(API_ENDPOINTS.MEETINGS.LLM_MODELS));
const models = res.data.models || [];
const models = Array.isArray(res.data) ? res.data : (res.data?.models || []);
setLlmModels(models);
const def = models.find(m => m.is_default);
if (def) setSelectedModelCode(def.model_code);