Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkbrnd committed Feb 14, 2025
1 parent dd18b40 commit 9ec63a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions libs/agno/agno/playground/async_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ async def chat_response_streamer(
agent: Agent,
message: str,
images: Optional[List[Image]] = None,
audio: Optional[List[Audio]] = None,
videos: Optional[List[Video]] = None,
) -> AsyncGenerator:
run_response = await agent.arun(
message,
images=images,
audio=audio,
videos=videos,
stream=True,
stream_intermediate_steps=True,
Expand Down Expand Up @@ -225,13 +227,12 @@ async def create_agent_run(
raise HTTPException(status_code=400, detail="Unsupported file type")

if stream:
if base64_audios:
raise HTTPException(status_code=400, detail="Audio is not supported in streaming mode")
return StreamingResponse(
chat_response_streamer(
new_agent_instance,
message,
images=base64_images if base64_images else None,
audio=base64_audios if base64_audios else None,
),
media_type="text/event-stream",
)
Expand Down
10 changes: 6 additions & 4 deletions libs/agno/agno/playground/sync_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ def get_agents():

return agent_list

def chat_response_streamer(agent: Agent, message: str, images: Optional[List[Image]] = None) -> Generator:
run_response = agent.run(message=message, images=images, stream=True, stream_intermediate_steps=True)
def chat_response_streamer(agent: Agent,
message: str,
images: Optional[List[Image]] = None,
audio: Optional[List[Audio]] = None) -> Generator:
run_response = agent.run(message=message, images=images, audio=audio, stream=True, stream_intermediate_steps=True)
for run_response_chunk in run_response:
run_response_chunk = cast(RunResponse, run_response_chunk)
yield run_response_chunk.to_json()
Expand Down Expand Up @@ -209,13 +212,12 @@ def create_agent_run(
raise HTTPException(status_code=400, detail="Unsupported file type")

if stream:
if base64_audios:
raise HTTPException(status_code=400, detail="Audio is not supported in streaming mode")
return StreamingResponse(
chat_response_streamer(
new_agent_instance,
message,
images=base64_images if base64_images else None,
audio=base64_audios if base64_audios else None,
),
media_type="text/event-stream",
)
Expand Down

0 comments on commit 9ec63a6

Please sign in to comment.