Update app.py
Browse files
app.py
CHANGED
@@ -191,14 +191,6 @@ def generate(prompt, history):
|
|
191 |
yield output
|
192 |
|
193 |
|
194 |
-
chat_bot=gr.ChatInterface(
|
195 |
-
fn=generate,
|
196 |
-
chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
|
197 |
-
title="""AI Chat Bot - ECU IVADE"""
|
198 |
-
)
|
199 |
-
def blank():
|
200 |
-
print("Success")
|
201 |
-
|
202 |
def name_interface(name,occupation,ethnicity,gender,age):
|
203 |
global Name, Occupation,Ethnicity,Gender,Age,chat_log_name
|
204 |
|
@@ -213,8 +205,50 @@ def name_interface(name,occupation,ethnicity,gender,age):
|
|
213 |
return f"You can start chatting now {Name}"
|
214 |
else:
|
215 |
return "Enter ALL the details to start chatting"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
name_interface = gr.Interface(
|
219 |
fn=name_interface,
|
220 |
inputs=[
|
|
|
191 |
yield output
|
192 |
|
193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
def name_interface(name,occupation,ethnicity,gender,age):
|
195 |
global Name, Occupation,Ethnicity,Gender,Age,chat_log_name
|
196 |
|
|
|
205 |
return f"You can start chatting now {Name}"
|
206 |
else:
|
207 |
return "Enter ALL the details to start chatting"
|
208 |
+
|
209 |
+
def reset_chat_interface():
|
210 |
+
global chat_history, chat_log_history, isFirstRun
|
211 |
+
chat_history = []
|
212 |
+
chat_log_history = []
|
213 |
+
isFirstRun = True
|
214 |
+
return "Chat has been reset."
|
215 |
+
|
216 |
+
def reset_name_interface():
|
217 |
+
global Name, Occupation, Ethnicity, Gender, Age, chat_log_name
|
218 |
+
Name = ""
|
219 |
+
Occupation = ""
|
220 |
+
Ethnicity = ""
|
221 |
+
Gender = ""
|
222 |
+
Age = ""
|
223 |
+
chat_log_name = ""
|
224 |
+
return "User info has been reset."
|
225 |
+
|
226 |
+
def reset_all():
|
227 |
+
message1 = reset_chat_interface()
|
228 |
+
message2 = reset_name_interface()
|
229 |
+
return f"{message1}\n{message2}"
|
230 |
+
|
231 |
+
chat_bot=gr.ChatInterface(
|
232 |
+
fn=generate,
|
233 |
+
chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
|
234 |
+
title="""AI Chat Bot - ECU IVADE"""
|
235 |
+
)
|
236 |
|
237 |
+
reset_interface = gr.Interface(
|
238 |
+
fn=lambda x: x, # Placeholder function, actual reset is handled by button actions
|
239 |
+
inputs=[gr.Buttons(choices=["Reset Chat", "Reset User Info", "Reset All"], label="Select what to reset")],
|
240 |
+
outputs="text",
|
241 |
+
title="Reset Controls",
|
242 |
+
description="Use the buttons below to reset chat, user information, or both."
|
243 |
+
)
|
244 |
|
245 |
+
reset_interface.update(
|
246 |
+
fn=dict(
|
247 |
+
Reset_Chat=reset_chat_interface,
|
248 |
+
Reset_User_Info=reset_name_interface,
|
249 |
+
Reset_All=reset_all
|
250 |
+
)
|
251 |
+
)
|
252 |
name_interface = gr.Interface(
|
253 |
fn=name_interface,
|
254 |
inputs=[
|