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