|
import streamlit as st
|
|
from openai import OpenAI
|
|
|
|
|
|
client = OpenAI(
|
|
api_key="9a70a7b82dd84c8cb2e8c43a156be3c7",
|
|
base_url="https://api.aimlapi.com",
|
|
)
|
|
|
|
|
|
st.title("Mood-based Exercise Recommendations")
|
|
|
|
|
|
user_feeling = st.text_input("How are you feeling right now?", placeholder="e.g., tired, stressed, happy...")
|
|
|
|
|
|
if user_feeling:
|
|
with st.spinner("Generating exercise recommendation..."):
|
|
|
|
response = client.chat.completions.create(
|
|
model="meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo",
|
|
messages=[
|
|
{
|
|
"role": "system",
|
|
"content": "You are a fitness coach and a doctor . Based on the user's current mood, suggest a suitable exercise in one sentence. and write them in bullet"
|
|
},
|
|
{
|
|
"role": "user",
|
|
"content": f"I am feeling {user_feeling}. What exercise should I do?"
|
|
},
|
|
],
|
|
)
|
|
|
|
|
|
message = response.choices[0].message.content
|
|
|
|
|
|
st.write(f"Based on how you're feeling, here's an exercise suggestion for you: {message}")
|
|
|