diff --git a/stream_example.py b/stream_example.py index 3978fcaa..22e21d9f 100644 --- a/stream_example.py +++ b/stream_example.py @@ -3,10 +3,10 @@ from swarms import Agent # Enable real-time streaming agent = Agent( agent_name="StoryAgent", - model_name="gpt-4o-mini", - streaming_on=True, # 🔥 This enables real streaming! - max_loops=1, - print_on=False, # By Default its False, raw streaming !! + model_name="gpt-4o-mini", # 🔥 This enables real streaming! + max_loops=4, + streaming_on=True, + print_on=True, output_type="all", ) @@ -14,4 +14,4 @@ agent = Agent( response = agent.run( "Tell me a detailed story about Humanity colonizing the stars" ) -print(response) +# print(response) diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index 72cfdfc0..9fce6eea 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -2518,13 +2518,8 @@ class Agent: ) and not isinstance(streaming_response, str): # Check print_on parameter for different streaming behaviors if self.print_on is False: - # Show raw streaming text without formatting panels + # Silent streaming - no printing, just collect chunks chunks = [] - print( - f"\n{self.agent_name}: ", - end="", - flush=True, - ) for chunk in streaming_response: if ( hasattr(chunk, "choices") @@ -2533,11 +2528,7 @@ class Agent: content = chunk.choices[ 0 ].delta.content - print( - content, end="", flush=True - ) # Print raw streaming text chunks.append(content) - print() # New line after streaming completes complete_response = "".join(chunks) else: # Collect chunks for conversation saving @@ -2802,8 +2793,8 @@ class Agent: return if self.print_on is False: - # Show raw text without formatting panels - print(f"\n{self.agent_name}: {response}\n") + # Silent mode - no printing at all + return else: # Use formatted panels (default behavior when print_on=True) formatter.print_panel( diff --git a/swarms/utils/formatter.py b/swarms/utils/formatter.py index e10afc7f..b8f9d963 100644 --- a/swarms/utils/formatter.py +++ b/swarms/utils/formatter.py @@ -181,7 +181,7 @@ class Formatter: def create_streaming_panel(text_obj, is_complete=False): """Create panel with proper text wrapping using Rich's built-in capabilities""" - panel_title = f"[bold cyan]{title}[/bold cyan]" + panel_title = f"[white]{title}[/white]" if is_complete: panel_title += " [bold green]✅[/bold green]"