Spaces:
Sleeping
Sleeping
File size: 2,326 Bytes
b01502c 843886a b01502c 843886a b01502c d67ec96 843886a bacbdae a15fa58 bacbdae a15fa58 a69f8b1 3f0b6cc b01502c 843886a d67ec96 843886a b01502c d67ec96 843886a d67ec96 b01502c d67ec96 843886a d67ec96 b01502c d67ec96 b01502c d67ec96 b01502c 843886a b01502c d67ec96 b01502c d67ec96 843886a b01502c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# app.py
from google import genai
import gradio as gr
API_KEY = "AIzaSyB4JKubDJd7nLx1NqPhDfMGeVWeQ7kqClY"
client = genai.Client(api_key=API_KEY)
MODEL_NAME = "gemini-2.5-flash"
def generate_study_schedule(subject_names, available_days, hours_per_day):
# Check inputs
if not subject_names.strip() or not available_days.strip() or not hours_per_day.strip():
return "Please fill in all fields first."
prompt = f"""
المواد الدراسية: {subject_names}
عدد الأيام المتاحة للدراسة: {available_days}
عدد الساعات المتاحة للدراسة في كل يوم: {hours_per_day}
المطلوب:
اقترح برنامج دراسي منطقي يراعي راحة واستيعاب الطالب لتغطية المعطيات السابقة مثل هذا التنسيق بالضبط :
"
يوم _ :
__ : __ - __ :__ : فيزياء
__ :__ - __ :__ : رياضيات
__ :__ - __:__ : فيزياء
"
مع الاخذ بعين الاعتبار وجود استراحة حسب الساعات المتاحة
اكتب فقط البرنامج بدون اي عبارات اضافية.
"""
try:
response = client.models.generate_content(model=MODEL_NAME, contents=prompt)
return response.text.strip()
except Exception as e:
return f"Error while connecting to API: {e}"
with gr.Blocks() as app:
gr.Markdown("## Space Study Program — Auto Study Schedule Generator")
with gr.Row():
subjects_input = gr.Textbox(
label="Subject Names",
placeholder="Example: Math, Physics, Chemistry",
lines=2
)
days_input = gr.Textbox(
label="Available Days",
placeholder="Example: 7",
lines=1
)
hours_input = gr.Textbox(
label="Study Hours per Day",
placeholder="Example: 4",
lines=1
)
schedule_output = gr.Textbox(label="Generated Study Schedule (Paragraph)", lines=10)
generate_btn = gr.Button("Generate Schedule")
generate_btn.click(
fn=generate_study_schedule,
inputs=[subjects_input, days_input, hours_input],
outputs=schedule_output
)
if __name__ == "__main__":
app.launch(share=True, show_error=True)
|