Spaces:
Sleeping
Sleeping
Update kadi_apy_bot.py
Browse files- kadi_apy_bot.py +4 -2
kadi_apy_bot.py
CHANGED
@@ -25,7 +25,7 @@ class KadiAPYBot:
|
|
25 |
|
26 |
# Retrieve contexts
|
27 |
doc_contexts = self.retrieve_contexts(query, k=5, filter={"usage": "doc"})
|
28 |
-
code_contexts = self.retrieve_contexts(rewritten_query, k=
|
29 |
|
30 |
# Format contexts
|
31 |
formatted_doc_contexts = self.format_documents(doc_contexts)
|
@@ -40,6 +40,7 @@ class KadiAPYBot:
|
|
40 |
return response
|
41 |
|
42 |
|
|
|
43 |
def add_to_conversation(self, user_query=None, llm_response=None):
|
44 |
"""
|
45 |
Add either the user's query, the LLM's response, or both to the conversation history.
|
@@ -124,6 +125,7 @@ class KadiAPYBot:
|
|
124 |
|
125 |
def format_documents(self, documents):
|
126 |
formatted_docs = []
|
|
|
127 |
for i, doc in enumerate(documents, start=1):
|
128 |
formatted_docs.append(f"Snippet {i}: \n")
|
129 |
formatted_docs.append("\n")
|
@@ -140,7 +142,7 @@ class KadiAPYBot:
|
|
140 |
print(doc.page_content)
|
141 |
print("\n\n")
|
142 |
print("------------------------------End of retrived doc------------------------------------------------")
|
143 |
-
formatted_docs.append("\n\n
|
144 |
|
145 |
return formatted_docs
|
146 |
|
|
|
25 |
|
26 |
# Retrieve contexts
|
27 |
doc_contexts = self.retrieve_contexts(query, k=5, filter={"usage": "doc"})
|
28 |
+
code_contexts = self.retrieve_contexts(rewritten_query, k=5, filter={"usage": code_library_usage_prediction})
|
29 |
|
30 |
# Format contexts
|
31 |
formatted_doc_contexts = self.format_documents(doc_contexts)
|
|
|
40 |
return response
|
41 |
|
42 |
|
43 |
+
#not supported yet, need session handling in app.py
|
44 |
def add_to_conversation(self, user_query=None, llm_response=None):
|
45 |
"""
|
46 |
Add either the user's query, the LLM's response, or both to the conversation history.
|
|
|
125 |
|
126 |
def format_documents(self, documents):
|
127 |
formatted_docs = []
|
128 |
+
print("################################# start of doc #######################################")
|
129 |
for i, doc in enumerate(documents, start=1):
|
130 |
formatted_docs.append(f"Snippet {i}: \n")
|
131 |
formatted_docs.append("\n")
|
|
|
142 |
print(doc.page_content)
|
143 |
print("\n\n")
|
144 |
print("------------------------------End of retrived doc------------------------------------------------")
|
145 |
+
formatted_docs.append("\n\n")
|
146 |
|
147 |
return formatted_docs
|
148 |
|