Spaces:
Sleeping
Sleeping
Merge branch 'main' of https://huggingface.co/spaces/bziiit/VEGETALIS_AI_API into main
Browse files
main.py
CHANGED
|
@@ -235,7 +235,7 @@ def generate_answer(user_input: UserInput):
|
|
| 235 |
|
| 236 |
template_prompt = base_template
|
| 237 |
|
| 238 |
-
context = get_retreive_answer(enterprise_id, prompt, index, common_namespace)
|
| 239 |
|
| 240 |
#final_prompt_simplified = prompt_formatting(prompt,template,context)
|
| 241 |
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",""))
|
|
|
|
| 235 |
|
| 236 |
template_prompt = base_template
|
| 237 |
|
| 238 |
+
context = get_retreive_answer(enterprise_id, prompt, index, common_namespace, user_id=user_input.user_id)
|
| 239 |
|
| 240 |
#final_prompt_simplified = prompt_formatting(prompt,template,context)
|
| 241 |
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
|
@@ -110,7 +110,7 @@ def add_to_knowledge_base(enterprise_id,information,index,enterprise_name,user_i
|
|
| 110 |
print(e)
|
| 111 |
return False
|
| 112 |
|
| 113 |
-
def get_retreive_answer(enterprise_id,prompt,index,common_id):
|
| 114 |
try:
|
| 115 |
print("common_id ",common_id)
|
| 116 |
|
|
@@ -123,6 +123,7 @@ def get_retreive_answer(enterprise_id,prompt,index,common_id):
|
|
| 123 |
)
|
| 124 |
|
| 125 |
enterprise_context = retriever.invoke(prompt)
|
|
|
|
| 126 |
|
| 127 |
if enterprise_context:
|
| 128 |
print("found enterprise context")
|
|
@@ -149,7 +150,7 @@ def get_retreive_answer(enterprise_id,prompt,index,common_id):
|
|
| 149 |
else:
|
| 150 |
print("no commun context")
|
| 151 |
|
| 152 |
-
response = enterprise_context + commun_context
|
| 153 |
|
| 154 |
else:
|
| 155 |
response = retriever.invoke(prompt)
|
|
|
|
| 110 |
print(e)
|
| 111 |
return False
|
| 112 |
|
| 113 |
+
def get_retreive_answer(enterprise_id,prompt,index,common_id,user_id=""):
|
| 114 |
try:
|
| 115 |
print("common_id ",common_id)
|
| 116 |
|
|
|
|
| 123 |
)
|
| 124 |
|
| 125 |
enterprise_context = retriever.invoke(prompt)
|
| 126 |
+
user_memory = retriever.invoke(prompt,filters={"user_id":user_id})
|
| 127 |
|
| 128 |
if enterprise_context:
|
| 129 |
print("found enterprise context")
|
|
|
|
| 150 |
else:
|
| 151 |
print("no commun context")
|
| 152 |
|
| 153 |
+
response = user_memory + enterprise_context + commun_context
|
| 154 |
|
| 155 |
else:
|
| 156 |
response = retriever.invoke(prompt)
|