feat: pass params from HTTP post body

This commit is contained in:
Li Xin 2025-04-19 22:11:41 +08:00
parent b96e47746e
commit 4d33aeed6a
2 changed files with 15 additions and 5 deletions

View File

@ -16,7 +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.server.chat_request import ChatMessage, ChatRequest, TTSRequest
from src.server.chat_request import (
ChatMessage,
ChatRequest,
GeneratePodcastRequest,
TTSRequest,
)
from src.tools import VolcengineTTS
logger = logging.getLogger(__name__)
@ -199,10 +204,11 @@ async def text_to_speech(request: TTSRequest):
raise HTTPException(status_code=500, detail=str(e))
@app.get("/api/podcast/generate")
async def generate_podcast():
@app.post("/api/podcast/generate")
async def generate_podcast(request: GeneratePodcastRequest):
try:
report_content = open("examples/nanjing_tangbao.md").read()
report_content = request.content
print(report_content)
workflow = build_podcast_graph()
final_state = workflow.invoke({"input": report_content})
audio_bytes = final_state["output"]

View File

@ -1,7 +1,7 @@
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
# SPDX-License-Identifier: MIT
from typing import List, Optional, Union, Dict, Any
from typing import List, Optional, Union
from pydantic import BaseModel, Field
@ -60,3 +60,7 @@ class TTSRequest(BaseModel):
1, description="Whether to use frontend processing"
)
frontend_type: Optional[str] = Field("unitTson", description="Frontend type")
class GeneratePodcastRequest(BaseModel):
content: str = Field(..., description="The content of the podcast")