|
|
@@ -1,6 +1,6 @@
|
|
|
import { analysis } from '@/request';
|
|
|
import type { AnalysisHealthKey, AnalysisHealthModel } from '@/modules/chat/types';
|
|
|
-import type { AnalysisHealthReportModel } from '@/request/model/analysis-health.model.ts';
|
|
|
+import type { AnalysisHealthReportError, AnalysisHealthReportModel } from '@/request/model/analysis-health.model.ts';
|
|
|
import { camelToUnderline } from '@/tools';
|
|
|
|
|
|
export function analysisHealthMethod(model: AnalysisHealthModel) {
|
|
|
@@ -31,7 +31,9 @@ export function analysisHealthMethod(model: AnalysisHealthModel) {
|
|
|
}
|
|
|
|
|
|
const result: AnalysisHealthReportModel = {};
|
|
|
- if (data.tongue_str)
|
|
|
+ const error: AnalysisHealthReportError = {};
|
|
|
+ if (data.tongue_str.startsWith(`图像检测失败`)) error.tongue = data.tongue_str.replace('图像', '舌象');
|
|
|
+ else if (data.tongue_str)
|
|
|
result.tongue = {
|
|
|
result: data.tongue_str,
|
|
|
cover: {
|
|
|
@@ -39,7 +41,9 @@ export function analysisHealthMethod(model: AnalysisHealthModel) {
|
|
|
down: getUrl(data.tongue_under_origin_path)!,
|
|
|
},
|
|
|
};
|
|
|
- if (data.face_str)
|
|
|
+
|
|
|
+ if (data.face_str.startsWith(`图像检测失败`)) error.tongue = data.face_str.replace('图像', '面象');
|
|
|
+ else if (data.face_str)
|
|
|
result.face = {
|
|
|
result: data.face_str,
|
|
|
cover: {
|
|
|
@@ -47,6 +51,11 @@ export function analysisHealthMethod(model: AnalysisHealthModel) {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
+ if (Object.keys(error).length > 0) {
|
|
|
+ error.message = [error.tongue, error.face].filter(Boolean).join('\n');
|
|
|
+ throw error;
|
|
|
+ }
|
|
|
+
|
|
|
return { model, result } as { model: AnalysisHealthModel; result: AnalysisHealthReportModel };
|
|
|
},
|
|
|
});
|