Spaces:
Runtime error
Runtime error
Update kadi_apy_bot.py
Browse files- kadi_apy_bot.py +6 -15
kadi_apy_bot.py
CHANGED
|
@@ -18,7 +18,7 @@ class KadiAPYBot:
|
|
| 18 |
#self.add_to_conversation(user_query=query)
|
| 19 |
|
| 20 |
# Rewrite query
|
| 21 |
-
|
| 22 |
|
| 23 |
# Predict library usage
|
| 24 |
# code_library_usage_prediction = self.predict_library_usage(query)
|
|
@@ -27,8 +27,8 @@ class KadiAPYBot:
|
|
| 27 |
# doc_contexts = self.retrieve_contexts(query, k=3, filter={"usage": "doc"})
|
| 28 |
# code_contexts = self.retrieve_contexts(rewritten_query, k=5, filter={"usage": code_library_usage_prediction})
|
| 29 |
|
| 30 |
-
doc_contexts = self.retrieve_contexts(query, k=3, filter={"
|
| 31 |
-
code_contexts = self.retrieve_contexts(rewritten_query, k=5, filter={"
|
| 32 |
|
| 33 |
# Format contexts
|
| 34 |
# formatted_doc_contexts = self.format_documents(doc_contexts)
|
|
@@ -153,23 +153,14 @@ class KadiAPYBot:
|
|
| 153 |
"""
|
| 154 |
Generate a response using the retrieved contexts and the LLM.
|
| 155 |
"""
|
| 156 |
-
prompt = f"""You are an expert python developer. You are assisting in generating code for users
|
| 157 |
-
make use of a python library named 'kadiAPY' to interact with the API of a software. It provides an object-oriented
|
| 158 |
-
approach for interfacing with the API.
|
| 159 |
-
|
| 160 |
-
You are given "Documentation Snippets" and "Code Snippets"
|
| 161 |
-
"Documentation Snippets:" Contains a collection of potentially useful snippets, including code examples and documentation excerpts of "kadiAPY"
|
| 162 |
-
"Code Snippets:" Contains potentially useful snippets from the source code of "kadiAPY"
|
| 163 |
-
|
| 164 |
-
Based on the retrieved snippets (Documentation Snippets and Code Snippets) and the guidelines answer the "query".
|
| 165 |
|
| 166 |
-
|
| 167 |
-
- If no related information is found from the snippets to answer the query, reply that you do not know.
|
| 168 |
|
| 169 |
Guidelines when generating code:
|
| 170 |
- Display the complete code first, followed by a concise explanation in no more than 5 sentences.
|
| 171 |
|
| 172 |
-
Documentation
|
| 173 |
{doc_context}
|
| 174 |
Code Snippets:
|
| 175 |
{code_context}
|
|
|
|
| 18 |
#self.add_to_conversation(user_query=query)
|
| 19 |
|
| 20 |
# Rewrite query
|
| 21 |
+
# rewritten_query = self.rewrite_query(query)
|
| 22 |
|
| 23 |
# Predict library usage
|
| 24 |
# code_library_usage_prediction = self.predict_library_usage(query)
|
|
|
|
| 27 |
# doc_contexts = self.retrieve_contexts(query, k=3, filter={"usage": "doc"})
|
| 28 |
# code_contexts = self.retrieve_contexts(rewritten_query, k=5, filter={"usage": code_library_usage_prediction})
|
| 29 |
|
| 30 |
+
doc_contexts = self.retrieve_contexts(query, k=3, filter={"folder": "doc/"})
|
| 31 |
+
code_contexts = self.retrieve_contexts(rewritten_query, k=5, filter={"folder": "kadi_apy/"})
|
| 32 |
|
| 33 |
# Format contexts
|
| 34 |
# formatted_doc_contexts = self.format_documents(doc_contexts)
|
|
|
|
| 153 |
"""
|
| 154 |
Generate a response using the retrieved contexts and the LLM.
|
| 155 |
"""
|
| 156 |
+
prompt = f"""You are an expert python developer. You are assisting in generating code for users.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
+
Based on the retrieved document and code snippets and the guidelines answer the "query".
|
|
|
|
| 159 |
|
| 160 |
Guidelines when generating code:
|
| 161 |
- Display the complete code first, followed by a concise explanation in no more than 5 sentences.
|
| 162 |
|
| 163 |
+
Documentation context:
|
| 164 |
{doc_context}
|
| 165 |
Code Snippets:
|
| 166 |
{code_context}
|