Spaces:
Sleeping
Sleeping
Update kadi_apy_bot.py
Browse files- kadi_apy_bot.py +36 -0
kadi_apy_bot.py
CHANGED
@@ -164,7 +164,43 @@ class KadiAPYBot:
|
|
164 |
"""
|
165 |
return self.llm.invoke(prompt).content
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
def format_documents(self, documents):
|
169 |
formatted_docs = []
|
170 |
print("################################# start of doc #######################################")
|
|
|
164 |
"""
|
165 |
return self.llm.invoke(prompt).content
|
166 |
|
167 |
+
|
168 |
+
def generate_response(self, query, history, doc_context, code_context):
|
169 |
+
"""
|
170 |
+
Generate a response using the retrieved contexts and the LLM.
|
171 |
+
"""
|
172 |
+
formatted_history = format_history(history)
|
173 |
|
174 |
+
# Update the prompt with history included
|
175 |
+
prompt = f"""
|
176 |
+
You are a Python programming assistant specialized in the "Kadi-APY" library.
|
177 |
+
The "Kadi-APY" library is a Python package designed to facilitate interaction with the REST-like API of a software platform called Kadi4Mat.
|
178 |
+
Your task is to answer the user's query based on the guidelines, and if needed, combine understanding provided by
|
179 |
+
"Document Snippets" with the implementation details provided by "Code Snippets."
|
180 |
+
|
181 |
+
Guidelines if generating code:
|
182 |
+
- Display the complete code first, followed by a concise explanation in no more than 5 sentences.
|
183 |
+
|
184 |
+
General Guidelines:
|
185 |
+
- If the user's query cannot be fulfilled based on the provided snippets, reply with "The API does not support the requested functionality."
|
186 |
+
- If the user's query does not implicate any task, reply with a question asking the user to elaborate.
|
187 |
+
|
188 |
+
Conversation History:
|
189 |
+
{formatted_history}
|
190 |
+
|
191 |
+
Document Snippets:
|
192 |
+
{doc_context}
|
193 |
+
|
194 |
+
Code Snippets:
|
195 |
+
{code_context}
|
196 |
+
|
197 |
+
Query:
|
198 |
+
{query}
|
199 |
+
"""
|
200 |
+
return self.llm.invoke(prompt).content
|
201 |
+
|
202 |
+
|
203 |
+
|
204 |
def format_documents(self, documents):
|
205 |
formatted_docs = []
|
206 |
print("################################# start of doc #######################################")
|