Spaces:
Sleeping
Sleeping
Commit
·
6250a13
1
Parent(s):
d249abf
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ from gradio_client import Client
|
|
6 |
|
7 |
|
8 |
def get_response(query, history):
|
9 |
-
|
10 |
client = Client("https://traversaal-fitx-ai.hf.space/")
|
11 |
result = client.predict(
|
12 |
query, # str in 'query' Textbox component
|
@@ -57,13 +57,9 @@ custom_css = """
|
|
57 |
"""
|
58 |
|
59 |
def respond(message, chat_history):
|
60 |
-
|
61 |
-
# Display a welcome message if chat_history is empty
|
62 |
-
welcome_message = "Welcome to the AI Trainer Chatbot! I'm here to assist you with your questions."
|
63 |
-
chat_history = [(welcome_message, get_response(welcome_message, chat_history))]
|
64 |
-
|
65 |
bot_message = get_response(message, chat_history)
|
66 |
-
chat_history.append(bot_message)
|
67 |
time.sleep(0.5)
|
68 |
return "", chat_history
|
69 |
|
@@ -71,12 +67,12 @@ def respond(message, chat_history):
|
|
71 |
welcome_message = "Welcome to the AI Trainer Chatbot! I'm here to assist you with your questions."
|
72 |
print(welcome_message)
|
73 |
|
74 |
-
with gr.Blocks(
|
75 |
-
|
76 |
-
chatbot = gr.Chatbot()
|
77 |
msg = gr.Textbox(placeholder="I am your personal AI Trainer. Ask me a question")
|
78 |
|
79 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
80 |
|
81 |
|
82 |
-
demo.launch(debug=True)
|
|
|
|
6 |
|
7 |
|
8 |
def get_response(query, history):
|
9 |
+
history = str(history[0][0]) + str(history[0][1])
|
10 |
client = Client("https://traversaal-fitx-ai.hf.space/")
|
11 |
result = client.predict(
|
12 |
query, # str in 'query' Textbox component
|
|
|
57 |
"""
|
58 |
|
59 |
def respond(message, chat_history):
|
60 |
+
|
|
|
|
|
|
|
|
|
61 |
bot_message = get_response(message, chat_history)
|
62 |
+
chat_history.append((message, bot_message))
|
63 |
time.sleep(0.5)
|
64 |
return "", chat_history
|
65 |
|
|
|
67 |
welcome_message = "Welcome to the AI Trainer Chatbot! I'm here to assist you with your questions."
|
68 |
print(welcome_message)
|
69 |
|
70 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
71 |
+
chatbot = gr.Chatbot(title="Fitx AI Chatbot")
|
|
|
72 |
msg = gr.Textbox(placeholder="I am your personal AI Trainer. Ask me a question")
|
73 |
|
74 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
75 |
|
76 |
|
77 |
+
demo.launch(share=True, debug=True)
|
78 |
+
|