From 49e3e0bafa2cf2f0babf036e68da75214d66ef6b Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Tue, 29 Oct 2024 21:51:24 +0100 Subject: [PATCH 1/5] Parser sort of works prompt: I am Dutch so use imperial. You can approximate units like cups and depending on the ingredient use liters or grams. Obviously, ml should be used for ingredients that are liquid and grams for ingredients that are solid. Teaspoons and pinches you can keep the same. You may also convert inches to cm --- docker/Dockerfile | 2 +- frontend/lib/api/user/recipes/recipe.ts | 6 +++ .../_groupSlug/r/_slug/ingredient-parser.vue | 48 +++++++++++++++++++ mealie/routes/parser/ingredient_parser.py | 9 +++- mealie/schema/recipe/recipe_ingredient.py | 5 ++ .../prompts/recipes/convert-recipe-units.txt | 18 +++++++ mealie/services/parser_services/_base.py | 3 ++ .../services/parser_services/openai/parser.py | 46 ++++++++++++++++++ 8 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 mealie/services/openai/prompts/recipes/convert-recipe-units.txt diff --git a/docker/Dockerfile b/docker/Dockerfile index 6c9c09066ee..7a4870f3e3a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -134,7 +134,7 @@ HEALTHCHECK CMD python $MEALIE_HOME/mealie/scripts/healthcheck.py || exit 1 ENV STATIC_FILES=/spa/static COPY --from=builder /app/dist ${STATIC_FILES} -ENV HOST 0.0.0.0 +ENV HOST 127.0.0.1 EXPOSE ${APP_PORT} COPY ./docker/entry.sh $MEALIE_HOME/run.sh diff --git a/frontend/lib/api/user/recipes/recipe.ts b/frontend/lib/api/user/recipes/recipe.ts index 87288814c19..0e98bf2bf75 100644 --- a/frontend/lib/api/user/recipes/recipe.ts +++ b/frontend/lib/api/user/recipes/recipe.ts @@ -40,6 +40,7 @@ const routes = { recipesCategory: `${prefix}/recipes/category`, recipesParseIngredient: `${prefix}/parser/ingredient`, recipesParseIngredients: `${prefix}/parser/ingredients`, + recipesConvertUnits: `${prefix}/parser/convert-units`, recipesTimelineEvent: `${prefix}/recipes/timeline/events`, recipesRecipeSlug: (recipe_slug: string) => `${prefix}/recipes/${recipe_slug}`, @@ -165,6 +166,11 @@ export class RecipeAPI extends BaseCRUDAPI { return await this.requests.post(routes.recipesParseIngredients, { parser, ingredients }); } + async convertUnits(parser: Parser, ingredients: Array, user_prompt: string) { + parser = "openai"; + return await this.requests.post(routes.recipesConvertUnits, { parser, ingredients, user_prompt }); + } + async parseIngredient(parser: Parser, ingredient: string) { parser = parser || "nlp"; return await this.requests.post(routes.recipesParseIngredient, { parser, ingredient }); diff --git a/frontend/pages/g/_groupSlug/r/_slug/ingredient-parser.vue b/frontend/pages/g/_groupSlug/r/_slug/ingredient-parser.vue index 0c978d9f052..b2f52805d87 100644 --- a/frontend/pages/g/_groupSlug/r/_slug/ingredient-parser.vue +++ b/frontend/pages/g/_groupSlug/r/_slug/ingredient-parser.vue @@ -22,9 +22,21 @@ :items="availableParsers" /> +
+
USer prompt:
+ +
+ + + convert units + @@ -183,6 +195,8 @@ export default defineComponent({ parserPreferences.value.parser = val; }); + const userPrompt = ref(null); + function processIngredientError(ing: ParsedIngredient, index: number): Error { const unitError = !checkForUnit(ing.ingredient.unit); const foodError = !checkForFood(ing.ingredient.food); @@ -248,6 +262,38 @@ export default defineComponent({ } } + async function convertUnits() { + if (!recipe.value || !recipe.value.recipeIngredient || !userPrompt.value) { + return; + } + const raw = recipe.value.recipeIngredient.map((ing) => ing.note ?? ""); + + parserLoading.value = true; + const { data } = await api.recipes.convertUnits(parser.value, raw, userPrompt.value); + parserLoading.value = false; + + if (data) { + // When we send the recipe ingredient text to be parsed, we lose the reference to the original unparsed ingredient. + // Generally this is fine, but if the unparsed ingredient had a title, we lose it; we add back the title for each ingredient here. + try { + for (let i = 0; i < recipe.value.recipeIngredient.length; i++) { + data[i].ingredient.title = recipe.value.recipeIngredient[i].title; + } + } catch (TypeError) { + console.error("Index Mismatch Error during recipe ingredient parsing; did the number of ingredients change?"); + } + + parsedIng.value = data; + + errors.value = data.map((ing, index: number) => { + return processIngredientError(ing, index); + }); + } else { + alert.error(i18n.t("events.something-went-wrong") as string); + parsedIng.value = []; + } + } + function isError(ing: ParsedIngredient) { if (!ing?.confidence?.average) { return true; @@ -373,6 +419,7 @@ export default defineComponent({ return { parser, + userPrompt, availableParsers, saveAll, createFood, @@ -386,6 +433,7 @@ export default defineComponent({ panels, asPercentage, fetchParsed, + convertUnits, parsedIng, recipe, loading, diff --git a/mealie/routes/parser/ingredient_parser.py b/mealie/routes/parser/ingredient_parser.py index a4a36d2aa39..303bff1e39c 100644 --- a/mealie/routes/parser/ingredient_parser.py +++ b/mealie/routes/parser/ingredient_parser.py @@ -2,7 +2,7 @@ from mealie.routes._base import BaseUserController, controller from mealie.schema.recipe import ParsedIngredient -from mealie.schema.recipe.recipe_ingredient import IngredientRequest, IngredientsRequest +from mealie.schema.recipe.recipe_ingredient import IngredientRequest, IngredientsRequest, IngredientsConvertRequest from mealie.services.parser_services import get_parser router = APIRouter(prefix="/parser") @@ -20,3 +20,10 @@ async def parse_ingredient(self, ingredient: IngredientRequest): async def parse_ingredients(self, ingredients: IngredientsRequest): parser = get_parser(ingredients.parser, self.group_id, self.session) return await parser.parse(ingredients.ingredients) + + @router.post("/convert-units", response_model=list[ParsedIngredient]) + async def parse_ingredients(self, ingredients: IngredientsConvertRequest): + print("df") + parser = get_parser(ingredients.parser, self.group_id, self.session) + return await parser.convert_units(ingredients.ingredients, ingredients.user_prompt) + diff --git a/mealie/schema/recipe/recipe_ingredient.py b/mealie/schema/recipe/recipe_ingredient.py index 086991bf3bd..51b703484f3 100644 --- a/mealie/schema/recipe/recipe_ingredient.py +++ b/mealie/schema/recipe/recipe_ingredient.py @@ -342,6 +342,11 @@ class IngredientsRequest(MealieModel): parser: RegisteredParser = RegisteredParser.nlp ingredients: list[str] +class IngredientsConvertRequest(MealieModel): + parser: RegisteredParser = RegisteredParser.openai + ingredients: list[str] + user_prompt: str + class IngredientRequest(MealieModel): parser: RegisteredParser = RegisteredParser.nlp diff --git a/mealie/services/openai/prompts/recipes/convert-recipe-units.txt b/mealie/services/openai/prompts/recipes/convert-recipe-units.txt new file mode 100644 index 00000000000..02da0778c06 --- /dev/null +++ b/mealie/services/openai/prompts/recipes/convert-recipe-units.txt @@ -0,0 +1,18 @@ +You are a bot that converts units of ingredients in recipes. You will receive a list of one or more ingredients, each containing one or more of the following components: quantity, unit, food, and note. Their definitions are stated in the JSON schema below. While parsing the ingredients, there are some things to keep in mind: + - If you cannot accurately determine the quantity, unit, food, or note, you should place everything into the note field and leave everything else empty. It's better to err on the side of putting everything in the note field than being wrong + - You may receive recipe ingredients from multiple different languages. You should adhere to the grammar rules of the input language when trying to parse the ingredient string + - Sometimes foods or units will be in their singular, plural, or other grammatical forms. You must interpret all of them appropriately + - Sometimes ingredients will have text in parenthesis (like this). Parenthesis typically indicate something that should appear in the notes. For example: an input of "3 potatoes (roughly chopped)" would parse "roughly chopped" into the notes. Notice that when this occurs, the parenthesis are dropped, and you should use "roughly chopped" instead of "(roughly chopped)" in the note + - It's possible for the input to contain typos. For instance, you might see the word "potatos" instead of "potatoes". If it is a common misspelling, you may correct it + - Pay close attention to what can be considered a unit of measurement. There are common measurements such as tablespoon, teaspoon, and gram, abbreviations such as tsp, tbsp, and oz, and others such as sprig, can, bundle, bunch, unit, cube, package, and pinch + - Sometimes quantities can be given a range, such as "3-5" or "1 to 2" or "three or four". In this instance, choose the lower quantity; do not try to average or otherwise calculate the quantity. For instance, if the input it "2-3 lbs of chicken breast" the quantity should be "2" + - Any text that does not appear in the unit or food must appear in the notes. No text should be left off. The only exception for this is if a quantity is converted from text into a number. For instance, if you convert "2 dozen" into the number "24", you should not put the word "dozen" into any other field + +It is imperative that you do not create any data or otherwise make up any information, you may approximate the conversion however. Failure to adhere to this rule is illegal and will result in harsh punishment. If you are unsure, place the entire string into the note section of the response. Do not make things up. + +Below you will receive the JSON schema for your response. Your response must be in valid JSON in the below schema as provided. You must respond in this JSON schema; failure to do so is illegal. It is imperative that you follow the schema precisely to avoid punishment. You must follow the JSON schema. + +The user message that you receive will be the list of one or more recipe ingredients for you to parse. Your response should have exactly one item for each item provided. For instance, if you receive 12 items to parse, then your response should be an array of 12 parsed items. + +The user message will also include a prompt indicating their preferred units of measurement. The user message may also specify their country +or region, infer the preferred units from the country or region and add them to the preferred units list. You should convert all units to the preferred units. diff --git a/mealie/services/parser_services/_base.py b/mealie/services/parser_services/_base.py index 33e5a265cb2..8a91a79ed51 100644 --- a/mealie/services/parser_services/_base.py +++ b/mealie/services/parser_services/_base.py @@ -154,6 +154,9 @@ async def parse_one(self, ingredient_string: str) -> ParsedIngredient: ... @abstractmethod async def parse(self, ingredients: list[str]) -> list[ParsedIngredient]: ... + @abstractmethod + async def convert_units(self, ingredients: list[str], user_prompt: str) -> list[ParsedIngredient]: ... + def find_ingredient_match(self, ingredient: ParsedIngredient) -> ParsedIngredient: if ingredient.ingredient.food and (food_match := self.data_matcher.find_food_match(ingredient.ingredient.food)): ingredient.ingredient.food = food_match diff --git a/mealie/services/parser_services/openai/parser.py b/mealie/services/parser_services/openai/parser.py index 0e01931bef5..cdee3048995 100644 --- a/mealie/services/parser_services/openai/parser.py +++ b/mealie/services/parser_services/openai/parser.py @@ -108,3 +108,49 @@ async def parse_one(self, ingredient_string: str) -> ParsedIngredient: async def parse(self, ingredients: list[str]) -> list[ParsedIngredient]: response = await self._parse(ingredients) return [self._convert_ingredient(ing) for ing in response.ingredients] + + async def convert_units(self, ingredients: list[str], user_prompt: str) -> list[ParsedIngredient]: + service = OpenAIService() + data_injections = [ + OpenAIDataInjection( + description=( + "This is the JSON response schema. You must respond in valid JSON that follows this schema. " + "Your payload should be as compact as possible, eliminating unncessesary whitespace. Any fields " + "with default values which you do not populate should not be in the payload." + ), + value=OpenAIIngredients, + ), + OpenAIDataInjection(description="User Prompt containing the preferences of the user", value=user_prompt), + ] + prompt = service.get_prompt("recipes.convert-recipe-units", data_injections=data_injections) + print(prompt) + # chunk ingredients and send each chunk to its own worker + ingredient_chunks = self._chunk_messages(ingredients, n=service.workers) + tasks: list[Awaitable[str | None]] = [] + for ingredient_chunk in ingredient_chunks: + message = json.dumps(ingredient_chunk, separators=(",", ":")) + tasks.append(service.get_response(prompt, message, force_json_response=True)) + + # re-combine chunks into one response + try: + responses_json = await asyncio.gather(*tasks) + except Exception as e: + raise Exception("Failed to call OpenAI services") from e + + try: + responses = [ + OpenAIIngredients.parse_openai_response(response_json) + for response_json in responses_json + if responses_json + ] + except Exception as e: + raise Exception("Failed to parse OpenAI response") from e + + if not responses: + raise Exception("No response from OpenAI") + + res = OpenAIIngredients( + ingredients=[ingredient for response in responses for ingredient in response.ingredients] + ) + + return [self._convert_ingredient(ing) for ing in res.ingredients] From 96d1ec6b0b2fca726d551a9be1d66cbf300fe3cd Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Mon, 4 Nov 2024 13:16:54 +0100 Subject: [PATCH 2/5] Made it more general and nicer --- frontend/lib/api/user/recipes/recipe.ts | 4 ++-- .../_groupSlug/r/_slug/ingredient-parser.vue | 21 +++++-------------- mealie/routes/parser/ingredient_parser.py | 8 +++---- mealie/schema/recipe/recipe_ingredient.py | 8 ++++++- .../prompts/recipes/convert-recipe-units.txt | 17 ++++++++------- .../services/parser_services/openai/parser.py | 10 +++++---- 6 files changed, 33 insertions(+), 35 deletions(-) diff --git a/frontend/lib/api/user/recipes/recipe.ts b/frontend/lib/api/user/recipes/recipe.ts index 0e98bf2bf75..0d1ad42ac86 100644 --- a/frontend/lib/api/user/recipes/recipe.ts +++ b/frontend/lib/api/user/recipes/recipe.ts @@ -166,9 +166,9 @@ export class RecipeAPI extends BaseCRUDAPI { return await this.requests.post(routes.recipesParseIngredients, { parser, ingredients }); } - async convertUnits(parser: Parser, ingredients: Array, user_prompt: string) { + async convertUnits(parser: Parser, ingredients: Array, convert_to: "metric" | "imperial") { parser = "openai"; - return await this.requests.post(routes.recipesConvertUnits, { parser, ingredients, user_prompt }); + return await this.requests.post(routes.recipesConvertUnits, { parser, ingredients, convert_to }); } async parseIngredient(parser: Parser, ingredient: string) { diff --git a/frontend/pages/g/_groupSlug/r/_slug/ingredient-parser.vue b/frontend/pages/g/_groupSlug/r/_slug/ingredient-parser.vue index b2f52805d87..134760680f3 100644 --- a/frontend/pages/g/_groupSlug/r/_slug/ingredient-parser.vue +++ b/frontend/pages/g/_groupSlug/r/_slug/ingredient-parser.vue @@ -22,22 +22,14 @@ :items="availableParsers" />
-
-
USer prompt:
- -
+ - - convert units + + Parse and convert units (Metric) - {{ $tc("recipe.parser.parse-all") }} @@ -195,8 +187,6 @@ export default defineComponent({ parserPreferences.value.parser = val; }); - const userPrompt = ref(null); - function processIngredientError(ing: ParsedIngredient, index: number): Error { const unitError = !checkForUnit(ing.ingredient.unit); const foodError = !checkForFood(ing.ingredient.food); @@ -263,13 +253,13 @@ export default defineComponent({ } async function convertUnits() { - if (!recipe.value || !recipe.value.recipeIngredient || !userPrompt.value) { + if (!recipe.value || !recipe.value.recipeIngredient) { return; } const raw = recipe.value.recipeIngredient.map((ing) => ing.note ?? ""); parserLoading.value = true; - const { data } = await api.recipes.convertUnits(parser.value, raw, userPrompt.value); + const { data } = await api.recipes.convertUnits(parser.value, raw, "metric"); parserLoading.value = false; if (data) { @@ -419,7 +409,6 @@ export default defineComponent({ return { parser, - userPrompt, availableParsers, saveAll, createFood, diff --git a/mealie/routes/parser/ingredient_parser.py b/mealie/routes/parser/ingredient_parser.py index 303bff1e39c..33485e435c2 100644 --- a/mealie/routes/parser/ingredient_parser.py +++ b/mealie/routes/parser/ingredient_parser.py @@ -2,7 +2,7 @@ from mealie.routes._base import BaseUserController, controller from mealie.schema.recipe import ParsedIngredient -from mealie.schema.recipe.recipe_ingredient import IngredientRequest, IngredientsRequest, IngredientsConvertRequest +from mealie.schema.recipe.recipe_ingredient import IngredientRequest, IngredientsConvertRequest, IngredientsRequest from mealie.services.parser_services import get_parser router = APIRouter(prefix="/parser") @@ -22,8 +22,6 @@ async def parse_ingredients(self, ingredients: IngredientsRequest): return await parser.parse(ingredients.ingredients) @router.post("/convert-units", response_model=list[ParsedIngredient]) - async def parse_ingredients(self, ingredients: IngredientsConvertRequest): - print("df") + async def parse_and_convert_ingredients(self, ingredients: IngredientsConvertRequest): parser = get_parser(ingredients.parser, self.group_id, self.session) - return await parser.convert_units(ingredients.ingredients, ingredients.user_prompt) - + return await parser.convert_units(ingredients.ingredients, ingredients.convert_to.value) diff --git a/mealie/schema/recipe/recipe_ingredient.py b/mealie/schema/recipe/recipe_ingredient.py index 51b703484f3..eab817b7e63 100644 --- a/mealie/schema/recipe/recipe_ingredient.py +++ b/mealie/schema/recipe/recipe_ingredient.py @@ -342,10 +342,16 @@ class IngredientsRequest(MealieModel): parser: RegisteredParser = RegisteredParser.nlp ingredients: list[str] + +class ConvertTo(enum.Enum): + metric = "metric" + imperial = "imperial" + + class IngredientsConvertRequest(MealieModel): parser: RegisteredParser = RegisteredParser.openai ingredients: list[str] - user_prompt: str + convert_to: ConvertTo class IngredientRequest(MealieModel): diff --git a/mealie/services/openai/prompts/recipes/convert-recipe-units.txt b/mealie/services/openai/prompts/recipes/convert-recipe-units.txt index 02da0778c06..da27eaba621 100644 --- a/mealie/services/openai/prompts/recipes/convert-recipe-units.txt +++ b/mealie/services/openai/prompts/recipes/convert-recipe-units.txt @@ -1,4 +1,4 @@ -You are a bot that converts units of ingredients in recipes. You will receive a list of one or more ingredients, each containing one or more of the following components: quantity, unit, food, and note. Their definitions are stated in the JSON schema below. While parsing the ingredients, there are some things to keep in mind: +You are a bot that parses and converts units of ingredients in recipes. You will receive a list of one or more ingredients, each containing one or more of the following components: quantity, unit, food, and note. Their definitions are stated in the JSON schema below. While parsing the ingredients, there are some things to keep in mind: - If you cannot accurately determine the quantity, unit, food, or note, you should place everything into the note field and leave everything else empty. It's better to err on the side of putting everything in the note field than being wrong - You may receive recipe ingredients from multiple different languages. You should adhere to the grammar rules of the input language when trying to parse the ingredient string - Sometimes foods or units will be in their singular, plural, or other grammatical forms. You must interpret all of them appropriately @@ -8,11 +8,14 @@ You are a bot that converts units of ingredients in recipes. You will receive a - Sometimes quantities can be given a range, such as "3-5" or "1 to 2" or "three or four". In this instance, choose the lower quantity; do not try to average or otherwise calculate the quantity. For instance, if the input it "2-3 lbs of chicken breast" the quantity should be "2" - Any text that does not appear in the unit or food must appear in the notes. No text should be left off. The only exception for this is if a quantity is converted from text into a number. For instance, if you convert "2 dozen" into the number "24", you should not put the word "dozen" into any other field -It is imperative that you do not create any data or otherwise make up any information, you may approximate the conversion however. Failure to adhere to this rule is illegal and will result in harsh punishment. If you are unsure, place the entire string into the note section of the response. Do not make things up. +You will receive whether you should convert from imperial to metric or the other way around. These are the rules you should follow when converting the units: + - When converting from units such as cups you can approximate the answer. + - When converting the units you should use units such as liters, ml or cl for liquid ingredients. Example: 100ml of milk, 2l of stock. + - When converting the units you should use units such as grams, kg or mg for solid ingredients. Example: 10g of salt, 300gr of mozzarella. + - You should also convert length measurements to measurements like meter, cm and mm. Even when these measurements are in the note field. Example: '1/8 inch thick slices' should be '3mm thick slices'. + - Teaspoons and pinches you can keep the same. + - When converting round up the numbers which make sense depending on the size of the ingredient. For example, if you have 1/3 cup of sugar, you should round it to 70mg of sugar. -Below you will receive the JSON schema for your response. Your response must be in valid JSON in the below schema as provided. You must respond in this JSON schema; failure to do so is illegal. It is imperative that you follow the schema precisely to avoid punishment. You must follow the JSON schema. - -The user message that you receive will be the list of one or more recipe ingredients for you to parse. Your response should have exactly one item for each item provided. For instance, if you receive 12 items to parse, then your response should be an array of 12 parsed items. +It is imperative that you do not create any data or otherwise make up any information, however you may approximate the conversion. Failure to adhere to this rule is illegal and will result in harsh punishment. If you are unsure, place the entire string into the note section of the response. Do not make things up. -The user message will also include a prompt indicating their preferred units of measurement. The user message may also specify their country -or region, infer the preferred units from the country or region and add them to the preferred units list. You should convert all units to the preferred units. +Below you will receive the JSON schema for your response. Your response must be in valid JSON in the below schema as provided. You must respond in this JSON schema; failure to do so is illegal. It is imperative that you follow the schema precisely to avoid punishment. You must follow the JSON schema. diff --git a/mealie/services/parser_services/openai/parser.py b/mealie/services/parser_services/openai/parser.py index cdee3048995..3b11078ef3f 100644 --- a/mealie/services/parser_services/openai/parser.py +++ b/mealie/services/parser_services/openai/parser.py @@ -4,6 +4,7 @@ from mealie.schema.openai.recipe_ingredient import OpenAIIngredient, OpenAIIngredients from mealie.schema.recipe.recipe_ingredient import ( + ConvertTo, CreateIngredientFood, CreateIngredientUnit, IngredientConfidence, @@ -109,7 +110,7 @@ async def parse(self, ingredients: list[str]) -> list[ParsedIngredient]: response = await self._parse(ingredients) return [self._convert_ingredient(ing) for ing in response.ingredients] - async def convert_units(self, ingredients: list[str], user_prompt: str) -> list[ParsedIngredient]: + async def convert_units(self, ingredients: list[str], convert_to: ConvertTo) -> list[ParsedIngredient]: service = OpenAIService() data_injections = [ OpenAIDataInjection( @@ -120,10 +121,11 @@ async def convert_units(self, ingredients: list[str], user_prompt: str) -> list[ ), value=OpenAIIngredients, ), - OpenAIDataInjection(description="User Prompt containing the preferences of the user", value=user_prompt), + OpenAIDataInjection( + description="The direction to which you should convert. You should convert to:", value=convert_to + ), ] prompt = service.get_prompt("recipes.convert-recipe-units", data_injections=data_injections) - print(prompt) # chunk ingredients and send each chunk to its own worker ingredient_chunks = self._chunk_messages(ingredients, n=service.workers) tasks: list[Awaitable[str | None]] = [] @@ -149,7 +151,7 @@ async def convert_units(self, ingredients: list[str], user_prompt: str) -> list[ if not responses: raise Exception("No response from OpenAI") - res = OpenAIIngredients( + res = OpenAIIngredients( ingredients=[ingredient for response in responses for ingredient in response.ingredients] ) From c6724cf53e208c72e9df8e549c6e6d42f92d634d Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Mon, 4 Nov 2024 13:21:53 +0100 Subject: [PATCH 3/5] Edited the prompt --- .../services/openai/prompts/recipes/convert-recipe-units.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mealie/services/openai/prompts/recipes/convert-recipe-units.txt b/mealie/services/openai/prompts/recipes/convert-recipe-units.txt index da27eaba621..d50109b2558 100644 --- a/mealie/services/openai/prompts/recipes/convert-recipe-units.txt +++ b/mealie/services/openai/prompts/recipes/convert-recipe-units.txt @@ -12,9 +12,10 @@ You will receive whether you should convert from imperial to metric or the other - When converting from units such as cups you can approximate the answer. - When converting the units you should use units such as liters, ml or cl for liquid ingredients. Example: 100ml of milk, 2l of stock. - When converting the units you should use units such as grams, kg or mg for solid ingredients. Example: 10g of salt, 300gr of mozzarella. - - You should also convert length measurements to measurements like meter, cm and mm. Even when these measurements are in the note field. Example: '1/8 inch thick slices' should be '3mm thick slices'. - - Teaspoons and pinches you can keep the same. - When converting round up the numbers which make sense depending on the size of the ingredient. For example, if you have 1/3 cup of sugar, you should round it to 70mg of sugar. + - You should also convert length measurements to measurements like meter, cm and mm. Example: '1/8 inch thick slices' should be '3mm thick slices'. + - You need to convert units and measurements which are in the notes field. + - Teaspoons and pinches you can keep the same. It is imperative that you do not create any data or otherwise make up any information, however you may approximate the conversion. Failure to adhere to this rule is illegal and will result in harsh punishment. If you are unsure, place the entire string into the note section of the response. Do not make things up. From 138ef95e119ad0aa78846c765204dfda10986286 Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Mon, 4 Nov 2024 13:24:21 +0100 Subject: [PATCH 4/5] Remove dev changes --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 7a4870f3e3a..6c9c09066ee 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -134,7 +134,7 @@ HEALTHCHECK CMD python $MEALIE_HOME/mealie/scripts/healthcheck.py || exit 1 ENV STATIC_FILES=/spa/static COPY --from=builder /app/dist ${STATIC_FILES} -ENV HOST 127.0.0.1 +ENV HOST 0.0.0.0 EXPOSE ${APP_PORT} COPY ./docker/entry.sh $MEALIE_HOME/run.sh From ee07ce6788f25022a6f478a4a8ce8ac34079ed8a Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Mon, 4 Nov 2024 13:34:58 +0100 Subject: [PATCH 5/5] Added temperature to prompt --- mealie/services/openai/prompts/recipes/convert-recipe-units.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/mealie/services/openai/prompts/recipes/convert-recipe-units.txt b/mealie/services/openai/prompts/recipes/convert-recipe-units.txt index d50109b2558..145983bcc2c 100644 --- a/mealie/services/openai/prompts/recipes/convert-recipe-units.txt +++ b/mealie/services/openai/prompts/recipes/convert-recipe-units.txt @@ -13,6 +13,7 @@ You will receive whether you should convert from imperial to metric or the other - When converting the units you should use units such as liters, ml or cl for liquid ingredients. Example: 100ml of milk, 2l of stock. - When converting the units you should use units such as grams, kg or mg for solid ingredients. Example: 10g of salt, 300gr of mozzarella. - When converting round up the numbers which make sense depending on the size of the ingredient. For example, if you have 1/3 cup of sugar, you should round it to 70mg of sugar. + - You should convert temperature measurements to Celsius. Example: '350°F' should be '180°C'. - You should also convert length measurements to measurements like meter, cm and mm. Example: '1/8 inch thick slices' should be '3mm thick slices'. - You need to convert units and measurements which are in the notes field. - Teaspoons and pinches you can keep the same.