Skip to content

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

alejandrojnm
Copy link

@alejandrojnm alejandrojnm commented Jul 26, 2025

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

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.
@alejandrojnm
Copy link
Author

HI @sashabaranov you think we can put this one in the next release ?

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.

1 participant