fix: VLM 食物识别全链路修复 + 用药 Agent Prompt 优化
- 图片上传自动压缩(max 860px, JPEG Q65),解决大图超 API 129KB 限制 - 修复 VLM 传 file:// 本地路径 Bug,改为 base64 data URL - VLM Prompt 优化为中文食堂场景,附带常见中餐热量参考 - 千问 API 错误信息透传,方便调试 - 用药 Agent Prompt 加查询规则:先调 manage_medication 再回答 - 新增 System.Drawing.Common 依赖用于服务端图片压缩
This commit is contained in:
@@ -129,7 +129,11 @@ public sealed class QwenVisionClient(HttpClient http, IConfiguration config)
|
||||
var json = JsonSerializer.Serialize(request, _jsonOptions);
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = await _http.PostAsync("chat/completions", content, ct);
|
||||
response.EnsureSuccessStatusCode();
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
var errorBody = await response.Content.ReadAsStringAsync(ct);
|
||||
throw new HttpRequestException($"VLM API {response.StatusCode}: {errorBody}");
|
||||
}
|
||||
var body = await response.Content.ReadAsStringAsync(ct);
|
||||
return JsonSerializer.Deserialize<ChatCompletionResponse>(body, _jsonOptions)!;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user