Skip to content

git: Handle None values in ChatMessage content#422

Merged
aniketmaurya merged 2 commits intoLightning-AI:mainfrom
Lucaz0619:lucalin/fix-chat-message-null-content
Feb 6, 2025
Merged

git: Handle None values in ChatMessage content#422
aniketmaurya merged 2 commits intoLightning-AI:mainfrom
Lucaz0619:lucalin/fix-chat-message-null-content

Conversation

@Lucaz0619
Copy link
Copy Markdown
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! 🙃

@codecov
Copy link
Copy Markdown

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
Copy Markdown
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
20 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