[DOCS] Token Stream in Agent class

pull/1167/head
Aksh Parekh 3 weeks ago committed by GitHub
parent a9be38ea9c
commit 9faf30f102
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -83,6 +83,7 @@ The `Agent` class establishes a conversational loop with a language model, allow
| `traceback` | `Optional[Any]` | Object used for traceback handling. | | `traceback` | `Optional[Any]` | Object used for traceback handling. |
| `traceback_handlers` | `Optional[Any]` | List of traceback handlers. | | `traceback_handlers` | `Optional[Any]` | List of traceback handlers. |
| `streaming_on` | `Optional[bool]` | Boolean indicating whether to stream responses. | | `streaming_on` | `Optional[bool]` | Boolean indicating whether to stream responses. |
| `stream` | `Optional[bool]` | Boolean indicating whether to enable detailed token-by-token streaming with metadata. |
| `docs` | `List[str]` | List of document paths or contents to be ingested. | | `docs` | `List[str]` | List of document paths or contents to be ingested. |
| `docs_folder` | `Optional[str]` | Path to a folder containing documents to be ingested. | | `docs_folder` | `Optional[str]` | Path to a folder containing documents to be ingested. |
| `verbose` | `Optional[bool]` | Boolean indicating whether to print verbose output. | | `verbose` | `Optional[bool]` | Boolean indicating whether to print verbose output. |
@ -759,6 +760,22 @@ print(agent.system_prompt)
``` ```
### Token-by-Token Streaming
```python
from swarms import Agent
# Initialize agent with detailed streaming
agent = Agent(
model_name="gpt-4.1",
max_loops=1,
stream=True, # Enable detailed token-by-token streaming
)
# Run with detailed streaming - each token shows metadata
agent.run("Tell me a short story about a robot learning to paint.")
```
## Agent Structured Outputs ## Agent Structured Outputs
- Create a structured output schema for the agent [List[Dict]] - Create a structured output schema for the agent [List[Dict]]

Loading…
Cancel
Save