Spaces:
Sleeping
Sleeping
Commit
·
ed9e96d
1
Parent(s):
a964a99
Update main.py
Browse files
main.py
CHANGED
@@ -29,7 +29,19 @@ 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 |
@cl.author_rename
|
34 |
def rename(orig_author: str):
|
35 |
rename_dict = {"ConversationalRetrievalChain": "💬 Assistant conversationnel", "Retriever": "Agent conversationnel", "StuffDocumentsChain": "Chaîne de documents", "LLMChain": "Agent", "ChatAnthropic": "🤖 IA"}
|
@@ -78,20 +90,6 @@ async def on_action(action):
|
|
78 |
cl.Action(name="close_button", value="closed", label="Fermer", description="Fermer le volet d'information!")
|
79 |
]
|
80 |
await cl.Message(author="🌐🌐🌐",content="Fermer le panneau d'information", actions=others).send()
|
81 |
-
|
82 |
-
@cl.cache
|
83 |
-
def retriever_to_cache():
|
84 |
-
index_name = os.environ['PINECONE_INDEX_NAME']
|
85 |
-
embeddings = HuggingFaceEmbeddings()
|
86 |
-
pinecone.init(
|
87 |
-
api_key=os.environ['PINECONE_API_KEY'],
|
88 |
-
environment=os.environ['PINECONE_ENVIRONMENT']
|
89 |
-
)
|
90 |
-
vectorstore = Pinecone.from_existing_index(
|
91 |
-
index_name=index_name, embedding=embeddings
|
92 |
-
)
|
93 |
-
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 60,"filter": {'categorie': {'$eq': 'OF'}}})
|
94 |
-
return retriever
|
95 |
|
96 |
@cl.cache
|
97 |
def to_cache(file):
|
|
|
29 |
|
30 |
os.environ["TOKENIZERS_PARALLELISM"] = os.environ["TOKENIZERS_PARALLELISM"]
|
31 |
os.environ['ANTHROPIC_API_KEY'] = os.environ['ANTHROPIC_API_KEY']
|
32 |
+
def retriever_to_cache():
|
33 |
+
index_name = os.environ['PINECONE_INDEX_NAME']
|
34 |
+
embeddings = HuggingFaceEmbeddings()
|
35 |
+
pinecone.init(
|
36 |
+
api_key=os.environ['PINECONE_API_KEY'],
|
37 |
+
environment=os.environ['PINECONE_ENVIRONMENT']
|
38 |
+
)
|
39 |
+
vectorstore = Pinecone.from_existing_index(
|
40 |
+
index_name=index_name, embedding=embeddings
|
41 |
+
)
|
42 |
+
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 60,"filter": {'categorie': {'$eq': 'OF'}}})
|
43 |
+
return retriever
|
44 |
+
|
45 |
@cl.author_rename
|
46 |
def rename(orig_author: str):
|
47 |
rename_dict = {"ConversationalRetrievalChain": "💬 Assistant conversationnel", "Retriever": "Agent conversationnel", "StuffDocumentsChain": "Chaîne de documents", "LLMChain": "Agent", "ChatAnthropic": "🤖 IA"}
|
|
|
90 |
cl.Action(name="close_button", value="closed", label="Fermer", description="Fermer le volet d'information!")
|
91 |
]
|
92 |
await cl.Message(author="🌐🌐🌐",content="Fermer le panneau d'information", actions=others).send()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
@cl.cache
|
95 |
def to_cache(file):
|