yvann-ba / Robby-chatbot

AI chatbot 🤖 for chat with CSV, PDF, TXT files 📄 and YTB videos 🎥 | using Langchain🦜 | OpenAI | Streamlit ⚡
MIT License
766 stars 287 forks source link

Error : Environment variable 'OPEN_API_KEY'. #38

Closed jerpicard closed 1 year ago

jerpicard commented 1 year ago

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 variableOPENAI_API_KEYwhich contains it, or passopenai_api_keyas a named parameter. (type=value_error)

Any help would be very appreciated.

chatbot-error

jerpicard commented 1 year ago

Hello,

I solved the issue by replacing the line :

embeddings = OpenAIEmbeddings()

with

embeddings = OpenAIEmbeddings(openai_api_key=user_api_key)

Regards,