Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,20 +19,13 @@ os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY
|
|
| 19 |
def embedding_db():
|
| 20 |
embeddings = OpenAIEmbeddings()
|
| 21 |
|
| 22 |
-
#
|
|
|
|
| 23 |
pc = Pinecone(
|
| 24 |
api_key=PINECONE_API_KEY,
|
| 25 |
environment=PINECONE_ENV
|
| 26 |
)
|
| 27 |
|
| 28 |
-
# Check if index exists, create if needed
|
| 29 |
-
if 'langchain-demo-indexes' not in pc.list_indexes().names():
|
| 30 |
-
pc.create_index(
|
| 31 |
-
name='langchain-demo-indexes',
|
| 32 |
-
dimension=1536, # Adjust dimension if needed
|
| 33 |
-
metric='euclidean'
|
| 34 |
-
)
|
| 35 |
-
|
| 36 |
|
| 37 |
docs_split = doc_preprocessing() # Make sure this function is defined
|
| 38 |
doc_db = Pinecone.from_documents(
|
|
|
|
| 19 |
def embedding_db():
|
| 20 |
embeddings = OpenAIEmbeddings()
|
| 21 |
|
| 22 |
+
# Using 'from pinecone import Pinecone' explicitly:
|
| 23 |
+
from pinecone import Pinecone
|
| 24 |
pc = Pinecone(
|
| 25 |
api_key=PINECONE_API_KEY,
|
| 26 |
environment=PINECONE_ENV
|
| 27 |
)
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
docs_split = doc_preprocessing() # Make sure this function is defined
|
| 31 |
doc_db = Pinecone.from_documents(
|