-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #3544 based on the data-type of message #3554
Fixes #3544 based on the data-type of message #3554
Conversation
The value of response_obj["choices"][0]["message"] is Message object and dict Added a conditional to use .json only iff it is Message Object
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
we should assume the response will be of type ModelResponse and it's subsequent pydantic objects - e.g. Messages. (since that's the type we enforce on The correct fix here is to fix the ollama file to return the correct pydantic object. @paneru-rajan let me know if you want to close this and open another pr, or rework the existing pr to fix the actual issue. |
Thank you, I update this PR with the proper fix, that commit was just a patch so it makes sense not to go that route. |
Following statement replaces the Pydantic Message Object and initialize it with the dict model_response["choices"][0]["message"] = response_json["message"] We need to make sure message is always litellm.Message object As a fix, based on the code of ollama.py file, i am updating just the content intead of entire object for both sync and async functions
Updated: Preserving the Pydantic Message Object
We need to make sure message is always As a fix, based on the code of Relevant issuesFixes #3544 Type🐛 Bug Fix Testing
Looks good to me, handing over to you @krrishdholakia for review. |
@paneru-rajan, do you mind assigning @krrishdholakia as the reviewer? Would be so nice if we could get this through🤞🏼 |
@@ -300,7 +300,7 @@ def get_ollama_response( | |||
model_response["choices"][0]["message"] = message | |||
model_response["choices"][0]["finish_reason"] = "tool_calls" | |||
else: | |||
model_response["choices"][0]["message"] = response_json["message"] | |||
model_response["choices"][0]["message"]["content"] = response_json["message"]["content"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't fix the problem of the message being a dict object instead of pydantic.
@paneru-rajan can you share a test you wrote to see if this fixed the problem, and that it's passing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seemed Github does not allow us to add reviewer. I tried adding @krrishdholakia as reviewer and then left the comment instead because of that. |
LGTM! thanks for sharing the screenshot @paneru-rajan that helped |
Fixes the error while ollama_chat use langfuse
The value of response_obj["choices"][0]["message"] is Message object and dict
Added a conditional to use .json only iff it is Message Object
Relevant issues
Fixes #3544
Type
🐛 Bug Fix
Testing
Error Replicates with
After fix it will work for both:
ollama_chat/llama3:instruct
andollama/llama3:instruct