Spaces:
Sleeping
Sleeping
Update utils/chatbot_interface2.py
Browse files- utils/chatbot_interface2.py +17 -11
utils/chatbot_interface2.py
CHANGED
@@ -46,7 +46,13 @@ class ChatbotInterface:
|
|
46 |
api_key=api_key,
|
47 |
meta_prompt_file=meta_prompt_file
|
48 |
)
|
49 |
-
self.generate_response = self.response_manager.generate_response
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
logging.info(
|
51 |
"ChatbotInterface initialized with the following parameters:\n"
|
52 |
f" - Model: {model}\n"
|
@@ -138,14 +144,14 @@ class ChatbotInterface:
|
|
138 |
# elem_id="ask-button"
|
139 |
# )
|
140 |
|
141 |
-
# Define a local function to process input:
|
142 |
-
def process_input(self, user_message, chat_history):
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
|
150 |
# # Button actions
|
151 |
# submit.click(
|
@@ -163,12 +169,12 @@ class ChatbotInterface:
|
|
163 |
|
164 |
# Button actions
|
165 |
submit.click(
|
166 |
-
fn=self.
|
167 |
inputs=[user_input, chatbot_output],
|
168 |
outputs=[chatbot_output, user_input]
|
169 |
)
|
170 |
user_input.submit(
|
171 |
-
fn=self.
|
172 |
inputs=[user_input, chatbot_output],
|
173 |
outputs=[chatbot_output, user_input]
|
174 |
)
|
|
|
46 |
api_key=api_key,
|
47 |
meta_prompt_file=meta_prompt_file
|
48 |
)
|
49 |
+
# self.generate_response = self.response_manager.generate_response
|
50 |
+
|
51 |
+
self.generate_response = lambda user_message, chat_history: (
|
52 |
+
self.response_manager.generate_response(user_message, chat_history),
|
53 |
+
""
|
54 |
+
)
|
55 |
+
|
56 |
logging.info(
|
57 |
"ChatbotInterface initialized with the following parameters:\n"
|
58 |
f" - Model: {model}\n"
|
|
|
144 |
# elem_id="ask-button"
|
145 |
# )
|
146 |
|
147 |
+
# # Define a local function to process input:
|
148 |
+
# def process_input(self, user_message, chat_history):
|
149 |
+
# """
|
150 |
+
# Call generate_response with the user's message and chat history.
|
151 |
+
# Return a tuple with the updated chat history and an empty string to clear the input.
|
152 |
+
# """
|
153 |
+
# updated_history = self.generate_response(user_message, chat_history)
|
154 |
+
# return updated_history, ""
|
155 |
|
156 |
# # Button actions
|
157 |
# submit.click(
|
|
|
169 |
|
170 |
# Button actions
|
171 |
submit.click(
|
172 |
+
fn=self.generate_response,
|
173 |
inputs=[user_input, chatbot_output],
|
174 |
outputs=[chatbot_output, user_input]
|
175 |
)
|
176 |
user_input.submit(
|
177 |
+
fn=self.generate_response,
|
178 |
inputs=[user_input, chatbot_output],
|
179 |
outputs=[chatbot_output, user_input]
|
180 |
)
|