Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,14 +2,12 @@
|
|
| 2 |
from google import genai
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
API_KEY = "
|
| 6 |
|
| 7 |
-
# نمرر المفتاح مباشرة
|
| 8 |
client = genai.Client(api_key=API_KEY)
|
| 9 |
-
|
| 10 |
MODEL_NAME = "gemini-1.5-flash"
|
| 11 |
|
| 12 |
-
def generate_main_question_gemini(paragraph: str
|
| 13 |
if not paragraph or paragraph.strip() == "":
|
| 14 |
return "رجاءً أدخل فقرة أولاً."
|
| 15 |
|
|
@@ -18,7 +16,7 @@ def generate_main_question_gemini(paragraph: str, difficulty: str = "كتيير
|
|
| 18 |
{paragraph}
|
| 19 |
|
| 20 |
المطلوب:
|
| 21 |
-
- بشكل بسيط أنشئ سؤالًا أساسيًا باللغة العربية (مستوى الصعوبة:
|
| 22 |
"""
|
| 23 |
try:
|
| 24 |
response = client.models.generate_content(model=MODEL_NAME, contents=prompt)
|
|
@@ -29,10 +27,10 @@ def generate_main_question_gemini(paragraph: str, difficulty: str = "كتيير
|
|
| 29 |
with gr.Blocks() as demo:
|
| 30 |
gr.Markdown("## MainQuestion — مولّد سؤال أساسي (عربي)")
|
| 31 |
paragraph = gr.Textbox(label="الفقرة (النص)", lines=8, placeholder="ألصق الفقرة هون...")
|
| 32 |
-
difficulty = gr.Dropdown(label="مستوى الصعوبة", choices=["كتيير سهل","سهل","متوسط","صعب"], value="كتيير سهل")
|
| 33 |
output = gr.Textbox(label="السؤال الأساسي", lines=3)
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|
| 38 |
demo.launch(share=True, show_error=True)
|
|
|
|
| 2 |
from google import genai
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
API_KEY = "AIzaSyDedY-PdSeTyitSztgMl7MubbELhffNx7c"
|
| 6 |
|
|
|
|
| 7 |
client = genai.Client(api_key=API_KEY)
|
|
|
|
| 8 |
MODEL_NAME = "gemini-1.5-flash"
|
| 9 |
|
| 10 |
+
def generate_main_question_gemini(paragraph: str):
|
| 11 |
if not paragraph or paragraph.strip() == "":
|
| 12 |
return "رجاءً أدخل فقرة أولاً."
|
| 13 |
|
|
|
|
| 16 |
{paragraph}
|
| 17 |
|
| 18 |
المطلوب:
|
| 19 |
+
- بشكل بسيط أنشئ سؤالًا أساسيًا باللغة العربية (مستوى الصعوبة: كتيير سهل).
|
| 20 |
"""
|
| 21 |
try:
|
| 22 |
response = client.models.generate_content(model=MODEL_NAME, contents=prompt)
|
|
|
|
| 27 |
with gr.Blocks() as demo:
|
| 28 |
gr.Markdown("## MainQuestion — مولّد سؤال أساسي (عربي)")
|
| 29 |
paragraph = gr.Textbox(label="الفقرة (النص)", lines=8, placeholder="ألصق الفقرة هون...")
|
|
|
|
| 30 |
output = gr.Textbox(label="السؤال الأساسي", lines=3)
|
| 31 |
+
|
| 32 |
+
# يعمل التوليد تلقائياً عند إدخال نص
|
| 33 |
+
paragraph.change(fn=generate_main_question_gemini, inputs=paragraph, outputs=output)
|
| 34 |
|
| 35 |
if __name__ == "__main__":
|
| 36 |
demo.launch(share=True, show_error=True)
|