Skip to content

feat: warn when expected API key is missing #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2024
Merged
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
4 changes: 4 additions & 0 deletions pkg/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ import (
"github.com/gptscript-ai/gptscript/pkg/cache"
env2 "github.com/gptscript-ai/gptscript/pkg/env"
"github.com/gptscript-ai/gptscript/pkg/loader"
"github.com/gptscript-ai/gptscript/pkg/mvl"
"github.com/gptscript-ai/gptscript/pkg/openai"
"github.com/gptscript-ai/gptscript/pkg/runner"
"github.com/gptscript-ai/gptscript/pkg/types"
)

var log = mvl.Package()

type Client struct {
clientsLock sync.Mutex
cache *cache.Client
Expand Down Expand Up @@ -102,6 +105,7 @@ func (c *Client) clientFromURL(apiURL string) (*openai.Client, error) {
env := "GPTSCRIPT_PROVIDER_" + env2.ToEnvLike(parsed.Hostname()) + "_API_KEY"
apiKey := os.Getenv(env)
if apiKey == "" {
log.Warnf("No API key found for %s", env)
apiKey = "<unset>"
}
return openai.NewClient(openai.Options{
Expand Down