Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -49,32 +49,31 @@ def generate_plant_info(plant_name, language):
|
|
49 |
output = generator(messages)
|
50 |
return output[0]["generated_text"]
|
51 |
|
52 |
-
# Create Gradio interface with
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
-
|
|
|
|
|
58 |
|
59 |
-
|
60 |
-
output_text = gr.Textbox(label="🔍 Plant Information", interactive=False)
|
61 |
-
|
62 |
-
classify_button = gr.Button("🔍 Get Plant Info", variant="primary", elem_id="classify_button")
|
63 |
-
|
64 |
-
classify_button.click(generate_plant_info, inputs=[plant_name_input, language_selector], outputs=output_text)
|
65 |
-
|
66 |
-
gr.Markdown("<h2 style='text-align: center;'>🌼 Try Examples 🌼</h2>")
|
67 |
-
example_plants = [("Lavender", "English"), ("اللافندر", "Arabic"), ("Tulip", "English"), ("الصبار", "Arabic")]
|
68 |
-
|
69 |
-
with gr.Row():
|
70 |
-
for plant, lang in example_plants:
|
71 |
-
example_button = gr.Button(f"🌿 {plant}", variant="primary", elem_id="example_button")
|
72 |
-
|
73 |
-
def process_example(plant=plant, lang=lang):
|
74 |
-
return generate_plant_info(plant, lang)
|
75 |
-
|
76 |
-
example_button.click(process_example, inputs=[], outputs=output_text)
|
77 |
-
|
78 |
-
# Run the application
|
79 |
-
if __name__ == "__main__":
|
80 |
-
demo.launch(share=True)
|
|
|
49 |
output = generator(messages)
|
50 |
return output[0]["generated_text"]
|
51 |
|
52 |
+
# Create Gradio interface with enhancements
|
53 |
+
demo = gr.Interface(
|
54 |
+
fn=generate_plant_info,
|
55 |
+
inputs=[
|
56 |
+
gr.Textbox(placeholder="Enter plant name (e.g., Lavender, Aloe Vera)...", label="Plant Name"),
|
57 |
+
gr.Dropdown(
|
58 |
+
choices=["English", "Arabic"],
|
59 |
+
label="Choose Language",
|
60 |
+
value="English"
|
61 |
+
)
|
62 |
+
],
|
63 |
+
outputs=gr.Textbox(label="Plant Information"),
|
64 |
+
title="🌿 AI Plant Guide - English & Arabic 🌿",
|
65 |
+
description="Enter a plant name, and AI will provide detailed information about it in English or Arabic.",
|
66 |
+
examples=[
|
67 |
+
["Lavender", "English"],
|
68 |
+
["اللافندر", "Arabic"],
|
69 |
+
["Tulip", "English"],
|
70 |
+
["الصبار", "Arabic"]
|
71 |
+
],
|
72 |
+
theme="default",
|
73 |
+
)
|
74 |
|
75 |
+
# Custom function to fill the plant name based on example selection
|
76 |
+
def fill_plant_name(plant_name, language):
|
77 |
+
return plant_name, language
|
78 |
|
79 |
+
demo.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|