Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/maxkb-dev/maxkb
Browse files Browse the repository at this point in the history
  • Loading branch information
liqiang-fit2cloud committed Dec 10, 2024
2 parents 95a420b + cacdfbc commit 9977717
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 21 deletions.
20 changes: 17 additions & 3 deletions apps/dataset/serializers/document_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
delete_embedding_by_document, update_embedding_dataset_id, delete_embedding_by_paragraph_ids, \
embedding_by_document_list
from smartdoc.conf import PROJECT_DIR
from django.db import models

parse_qa_handle_list = [XlsParseQAHandle(), CsvParseQAHandle(), XlsxParseQAHandle()]
parse_table_handle_list = [CsvSplitHandle(), XlsSplitHandle(), XlsxSplitHandle()]
Expand Down Expand Up @@ -364,6 +363,7 @@ class Query(ApiMixin, serializers.Serializer):
"文档名称"))
hit_handling_method = serializers.CharField(required=False, error_messages=ErrMessage.char("命中处理方式"))
is_active = serializers.BooleanField(required=False, error_messages=ErrMessage.boolean("文档是否可用"))
task_type = serializers.IntegerField(required=False, error_messages=ErrMessage.integer("任务类型"))
status = serializers.CharField(required=False, error_messages=ErrMessage.char("文档状态"))

def get_query_set(self):
Expand All @@ -375,8 +375,22 @@ def get_query_set(self):
query_set = query_set.filter(**{'hit_handling_method': self.data.get('hit_handling_method')})
if 'is_active' in self.data and self.data.get('is_active') is not None:
query_set = query_set.filter(**{'is_active': self.data.get('is_active')})
if 'status' in self.data and self.data.get('status') is not None:
query_set = query_set.filter(**{'status': self.data.get('status')})
if 'status' in self.data and self.data.get(
'status') is not None:
task_type = self.data.get('task_type')
status = self.data.get(
'status')
if task_type is not None:
query_set = query_set.annotate(
reversed_status=Reverse('status'),
task_type_status=Substr('reversed_status', TaskType(task_type).value,
TaskType(task_type).value),
).filter(task_type_status__in=[State(status).value]).values('id')
else:
if status != State.SUCCESS.value:
query_set = query_set.filter(status__icontains=status)
else:
query_set = query_set.filter(status__iregex='^[2n]*$')
query_set = query_set.order_by('-create_time', 'id')
return query_set

Expand Down
24 changes: 19 additions & 5 deletions ui/src/components/ai-chat/component/chat-input-operate/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
<div
class="p-8-12"
v-loading="localLoading"
v-if="uploadDocumentList.length || uploadImageList.length || uploadAudioList.length || uploadVideoList.length"
v-if="
uploadDocumentList.length ||
uploadImageList.length ||
uploadAudioList.length ||
uploadVideoList.length
"
>
<el-space wrap>
<template v-for="(item, index) in uploadDocumentList" :key="index">
Expand Down Expand Up @@ -248,14 +253,21 @@ const getAcceptList = () => {
const checkMaxFilesLimit = () => {
return (
props.applicationDetails.file_upload_setting.maxFiles <=
uploadImageList.value.length + uploadDocumentList.value.length + uploadAudioList.value.length + uploadVideoList.value.length
uploadImageList.value.length +
uploadDocumentList.value.length +
uploadAudioList.value.length +
uploadVideoList.value.length
)
}
const uploadFile = async (file: any, fileList: any) => {
const { maxFiles, fileLimit } = props.applicationDetails.file_upload_setting
// 单次上传文件数量限制
const file_limit_once = uploadImageList.value.length + uploadDocumentList.value.length + uploadAudioList.value.length + uploadVideoList.value.length
const file_limit_once =
uploadImageList.value.length +
uploadDocumentList.value.length +
uploadAudioList.value.length +
uploadVideoList.value.length
if (file_limit_once >= maxFiles) {
MsgWarning('最多上传' + maxFiles + '个文件')
fileList.splice(0, fileList.length)
Expand Down Expand Up @@ -283,7 +295,6 @@ const uploadFile = async (file: any, fileList: any) => {
uploadAudioList.value.push(file)
}
if (!chatId_context.value) {
const res = await props.openChatId()
chatId_context.value = res
Expand Down Expand Up @@ -332,6 +343,9 @@ const uploadFile = async (file: any, fileList: any) => {
file.file_id = f[0].file_id
}
})
if (!inputValue.value && uploadImageList.value.length > 0) {
inputValue.value = '请解析图片内容'
}
})
}
const recorderTime = ref(0)
Expand Down Expand Up @@ -471,7 +485,7 @@ function sendChatHandle(event: any) {
image_list: uploadImageList.value,
document_list: uploadDocumentList.value,
audio_list: uploadAudioList.value,
video_list: uploadVideoList.value,
video_list: uploadVideoList.value
})
inputValue.value = ''
uploadImageList.value = []
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/application/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const applicationList = ref<any[]>([])
const paginationConfig = reactive({
current_page: 1,
page_size: 20,
page_size: 30,
total: 0
})
interface UserOption {
Expand Down
39 changes: 27 additions & 12 deletions ui/src/views/document/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,33 +99,43 @@
>全部</el-dropdown-item
>
<el-dropdown-item
:class="filterMethod['status'] === '1' ? 'is-active' : ''"
:class="filterMethod['status'] === State.SUCCESS ? 'is-active' : ''"
class="justify-center"
:command="beforeCommand('status', '1')"
:command="beforeCommand('status', State.SUCCESS)"
>成功</el-dropdown-item
>
<el-dropdown-item
:class="filterMethod['status'] === '2' ? 'is-active' : ''"
:class="filterMethod['status'] === State.FAILURE ? 'is-active' : ''"
class="justify-center"
:command="beforeCommand('status', '2')"
:command="beforeCommand('status', State.FAILURE)"
>失败</el-dropdown-item
>
<el-dropdown-item
:class="filterMethod['status'] === '0' ? 'is-active' : ''"
:class="
filterMethod['status'] === State.STARTED &&
filterMethod['task_type'] == TaskType.EMBEDDING
? 'is-active'
: ''
"
class="justify-center"
:command="beforeCommand('status', '0')"
:command="beforeCommand('status', State.STARTED, TaskType.EMBEDDING)"
>索引中</el-dropdown-item
>
<el-dropdown-item
:class="filterMethod['status'] === '3' ? 'is-active' : ''"
:class="filterMethod['status'] === State.PENDING ? 'is-active' : ''"
class="justify-center"
:command="beforeCommand('status', '3')"
:command="beforeCommand('status', State.PENDING)"
>排队中</el-dropdown-item
>
<el-dropdown-item
:class="filterMethod['status'] === '4' ? 'is-active' : ''"
:class="
filterMethod['status'] === State.STARTED &&
filterMethod['task_type'] === TaskType.GENERATE_PROBLEM
? 'is-active'
: ''
"
class="justify-center"
:command="beforeCommand('status', '4')"
:command="beforeCommand('status', State.STARTED, TaskType.GENERATE_PROBLEM)"
>生成问题中</el-dropdown-item
>
</el-dropdown-menu>
Expand Down Expand Up @@ -481,13 +491,18 @@ function openDatasetDialog(row?: any) {
function dropdownHandle(obj: any) {
filterMethod.value[obj.attr] = obj.command
if (obj.attr == 'status') {
filterMethod.value['task_type'] = obj.task_type
}
getList()
}
function beforeCommand(attr: string, val: any) {
function beforeCommand(attr: string, val: any, task_type?: number) {
return {
attr: attr,
command: val
command: val,
task_type
}
}
const cancelTask = (row: any, task_type: number) => {
Expand Down

0 comments on commit 9977717

Please sign in to comment.