forked from phoenix/litellm-mirror
fix(cohere_chat.py): handle tool_result + user message being passed in
This commit is contained in:
parent
6f34998cab
commit
259e3b1245
2 changed files with 6 additions and 0 deletions
|
@ -233,6 +233,11 @@ def completion(
|
||||||
optional_params["tool_results"] = [most_recent_message]
|
optional_params["tool_results"] = [most_recent_message]
|
||||||
elif isinstance(most_recent_message, str):
|
elif isinstance(most_recent_message, str):
|
||||||
optional_params["message"] = most_recent_message
|
optional_params["message"] = most_recent_message
|
||||||
|
|
||||||
|
## check if chat history message is 'user' and 'tool_results' is given -> force_single_step=True, else cohere api fails
|
||||||
|
if len(chat_history) > 0 and chat_history[-1]["role"] == "USER":
|
||||||
|
optional_params["force_single_step"] = True
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"model": model,
|
"model": model,
|
||||||
"chat_history": chat_history,
|
"chat_history": chat_history,
|
||||||
|
|
|
@ -1632,6 +1632,7 @@ def cohere_messages_pt_v2(
|
||||||
Note:
|
Note:
|
||||||
- cannot specify message if the last entry in chat history contains tool results
|
- cannot specify message if the last entry in chat history contains tool results
|
||||||
- message must be at least 1 token long or tool results must be specified.
|
- message must be at least 1 token long or tool results must be specified.
|
||||||
|
- cannot specify tool_results if the last entry in chat history contains a user message
|
||||||
"""
|
"""
|
||||||
tool_calls: List = get_all_tool_calls(messages=messages)
|
tool_calls: List = get_all_tool_calls(messages=messages)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue