File size: 1,672 Bytes
1d38a01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f5fc986
 
1d38a01
 
f5fc986
1d38a01
 
 
1669692
 
1d38a01
 
aa5a0a0
f900db5
 
1d38a01
 
30294df
1d38a01
30294df
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
import gradio as gr
import pandas as pd

# Load recipes from CSV file
def load_recipes(file_path):
    df = pd.read_csv(file_path)
    recipes = []
    for _, row in df.iterrows():
        recipes.append({
            "name": row["name"],
            "ingredients": [i.strip() for i in row["ingredients"].split(',')],
            "steps": row["steps"]
        })
    return recipes

# Load recipes
recipes = load_recipes('recipes_arabic.csv')

def suggest_recipes(user_ingredients):
    user_ingredients = [i.strip().lower() for i in user_ingredients.split(',')]
    matching_recipes = []
    for recipe in recipes:
        recipe_ingredients = [i.strip().lower() for i in recipe['ingredients']]
        if all(ingredient in recipe_ingredients for ingredient in user_ingredients):
            ingredient_list = ', '.join(recipe['ingredients'])
            matching_recipes.append(f"{recipe['name']}\nIngredients: {ingredient_list}\nSteps: {recipe['steps']}")
    if not matching_recipes:
        return "لا توجد وصفات تتناسب مع المكونات المدخلة."
    return "\n\n".join(matching_recipes)

# Create the Gradio interface
iface = gr.Interface(
    fn=suggest_recipes,
    inputs=gr.Textbox(label="ادخل المكونات (مفصولة بفواصل)"),
    outputs=gr.Textbox(label="الوصفات المقترحة"),
    title="اقتراحات الوصفات العربية",
    description="<img src='image.jpg' width='400'/> <br>ادخل المكونات التي لديك للحصول على اقتراحات لوصفات عربية تقليدية."


)

# Launch the interface
if __name__ == "__main__":
    iface.launch(share=True)