add support for LM Studio (#1663)

### What problem does this PR solve?

#1602 

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

---------

Co-authored-by: Zhedong Cen <cenzhedong2@126.com>
This commit is contained in:
黄腾
2024-07-24 12:46:43 +08:00
committed by GitHub
parent 100b3165d8
commit d96348eb22
10 changed files with 9791 additions and 26 deletions

View File

@ -21,7 +21,7 @@ from api.db import StatusEnum, LLMType
from api.db.db_models import TenantLLM
from api.utils.api_utils import get_json_result
from rag.llm import EmbeddingModel, ChatModel, RerankModel,CvModel
import requests
@manager.route('/factories', methods=['GET'])
@login_required
@ -189,9 +189,13 @@ def add_llm():
"ons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/256"
"0px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
)
m, tc = mdl.describe(img_url)
if not tc:
raise Exception(m)
res = requests.get(img_url)
if res.status_code == 200:
m, tc = mdl.describe(res.content)
if not tc:
raise Exception(m)
else:
raise ConnectionError("fail to download the test picture")
except Exception as e:
msg += f"\nFail to access model({llm['llm_name']})." + str(e)
else: