51 lines
2.0 KiB
Python
51 lines
2.0 KiB
Python
#
|
|
# Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
#
|
|
from flask import request
|
|
from api import settings
|
|
from api.db import StatusEnum
|
|
from api.db.services.dialog_service import DialogService
|
|
from api.db.services.knowledgebase_service import KnowledgebaseService
|
|
from api.db.services.llm_service import TenantLLMService
|
|
from api.db.services.user_service import TenantService
|
|
from api.utils import get_uuid
|
|
from api.utils.api_utils import get_error_data_result, token_required
|
|
from api.utils.api_utils import get_result
|
|
|
|
|
|
# 用户已经添加的模型 cyx 2025-01-26
|
|
@manager.route('/get_llms', methods=['GET'])
|
|
@token_required
|
|
def my_llms(tenant_id):
|
|
# request.args.get("id") 通过request.args.get 获取GET 方法传入的参数
|
|
model_type = request.args.get("type")
|
|
try:
|
|
res = {}
|
|
for o in TenantLLMService.get_my_llms(tenant_id):
|
|
if model_type is None or o["model_type"] == model_type: # 增加按类型的筛选
|
|
if o["llm_factory"] not in res:
|
|
res[o["llm_factory"]] = {
|
|
"tags": o["tags"],
|
|
"llm": []
|
|
}
|
|
|
|
res[o["llm_factory"]]["llm"].append({
|
|
"type": o["model_type"],
|
|
"name": o["llm_name"],
|
|
"used_token": o["used_tokens"]
|
|
})
|
|
return get_result(data=res)
|
|
except Exception as e:
|
|
return get_error_data_result(message=f"Get LLMS error {e}") |