Bläddra i källkod

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)
tags/v0.20.0
kuschzzp 3 månader sedan
förälder
incheckning
b638d3f773
Inget konto är kopplat till bidragsgivarens mejladress
2 ändrade filer med 7 tillägg och 6 borttagningar
  1. 6
    6
      api/apps/llm_app.py
  2. 1
    0
      api/utils/base64_image.py

+ 6
- 6
api/apps/llm_app.py Visa fil

@@ -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,10 +256,10 @@ 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())
if not m and not tc:
raise Exception(m)
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:
msg += f"\nFail to access model({mdl_nm})." + str(e)
elif llm["model_type"] == LLMType.TTS:

+ 1
- 0
api/utils/base64_image.py
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


Laddar…
Avbryt
Spara