Spaces:
Running
Running
AFischer1985
commited on
Commit
•
4cb0924
1
Parent(s):
57eea41
Update RAG
Browse files
run.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
# Title: Gradio Interface to LLM-chatbot with dynamic RAG-funcionality and ChromaDB
|
3 |
# Author: Andreas Fischer
|
4 |
# Date: October 10th, 2024
|
5 |
-
# Last update: October
|
6 |
##########################################################################################
|
7 |
|
8 |
import os
|
@@ -294,8 +294,9 @@ def multimodal_response(message, history, dropdown, hfToken, request: gr.Request
|
|
294 |
collection=add_doc(message["text"], session)
|
295 |
client = chromadb.PersistentClient(path=dbPath)
|
296 |
print(str(client.list_collections()))
|
297 |
-
x=collection.get(include=[])["ids"]
|
298 |
-
|
|
|
299 |
context=["<Kontext "+str(i)+"> "+str(c)+"</Kontext "+str(i)+">" for i,c in enumerate(context["documents"][0])]
|
300 |
gr.Info("Kontext:\n"+str(context))
|
301 |
generate_kwargs = dict(
|
|
|
2 |
# Title: Gradio Interface to LLM-chatbot with dynamic RAG-funcionality and ChromaDB
|
3 |
# Author: Andreas Fischer
|
4 |
# Date: October 10th, 2024
|
5 |
+
# Last update: October 24th, 2024
|
6 |
##########################################################################################
|
7 |
|
8 |
import os
|
|
|
294 |
collection=add_doc(message["text"], session)
|
295 |
client = chromadb.PersistentClient(path=dbPath)
|
296 |
print(str(client.list_collections()))
|
297 |
+
x=collection.get(include=[])["ids"]
|
298 |
+
ragQuery=[format_prompt(query, history) if len(history)>0 else query]
|
299 |
+
context=collection.query(query_texts=ragQuery, n_results=1)
|
300 |
context=["<Kontext "+str(i)+"> "+str(c)+"</Kontext "+str(i)+">" for i,c in enumerate(context["documents"][0])]
|
301 |
gr.Info("Kontext:\n"+str(context))
|
302 |
generate_kwargs = dict(
|