diff options
Diffstat (limited to 'makima/src/llm/groq.rs')
| -rw-r--r-- | makima/src/llm/groq.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/makima/src/llm/groq.rs b/makima/src/llm/groq.rs index be0e2bc..ee01fcf 100644 --- a/makima/src/llm/groq.rs +++ b/makima/src/llm/groq.rs @@ -92,6 +92,8 @@ struct MessageResponse { pub struct ChatResult { pub content: Option<String>, pub tool_calls: Vec<ToolCall>, + /// Raw tool call responses for including in subsequent messages + pub raw_tool_calls: Vec<ToolCallResponse>, pub finish_reason: String, } @@ -154,14 +156,13 @@ impl GroqClient { .next() .ok_or_else(|| GroqError::Api("No choices in response".to_string()))?; - let tool_calls = choice - .message - .tool_calls - .unwrap_or_default() - .into_iter() + let raw_tool_calls = choice.message.tool_calls.unwrap_or_default(); + + let tool_calls = raw_tool_calls + .iter() .map(|tc| ToolCall { - id: tc.id, - name: tc.function.name, + id: tc.id.clone(), + name: tc.function.name.clone(), arguments: serde_json::from_str(&tc.function.arguments).unwrap_or_default(), }) .collect(); @@ -169,6 +170,7 @@ impl GroqClient { Ok(ChatResult { content: choice.message.content, tool_calls, + raw_tool_calls, finish_reason: choice.finish_reason, }) } |
