feat: add ppt generation feat

This commit is contained in:
He Tao
2025-04-21 16:43:06 +08:00
parent d81eb40a80
commit 0d2f93c773
10 changed files with 256 additions and 0 deletions

View File

@@ -16,10 +16,12 @@ from langgraph.types import Command
from src.graph.builder import build_graph
from src.podcast.graph.builder import build_graph as build_podcast_graph
from src.ppt.graph.builder import build_graph as build_ppt_graph
from src.server.chat_request import (
ChatMessage,
ChatRequest,
GeneratePodcastRequest,
GeneratePPTRequest,
TTSRequest,
)
from src.tools import VolcengineTTS
@@ -216,3 +218,22 @@ async def generate_podcast(request: GeneratePodcastRequest):
except Exception as e:
logger.exception(f"Error occurred during podcast generation: {str(e)}")
raise HTTPException(status_code=500, detail=str(e))
@app.post("/api/ppt/generate")
async def generate_ppt(request: GeneratePPTRequest):
try:
report_content = request.content
print(report_content)
workflow = build_ppt_graph()
final_state = workflow.invoke({"input": report_content})
generated_file_path = final_state["generated_file_path"]
with open(generated_file_path, "rb") as f:
ppt_bytes = f.read()
return Response(
content=ppt_bytes,
media_type="application/vnd.openxmlformats-officedocument.presentationml.presentation",
)
except Exception as e:
logger.exception(f"Error occurred during ppt generation: {str(e)}")
raise HTTPException(status_code=500, detail=str(e))