Skip to content
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

Support Request Level Custom Http Headers.. #909

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,12 @@ func (c *Client) CreateChatCompletion(
if err = validateRequestForO1Models(request); err != nil {
return
}

req, err := c.newRequest(
ctx,
http.MethodPost,
c.fullURL(urlSuffix, withModel(request.Model)),
withBody(request),
withCustomHeaders(request.Metadata),
)
if err != nil {
return
Expand Down
8 changes: 8 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@
}
}

func withCustomHeaders(headers map[string]string) requestOption {
return func(args *requestOptions) {
for key, value := range headers {
args.header.Set(key, value)
}

Check warning on line 97 in client.go

View check run for this annotation

Codecov / codecov/patch

client.go#L96-L97

Added lines #L96 - L97 were not covered by tests
}
}

func withBetaAssistantVersion(version string) requestOption {
return func(args *requestOptions) {
args.header.Set("OpenAI-Beta", fmt.Sprintf("assistants=%s", version))
Expand Down
Loading