Skip to content
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

git: Handle None values in ChatMessage content #422

Conversation

Lucaz0619
Copy link
Contributor

@Lucaz0619 Lucaz0619 commented Feb 6, 2025

What does this PR do?

Fixes None values in ChatMessage content.
This PR aligns the ChatMessage model with the OpenAI API spec by allowing content to be either a string or null. It also updates the non_streaming_completion method to handle None values, preventing potential TypeError during message concatenation.

Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • [v] Did you read the contributor guideline, Pull Request section?
  • [v] Did you make sure to update the docs?
  • Did you write any new necessary tests?

💡 How Does This PR Impact Users?

✅ Improved OpenAI API Compatibility:
Users integrating with the OpenAI API will no longer face errors when the content field is null (which is always the case when OpenAI returns a function call). This ensures smooth interoperability, especially when handling function calls.
✅ Flexible Function Call Handling:
When OpenAI returns function calls with null content, users can now decide whether to handle these functions directly in the predict function, providing greater flexibility in managing LLM responses.

PR review

Focus on the changes to the ChatMessage model and non_streaming_completion method.

Did you have fun?

Absolutely! 🙃

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 89%. Comparing base (54f1430) to head (75d61da).
Report is 1 commits behind head on main.

Additional details and impacted files
@@         Coverage Diff         @@
##           main   #422   +/-   ##
===================================
- Coverage    89%    89%   -0%     
===================================
  Files        31     31           
  Lines      2021   2023    +2     
===================================
+ Hits       1807   1808    +1     
- Misses      214    215    +1     

Copy link
Collaborator

@aniketmaurya aniketmaurya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! thanks for the fix 🚀

@aniketmaurya aniketmaurya merged commit 38d7169 into Lightning-AI:main Feb 6, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants