### Quick Start: Basic Agent Usage Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai/README.md Demonstrates how to initialize and run a basic AI agent using the serdes-ai crate. Ensure you have the necessary environment variables set for the AI model provider. ```rust use serdes_ai::prelude::*; #[tokio::main] async fn main() -> anyhow::Result<()> { let agent = Agent::new(OpenAIChatModel::from_env("gpt-4o")?) .system_prompt("You are a helpful assistant.") .build(); let result = agent.run("Hello!", ()).await?; println!("{}", result.output); Ok(()) } ``` -------------------------------- ### Initialize Provider Registry and Get Provider Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-providers/README.md Demonstrates how to initialize the ProviderRegistry and retrieve a specific provider by its identifier. ```rust use serdes_ai_providers::{Provider, ProviderRegistry}; let registry = ProviderRegistry::default(); let provider = registry.get("openai")?; ``` -------------------------------- ### Initialize MCP Client and Toolset Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-mcp/README.md Initialize an MCP client using stdio transport and create a Toolset from it. This example requires the 'serdes_ai_mcp' crate and assumes an Agent struct is available. ```rust use serdes_ai_mcp::{McpClient, McpToolset}; let client = McpClient::stdio("npx", &["-y", "@modelcontextprotocol/server-filesystem"])?; let toolset = McpToolset::from_client(client).await?; let agent = Agent::new(model) .toolset(toolset) .build(); ``` -------------------------------- ### Instantiate AI Models from Environment Variables Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md These examples show how to initialize various AI models by reading their names or deployment details from environment variables. This is a common pattern for configuring model providers dynamically. ```rust // OpenAI let model = OpenAIChatModel::from_env("gpt-4o")?; ``` ```rust // Anthropic let model = AnthropicModel::from_env("claude-3-5-sonnet-20241022")?; ``` ```rust // Google Gemini let model = GeminiModel::from_env("gemini-1.5-pro")?; ``` ```rust // Groq (ultra-fast inference) let model = GroqModel::from_env("llama-3.1-70b-versatile")?; ``` ```rust // Mistral let model = MistralModel::from_env("mistral-large-latest")?; ``` ```rust // Azure OpenAI let model = AzureOpenAIModel::from_env("my-deployment")?; ``` ```rust // OpenRouter (multi-provider gateway) let model = OpenRouterModel::from_env("anthropic/claude-3.5-sonnet")?; ``` ```rust // HuggingFace let model = HuggingFaceModel::from_env("meta-llama/Llama-3.1-70B-Instruct")?; ``` ```rust // Cohere let model = CohereModel::from_env("command-r-plus")?; ``` ```rust // Antigravity let model = AntigravityModel::from_env("antigravity-model")?; ``` -------------------------------- ### Instantiate AWS Bedrock AI Model Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md This example demonstrates how to instantiate an AI model hosted on AWS Bedrock. It requires specifying the model identifier. ```rust // AWS Bedrock let model = BedrockModel::new("anthropic.claude-3-sonnet-20240229-v1:0")?; ``` -------------------------------- ### Instantiate Local Ollama AI Model Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md This example shows how to instantiate an AI model provided by Ollama, which allows running models locally. It requires specifying the model name. ```rust // Ollama (local) let model = OllamaModel::new("llama3.1"); ``` -------------------------------- ### Rust Dependency Installation Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-macros/README.md Add the serdes-ai-macros crate to your Cargo.toml file to include it in your project dependencies. ```toml [dependencies] serdes-ai-macros = "0.1" ``` -------------------------------- ### Connect to Remote Agent and Send Task Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-a2a/README.md Example of connecting to a remote agent using A2AClient, retrieving its agent card, and sending a task. Requires the 'serdes_ai_a2a' crate and 'tokio' runtime for async operations. ```rust use serdes_ai_a2a::{A2AClient, AgentCard}; // Connect to a remote agent let client = A2AClient::new("https://agent.example.com").await?; let card = client.get_agent_card().await?; println!("Connected to: {}", card.name); // Send a task to the remote agent let result = client.send_task("Analyze this data", data).await?; ``` -------------------------------- ### Process Agent Stream Events Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-streaming/README.md Iterate over AgentStreamEvent from an agent's run_stream method. This example specifically handles text deltas and the end event. ```rust use serdes_ai_streaming::AgentStreamEvent; use futures::StreamExt; let mut stream = agent.run_stream("Write a poem", ()).await?; while let Some(event) = stream.next().await { match event { AgentStreamEvent::TextDelta { content, .. } => { print!("{}", content); } AgentStreamEvent::End { .. } => break, _ => {} } } ``` -------------------------------- ### Create and Use a Toolset Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-toolsets/README.md Demonstrates how to create a new toolset, add tools to it, and then integrate it with an Agent. ```rust use serdes_ai_toolsets::Toolset; let toolset = Toolset::new() .add(MyTool) .add(AnotherTool); let agent = Agent::new(model) .toolset(toolset) .build(); ``` -------------------------------- ### Define and Run a Simple Graph Workflow Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-graph/README.md Demonstrates how to define a custom node, build a graph, and run it with initial state. The 'ProcessNode' modifies the state and returns a result. ```rust use serdes_ai_graph::{Graph, BaseNode, NodeResult, GraphRunContext, GraphResult}; use async_trait::async_trait; #[derive(Debug, Clone, Default)] struct MyState { data: String, } struct ProcessNode; #[async_trait] impl BaseNode for ProcessNode { fn name(&self) -> &str { "process" } async fn run( &self, ctx: &mut GraphRunContext, ) -> GraphResult> { ctx.state.data = "processed".to_string(); Ok(NodeResult::end(ctx.state.data.clone())) } } let graph = Graph::new() .node("process", ProcessNode) .entry("process") .build()?; let result = graph.run(MyState::default(), ()).await?; ``` -------------------------------- ### Initialize and Use OpenAI Chat Model Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-models/README.md Demonstrates how to initialize an OpenAI chat model from environment variables and make a chat request. Ensure the necessary environment variables for authentication are set. ```rust use serdes_ai_models::{OpenAIChatModel, Model}; let model = OpenAIChatModel::from_env("gpt-4o")?; let response = model.chat(messages, options).await?; ``` -------------------------------- ### Clone SerdesAI Repository and Build Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md Steps to clone the SerdesAI repository from GitHub and build the entire workspace with all features enabled. This is a prerequisite for running tests locally. ```bash git clone https://github.com/janfeddersen-wq/serdesAI cd serdesAI cargo build --workspace --all-features ``` -------------------------------- ### Basic Agent Usage Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-agent/README.md Instantiate and use the Agent to interact with an LLM. Requires a model and provides a system prompt for context. The run method takes a prompt and a context, returning a result asynchronously. ```rust use serdes_ai_agent::{Agent, AgentBuilder}; let agent = Agent::new(model) .system_prompt("You are helpful.") .build(); let result = agent.run("Hello!", ()).await?; ``` -------------------------------- ### Simple Chat Agent Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md Initialize and run a simple chat agent using SerdesAI with an OpenAI model. Requires OPENAI_API_KEY environment variable. ```rust use serdes_ai::prelude::*; use serdes_ai::OpenAIChatModel; #[tokio::main] async fn main() -> anyhow::Result<()> { let agent = Agent::new(OpenAIChatModel::from_env("gpt-4o")?) .system_prompt("You are a helpful assistant.") .build(); let result = agent.run("Hello! What can you help me with?", ()).await?; println!("{}", result.output); Ok(()) } ``` -------------------------------- ### Run SerdesAI Benchmarks Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md Command to execute benchmark tests for the SerdesAI workspace. This helps in evaluating the performance of different components. ```bash cargo bench --workspace ``` -------------------------------- ### Define and Run a Graph-Based Workflow in Rust Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md This snippet demonstrates how to define a simple graph with two nodes, 'research' and 'write', and then run it with an initial state. It shows the basic structure for creating and executing workflows using the serdes-ai-graph crate. ```rust use serdes_ai::prelude::*; use serdes_ai_graph::{Graph, BaseNode, NodeResult, GraphRunContext, GraphResult}; use async_trait::async_trait; #[derive(Debug, Clone, Default)] struct WorkflowState { query: String, research: Option, response: Option, } struct ResearchNode; struct WriteNode; #[async_trait] impl BaseNode for ResearchNode { fn name(&self) -> &str { "research" } async fn run( &self, ctx: &mut GraphRunContext, ) -> GraphResult> { ctx.state.research = Some(format!("Research for: {}", ctx.state.query)); Ok(NodeResult::next(WriteNode)) } } #[async_trait] impl BaseNode for WriteNode { fn name(&self) -> &str { "write" } async fn run( &self, ctx: &mut GraphRunContext, ) -> GraphResult> { let response = format!("Based on: {}", ctx.state.research.as_deref().unwrap_or("")); Ok(NodeResult::end(response)) } } let graph = Graph::new() .node("research", ResearchNode) .node("write", WriteNode) .entry("research") .build()?; let result = graph.run(WorkflowState::default(), ()).await?; ``` -------------------------------- ### Create a User Message Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-core/README.md Instantiate a user message using the Message::user constructor from the serdes-ai-core crate. Ensure the necessary types and roles are imported. ```rust use serdes_ai_core::{Message, Role, UserContent}; let message = Message::user("Hello, world!"); ``` -------------------------------- ### Initialize Vercel Stream Adapter Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-ui/README.md Initialize the VercelStreamAdapter for Vercel AI SDK compatibility. This adapter can be used to stream responses from an agent. ```rust use serdes_ai_ui::vercel::VercelStreamAdapter; let adapter = VercelStreamAdapter::new(); let response = adapter.stream_response(agent.run_stream("Hello", ()).await?); // Use with your web framework (axum, actix, etc.) ``` -------------------------------- ### Add Serdes-AI-UI to Dependencies Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-ui/README.md Add the serdes-ai-ui crate to your project's Cargo.toml file to include it as a dependency. ```toml [dependencies] serdes-ai-ui = "0.1" ``` -------------------------------- ### Add Serdes-AI Models to Dependencies Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-models/README.md Add this to your Cargo.toml file to include the serdes-ai-models crate in your project. ```toml [dependencies] serdes-ai-models = "0.1" ``` -------------------------------- ### Add SerdesAI to Cargo.toml Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md Add SerdesAI and Tokio to your project's dependencies in Cargo.toml. ```toml [dependencies] serdes-ai = "0.1" tokio = { version = "1", features = ["full"] } ``` -------------------------------- ### Add Serdes-AI Streaming Dependency Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-streaming/README.md Add the serdes-ai-streaming crate to your Cargo.toml file to include streaming support in your project. ```toml [dependencies] serdes-ai-streaming = "0.1" ``` -------------------------------- ### Run All SerdesAI Tests Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md Command to execute all tests across the SerdesAI workspace, including tests for all features. This is the most comprehensive test run. ```bash cargo test --workspace --all-features ``` -------------------------------- ### Run SerdesAI Tests with Specific Provider Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md Command to run tests for a specific feature, such as the 'openai' provider. This is useful for isolating tests related to a particular model integration. ```bash cargo test --features openai ``` -------------------------------- ### SerdesAI Dependencies with Full Feature Flag Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md This TOML snippet shows how to add SerdesAI to your project's dependencies with the 'full' feature enabled, which includes all available features. ```toml [dependencies] serdes-ai = { version = "0.1", features = ["full"] } ``` -------------------------------- ### Define and Use a Custom Output Type Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-output/README.md Define a struct with `Serialize`, `Deserialize`, and `Output` derives. Then, configure an Agent to use this custom output type. ```rust use serdes_ai_output::Output; use serdes_ai_macros::Output; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize, Output)] struct PersonInfo { name: String, age: u32, } let agent = Agent::new(model) .output_type::() .build(); ``` -------------------------------- ### Structured Output with SerdesAI Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md Define a struct for structured output and configure the agent to return this type. The struct must derive Serialize, Deserialize, and Output. ```rust use serdes_ai::prelude::*; use serdes_ai_macros::Output; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize, Output)] struct PersonInfo { name: String, age: u32, occupation: String, } let agent = Agent::new(model) .output_type::() .build(); let result = agent.run("John is a 30 year old engineer", ()).await?; println!("Extracted: {} is {} and works as {}", result.output.name, result.output.age, result.output.occupation ); ``` -------------------------------- ### Add Serdes-AI Core Dependency Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-core/README.md Add the serdes-ai-core crate to your project's Cargo.toml file to include its core functionalities. ```toml [dependencies] serdes-ai-core = "0.1" ``` -------------------------------- ### Tool Calling with SerdesAI Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md Define and use a custom tool for an agent. The tool definition includes parameters with a JSON schema. ```rust use serdes_ai::prelude::*; use serdes_ai_tools::{Tool, ToolDefinition, ToolReturn, ToolResult, SchemaBuilder}; struct CalculatorTool; impl Tool<()> for CalculatorTool { fn definition(&self) -> ToolDefinition { ToolDefinition::new("calculate", "Perform arithmetic calculations") .with_parameters( SchemaBuilder::new() .string("expression", "Math expression to evaluate", true) .build() .unwrap() ) } async fn call( &self, _ctx: &RunContext<()>, args: serde_json::Value ) -> ToolResult { let expr = args["expression"].as_str().unwrap(); // Evaluate the expression... Ok(ToolReturn::text("42")) } } let agent = Agent::new(model) .tool(CalculatorTool) .build(); ``` -------------------------------- ### Add Serdes-AI Retries to Dependencies Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-retries/README.md Add this TOML snippet to your Cargo.toml file to include the serdes-ai-retries crate. ```toml [dependencies] serdes-ai-retries = "0.1" ``` -------------------------------- ### Define and Run Evaluation Test Suite in Rust Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-evals/README.md Use EvalSuite, TestCase, and Evaluator to define a series of tests for an agent. The suite can be run asynchronously, and results include a pass rate. ```rust use serdes_ai_evals::{EvalSuite, TestCase, Evaluator}; let suite = EvalSuite::new("my-agent-tests") .case(TestCase::new("greeting") .input("Hello!") .expected_contains("Hello")) .case(TestCase::new("math") .input("What is 2+2?") .expected_contains("4")); let results = suite.run(&agent).await?; println!("Pass rate: {:.1}%", results.pass_rate() * 100.0); ``` -------------------------------- ### Configure Exponential Backoff Retry Strategy Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-retries/README.md Instantiate and configure an ExponentialBackoff retry strategy. Set the maximum number of retries, initial delay, and maximum delay. This strategy is then applied to an Agent. ```rust use serdes_ai_retries::{RetryStrategy, ExponentialBackoff}; let strategy = ExponentialBackoff::new() .max_retries(3) .initial_delay(Duration::from_millis(100)) .max_delay(Duration::from_secs(10)); let agent = Agent::new(model) .retry_strategy(strategy) .build(); ``` -------------------------------- ### Add Serdes-AI Dependency Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai/README.md Add the serdes-ai crate to your project's Cargo.toml file to include it as a dependency. ```toml [dependencies] serdes-ai = "0.1" ``` -------------------------------- ### Add Serdes-AI Agent Dependency Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-agent/README.md Add the serdes-ai-agent crate to your project's Cargo.toml file to include it as a dependency. ```toml [dependencies] serdes-ai-agent = "0.1" ``` -------------------------------- ### Add Serdes AI Providers Dependency Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-providers/README.md Add the serdes-ai-providers crate to your Cargo.toml file to include it in your project. ```toml [dependencies] serdes-ai-providers = "0.1" ``` -------------------------------- ### Add Serdes-AI Output Dependency Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-output/README.md Add the serdes-ai-output crate to your project's dependencies in Cargo.toml. ```toml [dependencies] serdes-ai-output = "0.1" ``` -------------------------------- ### Basic Usage of OpenAI Embeddings Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-embeddings/README.md Instantiate an OpenAI embedding model from environment variables and generate embeddings for a list of strings. Calculates cosine similarity between the first two generated embeddings. ```rust use serdes_ai_embeddings::{EmbeddingModel, OpenAIEmbeddings}; let model = OpenAIEmbeddings::from_env("text-embedding-3-small")?; let embeddings = model.embed(&["Hello, world!", "Goodbye!"]).await?; // Calculate similarity let similarity = embeddings[0].cosine_similarity(&embeddings[1]); ``` -------------------------------- ### Add serdes-ai-mcp to Dependencies Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-mcp/README.md Add the serdes-ai-mcp crate to your project's dependencies in Cargo.toml. ```toml [dependencies] serdes-ai-mcp = "0.1" ``` -------------------------------- ### SerdesAI Architecture Diagram Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md A visual representation of the SerdesAI crate architecture, illustrating the main facade crate and its sub-crates for agents, models, tools, and core functionalities. ```text ┌─────────────────────────────────────────────────────────────┐ │ serdes-ai │ │ (Main Facade Crate) │ └─────────────────────────────────────────────────────────────┘ │ ┌─────────────────────┼─────────────────────┐ │ │ │ ▼ ▼ ▼ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │ serdes-ai- │ │ serdes-ai- │ │ serdes-ai- │ │ agent │ │ models │ │ graph │ │ │ │ │ │ │ │ Agent logic │ │ Model trait │ │ Multi-agent │ │ Run context │ │ Providers │ │ workflows │ └───────────────┘ └───────────────┘ └───────────────┘ │ │ │ └──────────┬──────────┴──────────┬──────────┘ │ │ ▼ ▼ ┌───────────────┐ ┌───────────────┐ │ serdes-ai- │ │ serdes-ai- │ │ tools │ │ core │ │ │ │ │ │ Tool traits │ │ Messages │ │ Schema gen │ │ Errors │ └───────────────┘ └───────────────┘ ``` -------------------------------- ### Add Serdes-AI Graph Dependency Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-graph/README.md Add the serdes-ai-graph crate to your project's dependencies in Cargo.toml. ```toml [dependencies] serdes-ai-graph = "0.1" ``` -------------------------------- ### Add Serdes AI Tools Dependency Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-tools/README.md Add the serdes-ai-tools crate to your project's dependencies in Cargo.toml. ```toml [dependencies] serdes-ai-tools = "0.1" ``` -------------------------------- ### Add Serdes AI Toolsets Dependency Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-toolsets/README.md Add the serdes-ai-toolsets crate to your project's dependencies in Cargo.toml. ```toml [dependencies] serdes-ai-toolsets = "0.1" ``` -------------------------------- ### Add Serdes-AI Evals Dependency Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-evals/README.md Add the serdes-ai-evals crate to your Cargo.toml file to include it in your project dependencies. ```toml [dependencies] serdes-ai-evals = "0.1" ``` -------------------------------- ### Add Serdes-AI-A2A Dependency Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-a2a/README.md Add the serdes-ai-a2a crate to your project's dependencies in Cargo.toml. ```toml [dependencies] serdes-ai-a2a = "0.1" ``` -------------------------------- ### Rust Tool Derive Macro Usage Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-macros/README.md Apply the `#[tool]` macro to an async function to derive tool implementations. This macro takes a `description` argument for the tool. ```rust use serdes_ai_macros::tool; #[tool(description = "Calculate the sum of two numbers")] async fn add(a: i32, b: i32) -> i32 { a + b } ``` -------------------------------- ### Define a Custom Tool in Rust Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-tools/README.md Implement the Tool trait to define a custom tool. This includes defining its name, description, parameters using SchemaBuilder, and the call logic. ```rust use serdes_ai_tools::{Tool, ToolDefinition, ToolReturn, ToolResult, SchemaBuilder}; struct MyTool; impl Tool<()> for MyTool { fn definition(&self) -> ToolDefinition { ToolDefinition::new("my_tool", "Does something useful") .with_parameters( SchemaBuilder::new() .string("input", "The input value", true) .build() .unwrap() ) } async fn call( &self, _ctx: &RunContext<()>, args: serde_json::Value, ) -> ToolResult { Ok(ToolReturn::text("Done!")) } } ``` -------------------------------- ### Rust Output Derive Macro Usage Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-macros/README.md Use the `#[derive(Output)]` macro on a struct to automatically derive the Output trait, enabling JSON schema generation. Ensure `serde::{Deserialize, Serialize}` are also derived. ```rust use serdes_ai_macros::Output; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize, Output)] struct ExtractedData { /// The person's name name: String, /// Their age in years age: u32, /// Optional email address email: Option, } ``` -------------------------------- ### Add Serdes AI Embeddings Dependency Source: https://github.com/janfeddersen-wq/serdesai/blob/main/serdes-ai-embeddings/README.md Add the serdes-ai-embeddings crate to your project's Cargo.toml file to include embedding functionalities. ```toml [dependencies] serdes-ai-embeddings = "0.1" ``` -------------------------------- ### Streaming Responses with SerdesAI Source: https://github.com/janfeddersen-wq/serdesai/blob/main/README.md Process streaming responses from an agent. The stream yields AgentStreamEvent variants, and text deltas can be printed as they arrive. ```rust use serdes_ai::prelude::*; use serdes_ai_streaming::AgentStreamEvent; use futures::StreamExt; let mut stream = agent.run_stream("Write a poem", ()).await?; while let Some(event) = stream.next().await { if let AgentStreamEvent::TextDelta { content, .. } = event { print!("{}", content); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.