-
Notifications
You must be signed in to change notification settings - Fork 7
PR-500 simplified client wrapper functions #562
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR simplifies the client wrapper functions by introducing a unified helper to format OpenAI chat messages with various media types (image, audio, video) and by adding base64 conversion methods to the corresponding data types.
- Updated PIL image conversions by importing PILImage and aligning type hints.
- Added build_openai_chat_format and internal helper functions to process images, audio, and video.
- Extended data types with new to_base64_str methods for Image, Audio, and Video objects.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
clarifai/runners/utils/data_utils.py | Updated image conversion functions and added media processing functions for chat messages. |
clarifai/runners/utils/data_types.py | Added to_base64_str utility methods for converting media bytes to base64 strings. |
Comments suppressed due to low confidence (2)
clarifai/runners/utils/data_utils.py:132
- [nitpick] Consider using a distinct local variable for the base64 string conversion in _process_audio instead of reassigning the parameter 'audio', to improve code clarity.
if audio.bytes:
clarifai/runners/utils/data_utils.py:158
- [nitpick] Consider using a separate variable to hold the base64 string in _process_video rather than overwriting the parameter 'video', for improved readability.
if video.bytes:
Minimum allowed line rate is |
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.
Looks good, but not sure , should we add build_openai_chat_format
function to utils/openai_convertor.py
file?
@@ -58,6 +58,126 @@ def is_openai_chat_format(messages): | |||
return True | |||
|
|||
|
|||
def build_openai_chat_format(prompt: str, image: Image, images: List[Image], audio: Audio, |
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.
Not sure, do you think we could move this to here
Why
How
Tests