mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
Merge branch 'main' of github.com:maxkb-dev/maxkb
This commit is contained in:
commit
4a86dad733
|
|
@ -77,7 +77,7 @@ class Migration(migrations.Migration):
|
|||
('improve_paragraph_id_list', django.contrib.postgres.fields.ArrayField(base_field=models.UUIDField(blank=True), default=list, size=None, verbose_name='改进标注列表')),
|
||||
('index', models.IntegerField(verbose_name='对话下标')),
|
||||
('chat', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='application.chat')),
|
||||
('dataset', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='dataset.dataset', verbose_name='数据集')),
|
||||
('dataset', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='dataset.dataset', verbose_name='知识库')),
|
||||
('paragraph', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='dataset.paragraph', verbose_name='段落id')),
|
||||
],
|
||||
options={
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class ModelDatasetAssociation(serializers.Serializer):
|
|||
QuerySet(DataSet).filter(id__in=dataset_id_list, user_id=user_id)]
|
||||
for dataset_id in dataset_id_list:
|
||||
if not exist_dataset_id_list.__contains__(dataset_id):
|
||||
raise AppApiException(500, f'数据集id不存在【{dataset_id}】')
|
||||
raise AppApiException(500, f'知识库id不存在【{dataset_id}】')
|
||||
|
||||
|
||||
class ApplicationSerializerModel(serializers.ModelSerializer):
|
||||
|
|
@ -301,12 +301,12 @@ class ApplicationSerializer(serializers.Serializer):
|
|||
|
||||
if 'dataset_id_list' in instance:
|
||||
dataset_id_list = instance.get('dataset_id_list')
|
||||
# 当前用户可修改关联的数据集列表
|
||||
# 当前用户可修改关联的知识库列表
|
||||
application_dataset_id_list = [str(dataset_dict.get('id')) for dataset_dict in
|
||||
self.list_dataset(with_valid=False)]
|
||||
for dataset_id in dataset_id_list:
|
||||
if not application_dataset_id_list.__contains__(dataset_id):
|
||||
raise AppApiException(500, f"未知的数据集id${dataset_id},无法关联")
|
||||
raise AppApiException(500, f"未知的知识库id${dataset_id},无法关联")
|
||||
|
||||
# 删除已经关联的id
|
||||
QuerySet(ApplicationDatasetMapping).filter(dataset_id__in=application_dataset_id_list,
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ class ApplicationApi(ApiMixin):
|
|||
'update_time': openapi.Schema(type=openapi.TYPE_STRING, title="修改时间", description='修改时间'),
|
||||
'dataset_id_list': openapi.Schema(type=openapi.TYPE_ARRAY,
|
||||
items=openapi.Schema(type=openapi.TYPE_STRING),
|
||||
title="关联数据集Id列表",
|
||||
description="关联数据集Id列表(查询详情的时候返回)")
|
||||
title="关联知识库Id列表",
|
||||
description="关联知识库Id列表(查询详情的时候返回)")
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ class ApplicationApi(ApiMixin):
|
|||
title="示例列表", description="示例列表"),
|
||||
'dataset_id_list': openapi.Schema(type=openapi.TYPE_ARRAY,
|
||||
items=openapi.Schema(type=openapi.TYPE_STRING),
|
||||
title="关联数据集Id列表", description="关联数据集Id列表"),
|
||||
title="关联知识库Id列表", description="关联知识库Id列表"),
|
||||
|
||||
}
|
||||
)
|
||||
|
|
@ -167,7 +167,7 @@ class ApplicationApi(ApiMixin):
|
|||
title="示例列表", description="示例列表"),
|
||||
'dataset_id_list': openapi.Schema(type=openapi.TYPE_ARRAY,
|
||||
items=openapi.Schema(type=openapi.TYPE_STRING),
|
||||
title="关联数据集Id列表", description="关联数据集Id列表")
|
||||
title="关联知识库Id列表", description="关联知识库Id列表")
|
||||
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class ChatApi(ApiMixin):
|
|||
'model_id': openapi.Schema(type=openapi.TYPE_STRING, title="模型id", description="模型id"),
|
||||
'dataset_id_list': openapi.Schema(type=openapi.TYPE_ARRAY,
|
||||
items=openapi.Schema(type=openapi.TYPE_STRING),
|
||||
title="关联数据集Id列表", description="关联数据集Id列表"),
|
||||
title="关联知识库Id列表", description="关联知识库Id列表"),
|
||||
'multiple_rounds_dialogue': openapi.Schema(type=openapi.TYPE_BOOLEAN, title="是否开启多轮会话",
|
||||
description="是否开启多轮会话")
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ class ImproveApi(ApiMixin):
|
|||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
required=True,
|
||||
description='数据集id'),
|
||||
description='知识库id'),
|
||||
openapi.Parameter(name='document_id',
|
||||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
|
|
@ -201,8 +201,8 @@ class ChatRecordImproveApi(ApiMixin):
|
|||
description="点赞数量", default=1),
|
||||
'trample_num': openapi.Schema(type=openapi.TYPE_INTEGER, title="点踩数量",
|
||||
description="点踩数", default=1),
|
||||
'dataset_id': openapi.Schema(type=openapi.TYPE_STRING, title="数据集id",
|
||||
description="数据集id", default='xxx'),
|
||||
'dataset_id': openapi.Schema(type=openapi.TYPE_STRING, title="知识库id",
|
||||
description="知识库id", default='xxx'),
|
||||
'document_id': openapi.Schema(type=openapi.TYPE_STRING, title="文档id",
|
||||
description="文档id", default='xxx'),
|
||||
'is_active': openapi.Schema(type=openapi.TYPE_BOOLEAN, title="是否可用",
|
||||
|
|
|
|||
|
|
@ -238,8 +238,8 @@ class Application(APIView):
|
|||
authentication_classes = [TokenAuth]
|
||||
|
||||
@action(methods=['GET'], detail=False)
|
||||
@swagger_auto_schema(operation_summary="获取当前应用可使用的数据集",
|
||||
operation_id="获取当前应用可使用的数据集",
|
||||
@swagger_auto_schema(operation_summary="获取当前应用可使用的知识库",
|
||||
operation_id="获取当前应用可使用的知识库",
|
||||
manual_parameters=ApplicationApi.Operate.get_request_params_api(),
|
||||
responses=result.get_api_array_response(DataSetSerializers.Query.get_response_body_api()),
|
||||
tags=['应用'])
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class ChatView(APIView):
|
|||
authentication_classes = [TokenAuth]
|
||||
|
||||
@action(methods=['POST'], detail=False)
|
||||
@swagger_auto_schema(operation_summary="获取会话id(根据模型id,数据集列表,是否多轮会话)",
|
||||
@swagger_auto_schema(operation_summary="获取会话id(根据模型id,知识库列表,是否多轮会话)",
|
||||
operation_id="获取会话id",
|
||||
request_body=ChatApi.OpenTempChat.get_request_body_api(),
|
||||
tags=["应用/会话"])
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class TokenAuth(TokenAuthentication):
|
|||
token_cache.touch(auth, timeout=JWT_AUTH['JWT_EXPIRATION_DELTA'].total_seconds())
|
||||
rule = RoleConstants[user.role]
|
||||
permission_list = get_permission_list_by_role(RoleConstants[user.role])
|
||||
# 获取用户的应用和数据集的权限
|
||||
# 获取用户的应用和知识库的权限
|
||||
permission_list += get_user_dynamics_permission(str(user.id))
|
||||
return user, Auth(role_list=[rule],
|
||||
permission_list=permission_list)
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ class ListenerManagement:
|
|||
@poxy
|
||||
def embedding_by_dataset(dataset_id):
|
||||
"""
|
||||
向量化数据集
|
||||
:param dataset_id: 数据集id
|
||||
向量化知识库
|
||||
:param dataset_id: 知识库id
|
||||
:return: None
|
||||
"""
|
||||
status = Status.success
|
||||
|
|
@ -104,7 +104,7 @@ class ListenerManagement:
|
|||
'paragraph': QuerySet(Paragraph).filter(dataset_id=dataset_id)},
|
||||
select_string=get_file_content(
|
||||
os.path.join(PROJECT_DIR, "apps", "common", 'sql', 'list_embedding_text.sql')))
|
||||
# 删除数据集相关向量数据
|
||||
# 删除知识库相关向量数据
|
||||
VectorStore.get_embedding_vector().delete_by_dataset_id(dataset_id)
|
||||
# 批量向量化
|
||||
VectorStore.get_embedding_vector().batch_save(data_list)
|
||||
|
|
@ -148,7 +148,7 @@ class ListenerManagement:
|
|||
ListenerManagement.embedding_by_problem_signal.connect(self.embedding_by_problem)
|
||||
# 添加向量 根据段落id
|
||||
ListenerManagement.embedding_by_paragraph_signal.connect(self.embedding_by_paragraph)
|
||||
# 添加向量 根据数据集id
|
||||
# 添加向量 根据知识库id
|
||||
ListenerManagement.embedding_by_dataset_signal.connect(
|
||||
self.embedding_by_dataset)
|
||||
# 添加向量 根据文档id
|
||||
|
|
@ -156,7 +156,7 @@ class ListenerManagement:
|
|||
self.embedding_by_document)
|
||||
# 删除 向量 根据文档
|
||||
ListenerManagement.delete_embedding_by_document_signal.connect(self.delete_embedding_by_document)
|
||||
# 删除 向量 根据数据集id
|
||||
# 删除 向量 根据知识库id
|
||||
ListenerManagement.delete_embedding_by_dataset_signal.connect(self.delete_embedding_by_dataset)
|
||||
# 删除向量 根据段落id
|
||||
ListenerManagement.delete_embedding_by_paragraph_signal.connect(
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class Migration(migrations.Migration):
|
|||
('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
|
||||
('id', models.UUIDField(default=uuid.uuid1, editable=False, primary_key=True, serialize=False, verbose_name='主键id')),
|
||||
('name', models.CharField(max_length=150, verbose_name='数据集名称')),
|
||||
('name', models.CharField(max_length=150, verbose_name='知识库名称')),
|
||||
('desc', models.CharField(max_length=256, verbose_name='数据库描述')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='users.user', verbose_name='所属用户')),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class DataSetSerializers(serializers.ModelSerializer):
|
|||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
required=True,
|
||||
description='数据集id')
|
||||
description='知识库id')
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -106,17 +106,17 @@ class DataSetSerializers(serializers.ModelSerializer):
|
|||
name = serializers.CharField(required=False,
|
||||
validators=[
|
||||
validators.MaxLengthValidator(limit_value=20,
|
||||
message="数据集名称在1-20个字符之间"),
|
||||
message="知识库名称在1-20个字符之间"),
|
||||
validators.MinLengthValidator(limit_value=1,
|
||||
message="数据集名称在1-20个字符之间")
|
||||
message="知识库名称在1-20个字符之间")
|
||||
])
|
||||
|
||||
desc = serializers.CharField(required=False,
|
||||
validators=[
|
||||
validators.MaxLengthValidator(limit_value=256,
|
||||
message="数据集名称在1-256个字符之间"),
|
||||
message="知识库名称在1-256个字符之间"),
|
||||
validators.MinLengthValidator(limit_value=1,
|
||||
message="数据集名称在1-256个字符之间")
|
||||
message="知识库名称在1-256个字符之间")
|
||||
])
|
||||
|
||||
user_id = serializers.CharField(required=True)
|
||||
|
|
@ -169,12 +169,12 @@ class DataSetSerializers(serializers.ModelSerializer):
|
|||
in_=openapi.IN_QUERY,
|
||||
type=openapi.TYPE_STRING,
|
||||
required=False,
|
||||
description='数据集名称'),
|
||||
description='知识库名称'),
|
||||
openapi.Parameter(name='desc',
|
||||
in_=openapi.IN_QUERY,
|
||||
type=openapi.TYPE_STRING,
|
||||
required=False,
|
||||
description='数据集描述')
|
||||
description='知识库描述')
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -188,17 +188,17 @@ class DataSetSerializers(serializers.ModelSerializer):
|
|||
name = serializers.CharField(required=True,
|
||||
validators=[
|
||||
validators.MaxLengthValidator(limit_value=20,
|
||||
message="数据集名称在1-20个字符之间"),
|
||||
message="知识库名称在1-20个字符之间"),
|
||||
validators.MinLengthValidator(limit_value=1,
|
||||
message="数据集名称在1-20个字符之间")
|
||||
message="知识库名称在1-20个字符之间")
|
||||
])
|
||||
|
||||
desc = serializers.CharField(required=True,
|
||||
validators=[
|
||||
validators.MaxLengthValidator(limit_value=256,
|
||||
message="数据集名称在1-256个字符之间"),
|
||||
message="知识库名称在1-256个字符之间"),
|
||||
validators.MinLengthValidator(limit_value=1,
|
||||
message="数据集名称在1-256个字符之间")
|
||||
message="知识库名称在1-256个字符之间")
|
||||
])
|
||||
|
||||
documents = DocumentInstanceSerializer(required=False, many=True)
|
||||
|
|
@ -226,7 +226,7 @@ class DataSetSerializers(serializers.ModelSerializer):
|
|||
for problem in document_paragraph_dict_model.get('problem_model_list'):
|
||||
problem_model_list.append(problem)
|
||||
|
||||
# 插入数据集
|
||||
# 插入知识库
|
||||
dataset.save()
|
||||
# 插入文档
|
||||
QuerySet(Document).bulk_create(document_model_list) if len(document_model_list) > 0 else None
|
||||
|
|
@ -250,9 +250,9 @@ class DataSetSerializers(serializers.ModelSerializer):
|
|||
'id': openapi.Schema(type=openapi.TYPE_STRING, title="id",
|
||||
description="id", default="xx"),
|
||||
'name': openapi.Schema(type=openapi.TYPE_STRING, title="名称",
|
||||
description="名称", default="测试数据集"),
|
||||
description="名称", default="测试知识库"),
|
||||
'desc': openapi.Schema(type=openapi.TYPE_STRING, title="描述",
|
||||
description="描述", default="测试数据集描述"),
|
||||
description="描述", default="测试知识库描述"),
|
||||
'user_id': openapi.Schema(type=openapi.TYPE_STRING, title="所属用户id",
|
||||
description="所属用户id", default="user_xxxx"),
|
||||
'char_length': openapi.Schema(type=openapi.TYPE_STRING, title="字符数",
|
||||
|
|
@ -278,8 +278,8 @@ class DataSetSerializers(serializers.ModelSerializer):
|
|||
type=openapi.TYPE_OBJECT,
|
||||
required=['name', 'desc'],
|
||||
properties={
|
||||
'name': openapi.Schema(type=openapi.TYPE_STRING, title="数据集名称", description="数据集名称"),
|
||||
'desc': openapi.Schema(type=openapi.TYPE_STRING, title="数据集描述", description="数据集描述"),
|
||||
'name': openapi.Schema(type=openapi.TYPE_STRING, title="知识库名称", description="知识库名称"),
|
||||
'desc': openapi.Schema(type=openapi.TYPE_STRING, title="知识库描述", description="知识库描述"),
|
||||
'documents': openapi.Schema(type=openapi.TYPE_ARRAY, title="文档数据", description="文档数据",
|
||||
items=DocumentSerializers().Create.get_request_body_api()
|
||||
)
|
||||
|
|
@ -350,7 +350,7 @@ class DataSetSerializers(serializers.ModelSerializer):
|
|||
|
||||
def edit(self, dataset: Dict, user_id: str):
|
||||
"""
|
||||
修改数据集
|
||||
修改知识库
|
||||
:param user_id: 用户id
|
||||
:param dataset: Dict name desc
|
||||
:return:
|
||||
|
|
@ -364,7 +364,7 @@ class DataSetSerializers(serializers.ModelSerializer):
|
|||
_dataset.desc = dataset.get("desc")
|
||||
if 'application_id_list' in dataset and dataset.get('application_id_list') is not None:
|
||||
application_id_list = dataset.get('application_id_list')
|
||||
# 当前用户可修改关联的数据集列表
|
||||
# 当前用户可修改关联的知识库列表
|
||||
application_dataset_id_list = [str(dataset_dict.get('id')) for dataset_dict in
|
||||
self.list_application(with_valid=False)]
|
||||
for dataset_id in application_id_list:
|
||||
|
|
@ -391,8 +391,8 @@ class DataSetSerializers(serializers.ModelSerializer):
|
|||
type=openapi.TYPE_OBJECT,
|
||||
required=['name', 'desc'],
|
||||
properties={
|
||||
'name': openapi.Schema(type=openapi.TYPE_STRING, title="数据集名称", description="数据集名称"),
|
||||
'desc': openapi.Schema(type=openapi.TYPE_STRING, title="数据集描述", description="数据集描述"),
|
||||
'name': openapi.Schema(type=openapi.TYPE_STRING, title="知识库名称", description="知识库名称"),
|
||||
'desc': openapi.Schema(type=openapi.TYPE_STRING, title="知识库描述", description="知识库描述"),
|
||||
'application_id_list': openapi.Schema(type=openapi.TYPE_ARRAY, title="应用id列表",
|
||||
description="应用id列表",
|
||||
items=openapi.Schema(type=openapi.TYPE_STRING))
|
||||
|
|
@ -409,9 +409,9 @@ class DataSetSerializers(serializers.ModelSerializer):
|
|||
'id': openapi.Schema(type=openapi.TYPE_STRING, title="id",
|
||||
description="id", default="xx"),
|
||||
'name': openapi.Schema(type=openapi.TYPE_STRING, title="名称",
|
||||
description="名称", default="测试数据集"),
|
||||
description="名称", default="测试知识库"),
|
||||
'desc': openapi.Schema(type=openapi.TYPE_STRING, title="描述",
|
||||
description="描述", default="测试数据集描述"),
|
||||
description="描述", default="测试知识库描述"),
|
||||
'user_id': openapi.Schema(type=openapi.TYPE_STRING, title="所属用户id",
|
||||
description="所属用户id", default="user_xxxx"),
|
||||
'char_length': openapi.Schema(type=openapi.TYPE_STRING, title="字符数",
|
||||
|
|
@ -434,5 +434,5 @@ class DataSetSerializers(serializers.ModelSerializer):
|
|||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
required=True,
|
||||
description='数据集id')
|
||||
description='知识库id')
|
||||
]
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class DocumentInstanceSerializer(ApiMixin, serializers.Serializer):
|
|||
validators.MaxLengthValidator(limit_value=128,
|
||||
message="文档名称在1-128个字符之间"),
|
||||
validators.MinLengthValidator(limit_value=1,
|
||||
message="数据集名称在1-128个字符之间")
|
||||
message="知识库名称在1-128个字符之间")
|
||||
])
|
||||
|
||||
paragraphs = ParagraphInstanceSerializer(required=False, many=True, allow_null=True)
|
||||
|
|
@ -54,7 +54,7 @@ class DocumentInstanceSerializer(ApiMixin, serializers.Serializer):
|
|||
|
||||
class DocumentSerializers(ApiMixin, serializers.Serializer):
|
||||
class Query(ApiMixin, serializers.Serializer):
|
||||
# 数据集id
|
||||
# 知识库id
|
||||
dataset_id = serializers.UUIDField(required=True)
|
||||
|
||||
name = serializers.CharField(required=False,
|
||||
|
|
@ -62,7 +62,7 @@ class DocumentSerializers(ApiMixin, serializers.Serializer):
|
|||
validators.MaxLengthValidator(limit_value=128,
|
||||
message="文档名称在1-128个字符之间"),
|
||||
validators.MinLengthValidator(limit_value=1,
|
||||
message="数据集名称在1-128个字符之间")
|
||||
message="知识库名称在1-128个字符之间")
|
||||
])
|
||||
|
||||
def get_query_set(self):
|
||||
|
|
@ -108,7 +108,7 @@ class DocumentSerializers(ApiMixin, serializers.Serializer):
|
|||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
required=True,
|
||||
description='数据集id'),
|
||||
description='知识库id'),
|
||||
openapi.Parameter(name='document_id',
|
||||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
|
|
@ -170,7 +170,7 @@ class DocumentSerializers(ApiMixin, serializers.Serializer):
|
|||
'id': openapi.Schema(type=openapi.TYPE_STRING, title="id",
|
||||
description="id", default="xx"),
|
||||
'name': openapi.Schema(type=openapi.TYPE_STRING, title="名称",
|
||||
description="名称", default="测试数据集"),
|
||||
description="名称", default="测试知识库"),
|
||||
'char_length': openapi.Schema(type=openapi.TYPE_INTEGER, title="字符数",
|
||||
description="字符数", default=10),
|
||||
'user_id': openapi.Schema(type=openapi.TYPE_STRING, title="用户id", description="用户id"),
|
||||
|
|
@ -204,7 +204,7 @@ class DocumentSerializers(ApiMixin, serializers.Serializer):
|
|||
def is_valid(self, *, raise_exception=False):
|
||||
super().is_valid(raise_exception=True)
|
||||
if not QuerySet(DataSet).filter(id=self.data.get('dataset_id')).exists():
|
||||
raise AppApiException(10000, "数据集id不存在")
|
||||
raise AppApiException(10000, "知识库id不存在")
|
||||
return True
|
||||
|
||||
def save(self, instance: Dict, with_valid=False, with_embedding=True, **kwargs):
|
||||
|
|
@ -264,7 +264,7 @@ class DocumentSerializers(ApiMixin, serializers.Serializer):
|
|||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
required=True,
|
||||
description='数据集id')
|
||||
description='知识库id')
|
||||
]
|
||||
|
||||
class Split(ApiMixin, serializers.Serializer):
|
||||
|
|
|
|||
|
|
@ -72,9 +72,9 @@ class ParagraphSerializers(ApiMixin, serializers.Serializer):
|
|||
class Operate(ApiMixin, serializers.Serializer):
|
||||
# 段落id
|
||||
paragraph_id = serializers.UUIDField(required=True)
|
||||
# 数据集id
|
||||
# 知识库id
|
||||
dataset_id = serializers.UUIDField(required=True)
|
||||
# 数据集id
|
||||
# 知识库id
|
||||
document_id = serializers.UUIDField(required=True)
|
||||
|
||||
def is_valid(self, *, raise_exception=True):
|
||||
|
|
@ -218,7 +218,7 @@ class ParagraphSerializers(ApiMixin, serializers.Serializer):
|
|||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
required=True,
|
||||
description='数据集id'),
|
||||
description='知识库id'),
|
||||
openapi.Parameter(name='document_id', in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
required=True,
|
||||
|
|
@ -291,8 +291,8 @@ class ParagraphSerializers(ApiMixin, serializers.Serializer):
|
|||
description="点赞数量", default=1),
|
||||
'trample_num': openapi.Schema(type=openapi.TYPE_INTEGER, title="点踩数量",
|
||||
description="点踩数", default=1),
|
||||
'dataset_id': openapi.Schema(type=openapi.TYPE_STRING, title="数据集id",
|
||||
description="数据集id", default='xxx'),
|
||||
'dataset_id': openapi.Schema(type=openapi.TYPE_STRING, title="知识库id",
|
||||
description="知识库id", default='xxx'),
|
||||
'document_id': openapi.Schema(type=openapi.TYPE_STRING, title="文档id",
|
||||
description="文档id", default='xxx'),
|
||||
'is_active': openapi.Schema(type=openapi.TYPE_BOOLEAN, title="是否可用",
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class ProblemSerializers(ApiMixin, serializers.Serializer):
|
|||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
required=True,
|
||||
description='数据集id'),
|
||||
description='知识库id'),
|
||||
openapi.Parameter(name='document_id',
|
||||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
|
|
@ -142,7 +142,7 @@ class ProblemSerializers(ApiMixin, serializers.Serializer):
|
|||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
required=True,
|
||||
description='数据集id'),
|
||||
description='知识库id'),
|
||||
openapi.Parameter(name='document_id',
|
||||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
|
|
@ -182,7 +182,7 @@ class ProblemSerializers(ApiMixin, serializers.Serializer):
|
|||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
required=True,
|
||||
description='数据集id'),
|
||||
description='知识库id'),
|
||||
openapi.Parameter(name='document_id',
|
||||
in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_STRING,
|
||||
|
|
|
|||
|
|
@ -26,22 +26,22 @@ class Dataset(APIView):
|
|||
authentication_classes = [TokenAuth]
|
||||
|
||||
@action(methods=['GET'], detail=False)
|
||||
@swagger_auto_schema(operation_summary="获取数据集可用应用列表",
|
||||
operation_id="获取数据集可用应用列表",
|
||||
@swagger_auto_schema(operation_summary="获取知识库可用应用列表",
|
||||
operation_id="获取知识库可用应用列表",
|
||||
manual_parameters=DataSetSerializers.Application.get_request_params_api(),
|
||||
responses=result.get_api_array_response(
|
||||
DataSetSerializers.Application.get_response_body_api()),
|
||||
tags=["数据集"])
|
||||
tags=["知识库"])
|
||||
def get(self, request: Request, dataset_id: str):
|
||||
return result.success(DataSetSerializers.Operate(
|
||||
data={'id': dataset_id, 'user_id': str(request.user.id)}).list_application())
|
||||
|
||||
@action(methods=['GET'], detail=False)
|
||||
@swagger_auto_schema(operation_summary="获取数据集列表",
|
||||
operation_id="获取数据集列表",
|
||||
@swagger_auto_schema(operation_summary="获取知识库列表",
|
||||
operation_id="获取知识库列表",
|
||||
manual_parameters=DataSetSerializers.Query.get_request_params_api(),
|
||||
responses=result.get_api_array_response(DataSetSerializers.Query.get_response_body_api()),
|
||||
tags=["数据集"])
|
||||
tags=["知识库"])
|
||||
@has_permissions(PermissionConstants.DATASET_READ, compare=CompareConstants.AND)
|
||||
def get(self, request: Request):
|
||||
d = DataSetSerializers.Query(data={**request.query_params, 'user_id': str(request.user.id)})
|
||||
|
|
@ -49,11 +49,11 @@ class Dataset(APIView):
|
|||
return result.success(d.list())
|
||||
|
||||
@action(methods=['POST'], detail=False)
|
||||
@swagger_auto_schema(operation_summary="创建数据集",
|
||||
operation_id="创建数据集",
|
||||
@swagger_auto_schema(operation_summary="创建知识库",
|
||||
operation_id="创建知识库",
|
||||
request_body=DataSetSerializers.Create.get_request_body_api(),
|
||||
responses=get_api_response(DataSetSerializers.Create.get_response_body_api()),
|
||||
tags=["数据集"]
|
||||
tags=["知识库"]
|
||||
)
|
||||
@has_permissions(PermissionConstants.DATASET_CREATE, compare=CompareConstants.AND)
|
||||
def post(self, request: Request):
|
||||
|
|
@ -65,10 +65,10 @@ class Dataset(APIView):
|
|||
authentication_classes = [TokenAuth]
|
||||
|
||||
@action(methods="DELETE", detail=False)
|
||||
@swagger_auto_schema(operation_summary="删除数据集", operation_id="删除数据集",
|
||||
@swagger_auto_schema(operation_summary="删除知识库", operation_id="删除知识库",
|
||||
manual_parameters=DataSetSerializers.Operate.get_request_params_api(),
|
||||
responses=result.get_default_response(),
|
||||
tags=["数据集"])
|
||||
tags=["知识库"])
|
||||
@has_permissions(lambda r, keywords: Permission(group=Group.DATASET, operate=Operate.MANAGE,
|
||||
dynamic_tag=keywords.get('dataset_id')),
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.DELETE,
|
||||
|
|
@ -78,10 +78,10 @@ class Dataset(APIView):
|
|||
return result.success(operate.delete())
|
||||
|
||||
@action(methods="GET", detail=False)
|
||||
@swagger_auto_schema(operation_summary="查询数据集详情根据数据集id", operation_id="查询数据集详情根据数据集id",
|
||||
@swagger_auto_schema(operation_summary="查询知识库详情根据知识库id", operation_id="查询知识库详情根据知识库id",
|
||||
manual_parameters=DataSetSerializers.Operate.get_request_params_api(),
|
||||
responses=get_api_response(DataSetSerializers.Operate.get_response_body_api()),
|
||||
tags=["数据集"])
|
||||
tags=["知识库"])
|
||||
@has_permissions(lambda r, keywords: Permission(group=Group.DATASET, operate=Operate.USE,
|
||||
dynamic_tag=keywords.get('dataset_id')))
|
||||
def get(self, request: Request, dataset_id: str):
|
||||
|
|
@ -89,11 +89,11 @@ class Dataset(APIView):
|
|||
user_id=request.user.id))
|
||||
|
||||
@action(methods="PUT", detail=False)
|
||||
@swagger_auto_schema(operation_summary="修改数据集信息", operation_id="修改数据集信息",
|
||||
@swagger_auto_schema(operation_summary="修改知识库信息", operation_id="修改知识库信息",
|
||||
manual_parameters=DataSetSerializers.Operate.get_request_params_api(),
|
||||
request_body=DataSetSerializers.Operate.get_request_body_api(),
|
||||
responses=get_api_response(DataSetSerializers.Operate.get_response_body_api()),
|
||||
tags=["数据集"]
|
||||
tags=["知识库"]
|
||||
)
|
||||
@has_permissions(lambda r, keywords: Permission(group=Group.DATASET, operate=Operate.MANAGE,
|
||||
dynamic_tag=keywords.get('dataset_id')))
|
||||
|
|
@ -106,12 +106,12 @@ class Dataset(APIView):
|
|||
authentication_classes = [TokenAuth]
|
||||
|
||||
@action(methods=['GET'], detail=False)
|
||||
@swagger_auto_schema(operation_summary="获取数据集分页列表",
|
||||
operation_id="获取数据集分页列表",
|
||||
@swagger_auto_schema(operation_summary="获取知识库分页列表",
|
||||
operation_id="获取知识库分页列表",
|
||||
manual_parameters=get_page_request_params(
|
||||
DataSetSerializers.Query.get_request_params_api()),
|
||||
responses=get_page_api_response(DataSetSerializers.Query.get_response_body_api()),
|
||||
tags=["数据集"]
|
||||
tags=["知识库"]
|
||||
)
|
||||
@has_permissions(PermissionConstants.DATASET_READ, compare=CompareConstants.AND)
|
||||
def get(self, request: Request, current_page, page_size):
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class Document(APIView):
|
|||
request_body=DocumentSerializers.Create.get_request_body_api(),
|
||||
manual_parameters=DocumentSerializers.Create.get_request_params_api(),
|
||||
responses=result.get_api_response(DocumentSerializers.Operate.get_response_body_api()),
|
||||
tags=["数据集/文档"])
|
||||
tags=["知识库/文档"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.MANAGE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
@ -42,7 +42,7 @@ class Document(APIView):
|
|||
operation_id="文档列表",
|
||||
manual_parameters=DocumentSerializers.Query.get_request_params_api(),
|
||||
responses=result.get_api_response(DocumentSerializers.Query.get_response_body_api()),
|
||||
tags=["数据集/文档"])
|
||||
tags=["知识库/文档"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.USE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
@ -63,7 +63,7 @@ class Document(APIView):
|
|||
manual_parameters=DocumentSerializers.Create.get_request_params_api(),
|
||||
responses=result.get_api_array_response(
|
||||
DocumentSerializers.Operate.get_response_body_api()),
|
||||
tags=["数据集/文档"])
|
||||
tags=["知识库/文档"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.MANAGE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
@ -78,7 +78,7 @@ class Document(APIView):
|
|||
operation_id="刷新文档向量库",
|
||||
manual_parameters=DocumentSerializers.Operate.get_request_params_api(),
|
||||
responses=result.get_default_response(),
|
||||
tags=["数据集/文档"]
|
||||
tags=["知识库/文档"]
|
||||
)
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.MANAGE,
|
||||
|
|
@ -96,7 +96,7 @@ class Document(APIView):
|
|||
operation_id="获取文档详情",
|
||||
manual_parameters=DocumentSerializers.Operate.get_request_params_api(),
|
||||
responses=result.get_api_response(DocumentSerializers.Operate.get_response_body_api()),
|
||||
tags=["数据集/文档"])
|
||||
tags=["知识库/文档"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.USE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
@ -111,7 +111,7 @@ class Document(APIView):
|
|||
manual_parameters=DocumentSerializers.Operate.get_request_params_api(),
|
||||
request_body=DocumentSerializers.Operate.get_request_body_api(),
|
||||
responses=result.get_api_response(DocumentSerializers.Operate.get_response_body_api()),
|
||||
tags=["数据集/文档"]
|
||||
tags=["知识库/文档"]
|
||||
)
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.MANAGE,
|
||||
|
|
@ -127,7 +127,7 @@ class Document(APIView):
|
|||
operation_id="删除文档",
|
||||
manual_parameters=DocumentSerializers.Operate.get_request_params_api(),
|
||||
responses=result.get_default_response(),
|
||||
tags=["数据集/文档"])
|
||||
tags=["知识库/文档"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.MANAGE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
@ -140,7 +140,7 @@ class Document(APIView):
|
|||
@action(methods=['GET'], detail=False)
|
||||
@swagger_auto_schema(operation_summary="获取分段标识列表",
|
||||
operation_id="获取分段标识列表",
|
||||
tags=["数据集/文档"],
|
||||
tags=["知识库/文档"],
|
||||
security=[])
|
||||
def get(self, request: Request):
|
||||
return result.success(DocumentSerializers.SplitPattern.list())
|
||||
|
|
@ -152,7 +152,7 @@ class Document(APIView):
|
|||
@swagger_auto_schema(operation_summary="分段文档",
|
||||
operation_id="分段文档",
|
||||
manual_parameters=DocumentSerializers.Split.get_request_params_api(),
|
||||
tags=["数据集/文档"],
|
||||
tags=["知识库/文档"],
|
||||
security=[])
|
||||
def post(self, request: Request):
|
||||
split_data = {'file': request.FILES.getlist('file')}
|
||||
|
|
@ -173,11 +173,11 @@ class Document(APIView):
|
|||
authentication_classes = [TokenAuth]
|
||||
|
||||
@action(methods=['GET'], detail=False)
|
||||
@swagger_auto_schema(operation_summary="获取数据集分页列表",
|
||||
operation_id="获取数据集分页列表",
|
||||
@swagger_auto_schema(operation_summary="获取知识库分页列表",
|
||||
operation_id="获取知识库分页列表",
|
||||
manual_parameters=DocumentSerializers.Query.get_request_params_api(),
|
||||
responses=result.get_page_api_response(DocumentSerializers.Query.get_response_body_api()),
|
||||
tags=["数据集/文档"])
|
||||
tags=["知识库/文档"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.USE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class Paragraph(APIView):
|
|||
operation_id="段落列表",
|
||||
manual_parameters=ParagraphSerializers.Query.get_request_params_api(),
|
||||
responses=result.get_api_array_response(ParagraphSerializers.Query.get_response_body_api()),
|
||||
tags=["数据集/文档/段落"]
|
||||
tags=["知识库/文档/段落"]
|
||||
)
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.USE,
|
||||
|
|
@ -44,7 +44,7 @@ class Paragraph(APIView):
|
|||
manual_parameters=ParagraphSerializers.Create.get_request_params_api(),
|
||||
request_body=ParagraphSerializers.Create.get_request_body_api(),
|
||||
responses=result.get_api_response(ParagraphSerializers.Query.get_response_body_api()),
|
||||
tags=["数据集/文档/段落"])
|
||||
tags=["知识库/文档/段落"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.MANAGE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
@ -61,7 +61,7 @@ class Paragraph(APIView):
|
|||
manual_parameters=ParagraphSerializers.Operate.get_request_params_api(),
|
||||
request_body=ParagraphSerializers.Operate.get_request_body_api(),
|
||||
responses=result.get_api_response(ParagraphSerializers.Operate.get_response_body_api())
|
||||
,tags=["数据集/文档/段落"])
|
||||
,tags=["知识库/文档/段落"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.MANAGE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
@ -76,7 +76,7 @@ class Paragraph(APIView):
|
|||
operation_id="获取段落详情",
|
||||
manual_parameters=ParagraphSerializers.Operate.get_request_params_api(),
|
||||
responses=result.get_api_response(ParagraphSerializers.Operate.get_response_body_api()),
|
||||
tags=["数据集/文档/段落"])
|
||||
tags=["知识库/文档/段落"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.USE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
@ -91,7 +91,7 @@ class Paragraph(APIView):
|
|||
operation_id="删除段落",
|
||||
manual_parameters=ParagraphSerializers.Operate.get_request_params_api(),
|
||||
responses=result.get_default_response(),
|
||||
tags=["数据集/文档/段落"])
|
||||
tags=["知识库/文档/段落"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.MANAGE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
@ -110,7 +110,7 @@ class Paragraph(APIView):
|
|||
manual_parameters=result.get_page_request_params(
|
||||
ParagraphSerializers.Query.get_request_params_api()),
|
||||
responses=result.get_page_api_response(ParagraphSerializers.Query.get_response_body_api()),
|
||||
tags=["数据集/文档/段落"])
|
||||
tags=["知识库/文档/段落"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.USE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class Problem(APIView):
|
|||
manual_parameters=ProblemSerializers.Create.get_request_params_api(),
|
||||
request_body=ProblemSerializers.Create.get_request_body_api(),
|
||||
responses=result.get_api_response(ProblemSerializers.Operate.get_response_body_api()),
|
||||
tags=["数据集/文档/段落/问题"])
|
||||
tags=["知识库/文档/段落/问题"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.MANAGE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
@ -40,7 +40,7 @@ class Problem(APIView):
|
|||
operation_id="获取段落问题列表",
|
||||
manual_parameters=ProblemSerializers.Query.get_request_params_api(),
|
||||
responses=result.get_api_array_response(ProblemSerializers.Operate.get_response_body_api()),
|
||||
tags=["数据集/文档/段落/问题"])
|
||||
tags=["知识库/文档/段落/问题"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.USE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
@ -57,7 +57,7 @@ class Problem(APIView):
|
|||
operation_id="删除段落问题",
|
||||
manual_parameters=ProblemSerializers.Query.get_request_params_api(),
|
||||
responses=result.get_default_response(),
|
||||
tags=["数据集/文档/段落/问题"])
|
||||
tags=["知识库/文档/段落/问题"])
|
||||
@has_permissions(
|
||||
lambda r, k: Permission(group=Group.DATASET, operate=Operate.MANAGE,
|
||||
dynamic_tag=k.get('dataset_id')))
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class BaseVectorStore(ABC):
|
|||
"""
|
||||
插入向量数据
|
||||
:param source_id: 资源id
|
||||
:param dataset_id: 数据集id
|
||||
:param dataset_id: 知识库id
|
||||
:param text: 文本
|
||||
:param source_type: 资源类型
|
||||
:param document_id: 文档id
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ class Migration(migrations.Migration):
|
|||
('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
|
||||
('id', models.UUIDField(default=uuid.uuid1, editable=False, primary_key=True, serialize=False, verbose_name='主键id')),
|
||||
('auth_target_type', models.CharField(choices=[('DATASET', '数据集'), ('APPLICATION', '应用')], default='DATASET', max_length=128, verbose_name='授权目标')),
|
||||
('target', models.UUIDField(verbose_name='数据集/应用id')),
|
||||
('auth_target_type', models.CharField(choices=[('DATASET', '知识库'), ('APPLICATION', '应用')], default='DATASET', max_length=128, verbose_name='授权目标')),
|
||||
('target', models.UUIDField(verbose_name='知识库/应用id')),
|
||||
('operate', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, choices=[('MANAGE', '管理'), ('USE', '使用')], default='USE', max_length=256), size=None, verbose_name='权限操作列表')),
|
||||
('member', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='setting.teammember', verbose_name='团队成员')),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -92,11 +92,11 @@ model_dict = {
|
|||
ModelTypeConst.LLM, win_xin_llm_model_credential),
|
||||
|
||||
'Qianfan-Chinese-Llama-2-7B': ModelInfo('Qianfan-Chinese-Llama-2-7B',
|
||||
'千帆团队在Llama-2-7b基础上的中文增强版本,在CMMLU、C-EVAL等中文数据集上表现优异。',
|
||||
'千帆团队在Llama-2-7b基础上的中文增强版本,在CMMLU、C-EVAL等中文知识库上表现优异。',
|
||||
ModelTypeConst.LLM, win_xin_llm_model_credential),
|
||||
|
||||
'Qianfan-Chinese-Llama-2-13B': ModelInfo('Qianfan-Chinese-Llama-2-13B',
|
||||
'千帆团队在Llama-2-13b基础上的中文增强版本,在CMMLU、C-EVAL等中文数据集上表现优异。',
|
||||
'千帆团队在Llama-2-13b基础上的中文增强版本,在CMMLU、C-EVAL等中文知识库上表现优异。',
|
||||
ModelTypeConst.LLM, win_xin_llm_model_credential)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,8 +77,8 @@ class UpdateTeamMemberItemPermissionSerializer(ApiMixin, serializers.Serializer)
|
|||
type=openapi.TYPE_OBJECT,
|
||||
required=['id', 'type', 'operate'],
|
||||
properties={
|
||||
'target_id': openapi.Schema(type=openapi.TYPE_STRING, title="数据集/应用id",
|
||||
description="数据集或者应用的id"),
|
||||
'target_id': openapi.Schema(type=openapi.TYPE_STRING, title="知识库/应用id",
|
||||
description="知识库或者应用的id"),
|
||||
'type': openapi.Schema(type=openapi.TYPE_STRING,
|
||||
title="类型",
|
||||
description="DATASET|APPLICATION",
|
||||
|
|
@ -99,7 +99,7 @@ class UpdateTeamMemberPermissionSerializer(ApiMixin, serializers.Serializer):
|
|||
os.path.join(PROJECT_DIR, "apps", "setting", 'sql', 'check_member_permission_target_exists.sql')),
|
||||
[json.dumps(permission_list), user_id, user_id])
|
||||
if illegal_target_id_list is not None and len(illegal_target_id_list) > 0:
|
||||
raise AppApiException(500, '不存在的 应用|数据集id[' + str(illegal_target_id_list) + ']')
|
||||
raise AppApiException(500, '不存在的 应用|知识库id[' + str(illegal_target_id_list) + ']')
|
||||
|
||||
def update_or_save(self, member_id: str):
|
||||
team_member_permission_list = self.data.get("team_member_permission_list")
|
||||
|
|
@ -264,7 +264,7 @@ class TeamMemberSerializer(ApiMixin, serializers.Serializer):
|
|||
self.is_valid(raise_exception=True)
|
||||
team_id = self.data.get('team_id')
|
||||
member_id = self.data.get("member_id")
|
||||
# 查询当前团队成员所有的数据集和应用的权限 注意 operate为null是为设置权限 默认值都是false
|
||||
# 查询当前团队成员所有的知识库和应用的权限 注意 operate为null是为设置权限 默认值都是false
|
||||
member_permission_list = select_list(
|
||||
get_file_content(os.path.join(PROJECT_DIR, "apps", "setting", 'sql', 'get_member_permission.sql')),
|
||||
[team_id, team_id, (member_id if member_id != 'root' else uuid.uuid1())])
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ const getApplicationDetail: (
|
|||
}
|
||||
|
||||
/**
|
||||
* 获得当前应用可使用的数据集
|
||||
* 获得当前应用可使用的知识库
|
||||
* @param 参数 applicaiton_id
|
||||
*/
|
||||
const getApplicationDataset: (
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { type Ref } from 'vue'
|
|||
const prefix = '/dataset'
|
||||
|
||||
/**
|
||||
* 获取分页数据集
|
||||
* 获取分页知识库
|
||||
* @param 参数
|
||||
* page {
|
||||
"current_page": "string",
|
||||
|
|
@ -26,7 +26,7 @@ const getDateset: (
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取全部数据集
|
||||
* 获取全部知识库
|
||||
* @param 参数
|
||||
*/
|
||||
const getAllDateset: (loading?: Ref<boolean>) => Promise<Result<any[]>> = (loading) => {
|
||||
|
|
@ -34,7 +34,7 @@ const getAllDateset: (loading?: Ref<boolean>) => Promise<Result<any[]>> = (loadi
|
|||
}
|
||||
|
||||
/**
|
||||
* 删除数据集
|
||||
* 删除知识库
|
||||
* @param 参数 dataset_id
|
||||
*/
|
||||
const delDateset: (dataset_id: String, loading?: Ref<boolean>) => Promise<Result<boolean>> = (
|
||||
|
|
@ -45,7 +45,7 @@ const delDateset: (dataset_id: String, loading?: Ref<boolean>) => Promise<Result
|
|||
}
|
||||
|
||||
/**
|
||||
* 创建数据集
|
||||
* 创建知识库
|
||||
* @param 参数
|
||||
* {
|
||||
"name": "string",
|
||||
|
|
@ -74,7 +74,7 @@ const postDateset: (data: datasetData) => Promise<Result<any>> = (data) => {
|
|||
}
|
||||
|
||||
/**
|
||||
* 数据集详情
|
||||
* 知识库详情
|
||||
* @param 参数 dataset_id
|
||||
*/
|
||||
const getDatesetDetail: (dataset_id: string) => Promise<Result<any>> = (dataset_id) => {
|
||||
|
|
@ -82,7 +82,7 @@ const getDatesetDetail: (dataset_id: string) => Promise<Result<any>> = (dataset_
|
|||
}
|
||||
|
||||
/**
|
||||
* 修改数据集信息
|
||||
* 修改知识库信息
|
||||
* @param 参数
|
||||
* dataset_id
|
||||
* {
|
||||
|
|
@ -97,7 +97,7 @@ const putDateset: (dataset_id: string, data: any) => Promise<Result<any>> = (
|
|||
return put(`${prefix}/${dataset_id}`, data)
|
||||
}
|
||||
/**
|
||||
* 获取数据集 可关联的应用列表
|
||||
* 获取知识库 可关联的应用列表
|
||||
* @param dataset_id
|
||||
* @param loading
|
||||
* @returns
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 8.0 KiB |
|
|
@ -1,19 +0,0 @@
|
|||
<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M17.5 2.5H12.5V6.25H13.75V8.75H6.875C5.49429 8.75 4.375 9.86929 4.375 11.25V25C4.375 26.3807 5.49429 27.5 6.875 27.5H23.125C24.5057 27.5 25.625 26.3807 25.625 25V11.25C25.625 9.86929 24.5057 8.75 23.125 8.75H16.25V6.25H17.5V2.5ZM8.75 16.25H12.5V20H8.75V16.25ZM21.25 16.25V20H17.5V16.25H21.25Z" fill="url(#paint0_linear_1514_13484)"/>
|
||||
<path d="M2.5 15H0V21.25H2.5V15Z" fill="url(#paint1_linear_1514_13484)"/>
|
||||
<path d="M27.5 15H30V21.25H27.5V15Z" fill="url(#paint2_linear_1514_13484)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_1514_13484" x1="15" y1="2.5" x2="15" y2="27.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#3370FF"/>
|
||||
<stop offset="1" stop-color="#7F3BF5"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_1514_13484" x1="15" y1="2.5" x2="15" y2="27.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#3370FF"/>
|
||||
<stop offset="1" stop-color="#7F3BF5"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_1514_13484" x1="15" y1="2.5" x2="15" y2="27.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#3370FF"/>
|
||||
<stop offset="1" stop-color="#7F3BF5"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.2 KiB |
|
|
@ -32,11 +32,10 @@ defineProps({
|
|||
.title {
|
||||
font-size: 32px;
|
||||
.logo {
|
||||
background-image: url('@/assets/logo.svg');
|
||||
background-image: url('@/assets/logo.png');
|
||||
background-size: 100% 100%;
|
||||
width: 45px;
|
||||
height: 45px;
|
||||
background-position: center -2px;
|
||||
}
|
||||
}
|
||||
.sub-title {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
</template>
|
||||
<template v-else-if="isDataset">
|
||||
<el-button link @click="router.push({ path: '/dataset/create' })">
|
||||
<el-icon class="mr-4"><Plus /></el-icon> 创建数据集
|
||||
<el-icon class="mr-4"><Plus /></el-icon> 创建知识库
|
||||
</el-button>
|
||||
</template>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
<template>
|
||||
<el-dialog v-model="aboutDialogVisible" class="about-dialog">
|
||||
<template #header="{ titleId, titleClass }">
|
||||
<div class="flex-center">
|
||||
<div class="logo mr-4"></div>
|
||||
<div class="app-logo-font about-title" :id="titleId" :class="titleClass">
|
||||
{{ defaultTitle }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<ul class="about-ui">
|
||||
<li class="flex">
|
||||
<span class="label text-right">授权数量:</span><span class="text-center">-</span>
|
||||
</li>
|
||||
<li class="flex">
|
||||
<span class="label text-right">过期时间:</span><span class="text-center">-</span>
|
||||
</li>
|
||||
<li class="flex">
|
||||
<span class="label text-right">版本:</span><span class="text-center">-</span>
|
||||
</li>
|
||||
<li class="flex">
|
||||
<span class="label text-right">版本号:</span
|
||||
><span class="text-center">{{ PackageJSON.version }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import PackageJSON from '../../../../../package.json'
|
||||
const defaultTitle = import.meta.env.VITE_APP_TITLE
|
||||
const aboutDialogVisible = ref(false)
|
||||
|
||||
const open = () => {
|
||||
aboutDialogVisible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scope>
|
||||
.about-dialog {
|
||||
border-radius: 4px;
|
||||
.el-dialog__header {
|
||||
background: var(--app-header-bg-color);
|
||||
margin-right: 0;
|
||||
height: 45px;
|
||||
border-radius: 4px 4px 0 0;
|
||||
}
|
||||
.about-title {
|
||||
font-size: 24px;
|
||||
}
|
||||
.logo {
|
||||
background-image: url('@/assets/logo.png');
|
||||
background-size: 100% 100%;
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
}
|
||||
.about-ui {
|
||||
width: 200px;
|
||||
margin: 0 auto;
|
||||
line-height: 30px;
|
||||
span {
|
||||
width: 80px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -23,23 +23,30 @@
|
|||
<el-dropdown-item class="border-t p-8" @click="openResetPassword">
|
||||
修改密码
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item class="border-t"> 关于 </el-dropdown-item>
|
||||
<el-dropdown-item class="border-t" @click="openAbout"> 关于 </el-dropdown-item>
|
||||
<el-dropdown-item class="border-t" @click="logout"> 退出 </el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<ResetPassword ref="resetPasswordRef"></ResetPassword>
|
||||
<AboutDialog ref="AboutDialogRef"></AboutDialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import useStore from '@/stores'
|
||||
import { useRouter } from 'vue-router'
|
||||
import ResetPassword from './ResetPasssword.vue'
|
||||
import AboutDialog from './AboutDialog.vue'
|
||||
const { user } = useStore()
|
||||
const router = useRouter()
|
||||
|
||||
const AboutDialogRef = ref()
|
||||
const resetPasswordRef = ref<InstanceType<typeof ResetPassword>>()
|
||||
|
||||
const openAbout = () => {
|
||||
AboutDialogRef.value?.open()
|
||||
}
|
||||
|
||||
const openResetPassword = () => {
|
||||
resetPasswordRef.value?.open()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,11 +28,10 @@ const defaultTitle = import.meta.env.VITE_APP_TITLE
|
|||
.app-title-container {
|
||||
margin-right: 45px;
|
||||
.app-title-icon {
|
||||
background-image: url('@/assets/logo.svg');
|
||||
background-image: url('@/assets/logo.png');
|
||||
background-size: 100% 100%;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
background-position: center -1px;
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
}
|
||||
|
||||
.app-title-text {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import Layout from '@/layout/main-layout/index.vue'
|
|||
const datasetRouter = {
|
||||
path: '/dataset',
|
||||
name: 'dataset',
|
||||
meta: { title: '数据集', permission: 'DATASET:READ' },
|
||||
meta: { title: '知识库', permission: 'DATASET:READ' },
|
||||
redirect: '/dataset',
|
||||
children: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ export const MsgError = (message: string) => {
|
|||
}
|
||||
|
||||
/**
|
||||
* 删除数据集
|
||||
* 删除知识库
|
||||
* @param 参数 message: {title, decription,type}
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -82,17 +82,17 @@
|
|||
v-model="applicationForm.multiple_rounds_dialogue"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="关联数据集">
|
||||
<el-form-item label="关联知识库">
|
||||
<template #label>
|
||||
<div class="flex-between">
|
||||
<span>关联数据集</span>
|
||||
<span>关联知识库</span>
|
||||
<el-button type="primary" link @click="openDatasetDialog">
|
||||
<el-icon class="mr-4"><Plus /></el-icon> 添加
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<div v-if="applicationForm.dataset_id_list.length == 0">
|
||||
<el-text type="info">关联的数据集展示在这里</el-text>
|
||||
<el-text type="info">关联的知识库展示在这里</el-text>
|
||||
</div>
|
||||
<div class="w-full" v-else>
|
||||
<el-row :gutter="12">
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<template>
|
||||
<el-dialog title="添加关联数据集" v-model="dialogVisible" width="600">
|
||||
<el-dialog title="添加关联知识库" v-model="dialogVisible" width="600">
|
||||
<template #header="{ titleId, titleClass }">
|
||||
<div class="my-header flex">
|
||||
<h4 :id="titleId" :class="titleClass">添加关联数据集</h4>
|
||||
<h4 :id="titleId" :class="titleClass">添加关联知识库</h4>
|
||||
<el-button link class="ml-16" @click="refresh">
|
||||
<el-icon class="mr-4"><Refresh /></el-icon>刷新
|
||||
</el-button>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<LayoutContainer
|
||||
:header="isCreate ? '创建数据集' : '上传文档'"
|
||||
:header="isCreate ? '创建知识库' : '上传文档'"
|
||||
back-to="-1"
|
||||
class="create-dataset"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -7,19 +7,19 @@
|
|||
label-position="top"
|
||||
require-asterisk-position="right"
|
||||
>
|
||||
<el-form-item label="数据集名称" prop="name">
|
||||
<el-form-item label="知识库名称" prop="name">
|
||||
<el-input
|
||||
v-model.trim="form.name"
|
||||
placeholder="请输入数据集名称"
|
||||
v-model="form.name"
|
||||
placeholder="请输入知识库名称"
|
||||
maxlength="64"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据集描述" prop="desc">
|
||||
<el-form-item label="知识库描述" prop="desc">
|
||||
<el-input
|
||||
v-model.trim="form.desc"
|
||||
v-model="form.desc"
|
||||
type="textarea"
|
||||
placeholder="描述数据集的内容,详尽的描述将帮助AI能深入理解该数据集的内容,能更准确的检索到内容,提高该数据集的命中率。"
|
||||
placeholder="描述知识库的内容,详尽的描述将帮助AI能深入理解该知识库的内容,能更准确的检索到内容,提高该知识库的命中率。"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
:autosize="{ minRows: 3 }"
|
||||
|
|
@ -46,8 +46,8 @@ const form = ref<any>({
|
|||
})
|
||||
|
||||
const rules = reactive({
|
||||
name: [{ required: true, message: '请输入数据集名称', trigger: 'blur' }],
|
||||
desc: [{ required: true, message: '请输入数据集描述', trigger: 'blur' }]
|
||||
name: [{ required: true, message: '请输入知识库名称', trigger: 'blur' }],
|
||||
desc: [{ required: true, message: '请输入知识库描述', trigger: 'blur' }]
|
||||
})
|
||||
const FormRef = ref()
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ function editHandle(item: any, index: number, cIndex: number) {
|
|||
}
|
||||
|
||||
function deleteHandle(item: any, index: number, cIndex: number) {
|
||||
MsgConfirm(`是否删除分段:${item.title || '-'} ?`, `删除后将不会存入数据集,对本地文档无影响。`, {
|
||||
MsgConfirm(`是否删除分段:${item.title || '-'} ?`, `删除后将不会存入知识库,对本地文档无影响。`, {
|
||||
confirmButtonText: '删除',
|
||||
confirmButtonClass: 'danger'
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div class="dataset-list-container p-24" style="padding-top: 16px">
|
||||
<div class="flex-between mb-16">
|
||||
<h3>数据集</h3>
|
||||
<h3>知识库</h3>
|
||||
<el-input
|
||||
v-model="searchValue"
|
||||
@change="searchHandle"
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
>
|
||||
<el-row :gutter="15">
|
||||
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb-16">
|
||||
<CardAdd title="创建数据集" @click="router.push({ path: '/dataset/create' })" />
|
||||
<CardAdd title="创建知识库" @click="router.push({ path: '/dataset/create' })" />
|
||||
</el-col>
|
||||
<template v-for="(item, index) in datasetList" :key="index">
|
||||
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb-16">
|
||||
|
|
@ -83,8 +83,8 @@ function searchHandle() {
|
|||
|
||||
function deleteDateset(row: any) {
|
||||
MsgConfirm(
|
||||
`是否删除数据集:${row.name} ?`,
|
||||
`此数据集关联 ${row.char_length} 个应用,删除后无法恢复,请谨慎操作。`,
|
||||
`是否删除知识库:${row.name} ?`,
|
||||
`此知识库关联 ${row.char_length} 个应用,删除后无法恢复,请谨慎操作。`,
|
||||
{
|
||||
confirmButtonText: '删除',
|
||||
confirmButtonClass: 'danger'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<el-scrollbar>
|
||||
<el-result icon="success" title="🎉 数据集创建成功 🎉">
|
||||
<el-result icon="success" title="🎉 知识库创建成功 🎉">
|
||||
<template #sub-title>
|
||||
<div class="mt-8">
|
||||
<span class="bold">{{ data?.document_list.length || 0 }}</span>
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
</div>
|
||||
</template>
|
||||
<template #extra>
|
||||
<el-button @click="router.push({ path: `/dataset` })">返回数据集列表</el-button>
|
||||
<el-button @click="router.push({ path: `/dataset` })">返回知识库列表</el-button>
|
||||
<el-button type="primary" @click="router.push({ path: `/dataset/${data?.id}/document` })"
|
||||
>前往文档</el-button
|
||||
>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
/>
|
||||
<div class="p-24 pt-0">
|
||||
<el-table :data="data" :max-height="tableHeight">
|
||||
<el-table-column prop="name" :label="isApplication ? '应用名称' : '数据集名称'">
|
||||
<el-table-column prop="name" :label="isApplication ? '应用名称' : '知识库名称'">
|
||||
<template #default="{ row }">
|
||||
<div class="flex align-center">
|
||||
<AppAvatar
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ const tableHeight = ref(0)
|
|||
|
||||
const settingTags = reactive([
|
||||
{
|
||||
label: '数据集',
|
||||
label: '知识库',
|
||||
value: DATASET,
|
||||
data: [] as any
|
||||
},
|
||||
|
|
@ -154,7 +154,7 @@ function MemberPermissions(id: String) {
|
|||
function deleteMember(row: TeamMember) {
|
||||
MsgConfirm(
|
||||
`是否移除成员:${row.username}?`,
|
||||
'移除后将会取消成员拥有的数据集和应用权限。',
|
||||
'移除后将会取消成员拥有的知识库和应用权限。',
|
||||
|
||||
{
|
||||
confirmButtonText: '移除',
|
||||
|
|
|
|||
Loading…
Reference in New Issue