add api tool
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
__all__ = [
|
||||
'AIApiKeyViewSet',
|
||||
'AIModelViewSet',
|
||||
'ToolViewSet',
|
||||
]
|
||||
|
||||
from ai.views.ai_api_key import AIApiKeyViewSet
|
||||
from ai.views.ai_model import AIModelViewSet
|
||||
from ai.views.ai_model import AIModelViewSet
|
||||
from ai.views.tool import ToolViewSet
|
||||
24
backend/ai/views/tool.py
Normal file
24
backend/ai/views/tool.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from ai.models import Tool
|
||||
from utils.serializers import CustomModelSerializer
|
||||
from utils.custom_model_viewSet import CustomModelViewSet
|
||||
|
||||
class ToolSerializer(CustomModelSerializer):
|
||||
"""
|
||||
AI 工具 序列化器
|
||||
"""
|
||||
class Meta:
|
||||
model = Tool
|
||||
fields = '__all__'
|
||||
read_only_fields = ['id', 'create_time', 'update_time']
|
||||
|
||||
|
||||
class ToolViewSet(CustomModelViewSet):
|
||||
"""
|
||||
AI 工具 视图集
|
||||
"""
|
||||
queryset = Tool.objects.filter(is_deleted=False).order_by('-id')
|
||||
serializer_class = ToolSerializer
|
||||
filterset_fields = ['id', 'remark', 'creator', 'modifier', 'is_deleted', 'name', 'description', 'status']
|
||||
search_fields = ['name'] # 根据实际字段调整
|
||||
ordering_fields = ['create_time', 'id']
|
||||
ordering = ['-create_time']
|
||||
Reference in New Issue
Block a user