Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,11 +4,26 @@ import os
|
|
| 4 |
|
| 5 |
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
| 6 |
|
| 7 |
-
SYSTEM_PROMPT = """You are
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def respond(message, history, model, temperature, max_tokens):
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
for h in history:
|
| 14 |
messages.append({"role": "user", "content": h[0]})
|
|
@@ -31,8 +46,8 @@ def respond(message, history, model, temperature, max_tokens):
|
|
| 31 |
# ChatInterface with additional inputs for parameters
|
| 32 |
demo = gr.ChatInterface(
|
| 33 |
fn=respond,
|
| 34 |
-
title="🎬
|
| 35 |
-
description="
|
| 36 |
additional_inputs=[
|
| 37 |
gr.Dropdown(
|
| 38 |
choices=[
|
|
@@ -61,10 +76,11 @@ demo = gr.ChatInterface(
|
|
| 61 |
),
|
| 62 |
],
|
| 63 |
examples=[
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
| 68 |
theme="soft",
|
| 69 |
)
|
| 70 |
|
|
|
|
| 4 |
|
| 5 |
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
| 6 |
|
| 7 |
+
SYSTEM_PROMPT = """You are a professional exercise advisor and fitness coach.
|
| 8 |
+
Your goal is to help users improve their physical fitness safely.
|
| 9 |
+
Provide beginner-friendly workout advice, warm-up tips, and recovery guidance.
|
| 10 |
+
Avoid medical diagnosis and always encourage safe exercise habits."""
|
| 11 |
+
|
| 12 |
+
EXAMPLES = """
|
| 13 |
+
User: I am a beginner. How should I start exercising?
|
| 14 |
+
Assistant: Start with light exercises such as walking, stretching, and bodyweight movements. Aim for 15–20 minutes per session and increase gradually.
|
| 15 |
+
|
| 16 |
+
User: How many days per week should I work out?
|
| 17 |
+
Assistant: Beginners should exercise 3–4 days per week, allowing rest days for recovery.
|
| 18 |
+
|
| 19 |
+
User: What should I do before a workout?
|
| 20 |
+
Assistant: Always begin with a warm-up like light cardio and dynamic stretching to prevent injuries.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
|
| 24 |
def respond(message, history, model, temperature, max_tokens):
|
| 25 |
+
messages = [{"role": "system", "content": SYSTEM_PROMPT + EXAMPLES}]
|
| 26 |
+
|
| 27 |
|
| 28 |
for h in history:
|
| 29 |
messages.append({"role": "user", "content": h[0]})
|
|
|
|
| 46 |
# ChatInterface with additional inputs for parameters
|
| 47 |
demo = gr.ChatInterface(
|
| 48 |
fn=respond,
|
| 49 |
+
title="🎬 Exercise Advisor AI",
|
| 50 |
+
description="Your personal assistant for safe and effective workouts",
|
| 51 |
additional_inputs=[
|
| 52 |
gr.Dropdown(
|
| 53 |
choices=[
|
|
|
|
| 76 |
),
|
| 77 |
],
|
| 78 |
examples=[
|
| 79 |
+
["I am a beginner. How should I start exercising?"],
|
| 80 |
+
["How many days per week should I work out?"],
|
| 81 |
+
["What is the best warm-up before training?"],
|
| 82 |
+
]
|
| 83 |
+
|
| 84 |
theme="soft",
|
| 85 |
)
|
| 86 |
|