Image validation of the image2text model without using local paths (#9052)

### What problem does this PR solve?

#9050

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
kuschzzp
2025-07-30 12:57:24 +08:00
committed by GitHub
parent 30356b0b79
commit b638d3f773
2 changed files with 7 additions and 6 deletions

View File

@ -15,7 +15,7 @@
#
import logging
import json
import os
import base64
from flask import request
from flask_login import login_required, current_user
from api.db.services.llm_service import LLMFactoriesService, TenantLLMService, LLMService
@ -24,7 +24,7 @@ from api.utils.api_utils import server_error_response, get_data_error_result, va
from api.db import StatusEnum, LLMType
from api.db.db_models import TenantLLM
from api.utils.api_utils import get_json_result
from api.utils.file_utils import get_project_base_directory
from api.utils.base64_image import test_image_base64
from rag.llm import EmbeddingModel, ChatModel, RerankModel, CvModel, TTSModel
@ -256,8 +256,8 @@ def add_llm():
base_url=llm["api_base"]
)
try:
with open(os.path.join(get_project_base_directory(), "web/src/assets/yay.jpg"), "rb") as f:
m, tc = mdl.describe(f.read())
image_data = base64.b64decode(test_image_base64)
m, tc = mdl.describe(image_data)
if not m and not tc:
raise Exception(m)
except Exception as e:

File diff suppressed because one or more lines are too long