From cf93b90b2450f572d759b0c50ebc5a5ef29ccf41 Mon Sep 17 00:00:00 2001 From: MingNian <1281442923@qq.com> Date: Tue, 2 Jun 2026 14:33:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=A4=9A=E8=A7=92?= =?UTF-8?q?=E5=BA=A6=E6=8B=8D=E7=85=A7=20+=20=E8=AF=A6=E7=BB=86=E8=90=A5?= =?UTF-8?q?=E5=85=BB=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 最多上传 8 张照片,多角度拍摄提高份量估算精度 - VLM prompt 升级:识别名称+份量+热量+蛋白质+碳水+脂肪 - 提示 VLM 综合分析多张照片判断份量 --- .../Health.WebApi/Endpoints/ai_chat_endpoints.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/src/Health.WebApi/Endpoints/ai_chat_endpoints.cs b/backend/src/Health.WebApi/Endpoints/ai_chat_endpoints.cs index 8959829..0f19f3a 100644 --- a/backend/src/Health.WebApi/Endpoints/ai_chat_endpoints.cs +++ b/backend/src/Health.WebApi/Endpoints/ai_chat_endpoints.cs @@ -242,6 +242,8 @@ public static class AiChatEndpoints var files = form.Files.GetFiles("images"); if (files == null || files.Count == 0) return Results.Ok(new { code = 40001, data = (object?)null, message = "请上传至少一张图片" }); + if (files.Count > 8) + return Results.Ok(new { code = 40001, data = (object?)null, message = "一次最多上传 8 张图片" }); var imageUrls = new List(); var uploadsDir = Path.Combine(Directory.GetCurrentDirectory(), "uploads"); @@ -270,9 +272,19 @@ public static class AiChatEndpoints } var prompt = """ - 识别图片中所有食物,用中文名称,只返回JSON: + 你是一个专业营养师。请仔细分析这些食物照片(可能是同一餐不同角度拍摄)。 + + 要求: + 1. 识别所有食物,用中文名称 + 2. 根据多角度照片综合判断份量,尽量精准 + 3. 估算每项的热量、蛋白质、碳水、脂肪(克) + + 只返回JSON: { - "foods": [{"name":"食物名","portion":"份量","calories":整数}] + "foods": [ + {"name":"食物名","portion":"份量描述","calories":整数,"proteinGrams":整数,"carbsGrams":整数,"fatGrams":整数} + ], + "totalCalories":整数 } """;