加入脑图功能
parent
689300044c
commit
f6e1fd6d94
|
|
@ -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)):
|
def generate_meeting_summary_async(meeting_id: int, request: GenerateSummaryRequest, background_tasks: BackgroundTasks, current_user: dict = Depends(get_current_user)):
|
||||||
"""生成会议AI总结(异步版本)"""
|
"""生成会议AI总结(异步版本)"""
|
||||||
try:
|
try:
|
||||||
# 检查会议是否存在
|
|
||||||
|
# 1. 检查会议是否存在
|
||||||
with get_db_connection() as connection:
|
with get_db_connection() as connection:
|
||||||
cursor = connection.cursor(dictionary=True)
|
cursor = connection.cursor(dictionary=True)
|
||||||
cursor.execute("SELECT meeting_id FROM meetings WHERE meeting_id = %s", (meeting_id,))
|
cursor.execute("SELECT meeting_id FROM meetings WHERE meeting_id = %s", (meeting_id,))
|
||||||
if not cursor.fetchone():
|
if not cursor.fetchone():
|
||||||
raise HTTPException(status_code=404, detail="Meeting not found")
|
raise HTTPException(status_code=404, detail="Meeting not found")
|
||||||
|
|
||||||
# 启动异步任务
|
# 2. 启动异步任务
|
||||||
task_id = async_llm_service.start_summary_generation(meeting_id, request.user_prompt)
|
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)
|
background_tasks.add_task(async_llm_service._process_task, task_id)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -878,31 +879,31 @@ def get_meeting_llm_tasks(meeting_id: int, current_user: dict = Depends(get_curr
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise HTTPException(status_code=500, detail=f"Failed to get LLM tasks: {str(e)}")
|
raise HTTPException(status_code=500, detail=f"Failed to get LLM tasks: {str(e)}")
|
||||||
|
|
||||||
@router.get("/meetings/{meeting_id}/latest-llm-task")
|
# @router.get("/meetings/{meeting_id}/latest-llm-task") #此方法被替代
|
||||||
def get_latest_llm_task(meeting_id: int, current_user: dict = Depends(get_current_user)):
|
# def get_latest_llm_task(meeting_id: int, current_user: dict = Depends(get_current_user)):
|
||||||
"""获取会议最新的LLM任务状态"""
|
# """获取会议最新的LLM任务状态"""
|
||||||
try:
|
# try:
|
||||||
tasks = async_llm_service.get_meeting_llm_tasks(meeting_id)
|
# tasks = async_llm_service.get_meeting_llm_tasks(meeting_id)
|
||||||
|
|
||||||
if not tasks:
|
# if not tasks:
|
||||||
return {
|
# return {
|
||||||
"meeting_id": meeting_id,
|
# "meeting_id": meeting_id,
|
||||||
"task": None,
|
# "task": None,
|
||||||
"message": "No LLM tasks found for this meeting"
|
# "message": "No LLM tasks found for this meeting"
|
||||||
}
|
# }
|
||||||
|
|
||||||
# 返回最新的任务
|
# # 返回最新的任务
|
||||||
latest_task = tasks[0]
|
# latest_task = tasks[0]
|
||||||
|
|
||||||
# 如果任务还在进行中,获取实时状态
|
# # 如果任务还在进行中,获取实时状态
|
||||||
if latest_task['status'] in ['pending', 'processing']:
|
# if latest_task['status'] in ['pending', 'processing']:
|
||||||
latest_status = async_llm_service.get_task_status(latest_task['task_id'])
|
# latest_status = async_llm_service.get_task_status(latest_task['task_id'])
|
||||||
latest_task.update(latest_status)
|
# latest_task.update(latest_status)
|
||||||
|
|
||||||
return {
|
# return {
|
||||||
"meeting_id": meeting_id,
|
# "meeting_id": meeting_id,
|
||||||
"task": latest_task
|
# "task": latest_task
|
||||||
}
|
# }
|
||||||
|
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
raise HTTPException(status_code=500, detail=f"Failed to get latest LLM task: {str(e)}")
|
# raise HTTPException(status_code=500, detail=f"Failed to get latest LLM task: {str(e)}")
|
||||||
Loading…
Reference in New Issue