JayZeeDesign / researcher-gpt

454 stars 253 forks source link

Cannot find openai_api_key #8

Closed iainvdp closed 1 year ago

iainvdp commented 1 year ago

Hi All,

Get the following error when running app.py:

2023-09-05 20:07:01.187 Uncaught app exception Traceback (most recent call last): File "/Users/xxxx/Desktop/GPT_RESEARCHER_PROJECT/myenv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script exec(code, module.dict) File "/Users/xxxx/Desktop/GPT_RESEARCHER_PROJECT/researcher-gpt/app.py", line 161, in llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo-16k-0613", openai_api_key=OpenAI_key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/xxxx/Desktop/GPT_RESEARCHER_PROJECT/myenv/lib/python3.11/site-packages/langchain/load/serializable.py", line 75, in init super().init(**kwargs) File "/Users/xxxx/Desktop/GPT_RESEARCHER_PROJECT/myenv/lib/python3.11/site-packages/pydantic/v1/main.py", line 341, in init raise validation_error pydantic.v1.error_wrappers.ValidationError: 1 validation error for ChatOpenAI root 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. (type=value_error)

Have attempted to define openai_api_key="xxxx" directly as shown but to no avail.

Any help would be greatly appreciated!! Thanks

iainvdp commented 1 year ago

My API key was invalid. Generated a new one and solved the issue. Thanks