Spaces:
Runtime error
Runtime error
Update kadiApy_ragchain.py
Browse files- kadiApy_ragchain.py +4 -0
kadiApy_ragchain.py
CHANGED
|
@@ -20,9 +20,11 @@ class KadiApyRagchain:
|
|
| 20 |
rewritten_query = self.rewrite_query(query)
|
| 21 |
print("RRRRRRRRRREEEEEEEEEEWRITEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE: ",rewritten_query)
|
| 22 |
# Predict library usage
|
|
|
|
| 23 |
code_library_usage_prediction = self.predict_library_usage(query)
|
| 24 |
|
| 25 |
# Retrieve contexts
|
|
|
|
| 26 |
doc_contexts = self.retrieve_contexts(query, k=3, filter={"dataset_category": "kadi_apy_docs"})
|
| 27 |
code_contexts = self.retrieve_contexts(rewritten_query, k=5, filter={"usage": code_library_usage_prediction})
|
| 28 |
|
|
@@ -36,10 +38,12 @@ class KadiApyRagchain:
|
|
| 36 |
|
| 37 |
|
| 38 |
# Format contexts
|
|
|
|
| 39 |
formatted_doc_contexts = self.format_documents(doc_contexts)
|
| 40 |
formatted_code_contexts = self.format_documents(code_contexts)
|
| 41 |
|
| 42 |
# Generate response
|
|
|
|
| 43 |
response = self.generate_response(query, chat_history, formatted_doc_contexts, formatted_code_contexts)
|
| 44 |
|
| 45 |
# Add the response to the existing query in the conversation history
|
|
|
|
| 20 |
rewritten_query = self.rewrite_query(query)
|
| 21 |
print("RRRRRRRRRREEEEEEEEEEWRITEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE: ",rewritten_query)
|
| 22 |
# Predict library usage
|
| 23 |
+
print("Start prediction:")
|
| 24 |
code_library_usage_prediction = self.predict_library_usage(query)
|
| 25 |
|
| 26 |
# Retrieve contexts
|
| 27 |
+
print("Start retrieving:")
|
| 28 |
doc_contexts = self.retrieve_contexts(query, k=3, filter={"dataset_category": "kadi_apy_docs"})
|
| 29 |
code_contexts = self.retrieve_contexts(rewritten_query, k=5, filter={"usage": code_library_usage_prediction})
|
| 30 |
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
# Format contexts
|
| 41 |
+
print("Formatting docs:")
|
| 42 |
formatted_doc_contexts = self.format_documents(doc_contexts)
|
| 43 |
formatted_code_contexts = self.format_documents(code_contexts)
|
| 44 |
|
| 45 |
# Generate response
|
| 46 |
+
print("Start generatin repsonsse:")
|
| 47 |
response = self.generate_response(query, chat_history, formatted_doc_contexts, formatted_code_contexts)
|
| 48 |
|
| 49 |
# Add the response to the existing query in the conversation history
|