Spaces:
Sleeping
Sleeping
Commit
·
1fd02ed
1
Parent(s):
bcc83c3
Update main.py
Browse files
main.py
CHANGED
@@ -29,20 +29,12 @@ import datetime
|
|
29 |
|
30 |
os.environ["TOKENIZERS_PARALLELISM"] = os.environ["TOKENIZERS_PARALLELISM"]
|
31 |
os.environ['ANTHROPIC_API_KEY'] = os.environ['ANTHROPIC_API_KEY']
|
32 |
-
|
33 |
embeddings = HuggingFaceEmbeddings()
|
34 |
pinecone.init(
|
35 |
api_key=os.environ['PINECONE_API_KEY'],
|
36 |
environment="us-west4-gcp-free"
|
37 |
)
|
38 |
-
index_name = pinecone.Index("")
|
39 |
-
@cl.cache
|
40 |
-
def retriever_to_cache():
|
41 |
-
vectorstore = Pinecone.from_existing_index(
|
42 |
-
index_name=index_name, embedding=embeddings
|
43 |
-
)
|
44 |
-
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 30,"filter": {'categorie': {'$eq': 'OF'}}})
|
45 |
-
return retriever
|
46 |
|
47 |
@cl.author_rename
|
48 |
def rename(orig_author: str):
|
@@ -98,6 +90,13 @@ def to_cache(file):
|
|
98 |
#time.sleep(5) # Simulate a time-consuming process
|
99 |
return "https://cipen.univ-gustave-eiffel.fr/fileadmin/CIPEN/datas/assets/docs/" + file + ".csv"
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
@cl.set_chat_profiles
|
103 |
async def chat_profile():
|
|
|
29 |
|
30 |
os.environ["TOKENIZERS_PARALLELISM"] = os.environ["TOKENIZERS_PARALLELISM"]
|
31 |
os.environ['ANTHROPIC_API_KEY'] = os.environ['ANTHROPIC_API_KEY']
|
32 |
+
index_name = os.environ['PINECONE_INDEX_NAME']
|
33 |
embeddings = HuggingFaceEmbeddings()
|
34 |
pinecone.init(
|
35 |
api_key=os.environ['PINECONE_API_KEY'],
|
36 |
environment="us-west4-gcp-free"
|
37 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
@cl.author_rename
|
40 |
def rename(orig_author: str):
|
|
|
90 |
#time.sleep(5) # Simulate a time-consuming process
|
91 |
return "https://cipen.univ-gustave-eiffel.fr/fileadmin/CIPEN/datas/assets/docs/" + file + ".csv"
|
92 |
|
93 |
+
@cl.cache
|
94 |
+
def retriever_to_cache():
|
95 |
+
vectorstore = Pinecone.from_existing_index(
|
96 |
+
index_name=index_name, embedding=embeddings
|
97 |
+
)
|
98 |
+
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 30,"filter": {'categorie': {'$eq': 'OF'}}})
|
99 |
+
return retriever
|
100 |
|
101 |
@cl.set_chat_profiles
|
102 |
async def chat_profile():
|