Error : Environment variable 'OPEN_API_KEY'.
jerpicard opened this issue · 1 comments
Hello,
Thanks for your tuto, very interesting and helpful!
When I launch the script and after entering the information "API Key" and the file, I got this issue :
Uncaught app exception Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script exec(code, module.__dict__) File "/Users/jerome/Downloads/tuto_chatbot_csv.py", line 28, in <module> embeddings = OpenAIEmbeddings() File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__ pydantic.error_wrappers.ValidationError: 1 validation error for OpenAIEmbeddings __root__ Did not find openai_api_key, please add an environment variable
OPENAI_API_KEYwhich contains it, or pass
openai_api_keyas a named parameter. (type=value_error)
Any help would be very appreciated.
Hello,
I solved the issue by replacing the line :
embeddings = OpenAIEmbeddings()
with
embeddings = OpenAIEmbeddings(openai_api_key=user_api_key)
Regards,