GithubHelp home page GithubHelp logo

Did not find openai_api_key, please add an environment variable `OPENAI_API_KEY` which contains it, or pass `openai_api_key` as a named parameter. about chrome-gpt HOT 4 CLOSED

richardyc avatar richardyc commented on June 11, 2024
Did not find openai_api_key, please add an environment variable `OPENAI_API_KEY` which contains it, or pass `openai_api_key` as a named parameter.

from chrome-gpt.

Comments (4)

NickR23 avatar NickR23 commented on June 11, 2024

Seems to be a bug with getting environment variables from the calling bash shell in poetry.

A quick work around that works is to just pass the api key in chromegpt/agent/zeroshot.py:

 43 class ZeroShotAgent(ChromeGPTAgent):
 44     def __init__(self, model: str = "gpt-3.5-turbo", verbose: bool = False) -> None:
 45         """Initialize the ZeroShotAgent."""
 46         self.model = model
 47         self.agent = get_zeroshot_agent(
 48             llm=ChatOpenAI(model_name=model, temperature=0, openai_api_key='{YOUR_API_KEY_HERE}'),  # type: ignore
 49             verbose=verbose,
 50         )

Replace YOUR_API_KEY_HERE with your key.

from chrome-gpt.

BaseInfinity avatar BaseInfinity commented on June 11, 2024

Seems to be a bug with getting environment variables from the calling bash shell in poetry.

A quick work around that works is to just pass the api key in chromegpt/agent/zeroshot.py:

 43 class ZeroShotAgent(ChromeGPTAgent):
 44     def __init__(self, model: str = "gpt-3.5-turbo", verbose: bool = False) -> None:
 45         """Initialize the ZeroShotAgent."""
 46         self.model = model
 47         self.agent = get_zeroshot_agent(
 48             llm=ChatOpenAI(model_name=model, temperature=0, openai_api_key='{YOUR_API_KEY_HERE}'),  # type: ignore
 49             verbose=verbose,
 50         )

Replace YOUR_API_KEY_HERE with your key.

Ahh okay, I'll try that tomorrow and give it another whirl

from chrome-gpt.

NickR23 avatar NickR23 commented on June 11, 2024

Side note
There's different functions that use the api key for each agent so make sure you read the error logs for the right line to change

For example:

{...}
  File "/Users/nr/chromegpt/Chrome-GPT/chromegpt/agent/autogpt/autogpt.py", line 25, in __init__
    llm=ChatOpenAI(model_name=model, temperature=0),  # type: ignore
{...}

Would mean you should change that line to:
llm=ChatOpenAI(model_name=model, temperature=0, openai_api_key='{YOUR_API_KEY_HERE}'), # type: ignore

Just in case anyone else has this problem :)

from chrome-gpt.

BaseInfinity avatar BaseInfinity commented on June 11, 2024

This appears to be fixed in the latest version but ty for the quick response!

from chrome-gpt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.