forked from sashabaranov/go-openai
-
Notifications
You must be signed in to change notification settings - 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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
16e8cff
Add file part support to chat message structure
alejandrojnm 5ebd614
Rename ChatMessagePartFile to ChatMessageFile
alejandrojnm d970292
Fix indentation in ChatMessagePart struct
alejandrojnm dfe5ae2
Update tests to use ChatMessageFile type
alejandrojnm 1000a61
Fix formatting in multipart chat message test
alejandrojnm fa78712
Update chat.go
alejandrojnm 5d7a276
Stop stripping dots in azure model mapper for models that aren't 3.5 …
krissetto 02e8eae
Merge remote-tracking branch 'sashabaranov/master' into release/v1.41.2
kabirkhan 8a32d42
Merge remote-tracking branch 'alejandrojnm/master' into release/v1.41.2
kabirkhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ package openai | |
| import ( | ||
| "net/http" | ||
| "regexp" | ||
| "strings" | ||
| ) | ||
|
|
||
| const ( | ||
|
|
@@ -70,7 +71,11 @@ func DefaultAzureConfig(apiKey, baseURL string) ClientConfig { | |
| APIType: APITypeAzure, | ||
| APIVersion: "2023-05-15", | ||
| AzureModelMapperFunc: func(model string) string { | ||
| return regexp.MustCompile(`[.:]`).ReplaceAllString(model, "") | ||
| // 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, ":", "") | ||
|
Comment on lines
+74
to
+78
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is the latest from upstream |
||
| }, | ||
|
|
||
| HTTPClient: &http.Client{}, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 @matthewmorgan . I wasn't using their docs site correctly.