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

pydantic.v1.error_wrappers.ValidationError | Did not find openai_api_key #17

Open
ravisksahu opened this issue Nov 22, 2024 · 1 comment

Comments

@ravisksahu
Copy link

Hi, I am a complete novice in coding. tried replicating the steps and got errors. Following is the log-

Traceback (most recent call last):
File "C:\Users\Ravi Kumar\Desktop\New folder\langchain-rag-tutorial-main\langchain-rag-tutorial-in-rag-tutorial-main\query_data.py", line 29, in main
embedding_function = OpenAIEmbeddings()
^^^^^^^^^^^^^^^^^^
File "C:\Users\Ravi Kumar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pydantic\v1\main.py", line 341, in init
raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for OpenAIEmbeddings
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)

please help.

@taureanamir
Copy link

you need to create a file named .env in the root directory of the project. it should contain the following line
OPENAI_API_KEY=sk-proj-xxxxxxx
The API key you can get from your open ai account https://platform.openai.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants