Skip to content
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

Driver Api Key Validation #1455

Open
1 task done
griptapeOsipa opened this issue Dec 17, 2024 · 3 comments
Open
1 task done

Driver Api Key Validation #1455

griptapeOsipa opened this issue Dec 17, 2024 · 3 comments
Labels
type: discussion Open for conversation or brainstorming type:enhancement Improvements to existing features

Comments

@griptapeOsipa
Copy link

griptapeOsipa commented Dec 17, 2024

Describe the issue
Missing API keys show up in logs/errors as timeouts/retries that require an interruption to proceed.

Describe the solution you'd like
Could we surface a "missing api key" error that halts the script execution?

Additional context

from griptape.structures import Agent
agent = Agent()
agent.run('What are the colors of the rainbow?')

Results in:

[12/17/24 09:47:05] INFO     PromptTask 688ec1b7830f4d6ebf2df8310b5c41e6                                                         
                             Input: What are the colors of the rainbow?                                                          
WARNING:root:<RetryCallState 4383057408: attempt #1; slept for 0.0; last result: failed (OpenAIError The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable)>
WARNING:root:<RetryCallState 4383057408: attempt #2; slept for 2.0; last result: failed (OpenAIError The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable)>
WARNING:root:<RetryCallState 4383057408: attempt #3; slept for 4.0; last result: failed (OpenAIError The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable)>

...<interrupted>
@griptapeOsipa griptapeOsipa added the type:enhancement Improvements to existing features label Dec 17, 2024
@collindutter collindutter removed their assignment Dec 17, 2024
@collindutter collindutter removed their assignment Dec 19, 2024
@collindutter collindutter added the type: discussion Open for conversation or brainstorming label Dec 19, 2024
@collindutter
Copy link
Member

Related to #1439, I wonder if the solution here is to just fail faster?

@shhlife
Copy link

shhlife commented Dec 19, 2024

I think failing faster would be great - but also, it'd be nice to fail with a clear message. for some reason this:

WARNING:root:<RetryCallState 4383057408: attempt #1; slept for 0.0; last result: failed (OpenAIError The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable)>

is really hard to read for users. I get lots of messages where people go "Your stuff is broken!" but when I look at the logs I see this message all over the place.

I wonder if we could clean up the message a bit.. even:

WARNING:root:IMPORTANT: OpenAI API key is missing or invalid. Set it by passing `api_key` to the client or defining `OPENAI_API_KEY` as an environment variable. Error Details: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

or if we want to get fancy..

WARNING:root:
  IMPORTANT: OpenAI API key is missing or invalid.
  To resolve this issue, set the API key by:
    1. Passing `api_key` to the client explicitly, OR
    2. Setting the `OPENAI_API_KEY` environment variable.

  Error Details: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

@collindutter
Copy link
Member

Roger all that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: discussion Open for conversation or brainstorming type:enhancement Improvements to existing features
Projects
None yet
Development

No branches or pull requests

3 participants