pub struct ConfigBuilder { /* private fields */ }Expand description
Builder for creating Config instances.
Implementations§
Source§impl ConfigBuilder
impl ConfigBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ConfigBuilder.
Examples found in repository?
examples/client_example_json.rs (line 40)
35fn main() {
36 let provider = "AnthropicProvider";
37 let model = "claude-3-haiku-20240307";
38
39 // Create agent with JSON server configuration
40 let config = ConfigBuilder::new()
41 .with_provider(provider)
42 .with_model(model)
43 .with_server_config(SERVER_CONFIG)
44 .build();
45
46 let agent = match GopherAgent::create(config) {
47 Ok(agent) => agent,
48 Err(e) => {
49 eprintln!("Error: {}", e);
50 std::process::exit(1);
51 }
52 };
53
54 println!("GopherAgent created!");
55
56 // Get question from command line args or use default
57 let args: Vec<String> = env::args().collect();
58 let question = if args.len() > 1 {
59 args[1..].join(" ")
60 } else {
61 "What is the weather like in New York?".to_string()
62 };
63
64 println!("Question: {}", question);
65
66 // Run the query
67 match agent.run(&question) {
68 Ok(answer) => {
69 println!("Answer:");
70 println!("{}", answer);
71 }
72 Err(e) => {
73 eprintln!("Error: {}", e);
74 std::process::exit(1);
75 }
76 }
77}Sourcepub fn with_provider<S: Into<String>>(self, provider: S) -> Self
pub fn with_provider<S: Into<String>>(self, provider: S) -> Self
Set the provider name.
Examples found in repository?
examples/client_example_json.rs (line 41)
35fn main() {
36 let provider = "AnthropicProvider";
37 let model = "claude-3-haiku-20240307";
38
39 // Create agent with JSON server configuration
40 let config = ConfigBuilder::new()
41 .with_provider(provider)
42 .with_model(model)
43 .with_server_config(SERVER_CONFIG)
44 .build();
45
46 let agent = match GopherAgent::create(config) {
47 Ok(agent) => agent,
48 Err(e) => {
49 eprintln!("Error: {}", e);
50 std::process::exit(1);
51 }
52 };
53
54 println!("GopherAgent created!");
55
56 // Get question from command line args or use default
57 let args: Vec<String> = env::args().collect();
58 let question = if args.len() > 1 {
59 args[1..].join(" ")
60 } else {
61 "What is the weather like in New York?".to_string()
62 };
63
64 println!("Question: {}", question);
65
66 // Run the query
67 match agent.run(&question) {
68 Ok(answer) => {
69 println!("Answer:");
70 println!("{}", answer);
71 }
72 Err(e) => {
73 eprintln!("Error: {}", e);
74 std::process::exit(1);
75 }
76 }
77}Sourcepub fn with_model<S: Into<String>>(self, model: S) -> Self
pub fn with_model<S: Into<String>>(self, model: S) -> Self
Set the model name.
Examples found in repository?
examples/client_example_json.rs (line 42)
35fn main() {
36 let provider = "AnthropicProvider";
37 let model = "claude-3-haiku-20240307";
38
39 // Create agent with JSON server configuration
40 let config = ConfigBuilder::new()
41 .with_provider(provider)
42 .with_model(model)
43 .with_server_config(SERVER_CONFIG)
44 .build();
45
46 let agent = match GopherAgent::create(config) {
47 Ok(agent) => agent,
48 Err(e) => {
49 eprintln!("Error: {}", e);
50 std::process::exit(1);
51 }
52 };
53
54 println!("GopherAgent created!");
55
56 // Get question from command line args or use default
57 let args: Vec<String> = env::args().collect();
58 let question = if args.len() > 1 {
59 args[1..].join(" ")
60 } else {
61 "What is the weather like in New York?".to_string()
62 };
63
64 println!("Question: {}", question);
65
66 // Run the query
67 match agent.run(&question) {
68 Ok(answer) => {
69 println!("Answer:");
70 println!("{}", answer);
71 }
72 Err(e) => {
73 eprintln!("Error: {}", e);
74 std::process::exit(1);
75 }
76 }
77}Sourcepub fn with_api_key<S: Into<String>>(self, api_key: S) -> Self
pub fn with_api_key<S: Into<String>>(self, api_key: S) -> Self
Set the API key.
Sourcepub fn with_server_config<S: Into<String>>(self, server_config: S) -> Self
pub fn with_server_config<S: Into<String>>(self, server_config: S) -> Self
Set the server config JSON.
Examples found in repository?
examples/client_example_json.rs (line 43)
35fn main() {
36 let provider = "AnthropicProvider";
37 let model = "claude-3-haiku-20240307";
38
39 // Create agent with JSON server configuration
40 let config = ConfigBuilder::new()
41 .with_provider(provider)
42 .with_model(model)
43 .with_server_config(SERVER_CONFIG)
44 .build();
45
46 let agent = match GopherAgent::create(config) {
47 Ok(agent) => agent,
48 Err(e) => {
49 eprintln!("Error: {}", e);
50 std::process::exit(1);
51 }
52 };
53
54 println!("GopherAgent created!");
55
56 // Get question from command line args or use default
57 let args: Vec<String> = env::args().collect();
58 let question = if args.len() > 1 {
59 args[1..].join(" ")
60 } else {
61 "What is the weather like in New York?".to_string()
62 };
63
64 println!("Question: {}", question);
65
66 // Run the query
67 match agent.run(&question) {
68 Ok(answer) => {
69 println!("Answer:");
70 println!("{}", answer);
71 }
72 Err(e) => {
73 eprintln!("Error: {}", e);
74 std::process::exit(1);
75 }
76 }
77}Sourcepub fn build(self) -> Config
pub fn build(self) -> Config
Build the Config.
Examples found in repository?
examples/client_example_json.rs (line 44)
35fn main() {
36 let provider = "AnthropicProvider";
37 let model = "claude-3-haiku-20240307";
38
39 // Create agent with JSON server configuration
40 let config = ConfigBuilder::new()
41 .with_provider(provider)
42 .with_model(model)
43 .with_server_config(SERVER_CONFIG)
44 .build();
45
46 let agent = match GopherAgent::create(config) {
47 Ok(agent) => agent,
48 Err(e) => {
49 eprintln!("Error: {}", e);
50 std::process::exit(1);
51 }
52 };
53
54 println!("GopherAgent created!");
55
56 // Get question from command line args or use default
57 let args: Vec<String> = env::args().collect();
58 let question = if args.len() > 1 {
59 args[1..].join(" ")
60 } else {
61 "What is the weather like in New York?".to_string()
62 };
63
64 println!("Question: {}", question);
65
66 // Run the query
67 match agent.run(&question) {
68 Ok(answer) => {
69 println!("Answer:");
70 println!("{}", answer);
71 }
72 Err(e) => {
73 eprintln!("Error: {}", e);
74 std::process::exit(1);
75 }
76 }
77}Trait Implementations§
Source§impl Debug for ConfigBuilder
impl Debug for ConfigBuilder
Source§impl Default for ConfigBuilder
impl Default for ConfigBuilder
Source§fn default() -> ConfigBuilder
fn default() -> ConfigBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ConfigBuilder
impl RefUnwindSafe for ConfigBuilder
impl Send for ConfigBuilder
impl Sync for ConfigBuilder
impl Unpin for ConfigBuilder
impl UnsafeUnpin for ConfigBuilder
impl UnwindSafe for ConfigBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more