-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Issue
I'm currently trying to implement the usage of tools in my application, but I've been running into one issue in particular:
{
"error": {
"message": "'messages.3' : for 'role:tool' the following must be satisfied[('messages.3.tool_call_id' : property 'tool_call_id' is missing)]",
"type": "invalid_request_error"
}
}
Here is an example of the tool output response that I am sending back to the API:
{
"role": "tool",
"tool_call_id": "fc_4cc123ae-0ea8-40cc-a66e-d5829fac76ff",
"content": "NASA's Perseverance rover has found signs of ancient microbial life on Mars, China and India launched a joint rocket program, Jeremy Clarkson went to space."
}
As you can see, tool_call_id
is there in what I'm sending but it doesn't seem to be getting to Groq. I've tested both in my application (React Native) and Postman, but I get the same error.
Potential Cause
I don't really know Rust but I was looking through the codebase and found what might be the cause of this issue (???) located here:
pub struct ChatCompletionMessage {
pub role: String,
pub content: String,
}
Since tool_call_id
is given in a message and there's no optional parameter for the tool_call_id
in this struct, it seems that it might not be getting passed to Groq. Again, I don't know if I'm correct or if I'm misunderstanding the codebase but that's just my two cents.
If that is the issue, this might be a fix:
pub struct ChatCompletionMessage {
pub role: String,
pub content: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_call_id: Option<String>,
}