Skip to content

Commit

Permalink
Add optFns
Browse files Browse the repository at this point in the history
  • Loading branch information
hupe1980 committed Jun 25, 2023
1 parent 39034d9 commit 57d46c6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion huggingface.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ type InferenceClient struct {
}

// NewInferenceClient creates a new InferenceClient instance with the specified token.
func NewInferenceClient(token string) *InferenceClient {
func NewInferenceClient(token string, optFns ...func(o *InferenceClientOptions)) *InferenceClient {
opts := InferenceClientOptions{
Endpoint: "https://huggingface.co",
InferenceEndpoint: "https://api-inference.huggingface.co",
}

for _, fn := range optFns {
fn(&opts)
}

return &InferenceClient{
httpClient: http.DefaultClient,
token: token,
Expand Down

0 comments on commit 57d46c6

Please sign in to comment.