Spaces:
Running
Running
gabrielaltay
commited on
Commit
•
85952ea
1
Parent(s):
3ac1a68
pinecone test
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from langchain_community.embeddings import HuggingFaceBgeEmbeddings
|
2 |
from langchain_community.vectorstores import Pinecone
|
|
|
3 |
from langchain_openai import ChatOpenAI
|
4 |
from pinecone import Pinecone as PineconeClient
|
5 |
import streamlit as st
|
@@ -34,10 +35,13 @@ def load_pinecone_vectorstore():
|
|
34 |
encode_kwargs=encode_kwargs,
|
35 |
query_instruction="Represent this question for searching relevant passages: ",
|
36 |
)
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
40 |
embedding=emb_fn,
|
|
|
|
|
41 |
)
|
42 |
return vectorstore
|
43 |
|
|
|
1 |
from langchain_community.embeddings import HuggingFaceBgeEmbeddings
|
2 |
from langchain_community.vectorstores import Pinecone
|
3 |
+
from langchain_community.vectorstores.utils import DistanceStrategy
|
4 |
from langchain_openai import ChatOpenAI
|
5 |
from pinecone import Pinecone as PineconeClient
|
6 |
import streamlit as st
|
|
|
35 |
encode_kwargs=encode_kwargs,
|
36 |
query_instruction="Represent this question for searching relevant passages: ",
|
37 |
)
|
38 |
+
pc = PineconeClient(api_key=st.secrets["pinecone_api_key"])
|
39 |
+
index = pc.Index(st.secrets["pinecone_index_name"])
|
40 |
+
vectorstore = Pinecone(
|
41 |
+
index=index,
|
42 |
embedding=emb_fn,
|
43 |
+
text_key="text",
|
44 |
+
distance_strategy=DistanceStrategy.COSINE,
|
45 |
)
|
46 |
return vectorstore
|
47 |
|