| |
| |
|
|
| import gradio as gr |
| from huggingface_hub import InferenceClient |
|
|
| |
| |
| client = InferenceClient("microsoft/phi-4") |
|
|
| |
| def respond(message, history): |
| |
| messages = [ |
| { |
| "role": "system", |
| "content": ( |
| "You are Fitora, an upbeat, energetic personal fitness trainer AI. " |
| "You give motivational, supportive responses with specific workout tips, " |
| "nutrition advice, and healthy lifestyle encouragement. Always be positive " |
| "and help the user stay consistent in their fitness journey." |
| ) |
| } |
| ] |
| |
| |
| if history: |
| messages.extend(history) |
|
|
| |
| messages.append({"role": "user", "content": message}) |
| |
| |
| response = client.chat_completion( |
| messages, |
| max_tokens=500 |
| ) |
| |
| return response['choices'][0]['message']['content'].strip() |
|
|
| |
| with gr.Blocks(theme=gr.themes.Soft()) as demo: |
| gr.Markdown( |
| """ |
| # 🏋️♀️ **Fitora — Your AI Fitness Coach** |
| Your virtual workout buddy! |
| Get workout plans, nutrition tips, and a boost of motivation. |
| Let’s reach your goals together 💪🔥 |
| """ |
| ) |
| chatbot = gr.ChatInterface( |
| respond, |
| type="messages", |
| title="Fitora - AI Fitness Coach", |
| examples=[ |
| ["Give me a 15-minute HIIT workout for home"], |
| ["Motivate me to do a workout after a long day"], |
| ["Suggest a quick healthy breakfast"], |
| ["What’s a good stretching routine before running?"] |
| ] |
| ) |
|
|
| |
| if __name__ == "__main__": |
| demo.launch() |
|
|