Tublian / DevDocGenie

API assistance for developers. It will digest all the API docs and act as a helper for a developer.
Apache License 2.0
6 stars 7 forks source link

FIXED #3

Open itsayopapi opened 9 months ago

itsayopapi commented 9 months ago

Problem: You were working on using Langchain RAG for your DocGenie project. The goal was to divide the process into two main steps: indexing, where you load documents and store embeddings, and retrieval, where you find the right embeddings to generate responses. You created two files, store.py for indexing and genie.py for answering questions using the stored data. However, when you ran genie.py, it threw an error.

Issue Details: The error pointed to a problem with the OpenAI API key. Specifically, it said the "OPENAI_API_KEY" environment variable wasn't set.

Initial Attempt: Originally, the code tried to set the "OPENAI_API_KEY" environment variable using os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY").

Identified Problem: The error happened because os.getenv("OPENAI_API_KEY") returned None when the environment variable wasn't set. Trying to assign this None value to os.environ["OPENAI_API_KEY"] caused a TypeError.

Solution Steps: Checked if the "OPENAI_API_KEY" environment variable was already set using "OPENAI_API_KEY" not in os.environ. If not set, printed an error message and exited the script using sys.exit(1). Set the "OPENAI_API_KEY" environment variable using os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY", ""). This ensured that if os.getenv("OPENAI_API_KEY") returned None, an empty string was used as a default value. Result: Now, the script checks if the "OPENAI_API_KEY" environment variable is set before using it. If the key is missing, the script prints an error message and exits, preventing the NoneType error.

User Action: To run the script successfully, you just need to set the "OPENAI_API_KEY" environment variable in your environment or in a .env file before running the script

nraychaudhuri commented 9 months ago

Actually, the issue is not with OPENAI_API_KEY. The issue is with the chroma_db. Please create a .env file add your OPENAI_API_KEY and run the genie.py file. You should be able to reproduce the issue

nraychaudhuri commented 9 months ago

@itsayopapi any update on this?