diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/openai.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/client/openai.rs b/src/client/openai.rs index e5f4d23..ab12b1a 100644 --- a/src/client/openai.rs +++ b/src/client/openai.rs @@ -110,6 +110,9 @@ pub async fn openai_chat_completions_streaming( let handle = |message: SseMmessage| -> Result<bool> { if message.data == "[DONE]" { if !function_name.is_empty() { + if function_arguments.is_empty() { + function_arguments = String::from("{}"); + } let arguments: Value = function_arguments.parse().with_context(|| { format!("Tool call '{function_name}' have non-JSON arguments '{function_arguments}'") })?; @@ -153,6 +156,9 @@ pub async fn openai_chat_completions_streaming( let maybe_call_id = format!("{}/{}", id.unwrap_or_default(), index.unwrap_or_default()); if maybe_call_id != call_id && maybe_call_id.len() >= call_id.len() { if !function_name.is_empty() { + if function_arguments.is_empty() { + function_arguments = String::from("{}"); + } let arguments: Value = function_arguments.parse().with_context(|| { format!("Tool call '{function_name}' have non-JSON arguments '{function_arguments}'") })?; |
