HassanDataSci commited on
Commit
4bfa63a
·
verified ·
1 Parent(s): dee9805

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -23,9 +23,15 @@ def get_ingredients_google(food_name):
23
  """
24
  Generate a list of ingredients for the given food item using Google Gemini AI.
25
  """
26
- prompt = f"List the main ingredients typically used to prepare {food_name}:"
27
- response = palm.chat(messages=[{"content": prompt}])
28
- return response.last.strip() if response else "Could not generate ingredients."
 
 
 
 
 
 
29
 
30
  # Streamlit app setup
31
  st.title("Food Image Recognition with Ingredients")
 
23
  """
24
  Generate a list of ingredients for the given food item using Google Gemini AI.
25
  """
26
+ prompt = f"List the main ingredients typically used to prepare {food_name}."
27
+ try:
28
+ response = palm.generate_text(prompt=prompt)
29
+ if response and "candidates" in response:
30
+ return response["candidates"][0]["output"]
31
+ else:
32
+ return "No ingredients found."
33
+ except Exception as e:
34
+ return f"Error generating ingredients: {e}"
35
 
36
  # Streamlit app setup
37
  st.title("Food Image Recognition with Ingredients")