GoodLuckChuck commited on
Commit
14613dc
·
verified ·
1 Parent(s): 0b6069d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -28,22 +28,26 @@ def ensure_prompt_files_exist():
28
  default_recipe_converter = '''<prompt>
29
  <role_definition>
30
  <role>You are an expert recipe parsing AI model.</role>
31
- <purpose>Your primary function is to meticulously analyze raw text from various sources (text files, PDFs, web scrapes) and transform it into a structured JSON object representing a single, coherent recipe.</purpose>
32
  </role_definition>
33
 
34
  <instructions>
35
  <item>Your output MUST be a valid JSON array containing one or more recipe objects.</item>
36
- <item>From the provided text, extract the following fields for each recipe:</item>
37
- <field name="name">A descriptive and clear name for the recipe.</field>
38
- <field name="description">A brief summary of the dish.</field>
39
- <field name="ingredients">A list of strings, each with quantity and ingredient.</field>
40
- <field name="instructions">A list of strings, each a single cooking step.</field>
41
- <field name="cooking_time">Total preparation time (if available).</field>
42
- <field name="servings">Number of servings (if available).</field>
 
 
 
43
  </instructions>
44
 
45
  <user_query_template>
46
  Analyze the following recipe content and convert it into a structured JSON array.
 
47
 
48
  Recipe Content:
49
  {files_context}
@@ -130,7 +134,7 @@ class MealPreferences(BaseModel):
130
 
131
  class Recipe(BaseModel):
132
  name: str
133
- content: str
134
  description: str = ""
135
  ingredients: List[str] = Field(default_factory=list)
136
  instructions: List[str] = Field(default_factory=list)
 
28
  default_recipe_converter = '''<prompt>
29
  <role_definition>
30
  <role>You are an expert recipe parsing AI model.</role>
31
+ <purpose>Your primary function is to meticulously analyze raw text from various sources and transform it into structured recipe objects.</purpose>
32
  </role_definition>
33
 
34
  <instructions>
35
  <item>Your output MUST be a valid JSON array containing one or more recipe objects.</item>
36
+ <item>Each recipe object MUST include these fields:</item>
37
+ <field name="name">A descriptive name for the recipe (required)</field>
38
+ <field name="content">The original recipe text (can be empty string)</field>
39
+ <field name="description">A brief summary (can be empty string)</field>
40
+ <field name="ingredients">Array of ingredients with quantities (can be empty array)</field>
41
+ <field name="instructions">Array of cooking steps (can be empty array)</field>
42
+ <field name="cooking_time">Total time (optional)</field>
43
+ <field name="servings">Number of servings (optional integer)</field>
44
+ <field name="source_url">Source URL if from web (optional)</field>
45
+ <item>Even if some information is missing, always return a complete object with default values.</item>
46
  </instructions>
47
 
48
  <user_query_template>
49
  Analyze the following recipe content and convert it into a structured JSON array.
50
+ Always include all fields in the response, using empty strings or arrays for missing data.
51
 
52
  Recipe Content:
53
  {files_context}
 
134
 
135
  class Recipe(BaseModel):
136
  name: str
137
+ content: Optional[str] = "" # Make content optional with empty string default
138
  description: str = ""
139
  ingredients: List[str] = Field(default_factory=list)
140
  instructions: List[str] = Field(default_factory=list)