diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 95426be2..96dd276b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ $ ./scripts/lint This will install all the required dependencies and build the SDK. -You can also [install go 1.18+ manually](https://go.dev/doc/install). +You can also [install Go 1.21+ manually](https://go.dev/doc/install). ## Modifying/Adding code diff --git a/README.md b/README.md index 07370d9c..e1615406 100644 --- a/README.md +++ b/README.md @@ -872,7 +872,7 @@ func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, // Handle stuff after the request end := time.Now() - LogRes(res, err, start - end) + LogRes(res, err, end.Sub(start)) return res, err } @@ -895,13 +895,15 @@ middleware has been applied. ## Microsoft Azure OpenAI -To use this library with [Azure OpenAI]https://learn.microsoft.com/azure/ai-services/openai/overview), +To use this library with [Azure OpenAI](https://learn.microsoft.com/azure/ai-services/openai/overview), use the option.RequestOption functions in the `azure` package. ```go package main import ( + "fmt" + "os" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/openai/openai-go/v2" "github.com/openai/openai-go/v2/azure" @@ -911,7 +913,7 @@ func main() { const azureOpenAIEndpoint = "https://.openai.azure.com" // The latest API versions, including previews, can be found here: - // https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#rest-api-versionng + // https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#rest-api-versioning const azureOpenAIAPIVersion = "2024-06-01" tokenCredential, err := azidentity.NewDefaultAzureCredential(nil) diff --git a/azure/azure.go b/azure/azure.go index 866e80ad..559f2a8f 100644 --- a/azure/azure.go +++ b/azure/azure.go @@ -121,7 +121,7 @@ func WithTokenCredential(tokenCredential azcore.TokenCredential) option.RequestO // WithAPIKey configures this client to authenticate using an API key. // This function should be paired with a call to [WithEndpoint] to point to your Azure OpenAI instance. func WithAPIKey(apiKey string) option.RequestOption { - // NOTE: there is an option.WithApiKey(), but that adds the value into + // NOTE: there is an option.WithAPIKey(), but that adds the value into // the Authorization header instead so we're doing this instead. return option.WithHeader("Api-Key", apiKey) } @@ -234,4 +234,4 @@ func (mp policyAdapter) Do(req *policy.Request) (*http.Response, error) { return (option.MiddlewareNext)(mp)(req.Raw()) } -const version = "v.0.1.0" +const version = "v0.1.0" diff --git a/option/requestoption.go b/option/requestoption.go index b48feb5a..13405ddd 100644 --- a/option/requestoption.go +++ b/option/requestoption.go @@ -33,7 +33,7 @@ func WithBaseURL(base string) RequestOption { return requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error { if err != nil { - return fmt.Errorf("requestoption: WithBaseURL failed to parse url %s", err) + return fmt.Errorf("requestoption: WithBaseURL failed to parse base URL %q: %v", base, err) } r.BaseURL = u @@ -232,7 +232,7 @@ func WithResponseInto(dst **http.Response) RequestOption { // WithRequestBody returns a RequestOption that provides a custom serialized body with the given // content type. // -// body accepts an io.Reader or raw []bytes. +// body accepts an io.Reader or raw []byte. func WithRequestBody(contentType string, body any) RequestOption { return requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error { if reader, ok := body.(io.Reader); ok { @@ -270,7 +270,7 @@ func WithEnvironmentProduction() RequestOption { func WithAPIKey(value string) RequestOption { return requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error { r.APIKey = value - return r.Apply(WithHeader("authorization", fmt.Sprintf("Bearer %s", r.APIKey))) + return r.Apply(WithHeader("Authorization", fmt.Sprintf("Bearer %s", r.APIKey))) }) }