(executor: &mut AgentExecutor, input: &str)
| 1584 | } |
| 1585 | |
| 1586 | async fn process_message(executor: &mut AgentExecutor, input: &str) -> anyhow::Result<()> { |
| 1587 | print!("\nAssistant: "); |
| 1588 | io::stdout().flush()?; |
| 1589 | |
| 1590 | let stream = executor.execute_streaming(input.to_string()).await?; |
| 1591 | |
| 1592 | let mut stream = std::pin::pin!(stream); |
| 1593 | let mut full_response = String::new(); |
| 1594 | |
| 1595 | while let Some(event) = stream.next().await { |
| 1596 | match event { |
| 1597 | Ok(StreamEvent::TextDelta(text)) => { |
| 1598 | print!("{}", text); |
| 1599 | full_response.push_str(&text); |
| 1600 | io::stdout().flush()?; |
| 1601 | } |
| 1602 | Ok(StreamEvent::ToolCallStart { id: _, name }) => { |
| 1603 | println!("\n[Calling tool: {}]", name); |
| 1604 | } |
| 1605 | Ok(StreamEvent::ToolCallDelta { .. }) => {} |
| 1606 | Ok(StreamEvent::Done) => { |
| 1607 | break; |
| 1608 | } |
| 1609 | Ok(StreamEvent::Error(e)) => { |
| 1610 | eprintln!("\nError: {}", e); |
| 1611 | break; |
| 1612 | } |
| 1613 | Err(e) => { |
| 1614 | eprintln!("\nError: {}", e); |
| 1615 | break; |
| 1616 | } |
| 1617 | _ => {} |
| 1618 | } |
| 1619 | } |
| 1620 | |
| 1621 | println!("\n"); |
| 1622 | Ok(()) |
| 1623 | } |
| 1624 | |
| 1625 | fn list_models_interactive(registry: &ProviderRegistry) { |
| 1626 | println!("\nAvailable Models:\n"); |
no test coverage detected