fix: 供应商列表报错,模型添加根据供应商名称查询
This commit is contained in:
parent
47fd0226c0
commit
128dc0a201
@ -7,12 +7,10 @@
|
|||||||
@desc:
|
@desc:
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
from typing import Dict, List
|
from typing import Dict
|
||||||
|
|
||||||
from langchain.chat_models import AzureChatOpenAI
|
from langchain.chat_models import AzureChatOpenAI
|
||||||
from langchain.chat_models.base import BaseChatModel
|
from langchain.schema import HumanMessage
|
||||||
from langchain.schema import HumanMessage, BaseMessage
|
|
||||||
from langchain.schema.language_model import LanguageModelInput
|
|
||||||
|
|
||||||
from common import froms
|
from common import froms
|
||||||
from common.exception.app_exception import AppApiException
|
from common.exception.app_exception import AppApiException
|
||||||
|
|||||||
@ -29,6 +29,8 @@ class ModelSerializer(serializers.Serializer):
|
|||||||
|
|
||||||
model_name = serializers.CharField(required=False)
|
model_name = serializers.CharField(required=False)
|
||||||
|
|
||||||
|
provider = serializers.CharField(required=False)
|
||||||
|
|
||||||
def list(self, with_valid):
|
def list(self, with_valid):
|
||||||
if with_valid:
|
if with_valid:
|
||||||
self.is_valid(raise_exception=True)
|
self.is_valid(raise_exception=True)
|
||||||
@ -42,6 +44,9 @@ class ModelSerializer(serializers.Serializer):
|
|||||||
query_params['model_type'] = self.data.get('model_type')
|
query_params['model_type'] = self.data.get('model_type')
|
||||||
if self.data.get('model_name') is not None:
|
if self.data.get('model_name') is not None:
|
||||||
query_params['model_name'] = self.data.get('model_name')
|
query_params['model_name'] = self.data.get('model_name')
|
||||||
|
if self.data.get('provider') is not None:
|
||||||
|
query_params['provider'] = self.data.get('provider')
|
||||||
|
|
||||||
return [ModelSerializer.model_to_dict(model) for model in model_query_set.filter(**query_params)]
|
return [ModelSerializer.model_to_dict(model) for model in model_query_set.filter(**query_params)]
|
||||||
|
|
||||||
class Create(serializers.Serializer):
|
class Create(serializers.Serializer):
|
||||||
|
|||||||
@ -26,7 +26,12 @@ class ModelQueryApi(ApiMixin):
|
|||||||
openapi.Parameter(name='model_name', in_=openapi.IN_QUERY,
|
openapi.Parameter(name='model_name', in_=openapi.IN_QUERY,
|
||||||
type=openapi.TYPE_STRING,
|
type=openapi.TYPE_STRING,
|
||||||
required=False,
|
required=False,
|
||||||
description='基础模型名称')
|
description='基础模型名称'),
|
||||||
|
openapi.Parameter(name='provider',
|
||||||
|
in_=openapi.IN_QUERY,
|
||||||
|
type=openapi.TYPE_STRING,
|
||||||
|
required=False,
|
||||||
|
description='供应名称')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -48,6 +48,7 @@ class Model(APIView):
|
|||||||
|
|
||||||
|
|
||||||
class Provide(APIView):
|
class Provide(APIView):
|
||||||
|
authentication_classes = [TokenAuth]
|
||||||
class Exec(APIView):
|
class Exec(APIView):
|
||||||
authentication_classes = [TokenAuth]
|
authentication_classes = [TokenAuth]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user