daniescamilla commited on
Commit
bf4b0df
·
verified ·
1 Parent(s): e2663ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -13,14 +13,24 @@ image_to_text = pipeline("image-to-text", model="Salesforce/blip-image-captionin
13
  def generate_recipe(description):
14
  url = "https://api-inference.huggingface.co/models/Qwen/Qwen2.5-72B-Instruct"
15
  headers = {"Authorization": f"Bearer {hf_token}"}
16
- # Reformulamos el prompt para que sea más específico
 
 
 
 
 
 
17
  prompt = (
18
- f"Provide a full recipe for a dish described as: {description}. "
19
- "Include a list of ingredients and detailed step-by-step instructions."
20
  )
 
21
  payload = {
22
  "inputs": prompt,
23
- "parameters": {"max_length": 5000} # Increase max_length for a more detailed response
 
 
 
24
  }
25
 
26
  response = requests.post(url, headers=headers, json=payload)
 
13
  def generate_recipe(description):
14
  url = "https://api-inference.huggingface.co/models/Qwen/Qwen2.5-72B-Instruct"
15
  headers = {"Authorization": f"Bearer {hf_token}"}
16
+
17
+ # Añade el system input para definir el rol del modelo
18
+ system_input = (
19
+ "Act as a professional chef. Your task is to explain to a regular person "
20
+ "how to cook a given dish, providing a step-by-step guide and a list of ingredients with exact quantities."
21
+ )
22
+
23
  prompt = (
24
+ f"{system_input} The dish is described as: {description}. "
25
+ "Provide a list of ingredients followed by detailed cooking instructions."
26
  )
27
+
28
  payload = {
29
  "inputs": prompt,
30
+ "parameters": {
31
+ "max_length": 5000, # Maximum length for the response
32
+ "min_length": 2000 # Minimum length for the response
33
+ }
34
  }
35
 
36
  response = requests.post(url, headers=headers, json=payload)