Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ from langchain.embeddings import HuggingFaceEmbeddings
|
|
6 |
from langchain.document_loaders import WhatsAppChatLoader
|
7 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
8 |
from dotenv import load_dotenv
|
9 |
-
import
|
10 |
|
11 |
load_dotenv()
|
12 |
|
@@ -15,12 +15,16 @@ pinecone_key = os.getenv("PINECONE_API_KEY")
|
|
15 |
pinecone.init(api_key=pinecone_key, environment='us-west1-gcp')
|
16 |
index_name = "whatsapp-chat-index"
|
17 |
|
18 |
-
if index_name not in
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
|
25 |
index = pinecone.Index(index_name)
|
26 |
|
|
|
6 |
from langchain.document_loaders import WhatsAppChatLoader
|
7 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
8 |
from dotenv import load_dotenv
|
9 |
+
from pinecone import Pinecone, ServerlessSpec
|
10 |
|
11 |
load_dotenv()
|
12 |
|
|
|
15 |
pinecone.init(api_key=pinecone_key, environment='us-west1-gcp')
|
16 |
index_name = "whatsapp-chat-index"
|
17 |
|
18 |
+
if 'index_name' not in pc.list_indexes().names():
|
19 |
+
pc.create_index(
|
20 |
+
name=index_name,
|
21 |
+
dimension=1536,
|
22 |
+
metric='euclidean',
|
23 |
+
spec=ServerlessSpec(
|
24 |
+
cloud='aws',
|
25 |
+
region='us-west-2'
|
26 |
+
)
|
27 |
+
)
|
28 |
|
29 |
index = pinecone.Index(index_name)
|
30 |
|