Skip to content

Commit 868dcc6

Browse files
committed
fix index
1 parent a599063 commit 868dcc6

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

.env.example

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
OPENAI_API_KEY=""
22
PINECONE_API_KEY=""
3-
PINECONE_INDEX="movie-history"
4-
FEATURE_NAME="chat"
3+
PINECONE_INDEX_NAME="movie-history"
4+
FEATURE_NAME="chat" # "qa"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ This is a Retrieval-Augmented Generation (RAG) application using Langchain, Open
3838
```plaintext
3939
OPENAI_API_KEY=""
4040
PINECONE_API_KEY=""
41-
PINECONE_INDEX="movie-history"
41+
PINECONE_INDEX_NAME="movie-history"
4242
FEATURE_NAME="chat" # "qa"
4343
```
4444

src/feature/chat/chat_utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def __init__(self):
1717
# Set up API keys
1818
self.openai_api_key = os.environ.get("OPENAI_API_KEY")
1919
self.pinecone_api_key = os.environ.get("PINECONE_API_KEY")
20+
self.pinecone_index_name = os.environ.get("PINECONE_INDEX_NAME")
2021

2122

2223
# Initialize LLM
@@ -26,7 +27,7 @@ def __init__(self):
2627
embeddings = OpenAIEmbeddings(openai_api_key=self.openai_api_key)
2728

2829
# Initialize Pinecone Vector Store
29-
self.pincone_index = os.environ.get("PINECONE_INDEX")
30+
self.index_name = self.pinecone_index_name
3031
self.vectorstore = PineconeVectorStore(index_name=self.index_name, embedding=embeddings)
3132

3233
# Contextualize question

src/feature/qa/qa_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
# Set up API keys
1212
openai_api_key = os.environ.get("OPENAI_API_KEY")
1313
pinecone_api_key = os.environ.get("PINECONE_API_KEY")
14-
pincone_index = os.environ.get("PINECONE_INDEX")
14+
pincone_index_name = os.environ.get("PINECONE_INDEX_NAME")
1515

1616
class MovieQASystem:
1717
def __init__(self):
1818
embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
19-
self.index_name = pincone_index
19+
self.index_name = pincone_index_name
2020
self.vectorstore = PineconeVectorStore(index_name=self.index_name, embedding=embeddings)
2121

2222
# Using VectorStoreRetriever

src/vector_store/load_data.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,17 @@ def create_vectorstore():
3838
# Retrieve API keys and index name from environment variables
3939
openai_api_key = os.environ.get("OPENAI_API_KEY")
4040
pinecone_api_key = os.environ.get("PINECONE_API_KEY")
41-
pinecone_index = os.environ.get("PINECONE_INDEX")
41+
pinecone_index_name = os.environ.get("PINECONE_INDEX_NAME")
4242

4343
# Initialize OpenAI embeddings and Pinecone
4444
embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
4545
pc = Pinecone(api_key=pinecone_api_key)
4646

4747
# Create or connect to the Pinecone index
48-
index_name = pinecone_index
48+
index_name = pinecone_index_name
4949
if index_name not in pc.list_indexes().names():
50-
pc.create_index(name=index_name, dimension=1536, metric="cosine")
50+
print(f"pinecone {index_name} is not exist, create index and try again")
51+
return
5152

5253
print("Vector is storing, wait...")
5354
# Create the vector store using the split documents and embeddings

0 commit comments

Comments
 (0)