pub struct GopherAgent { /* private fields */ }Expand description
A gopher-orch agent for running AI queries.
Implementations§
Source§impl GopherAgent
impl GopherAgent
Sourcepub fn create(config: Config) -> Result<Self>
pub fn create(config: Config) -> Result<Self>
Create a new GopherAgent with the given configuration.
Examples found in repository?
examples/client_example_json.rs (line 46)
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 create_with_api_key(
provider: &str,
model: &str,
api_key: &str,
) -> Result<Self>
pub fn create_with_api_key( provider: &str, model: &str, api_key: &str, ) -> Result<Self>
Create a new GopherAgent with an API key.
Sourcepub fn create_with_server_config(
provider: &str,
model: &str,
server_config: &str,
) -> Result<Self>
pub fn create_with_server_config( provider: &str, model: &str, server_config: &str, ) -> Result<Self>
Create a new GopherAgent with a server config.
Sourcepub fn run(&self, query: &str) -> Result<String>
pub fn run(&self, query: &str) -> Result<String>
Run a query against the agent with the default timeout (60 seconds).
Examples found in repository?
examples/client_example_json.rs (line 67)
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 run_with_timeout(&self, query: &str, timeout_ms: u64) -> Result<String>
pub fn run_with_timeout(&self, query: &str, timeout_ms: u64) -> Result<String>
Run a query against the agent with a custom timeout.
Sourcepub fn run_detailed(&self, query: &str) -> AgentResult
pub fn run_detailed(&self, query: &str) -> AgentResult
Run a query and return detailed result information.
Sourcepub fn run_detailed_with_timeout(
&self,
query: &str,
timeout_ms: u64,
) -> AgentResult
pub fn run_detailed_with_timeout( &self, query: &str, timeout_ms: u64, ) -> AgentResult
Run a query with custom timeout and return detailed result.
Sourcepub fn is_disposed(&self) -> bool
pub fn is_disposed(&self) -> bool
Check if the agent has been disposed.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for GopherAgent
impl RefUnwindSafe for GopherAgent
impl Unpin for GopherAgent
impl UnsafeUnpin for GopherAgent
impl UnwindSafe for GopherAgent
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