improved the experience when no transaction information is detected

This commit is contained in:
MaysWind
2025-09-21 15:28:26 +08:00
parent 32fed8d6fb
commit ae19ca4383
15 changed files with 22 additions and 2 deletions
+7 -1
View File
@@ -219,6 +219,10 @@ func (a *LargeLanguageModelsApi) RecognizeReceiptImageHandler(c *core.WebContext
return nil, errs.Or(err, errs.ErrOperationFailed)
}
if llmResponse == nil || len(llmResponse.Content) == 0 || strings.HasPrefix(llmResponse.Content, "{}") {
return nil, errs.ErrNoTransactionInformationInImage
}
var result *models.RecognizedReceiptImageResult
if err := json.Unmarshal([]byte(llmResponse.Content), &result); err != nil {
@@ -236,7 +240,7 @@ func (a *LargeLanguageModelsApi) parseRecognizedReceiptImageResponse(c *core.Web
if recognizedResult == nil {
log.Errorf(c, "[large_language_models.parseRecognizedReceiptImageResponse] recoginzed result is null")
return nil, errs.ErrOperationFailed
return nil, errs.ErrNoTransactionInformationInImage
}
if recognizedResult.Type == "income" {
@@ -269,6 +273,8 @@ func (a *LargeLanguageModelsApi) parseRecognizedReceiptImageResponse(c *core.Web
recognizedReceiptImageResponse.CategoryId = category.CategoryId
}
}
} else if len(recognizedResult.Type) == 0 {
return nil, errs.ErrNoTransactionInformationInImage
} else {
log.Errorf(c, "[large_language_models.parseRecognizedReceiptImageResponse] recoginzed transaction type \"%s\" is invalid", recognizedResult.Type)
return nil, errs.ErrOperationFailed
+1
View File
@@ -8,4 +8,5 @@ var (
ErrNoAIRecognitionImage = NewNormalError(NormalSubcategoryLargeLanguageModel, 1, http.StatusBadRequest, "no image for AI recognition")
ErrAIRecognitionImageIsEmpty = NewNormalError(NormalSubcategoryLargeLanguageModel, 2, http.StatusBadRequest, "image for AI recognition is empty")
ErrExceedMaxAIRecognitionImageFileSize = NewNormalError(NormalSubcategoryLargeLanguageModel, 3, http.StatusBadRequest, "exceed the maximum size of image file for AI recognition")
ErrNoTransactionInformationInImage = NewNormalError(NormalSubcategoryLargeLanguageModel, 4, http.StatusBadRequest, "no transaction information detected")
)
+1
View File
@@ -1228,6 +1228,7 @@
"no image for AI recognition": "There is no image for AI recognition",
"image for AI recognition is empty": "Image for AI recognition file is empty",
"exceed the maximum size of image file for AI recognition": "The uploaded image for AI recognition exceeds the maximum allowed file size",
"no transaction information detected": "No transaction information detected",
"query items cannot be blank": "Abfrageelemente dürfen nicht leer sein",
"query items too much": "Zu viele Abfrageelemente",
"query items have invalid item": "Ungültiges Element in Abfrageelementen",
+1
View File
@@ -1228,6 +1228,7 @@
"no image for AI recognition": "There is no image for AI recognition",
"image for AI recognition is empty": "Image for AI recognition file is empty",
"exceed the maximum size of image file for AI recognition": "The uploaded image for AI recognition exceeds the maximum allowed file size",
"no transaction information detected": "No transaction information detected",
"query items cannot be blank": "There are no query items",
"query items too much": "There are too many query items",
"query items have invalid item": "There is invalid item in query items",
+1
View File
@@ -1228,6 +1228,7 @@
"no image for AI recognition": "There is no image for AI recognition",
"image for AI recognition is empty": "Image for AI recognition file is empty",
"exceed the maximum size of image file for AI recognition": "The uploaded image for AI recognition exceeds the maximum allowed file size",
"no transaction information detected": "No transaction information detected",
"query items cannot be blank": "--",
"query items too much": "--",
"query items have invalid item": "Hay un elemento no válido en los elementos de consulta",
+1
View File
@@ -1228,6 +1228,7 @@
"no image for AI recognition": "There is no image for AI recognition",
"image for AI recognition is empty": "Image for AI recognition file is empty",
"exceed the maximum size of image file for AI recognition": "The uploaded image for AI recognition exceeds the maximum allowed file size",
"no transaction information detected": "No transaction information detected",
"query items cannot be blank": "Non ci sono elementi di query",
"query items too much": "Ci sono troppi elementi di query",
"query items have invalid item": "C'è un elemento non valido negli elementi di query",
+1
View File
@@ -1228,6 +1228,7 @@
"no image for AI recognition": "There is no image for AI recognition",
"image for AI recognition is empty": "Image for AI recognition file is empty",
"exceed the maximum size of image file for AI recognition": "The uploaded image for AI recognition exceeds the maximum allowed file size",
"no transaction information detected": "No transaction information detected",
"query items cannot be blank": "クエリ項目がありません",
"query items too much": "クエリ項目が多すぎます",
"query items have invalid item": "クエリ項目に無効な項目があります",
+1
View File
@@ -1228,6 +1228,7 @@
"no image for AI recognition": "There is no image for AI recognition",
"image for AI recognition is empty": "Image for AI recognition file is empty",
"exceed the maximum size of image file for AI recognition": "The uploaded image for AI recognition exceeds the maximum allowed file size",
"no transaction information detected": "No transaction information detected",
"query items cannot be blank": "Geen zoekitems opgegeven",
"query items too much": "Te veel zoekitems",
"query items have invalid item": "Ongeldig item in zoekitems",
+1
View File
@@ -1228,6 +1228,7 @@
"no image for AI recognition": "There is no image for AI recognition",
"image for AI recognition is empty": "Image for AI recognition file is empty",
"exceed the maximum size of image file for AI recognition": "The uploaded image for AI recognition exceeds the maximum allowed file size",
"no transaction information detected": "No transaction information detected",
"query items cannot be blank": "Não há itens de consulta",
"query items too much": "Há muitos itens de consulta",
"query items have invalid item": "Há item inválido nos itens de consulta",
+1
View File
@@ -1228,6 +1228,7 @@
"no image for AI recognition": "There is no image for AI recognition",
"image for AI recognition is empty": "Image for AI recognition file is empty",
"exceed the maximum size of image file for AI recognition": "The uploaded image for AI recognition exceeds the maximum allowed file size",
"no transaction information detected": "No transaction information detected",
"query items cannot be blank": "Нет элементов запроса",
"query items too much": "Слишком много элементов запроса",
"query items have invalid item": "В элементах запроса присутствует недопустимый элемент",
+1
View File
@@ -1228,6 +1228,7 @@
"no image for AI recognition": "There is no image for AI recognition",
"image for AI recognition is empty": "Image for AI recognition file is empty",
"exceed the maximum size of image file for AI recognition": "The uploaded image for AI recognition exceeds the maximum allowed file size",
"no transaction information detected": "No transaction information detected",
"query items cannot be blank": "Елементи запиту не можуть бути порожніми",
"query items too much": "Занадто багато елементів запиту",
"query items have invalid item": "Запит містить недійсний елемент",
+1
View File
@@ -1228,6 +1228,7 @@
"no image for AI recognition": "There is no image for AI recognition",
"image for AI recognition is empty": "Image for AI recognition file is empty",
"exceed the maximum size of image file for AI recognition": "The uploaded image for AI recognition exceeds the maximum allowed file size",
"no transaction information detected": "No transaction information detected",
"query items cannot be blank": "Không có mục truy vấn",
"query items too much": "Có quá nhiều mục truy vấn",
"query items have invalid item": "Có mục không hợp lệ trong các mục truy vấn",
+1
View File
@@ -1228,6 +1228,7 @@
"no image for AI recognition": "没有用于AI识别的图片",
"image for AI recognition is empty": "用于AI识别的图片为空",
"exceed the maximum size of image file for AI recognition": "用于AI识别的图片超出了允许的最大文件大小",
"no transaction information detected": "没有检测到交易信息",
"query items cannot be blank": "请求项目不能为空",
"query items too much": "请求项目过多",
"query items have invalid item": "请求项目中有非法项目",
+1
View File
@@ -1228,6 +1228,7 @@
"no image for AI recognition": "沒有用於AI識別的圖片檔案",
"image for AI recognition is empty": "用於AI識別的圖片檔案為空",
"exceed the maximum size of image file for AI recognition": "用於AI識別的圖片超出了允許的最大檔案大小",
"no transaction information detected": "沒有檢測到交易資訊",
"query items cannot be blank": "查詢項目不能為空",
"query items too much": "查詢項目過多",
"query items have invalid item": "查詢項目中有非法項目",
@@ -25,7 +25,8 @@ Your task is to extract structured transaction data from images provided by the
1. Only include fields you can confidently identify.
2. If unsure about a value, omit the field (do not guess).
3. If the image contains multiple items, please combine them into a single transaction.
4. Always return valid JSON.
4. If the image contains no transaction information, simply return an empty JSON object.
5. Always return valid JSON.
## Options
### Expense categories: