File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package anthropic
22
33import (
4+ "cmp"
45 "context"
56 "encoding/base64"
67 "encoding/json"
@@ -37,17 +38,11 @@ func New(opts ...Option) ai.Provider {
3738 for _ , o := range opts {
3839 o (& options )
3940 }
40- if options .baseURL == "" {
41- options .baseURL = "https://api.anthropic.com"
42- }
4341
44- if options .name == "" {
45- options .name = "anthropic"
46- }
42+ options .baseURL = cmp .Or (options .baseURL , "https://api.anthropic.com" )
43+ options .name = cmp .Or (options .name , "anthropic" )
4744
48- return & provider {
49- options : options ,
50- }
45+ return & provider {options : options }
5146}
5247
5348func WithBaseURL (baseURL string ) Option {
Original file line number Diff line number Diff line change 11package openai
22
33import (
4+ "cmp"
45 "context"
56 "encoding/base64"
67 "encoding/json"
@@ -43,25 +44,17 @@ func New(opts ...Option) ai.Provider {
4344 o (& options )
4445 }
4546
46- if options .baseURL == "" {
47- options .baseURL = "https://api.openai.com/v1"
48- }
49-
50- if options .name == "" {
51- options .name = "openai"
52- }
47+ options .baseURL = cmp .Or (options .baseURL , "https://api.openai.com/v1" )
48+ options .name = cmp .Or (options .name , "openai" )
5349
5450 if options .organization != "" {
5551 options .headers ["OpenAi-Organization" ] = options .organization
5652 }
57-
5853 if options .project != "" {
5954 options .headers ["OpenAi-Project" ] = options .project
6055 }
6156
62- return & provider {
63- options : options ,
64- }
57+ return & provider {options : options }
6558}
6659
6760func WithBaseURL (baseURL string ) Option {
You can’t perform that action at this time.
0 commit comments