fix: enforce English canonical text in AI-generated dish and recipe data
RecognizeDish() and buildRecipePrompt() were generating text in the user's language and storing it in base tables, violating the project rule that base tables always hold English canonical text. - RecognizeDish(): hardcode English for dish_name; enrichDishInBackground() now correctly translates FROM English into all other languages - buildRecipePrompt(): remove langName lookup, hardcode English for all text fields; drop unused locale import Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -111,11 +111,7 @@ Return ONLY valid JSON without markdown:
|
||||
// RecognizeDish uses the vision model to identify a dish and estimate its nutritional content.
|
||||
// Returns 3–5 ranked candidates so the user can correct mis-identifications.
|
||||
func (c *Client) RecognizeDish(ctx context.Context, imageBase64, mimeType, lang string) (*ai.DishResult, error) {
|
||||
langName := langNames[lang]
|
||||
if langName == "" {
|
||||
langName = "English"
|
||||
}
|
||||
prompt := fmt.Sprintf(`You are a dietitian and culinary expert.
|
||||
prompt := `You are a dietitian and culinary expert.
|
||||
|
||||
Look at the dish photo and suggest 3 to 5 possible dishes it could be.
|
||||
Even if the first option is obvious, add 2–4 alternative dishes with lower confidence.
|
||||
@@ -128,7 +124,7 @@ For each candidate specify:
|
||||
|
||||
Sort candidates by descending confidence. First — most likely.
|
||||
|
||||
Return dish_name values in %s.
|
||||
Return dish_name values in English.
|
||||
Return ONLY valid JSON without markdown:
|
||||
{
|
||||
"candidates": [
|
||||
@@ -151,7 +147,7 @@ Return ONLY valid JSON without markdown:
|
||||
"confidence": 0.65
|
||||
}
|
||||
]
|
||||
}`, langName)
|
||||
}`
|
||||
|
||||
text, err := c.generateVisionContent(ctx, prompt, imageBase64, mimeType)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user