Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 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>
|
| 37 |
-
<field name="name">A descriptive
|
| 38 |
-
<field name="
|
| 39 |
-
<field name="
|
| 40 |
-
<field name="
|
| 41 |
-
<field name="
|
| 42 |
-
<field name="
|
|
|
|
|
|
|
|
|
|
| 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)
|