Update app.py
Browse files
app.py
CHANGED
@@ -33,7 +33,7 @@ def run_graph(input_message, history):
|
|
33 |
"watch", "tracker", "watch", "band", "height", "injured", "quick", "remedy", "solution", "solutions", "pain", "male", "female"
|
34 |
]
|
35 |
|
36 |
-
greetings=["hello", "hi", "how are you doing"]
|
37 |
|
38 |
# Check if the input message contains any relevant keywords
|
39 |
if any(keyword in input_message.lower() for keyword in relevant_keywords):
|
@@ -43,38 +43,29 @@ def run_graph(input_message, history):
|
|
43 |
return response['messages'][1].content
|
44 |
|
45 |
elif any(keyword in input_message.lower() for keyword in greetings):
|
46 |
-
return "Hi there, I am FIT bot, your personal wellbeing coach
|
47 |
|
48 |
else:
|
49 |
return "I'm here to assist with fitness, nutrition, mental health, and related topics. Please ask questions related to these areas."
|
50 |
except Exception as e:
|
51 |
return f"An error occurred while processing your request: {e}"
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
bot = gr.Chatbot(render=False,placeholder="<strong>Your Personal Assistant</strong><br>Ask Me Anything",
|
56 |
-
show_copy_button=True,
|
57 |
-
layout="bubble",
|
58 |
-
container=True,
|
59 |
-
label="FIT.AI",
|
60 |
-
show_label=True,
|
61 |
-
#avatar_images=("user.png","bot.png")
|
62 |
-
)
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
theme="soft",
|
68 |
-
autofocus=True,
|
69 |
-
textbox=gr.Textbox(placeholder="Ask away any fitness related questions", scale=7),
|
70 |
-
stop_btn="Stop",
|
71 |
-
show_progress="full",
|
72 |
-
description="<strong>An intelligent assistant for fitness, diet and mental health guidance.<strong>",
|
73 |
-
js="custom.js",
|
74 |
-
examples=["Provide health and fitness tips", "My daily Calorie intake",
|
75 |
-
"Better mental health","Best sleep habits","Water intake for a fully grown adult",
|
76 |
-
"Ergonomics in the workplace","Injuries Rehabilitation"],
|
77 |
-
chatbot=bot,
|
78 |
-
)
|
79 |
|
80 |
-
demo.launch(share=True)
|
|
|
33 |
"watch", "tracker", "watch", "band", "height", "injured", "quick", "remedy", "solution", "solutions", "pain", "male", "female"
|
34 |
]
|
35 |
|
36 |
+
greetings = ["hello", "hi", "how are you doing"]
|
37 |
|
38 |
# Check if the input message contains any relevant keywords
|
39 |
if any(keyword in input_message.lower() for keyword in relevant_keywords):
|
|
|
43 |
return response['messages'][1].content
|
44 |
|
45 |
elif any(keyword in input_message.lower() for keyword in greetings):
|
46 |
+
return "Hi there, I am FIT bot, your personal wellbeing coach!"
|
47 |
|
48 |
else:
|
49 |
return "I'm here to assist with fitness, nutrition, mental health, and related topics. Please ask questions related to these areas."
|
50 |
except Exception as e:
|
51 |
return f"An error occurred while processing your request: {e}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
+
# Interface Components
|
54 |
+
with gr.Blocks() as demo:
|
55 |
+
gr.Markdown("<strong>FIT.AI - Your Personal Wellbeing Coach</strong>")
|
56 |
+
chatbot = gr.Chatbot(label="Chat with FIT.AI")
|
57 |
+
text_input = gr.Textbox(placeholder="Type your question here...", label="Your Question")
|
58 |
+
submit_button = gr.Button("Submit")
|
59 |
+
clear_button = gr.Button("Clear")
|
60 |
+
|
61 |
+
# Chatbot logic
|
62 |
+
def submit_message(message, history=[]):
|
63 |
+
response = run_graph(message, history)
|
64 |
+
history.append(("User", message))
|
65 |
+
history.append(("FIT.AI", response))
|
66 |
+
return history, ""
|
67 |
|
68 |
+
submit_button.click(submit_message, inputs=[text_input, chatbot], outputs=[chatbot, text_input])
|
69 |
+
clear_button.click(lambda: ([], ""), inputs=None, outputs=[chatbot, text_input])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
+
demo.launch(share=True)
|