[CLEANUP] Removed Printing + Function Nesting

pull/1081/head
Aksh Parekh 2 months ago committed by GitHub
parent 8dcf3e11c9
commit 1124bb3b84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,17 +1,11 @@
from typing import Callable
from swarms.structs.agent import Agent
from swarms.structs.sequential_workflow import SequentialWorkflow
def create_streaming_callback() -> Callable[[str, str, bool], None]:
"""
Create a streaming callback that prints each chunk as it arrives, with no duplication or timestamps.
"""
def streaming_callback(agent_name: str, chunk: str, is_final: bool):
def streaming_callback(agent_name: str, chunk: str, is_final: bool):
if chunk:
print(chunk, end="", flush=True)
if is_final:
print()
return streaming_callback
def create_agents():
"""Create specialized agents for the workflow."""
@ -37,9 +31,6 @@ def create_agents():
]
if __name__ == "__main__":
print("🎯 SEQUENTIAL WORKFLOW STREAMING DEMO")
print("=" * 50)
agents = create_agents()
workflow = SequentialWorkflow(
id="research_analysis_workflow",
@ -53,19 +44,7 @@ if __name__ == "__main__":
task = "What are the latest advancements in AI?"
print(f"Task: {task.strip()}")
streaming_callback = create_streaming_callback()
print("\n🎬 EXECUTING WITH STREAMING CALLBACKS...")
print("Watch real-time agent outputs below:\n")
result = workflow.run(
workflow.run(
task=task,
streaming_callback=streaming_callback,
)
print("\n🎉 EXECUTION COMPLETED!")
print("\n📊 FINAL RESULT:")
print("-" * 50)
print(result)
Loading…
Cancel
Save