Skip to content

Commit

Permalink
improved code coverage and removed unnecessary checks
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushSawant18588 committed Nov 23, 2024
1 parent 88775cf commit b69335b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
18 changes: 6 additions & 12 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,14 @@ func withBody(body any) requestOption {

func withExtraBody(extraBody map[string]any) requestOption {
return func(args *requestOptions) {
// Initialize args.body as a map[string]any if it's nil.
if args.body == nil {
args.body = make(map[string]any)
}
// Assert that args.body is a map[string]any.
bodyMap, ok := args.body.(map[string]any)
if !ok {
// If it's not, initialize it as a map[string]any.
bodyMap = make(map[string]any)
args.body = bodyMap
}
// Add extraBody fields to args.body.
for key, value := range extraBody {
bodyMap[key] = value
if ok {
// If it's a map[string]any then only add extraBody
// fields to args.body otherwise keep only fields in request struct.
for key, value := range extraBody {
bodyMap[key] = value
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions embeddings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func TestEmbeddingEndpoint(t *testing.T) {
"input_type": "query",
"truncate": "NONE",
},
Dimensions: 1,
},
)
checks.NoError(t, err, "CreateEmbeddings error")
Expand Down

0 comments on commit b69335b

Please sign in to comment.