feat(medications): 增强AI药品识别质量控制和多图片支持
- 新增图片可读性预检查机制,识别前先判断图片质量 - 设置置信度阈值为60%,低于阈值自动识别失败 - 支持多图片上传(正面、侧面、辅助图片)提高识别准确度 - 完善识别失败场景的错误分类和用户指导提示 - 新增药品有效期字段支持 - 优化AI提示词,强调安全优先原则 - 更新模型版本为 glm-4.5v 和 glm-4.5-air 数据库变更: - Medication表新增 sideImageUrl, auxiliaryImageUrl, expiryDate 字段 - DTO层同步支持新增字段的传递和更新 质量控制策略: - 图片模糊或不可读时直接返回失败 - 无法识别药品名称时主动失败 - 置信度<60%时拒绝识别,建议重新拍摄 - 宁可识别失败也不提供不准确的药品信息
This commit is contained in:
@@ -26,14 +26,32 @@ export class CreateMedicationDto {
|
||||
name: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '药物照片URL',
|
||||
example: 'https://cdn.example.com/medications/med_001.jpg',
|
||||
description: '药物正面照片URL',
|
||||
example: 'https://cdn.example.com/medications/front_001.jpg',
|
||||
required: false,
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
photoUrl?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '药物侧面照片URL',
|
||||
example: 'https://cdn.example.com/medications/side_001.jpg',
|
||||
required: false,
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
sideImageUrl?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '药物辅助照片URL(可选的第三张图片)',
|
||||
example: 'https://cdn.example.com/medications/auxiliary_001.jpg',
|
||||
required: false,
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
auxiliaryImageUrl?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '药物剂型',
|
||||
enum: MedicationFormEnum,
|
||||
@@ -98,6 +116,15 @@ export class CreateMedicationDto {
|
||||
@IsOptional()
|
||||
endDate?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '药品有效期,ISO 8601 格式(可选)',
|
||||
example: '2026-12-31T23:59:59.999Z',
|
||||
required: false,
|
||||
})
|
||||
@IsDateString()
|
||||
@IsOptional()
|
||||
expiryDate?: string;
|
||||
|
||||
@ApiProperty({ description: '备注信息', example: '饭后服用', required: false })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
|
||||
@@ -6,15 +6,36 @@ import { MedicationFormEnum } from '../enums/medication-form.enum';
|
||||
* 包含创建药物所需的所有字段 + AI分析结果
|
||||
*/
|
||||
export class RecognitionResultDto {
|
||||
@ApiProperty({
|
||||
description: '图片是否清晰可读(AI判断)',
|
||||
example: true,
|
||||
required: false,
|
||||
})
|
||||
isReadable?: boolean;
|
||||
|
||||
@ApiProperty({ description: '药品名称', example: '阿莫西林胶囊' })
|
||||
name: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '药品照片URL(使用正面图片)',
|
||||
description: '药品正面照片URL',
|
||||
example: 'https://cdn.example.com/medications/front_001.jpg',
|
||||
})
|
||||
photoUrl: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '药品侧面照片URL',
|
||||
example: 'https://cdn.example.com/medications/side_001.jpg',
|
||||
required: false,
|
||||
})
|
||||
sideImageUrl?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '药品辅助照片URL',
|
||||
example: 'https://cdn.example.com/medications/auxiliary_001.jpg',
|
||||
required: false,
|
||||
})
|
||||
auxiliaryImageUrl?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '药物剂型',
|
||||
enum: MedicationFormEnum,
|
||||
|
||||
Reference in New Issue
Block a user