diff --git a/app/api/endpoints/meetings.py b/app/api/endpoints/meetings.py index d325eef..1def460 100644 --- a/app/api/endpoints/meetings.py +++ b/app/api/endpoints/meetings.py @@ -812,17 +812,18 @@ def get_summary_detail(meeting_id: int, summary_id: int, current_user: dict = De def generate_meeting_summary_async(meeting_id: int, request: GenerateSummaryRequest, background_tasks: BackgroundTasks, current_user: dict = Depends(get_current_user)): """生成会议AI总结(异步版本)""" try: - # 检查会议是否存在 + + # 1. 检查会议是否存在 with get_db_connection() as connection: cursor = connection.cursor(dictionary=True) cursor.execute("SELECT meeting_id FROM meetings WHERE meeting_id = %s", (meeting_id,)) if not cursor.fetchone(): raise HTTPException(status_code=404, detail="Meeting not found") - - # 启动异步任务 + + # 2. 启动异步任务 task_id = async_llm_service.start_summary_generation(meeting_id, request.user_prompt) - # 将真正的处理函数作为后台任务添加 + # 3. 将真正的处理函数作为后台任务添加 background_tasks.add_task(async_llm_service._process_task, task_id) return { @@ -878,31 +879,31 @@ def get_meeting_llm_tasks(meeting_id: int, current_user: dict = Depends(get_curr except Exception as e: raise HTTPException(status_code=500, detail=f"Failed to get LLM tasks: {str(e)}") -@router.get("/meetings/{meeting_id}/latest-llm-task") -def get_latest_llm_task(meeting_id: int, current_user: dict = Depends(get_current_user)): - """获取会议最新的LLM任务状态""" - try: - tasks = async_llm_service.get_meeting_llm_tasks(meeting_id) +# @router.get("/meetings/{meeting_id}/latest-llm-task") #此方法被替代 +# def get_latest_llm_task(meeting_id: int, current_user: dict = Depends(get_current_user)): +# """获取会议最新的LLM任务状态""" +# try: +# tasks = async_llm_service.get_meeting_llm_tasks(meeting_id) - if not tasks: - return { - "meeting_id": meeting_id, - "task": None, - "message": "No LLM tasks found for this meeting" - } +# if not tasks: +# return { +# "meeting_id": meeting_id, +# "task": None, +# "message": "No LLM tasks found for this meeting" +# } - # 返回最新的任务 - latest_task = tasks[0] +# # 返回最新的任务 +# latest_task = tasks[0] - # 如果任务还在进行中,获取实时状态 - if latest_task['status'] in ['pending', 'processing']: - latest_status = async_llm_service.get_task_status(latest_task['task_id']) - latest_task.update(latest_status) +# # 如果任务还在进行中,获取实时状态 +# if latest_task['status'] in ['pending', 'processing']: +# latest_status = async_llm_service.get_task_status(latest_task['task_id']) +# latest_task.update(latest_status) - return { - "meeting_id": meeting_id, - "task": latest_task - } +# return { +# "meeting_id": meeting_id, +# "task": latest_task +# } - except Exception as e: - raise HTTPException(status_code=500, detail=f"Failed to get latest LLM task: {str(e)}") \ No newline at end of file +# except Exception as e: +# raise HTTPException(status_code=500, detail=f"Failed to get latest LLM task: {str(e)}") \ No newline at end of file