-
Couldn't load subscription status.
- Fork 0
Add file input support to Chat Completion types #4
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.
Co-authored-by: Copilot <[email protected]>
…based (sashabaranov#1079) fixes sashabaranov#978 Signed-off-by: Christopher Petito <[email protected]>
| // only 3.5 models have the "." stripped in their names | ||
| if strings.Contains(model, "3.5") { | ||
| return regexp.MustCompile(`[.:]`).ReplaceAllString(model, "") | ||
| } | ||
| return strings.ReplaceAll(model, ":", "") |
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 like this is the latest from upstream main. No worries from me about this.
| // ChatMessageFile is a placeholder for file parts in chat messages. | ||
| type ChatMessageFile struct { | ||
| FileID string `json:"file_id,omitempty"` | ||
| FileName string `json:"filename,omitempty"` | ||
| FileData string `json:"file_data,omitempty"` // Base64 encoded file data | ||
| } | ||
|
|
||
| type ChatMessagePartType string | ||
|
|
||
| const ( | ||
| ChatMessagePartTypeText ChatMessagePartType = "text" | ||
| ChatMessagePartTypeImageURL ChatMessagePartType = "image_url" | ||
| ChatMessagePartTypeFile ChatMessagePartType = "file" | ||
| ) | ||
|
|
||
| type ChatMessagePart struct { | ||
| Type ChatMessagePartType `json:"type,omitempty"` | ||
| Text string `json:"text,omitempty"` | ||
| ImageURL *ChatMessageImageURL `json:"image_url,omitempty"` | ||
| File *ChatMessageFile `json:"file,omitempty"` |
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.
Assuming these all checkout to what OpenAI expects, LGTM. Alas, I'm failing to find where this API is documented in their chat completion API documentation.
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.
@rjcorwin this is what I've seen. It's not easy to find: https://platform.openai.com/docs/api-reference/chat/create#chat_create-messages-user_message-content-array_of_content_parts-file_content_part-file
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.
Thanks @kabirkhan ! I feel good about this knowing you and @rjcorwin have both looked at it. Looks correct to me.
Update to the most recent
sashabaranov/masterchanges.Also merge the commits from this currently Open PR: sashabaranov#1056
This change adds support for the File input parameters to the Chat Completions API and supports the Document input work in ai-guide.