imetting_backend/app/api/endpoints/tasks.py

32 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

from fastapi import APIRouter, Depends
from app.core.auth import get_current_user
from app.core.response import create_api_response
from app.services.async_transcription_service import AsyncTranscriptionService
from app.services.async_meeting_service import async_meeting_service
router = APIRouter()
transcription_service = AsyncTranscriptionService()
@router.get("/tasks/transcription/{task_id}/status")
def get_transcription_task_status(task_id: str, current_user: dict = Depends(get_current_user)):
"""获取转录任务状态"""
try:
status_info = transcription_service.get_task_status(task_id)
if not status_info or status_info.get('status') == 'not_found':
return create_api_response(code="404", message="Transcription task not found")
return create_api_response(code="200", message="Task status retrieved", data=status_info)
except Exception as e:
return create_api_response(code="500", message=f"Failed to get task status: {str(e)}")
@router.get("/tasks/summaries/{task_id}/status")
def get_llm_task_status(task_id: str, current_user: dict = Depends(get_current_user)):
"""获取LLM总结任务状态包括进度"""
try:
status = async_meeting_service.get_task_status(task_id)
if status.get('status') == 'not_found':
return create_api_response(code="404", message="Task not found")
return create_api_response(code="200", message="Task status retrieved", data=status)
except Exception as e:
return create_api_response(code="500", message=f"Failed to get task status: {str(e)}")