-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add file part support to chat message structure #1056
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
Introduces ChatMessagePartFile struct and ChatMessagePartTypeFile constant to support file attachments in chat messages. Updates ChatMessagePart to include file parts and adds comprehensive tests for serialization, deserialization, and constant definitions.
Refactored struct name for file parts in chat messages from ChatMessagePartFile to ChatMessageFile for consistency and clarity.
Corrected the indentation of the File field in the ChatMessagePart struct for improved code readability and consistency.
Replaces usage of ChatMessagePartFile with ChatMessageFile in chat_test.go to reflect updated type naming in the openai package. Also renames related test function for consistency.
Split a long conditional statement in TestMultipartChatMessageSerialization for improved readability.
HI @sashabaranov you think we can put this one in the next release ? |
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 adds support for file attachments in chat messages by introducing a new ChatMessageFile
struct and ChatMessagePartTypeFile
constant. This enables the OpenAI Go client to handle file parts within chat message structures.
- Introduces
ChatMessageFile
struct with fields for file ID, filename, and base64-encoded file data - Adds
ChatMessagePartTypeFile
constant and updatesChatMessagePart
to include file support - Comprehensive test coverage for serialization, deserialization, and constant validation
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
chat.go | Defines ChatMessageFile struct, adds ChatMessagePartTypeFile constant, and updates ChatMessagePart to include File field |
chat_test.go | Adds comprehensive tests for file part functionality including serialization/deserialization and constant validation |
Co-authored-by: Copilot <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1056 +/- ##
=======================================
Coverage 99.59% 99.59%
=======================================
Files 34 34
Lines 2205 2205
=======================================
Hits 2196 2196
Misses 6 6
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Introduces ChatMessageFile struct and ChatMessageTypeFile constant to support file attachments in chat messages. Updates ChatMessagePart to include file parts and adds comprehensive tests for serialization, deserialization, and constant definitions.
A similar PR may already be submitted!
Please search among the Pull request before creating one.
There is one https://github.com/sashabaranov/go-openai/pull/1053/files but this have the test
Describe the change
This PR is to add file to the message
Provide OpenAI documentation link
https://platform.openai.com/docs/api-reference/chat/create
Describe your solution
The solution is simple, there is not much to explain
Tests
Test are include