HassanDataSci commited on
Commit
3500d25
·
verified ·
1 Parent(s): 7ced002

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -27,11 +27,20 @@ pipe_llama = load_llama_pipeline()
27
  def get_ingredients_llama(food_name):
28
  """
29
  Generate a list of ingredients for the given food item using GPT-Neo.
 
30
  """
31
- prompt = f"List the main ingredients typically used to prepare {food_name}."
 
 
 
32
  try:
33
  response = pipe_llama(prompt, max_length=50, num_return_sequences=1)
34
- return response[0]["generated_text"].strip()
 
 
 
 
 
35
  except Exception as e:
36
  return f"Error generating ingredients: {e}"
37
 
 
27
  def get_ingredients_llama(food_name):
28
  """
29
  Generate a list of ingredients for the given food item using GPT-Neo.
30
+ Returns a clean, comma-separated list of ingredients.
31
  """
32
+ prompt = (
33
+ f"List the main ingredients typically used to prepare {food_name}. "
34
+ "Provide the ingredients as a concise, comma-separated list without any explanations."
35
+ )
36
  try:
37
  response = pipe_llama(prompt, max_length=50, num_return_sequences=1)
38
+ generated_text = response[0]["generated_text"].strip()
39
+
40
+ # Process the response to ensure it's a clean, comma-separated list
41
+ ingredients = generated_text.split(":")[-1].strip() # Handle cases like "Ingredients: ..."
42
+ ingredients = ingredients.replace(".", "").strip() # Remove periods and extra spaces
43
+ return ingredients
44
  except Exception as e:
45
  return f"Error generating ingredients: {e}"
46