Spaces:
Sleeping
Sleeping
Ilyas KHIAT
commited on
Commit
·
8698bd5
1
Parent(s):
d069333
user filter
Browse files
main.py
CHANGED
|
@@ -232,7 +232,7 @@ def generate_answer(user_input: UserInput):
|
|
| 232 |
|
| 233 |
template_prompt = base_template
|
| 234 |
|
| 235 |
-
context = get_retreive_answer(enterprise_id, prompt, index, common_namespace)
|
| 236 |
|
| 237 |
#final_prompt_simplified = prompt_formatting(prompt,template,context)
|
| 238 |
infos_added_to_kb = handle_calling_add_to_knowledge_base(prompt,enterprise_id,index,getattr(user_input,"marque",""),user_id=getattr(user_input,"user_id",""))
|
|
|
|
| 232 |
|
| 233 |
template_prompt = base_template
|
| 234 |
|
| 235 |
+
context = get_retreive_answer(enterprise_id, prompt, index, common_namespace, user_id=user_input.user_id)
|
| 236 |
|
| 237 |
#final_prompt_simplified = prompt_formatting(prompt,template,context)
|
| 238 |
infos_added_to_kb = handle_calling_add_to_knowledge_base(prompt,enterprise_id,index,getattr(user_input,"marque",""),user_id=getattr(user_input,"user_id",""))
|
rag.py
CHANGED
|
@@ -108,7 +108,7 @@ def add_to_knowledge_base(enterprise_id,information,index,enterprise_name,user_i
|
|
| 108 |
print(e)
|
| 109 |
return False
|
| 110 |
|
| 111 |
-
def get_retreive_answer(enterprise_id,prompt,index,common_id):
|
| 112 |
try:
|
| 113 |
print("common_id ",common_id)
|
| 114 |
|
|
@@ -121,6 +121,7 @@ def get_retreive_answer(enterprise_id,prompt,index,common_id):
|
|
| 121 |
)
|
| 122 |
|
| 123 |
enterprise_context = retriever.invoke(prompt)
|
|
|
|
| 124 |
|
| 125 |
if enterprise_context:
|
| 126 |
print("found enterprise context")
|
|
@@ -147,7 +148,7 @@ def get_retreive_answer(enterprise_id,prompt,index,common_id):
|
|
| 147 |
else:
|
| 148 |
print("no commun context")
|
| 149 |
|
| 150 |
-
response = enterprise_context + commun_context
|
| 151 |
|
| 152 |
else:
|
| 153 |
response = retriever.invoke(prompt)
|
|
|
|
| 108 |
print(e)
|
| 109 |
return False
|
| 110 |
|
| 111 |
+
def get_retreive_answer(enterprise_id,prompt,index,common_id,user_id=""):
|
| 112 |
try:
|
| 113 |
print("common_id ",common_id)
|
| 114 |
|
|
|
|
| 121 |
)
|
| 122 |
|
| 123 |
enterprise_context = retriever.invoke(prompt)
|
| 124 |
+
user_memory = retriever.invoke(prompt,filters={"user_id":user_id})
|
| 125 |
|
| 126 |
if enterprise_context:
|
| 127 |
print("found enterprise context")
|
|
|
|
| 148 |
else:
|
| 149 |
print("no commun context")
|
| 150 |
|
| 151 |
+
response = user_memory + enterprise_context + commun_context
|
| 152 |
|
| 153 |
else:
|
| 154 |
response = retriever.invoke(prompt)
|