tidyverse / elmer

Call LLM APIs from R
http://elmer.tidyverse.org/
Other
178 stars 24 forks source link

Groq: conversation history with tool calls causes HTTP 400 #162

Open jcheng5 opened 2 hours ago

jcheng5 commented 2 hours ago

It seems that Groq doesn't like tool calls in its message history?

library(elmer)

#' Get the current time
get_current_time <- function() {
  format(Sys.time())
}

chat <- chat_groq(model="llama-3.2-1b-preview")
chat$register_tool(tool(
  get_current_time,
  "Get the current time."
))

print(chat$chat("What time is it?"))
print(chat$chat("How about now?"))

Result:

Error in `req_perform()`:
! HTTP 400 Bad Request.
• 'messages.4' : for 'role:assistant' the following must be satisfied[('messages.4.content' : value must be a string)]
jcheng5 commented 2 hours ago

No such issue when using ollama with llama3.2. So appears to be Groq-specific.

hadley commented 2 hours ago

Do you think this needs more than documentation?