Spaces:
Runtime error
Runtime error
Commit
·
fb9cb6f
1
Parent(s):
48ec9ba
Update main.py
Browse files
main.py
CHANGED
|
@@ -247,7 +247,8 @@ async def main(message: cl.Message):
|
|
| 247 |
task1 = cl.Task(title="Connexion à la base documentaire, en attente...", status=cl.TaskStatus.RUNNING)
|
| 248 |
await pineconeRetriever.add_task(task1)
|
| 249 |
await pineconeRetriever.send()
|
| 250 |
-
|
|
|
|
| 251 |
index_name = os.environ['PINECONE_INDEX_NAME']
|
| 252 |
pinecone.init(
|
| 253 |
api_key=os.environ['PINECONE_API_KEY'],
|
|
@@ -255,15 +256,19 @@ async def main(message: cl.Message):
|
|
| 255 |
)
|
| 256 |
embeddings = HuggingFaceEmbeddings()
|
| 257 |
task1.status = cl.TaskStatus.DONE
|
| 258 |
-
task2 = cl.Task(title="Recherche par cosine similarity, en attente...", status=cl.TaskStatus.RUNNING)
|
| 259 |
await pineconeRetriever.add_task(task2)
|
| 260 |
await pineconeRetriever.send()
|
|
|
|
|
|
|
| 261 |
docsearch = Pinecone.from_existing_index(index_name, embeddings)
|
| 262 |
retrieve = docsearch.similarity_search(message.content, k=40, filter={'categorie': {'$eq': 'OF'}})
|
| 263 |
task2.status = cl.TaskStatus.DONE
|
| 264 |
task3 = cl.Task(title="Création du contexte documentaire, en attente...", status=cl.TaskStatus.RUNNING)
|
| 265 |
await pineconeRetriever.add_task(task3)
|
| 266 |
await pineconeRetriever.send()
|
|
|
|
|
|
|
| 267 |
context = ''
|
| 268 |
metadatas = ''
|
| 269 |
text_elements = []
|
|
@@ -276,6 +281,7 @@ async def main(message: cl.Message):
|
|
| 276 |
context += '\n' + retrieve[i].page_content
|
| 277 |
task3.status = cl.TaskStatus.DONE
|
| 278 |
await cl.sleep(20)
|
|
|
|
| 279 |
await pineconeRetriever.remove()
|
| 280 |
memory = cl.user_session.get("memory")
|
| 281 |
runnable = cl.user_session.get("runnable") # type: Runnable
|
|
|
|
| 247 |
task1 = cl.Task(title="Connexion à la base documentaire, en attente...", status=cl.TaskStatus.RUNNING)
|
| 248 |
await pineconeRetriever.add_task(task1)
|
| 249 |
await pineconeRetriever.send()
|
| 250 |
+
message_id1 = await cl.Message(content="Connexion en cours").send()
|
| 251 |
+
task1.forId = message_id1
|
| 252 |
index_name = os.environ['PINECONE_INDEX_NAME']
|
| 253 |
pinecone.init(
|
| 254 |
api_key=os.environ['PINECONE_API_KEY'],
|
|
|
|
| 256 |
)
|
| 257 |
embeddings = HuggingFaceEmbeddings()
|
| 258 |
task1.status = cl.TaskStatus.DONE
|
| 259 |
+
task2 = cl.Task(title="Recherche sémantique par cosine similarity, en attente...", status=cl.TaskStatus.RUNNING)
|
| 260 |
await pineconeRetriever.add_task(task2)
|
| 261 |
await pineconeRetriever.send()
|
| 262 |
+
message_id2 = await cl.Message(content="Recherche sémantique en cours").send()
|
| 263 |
+
task2.forId = message_id2
|
| 264 |
docsearch = Pinecone.from_existing_index(index_name, embeddings)
|
| 265 |
retrieve = docsearch.similarity_search(message.content, k=40, filter={'categorie': {'$eq': 'OF'}})
|
| 266 |
task2.status = cl.TaskStatus.DONE
|
| 267 |
task3 = cl.Task(title="Création du contexte documentaire, en attente...", status=cl.TaskStatus.RUNNING)
|
| 268 |
await pineconeRetriever.add_task(task3)
|
| 269 |
await pineconeRetriever.send()
|
| 270 |
+
message_id3 = await cl.Message(content="Création du contexte en cours").send()
|
| 271 |
+
task3.forId = message_id3
|
| 272 |
context = ''
|
| 273 |
metadatas = ''
|
| 274 |
text_elements = []
|
|
|
|
| 281 |
context += '\n' + retrieve[i].page_content
|
| 282 |
task3.status = cl.TaskStatus.DONE
|
| 283 |
await cl.sleep(20)
|
| 284 |
+
await pineconeRetriever.send()
|
| 285 |
await pineconeRetriever.remove()
|
| 286 |
memory = cl.user_session.get("memory")
|
| 287 |
runnable = cl.user_session.get("runnable") # type: Runnable
|