diff options
| author | Ren Kararou <[email protected]> | 2025-11-18 08:15:34 -0600 |
|---|---|---|
| committer | Ren Kararou <[email protected]> | 2025-11-18 08:15:34 -0600 |
| commit | 7f8802a39aafd3fe0098f165888d05ae8ad534d6 (patch) | |
| tree | 4648909b491555ca3bc8a6ae40aa4f0c77341ecd /src/main.rs | |
| parent | 222f490f07b9d8557ba40f503bb929589516fa11 (diff) | |
| download | violet-7f8802a39aafd3fe0098f165888d05ae8ad534d6.tar.gz violet-7f8802a39aafd3fe0098f165888d05ae8ad534d6.tar.bz2 violet-7f8802a39aafd3fe0098f165888d05ae8ad534d6.zip | |
move call to end of routine
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 12cb491..a9ff484 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,6 +54,19 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { parameters: json!({}), }, }); + tools.push(Tool { + tool_type: "function".into(), + function: Function { + name: "wikipedia_lookup".into(), + description: Some("Look up a wikipedia article and have its summary returned.".into()), + parameters: json!({ + "title": { + "type": "string", + "description": "The title of the article to look up." + } + }), + }, + }); eprintln!("Tools Loaded"); let date: String = Utc::now().date_naive().to_string(); let system_prompt: String = format!("The current date is {date}. {}", &config.system_prompt); @@ -86,6 +99,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { if let Some(reason) = choice.finish_reason { match reason.as_str() { "tool_calls" => { + let mut need_call = false; if let Some(calls) = choice.message.clone().tool_calls { for call in calls { match call.function.name.as_str() { @@ -95,7 +109,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { let v = v["sign"].as_str().unwrap_or_default(); let val: String = get_horoscope(v).await; req.messages.push(Message::tool(val, call.id)); - response = client.chat(&req).await?; + need_call = true; }, "stop" => { println!("Agent has stopped the conversation."); @@ -109,6 +123,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { _ => (), } } + if need_call { + response = client.chat(&req).await?; + } } }, _ => (), |
