You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just want to have agent have some Tool.
I get this error???
[package]
name = "rust-abc"version = "0.1.0"edition = "2024"
[dependencies]
rig = { version = "0.42", features = ["agent"] } # 以 OpenAI 为例serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"anyhow = "1.0"tokio = { version = "1.0", features = ["full"] }
use rig::{Agent, client::Client, providers::openai};fnmain(){}#[derive(serde::Serialize, serde::Deserialize,Debug,Clone,Default)]pubstructOpenAIReq{puburl:String,pubapi_key:String,pubmodel:String,pubprompt:String,pubtemperature:Option<f64>,pubmax_tokens:Option<u32>,pubtop_p:Option<f64>,pubuser_system_prompt:Option<String>,}fnmake_agent(req:&OpenAIReq,preamble:Option<&str>) -> anyhow::Result<Agent>{let builder = openai::Client::builder().api_key(&req.api_key).base_url(&req.url);let api:Client<openai::OpenAIResponsesExt> = builder.build()?;letmut agent_builder = rig::client::AgentClientExt::agent(&api,&req.model);ifletSome(t) = req.max_tokens{
agent_builder = agent_builder.max_tokens(t asu64);}ifletSome(t) = preamble {
agent_builder = agent_builder.preamble(t);}ifletSome(t) = req.temperature{
agent_builder = agent_builder.temperature(t);}// TODO how to set this???
agent_builder = agent_builder.default_max_turns(20);
agent_builder = agent_builder.dynamic_tools(vec![]);let agent = agent_builder.build();
anyhow::Ok(agent)}
~/projects/rust-abc$ cargo b
Compiling rust-abc v0.1.0 (/home/yuyang/projects/rust-abc)
error[E0308]: mismatched types
--> src/main.rs:35:21
|
22 |let mut agent_builder = rig::client::AgentClientExt::agent(&api, &req.model);| ---------------------------------------------------- expected due to this value
...
35 | agent_builder = agent_builder.dynamic_tools(vec![]);| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `AgentBuilder`, found `AgentBuilder<WithBuilderTools>`|
= note: expected struct `AgentBuilder<NoToolConfig>`
found struct `AgentBuilder<WithBuilderTools>`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `rust-abc` (bin "rust-abc") due to 1 previous error
I get confused this error about.
someone can give a hint???
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
I have no idea,this error about??
I just want to have agent have some
Tool.I get this error???
I get confused this error about.
someone can give a hint???
All reactions