Spaces:
Sleeping
Sleeping
Update kadi_apy_bot.py
Browse files- kadi_apy_bot.py +0 -39
kadi_apy_bot.py
CHANGED
@@ -9,45 +9,6 @@ class KadiAPYBot:
|
|
9 |
self.conversation = []
|
10 |
|
11 |
|
12 |
-
|
13 |
-
# def process_query(self, query, chat_history):
|
14 |
-
"""
|
15 |
-
Process a user query, handle history, retrieve contexts, and generate a response.
|
16 |
-
"""
|
17 |
-
# Add the user query to the conversation history
|
18 |
-
self.add_to_conversation(user_query=query)
|
19 |
-
|
20 |
-
# Rewrite query
|
21 |
-
rewritten_query = self.rewrite_query(query)
|
22 |
-
print("RRRRRRRRRREEEEEEEEEEWRITEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE: ",rewritten_query)
|
23 |
-
# Predict library usage
|
24 |
-
code_library_usage_prediction = self.predict_library_usage(query)
|
25 |
-
|
26 |
-
# Retrieve contexts
|
27 |
-
doc_contexts = self.retrieve_contexts(query, k=3, filter={"directory": "doc/"})
|
28 |
-
code_contexts = self.retrieve_contexts(rewritten_query, k=5, filter={"usage": code_library_usage_prediction})
|
29 |
-
|
30 |
-
|
31 |
-
# Vanilla
|
32 |
-
#doc_contexts = self.retrieve_contexts(query, k=3, filter={"directory": "doc/"})
|
33 |
-
#code_contexts = self.retrieve_contexts(query, k=5, filter={"directory": "kadi_apy/"})
|
34 |
-
|
35 |
-
# doc_contexts = self.retrieve_contexts(query, k=3, filter={"directory": "doc/"})
|
36 |
-
# code_contexts = self.retrieve_contexts(rewritten_query, k=5, filter={"directory": "kadi_apy/"})
|
37 |
-
|
38 |
-
|
39 |
-
# Format contexts
|
40 |
-
formatted_doc_contexts = self.format_documents(doc_contexts)
|
41 |
-
formatted_code_contexts = self.format_documents(code_contexts)
|
42 |
-
|
43 |
-
# Generate response
|
44 |
-
response = self.generate_response(query, formatted_doc_contexts, formatted_code_contexts)
|
45 |
-
|
46 |
-
# Add the response to the existing query in the conversation history
|
47 |
-
#self.add_to_conversation(llm_response=response)
|
48 |
-
|
49 |
-
return response
|
50 |
-
|
51 |
def process_query(self, query):
|
52 |
"""
|
53 |
Process a user query, handle history, retrieve contexts, and generate a response.
|
|
|
9 |
self.conversation = []
|
10 |
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
def process_query(self, query):
|
13 |
"""
|
14 |
Process a user query, handle history, retrieve contexts, and generate a response.
|