summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-06-11 17:52:04 +0800
committerGitHub <noreply@github.com>2024-06-11 17:52:04 +0800
commitaa94fb2f831ef8a85e76d4b056811093dc4205cf (patch)
tree3074b02604f9572c5c273cb84f3df74bbac390cb
parentb05b730cb5c1acdb47611a67bb98325bd86c2969 (diff)
downloadaichat-aa94fb2f831ef8a85e76d4b056811093dc4205cf.tar.gz
fix: infinite loop of function calls on poor LLM (#585)
-rw-r--r--src/function.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/function.rs b/src/function.rs
index 068cee0..b763dc2 100644
--- a/src/function.rs
+++ b/src/function.rs
@@ -28,6 +28,9 @@ pub fn eval_tool_calls(
return Ok(output);
}
calls = ToolCall::dedup(calls);
+ if calls.is_empty() {
+ bail!("The request was aborted because an infinite loop of function calls was detected.")
+ }
for call in calls {
let result = call.eval(config)?;
output.push(ToolCallResult::new(call, result));