From 01823687445b7adc73a0421664c9b9c310abf739 Mon Sep 17 00:00:00 2001 From: Huu Le <39040748+leehuwuj@users.noreply.github.com> Date: Wed, 23 Oct 2024 17:38:48 +0700 Subject: [PATCH] Fix: UI streaming issue (#391) --- .changeset/popular-pears-repeat.md | 5 +++++ .../components/agents/python/blog/app/agents/workflow.py | 4 +++- .../agents/python/financial_report/app/agents/workflow.py | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changeset/popular-pears-repeat.md diff --git a/.changeset/popular-pears-repeat.md b/.changeset/popular-pears-repeat.md new file mode 100644 index 00000000..24407398 --- /dev/null +++ b/.changeset/popular-pears-repeat.md @@ -0,0 +1,5 @@ +--- +"create-llama": patch +--- + +Fix the streaming issue to prevent the UI from hanging. diff --git a/templates/components/agents/python/blog/app/agents/workflow.py b/templates/components/agents/python/blog/app/agents/workflow.py index c7bfbe51..50097a1a 100644 --- a/templates/components/agents/python/blog/app/agents/workflow.py +++ b/templates/components/agents/python/blog/app/agents/workflow.py @@ -238,7 +238,9 @@ class BlogPostWorkflow(Workflow): publisher: FunctionCallingAgent, ) -> StopEvent: try: - result: AgentRunResult = await self.run_agent(ctx, publisher, ev.input) + result: AgentRunResult = await self.run_agent( + ctx, publisher, ev.input, streaming=ctx.data["streaming"] + ) return StopEvent(result=result) except Exception as e: ctx.write_event_to_stream( diff --git a/templates/components/agents/python/financial_report/app/agents/workflow.py b/templates/components/agents/python/financial_report/app/agents/workflow.py index d995bab2..1c775819 100644 --- a/templates/components/agents/python/financial_report/app/agents/workflow.py +++ b/templates/components/agents/python/financial_report/app/agents/workflow.py @@ -148,7 +148,9 @@ class FinancialReportWorkflow(Workflow): self, ctx: Context, ev: ReportEvent, reporter: FunctionCallingAgent ) -> StopEvent: try: - result: AgentRunResult = await self.run_agent(ctx, reporter, ev.input) + result: AgentRunResult = await self.run_agent( + ctx, reporter, ev.input, streaming=ctx.data["streaming"] + ) return StopEvent(result=result) except Exception as e: ctx.write_event_to_stream( -- GitLab