Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import os | |
| from groq import Groq | |
| client = Groq( | |
| api_key=os.environ.get("GROQ_API_KEY"), | |
| ) | |
| # Function to call LLM for planning | |
| def plan_day(activities): | |
| if not activities.strip(): | |
| return "Please enter your activities for the day." | |
| prompt = f""" | |
| I have the following activities today: {activities}. | |
| Please create a structured daily plan by suggesting the best order, approximate times, | |
| and any productivity tips. Keep it short and easy to follow. | |
| """ | |
| response = client.chat.completions.create( | |
| model="llama-3.3-70b-versatile", # lightweight + fast, you can also try "gpt-4" or "gpt-3.5-turbo" | |
| messages=[{"role": "user", "content": prompt}] | |
| ) | |
| return response.choices[0].message.content | |
| # Gradio UI | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## ๐ AI Daily Planner") | |
| with gr.Row(): | |
| activities_input = gr.Textbox( | |
| label="Enter Your Activities", | |
| placeholder="e.g. Gym, Coding project, Reading, Team meeting", | |
| lines=4 | |
| ) | |
| plan_button = gr.Button("Generate AI Plan") | |
| plan_output = gr.Textbox(label="AI-Planned Schedule", lines=10, interactive=False) | |
| plan_button.click(fn=plan_day, inputs=activities_input, outputs=plan_output) | |
| demo.launch() |