|
| 1 | +use ag_ui_client::Agent; |
1 | 2 | use ag_ui_client::agent::{AgentError, RunAgentParams};
|
2 | 3 | use ag_ui_client::http::HttpAgent;
|
3 |
| -use reqwest::Url; |
4 |
| -use reqwest::header::{HeaderMap, HeaderValue}; |
5 | 4 |
|
6 |
| -use ag_ui_client::Agent; |
| 5 | +use ag_ui_core::JsonValue; |
7 | 6 | use ag_ui_core::types::ids::MessageId;
|
8 | 7 | use ag_ui_core::types::message::Message;
|
9 | 8 | use log::info;
|
| 9 | +use reqwest::Url; |
10 | 10 |
|
11 | 11 | #[tokio::main]
|
12 | 12 | async fn main() -> Result<(), AgentError> {
|
13 |
| - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); |
14 |
| - |
15 |
| - // Create a base URL for the mock server |
16 |
| - // Note: Make sure the mock server is running on this address |
17 |
| - let base_url = Url::parse("http://127.0.0.1:3001/") |
18 |
| - .map_err(|e| AgentError::ConfigError {message: e.to_string() })?; |
| 13 | + env_logger::Builder::from_default_env().init(); |
19 | 14 |
|
20 |
| - // Create headers |
21 |
| - let mut headers = HeaderMap::new(); |
22 |
| - headers.insert("Content-Type", HeaderValue::from_static("application/json")); |
| 15 | + // Base URL for the mock server |
| 16 | + // Run the following command to start the mock server: |
| 17 | + // `uv run rust-sdk/crates/ag-ui-client/scripts/basic_agent.py` |
| 18 | + let base_url = Url::parse("http://127.0.0.1:3001/").map_err(|e| AgentError::ConfigError { |
| 19 | + message: e.to_string(), |
| 20 | + })?; |
23 | 21 |
|
24 |
| - // Create the HTTP agent |
25 |
| - let agent = HttpAgent::new(base_url, headers); |
| 22 | + // Create agent |
| 23 | + let agent = HttpAgent::builder().with_url(base_url).build()?; |
26 | 24 |
|
27 | 25 | // Create run parameters
|
28 |
| - let params = RunAgentParams { |
29 |
| - run_id: None, |
30 |
| - tools: None, |
31 |
| - context: None, |
| 26 | + let params = RunAgentParams::<JsonValue, _> { |
32 | 27 | forwarded_props: Some(serde_json::json!({})),
|
33 | 28 | messages: vec![Message::User {
|
34 | 29 | id: MessageId::random(),
|
35 | 30 | content: "Can you give me the current temperature in New York?".into(),
|
36 | 31 | name: None,
|
37 | 32 | }],
|
38 |
| - state: serde_json::json!({}), |
| 33 | + ..Default::default() |
39 | 34 | };
|
40 | 35 |
|
41 | 36 | info!("Running agent...");
|
|
0 commit comments