Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -193,22 +193,35 @@ class get_recipe_name(BaseModel):
|
|
193 |
def generate_recipe_name(base64_image):
|
194 |
# Example of how the JSON should look to make it clearer
|
195 |
example_json_structure = {
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
# Generating the query prompt to ask for ingredients
|
204 |
text_query = f'''What are the ingredients used in these dishes? Do not add any explanation, just write the names of the ingredients in proper JSON according to the following format:
|
205 |
The JSON object must follow this schema:
|
206 |
{json.dumps(get_recipe_name.model_json_schema(), indent=2)}
|
207 |
-
|
208 |
Example format:
|
209 |
{json.dumps(example_json_structure, indent=2)}
|
210 |
-
|
211 |
-
Write the name of the dish and then
|
212 |
'''
|
213 |
|
214 |
chat_completion = client.chat.completions.create(
|
@@ -231,15 +244,9 @@ def generate_recipe_name(base64_image):
|
|
231 |
model="llama-3.2-90b-vision-preview")
|
232 |
return json.loads(chat_completion.choices[0].message.content)
|
233 |
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
app = FastAPI()
|
239 |
|
240 |
|
241 |
-
|
242 |
-
|
243 |
@app.post("/get_recipe/{token}")
|
244 |
async def get_recipe_response(token: str, recipe_user: RecipeData):
|
245 |
user = user_collection.find_one({"token": token})
|
|
|
193 |
def generate_recipe_name(base64_image):
|
194 |
# Example of how the JSON should look to make it clearer
|
195 |
example_json_structure = {
|
196 |
+
"recipe_name": "Chicken Karhai",
|
197 |
+
"ingredients": [
|
198 |
+
"chicken",
|
199 |
+
"tomatoes",
|
200 |
+
"onions",
|
201 |
+
"ginger",
|
202 |
+
"garlic",
|
203 |
+
"green chilies",
|
204 |
+
"yogurt",
|
205 |
+
"cumin seeds",
|
206 |
+
"coriander powder",
|
207 |
+
"red chili powder",
|
208 |
+
"turmeric powder",
|
209 |
+
"garam masala",
|
210 |
+
"fresh coriander leaves",
|
211 |
+
"oil",
|
212 |
+
"salt"
|
213 |
+
]
|
214 |
+
}
|
215 |
|
216 |
# Generating the query prompt to ask for ingredients
|
217 |
text_query = f'''What are the ingredients used in these dishes? Do not add any explanation, just write the names of the ingredients in proper JSON according to the following format:
|
218 |
The JSON object must follow this schema:
|
219 |
{json.dumps(get_recipe_name.model_json_schema(), indent=2)}
|
220 |
+
|
221 |
Example format:
|
222 |
{json.dumps(example_json_structure, indent=2)}
|
223 |
+
|
224 |
+
Write the name of the dish and then list the ingredients used for each recipe, focusing on traditional Pakistani ingredients and terminology.
|
225 |
'''
|
226 |
|
227 |
chat_completion = client.chat.completions.create(
|
|
|
244 |
model="llama-3.2-90b-vision-preview")
|
245 |
return json.loads(chat_completion.choices[0].message.content)
|
246 |
|
|
|
|
|
|
|
|
|
247 |
app = FastAPI()
|
248 |
|
249 |
|
|
|
|
|
250 |
@app.post("/get_recipe/{token}")
|
251 |
async def get_recipe_response(token: str, recipe_user: RecipeData):
|
252 |
user = user_collection.find_one({"token": token})
|