Skip to content

Commit dea8c73

Browse files
Merge branch 'main' of https://github.com/maxkb-dev/maxkb
2 parents 19ab61a + dc79a22 commit dea8c73

File tree

13 files changed

+217
-227
lines changed

13 files changed

+217
-227
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ MaxKB = Max Knowledge Base, it is a chatbot based on Large Language Models (LLM)
1717
- **Flexible Orchestration**: Equipped with a powerful workflow engine and function library, enabling the orchestration of AI processes to meet the needs of complex business scenarios.
1818
- **Seamless Integration**: Facilitates zero-coding rapid integration into third-party business systems, quickly equipping existing systems with intelligent Q&A capabilities to enhance user satisfaction.
1919
- **Model-Agnostic**: Supports various large models, including private models (such as DeepSeek, Llama, Qwen, etc.) and public models (like OpenAI, Claude, Gemini, etc.).
20+
- **Multi Modal**: Native support for input and output text, image, audio and video.
2021

2122
## Quick start
2223

apps/application/chat_pipeline/step/chat_step/impl/base_chat_step.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ def execute_block(self, message_list: List[BaseMessage],
307307
return manage.get_base_to_response().to_block_response(str(chat_id), str(chat_record_id),
308308
content, True,
309309
request_token, response_token,
310-
{'reasoning_content': reasoning_content})
310+
{'reasoning_content': reasoning_content,
311+
'answer_list': [{
312+
'content': content,
313+
'reasoning_content': reasoning_content
314+
}]})
311315
except Exception as e:
312316
all_text = 'Exception:' + str(e)
313317
write_context(self, manage, 0, 0, all_text)

apps/application/flow/workflow_manage.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,15 @@ def run_block(self, language='zh'):
337337
answer_text = '\n\n'.join(
338338
'\n\n'.join([a.get('content') for a in answer]) for answer in
339339
answer_text_list)
340+
answer_list = reduce(lambda pre, _n: [*pre, *_n], answer_text_list, [])
340341
self.work_flow_post_handler.handler(self.params['chat_id'], self.params['chat_record_id'],
341342
answer_text,
342343
self)
343344
return self.base_to_response.to_block_response(self.params['chat_id'],
344345
self.params['chat_record_id'], answer_text, True
345346
, message_tokens, answer_tokens,
346-
_status=status.HTTP_200_OK if self.status == 200 else status.HTTP_500_INTERNAL_SERVER_ERROR)
347+
_status=status.HTTP_200_OK if self.status == 200 else status.HTTP_500_INTERNAL_SERVER_ERROR,
348+
other_params={'answer_list': answer_list})
347349

348350
def run_stream(self, current_node, node_result_future, language='zh'):
349351
"""

apps/common/util/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from django.core.cache import cache
1414

1515
# alg使用的算法
16-
HEADER = {'typ': 'JWP', 'alg': 'default'}
16+
HEADER = {'type': 'JWP', 'alg': 'default'}
1717
TOKEN_KEY = 'solomon_world_token'
1818
TOKEN_SALT = '[email protected]'
1919
TIME_OUT = 30 * 60

apps/function_lib/serializers/function_lib_serializer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def export(self, with_valid=True):
249249
mk_instance = FlibInstance(application_dict, 'v1')
250250
application_pickle = pickle.dumps(mk_instance)
251251
response = HttpResponse(content_type='text/plain', content=application_pickle)
252-
response['Content-Disposition'] = f'attachment; filename="{function_lib.name}.flib"'
252+
response['Content-Disposition'] = f'attachment; filename="{function_lib.name}.fx"'
253253
return response
254254
except Exception as e:
255255
return result.error(str(e), response_status=status.HTTP_500_INTERNAL_SERVER_ERROR)

ui/src/api/function-lib.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const exportFunctionLib = (
105105
loading?: Ref<boolean>
106106
) => {
107107
return exportFile(
108-
name + '.flib',
108+
name + '.fx',
109109
`${prefix}/${id}/export`,
110110
undefined,
111111
loading

ui/src/components/codemirror-editor/index.vue

Lines changed: 88 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
11
<template>
2-
<Codemirror
3-
v-bind="$attrs"
4-
ref="cmRef"
5-
:extensions="extensions"
6-
:style="codemirrorStyle"
7-
:tab-size="4"
8-
:autofocus="true"
9-
/>
2+
<div class="codemirror-editor w-full">
3+
<Codemirror
4+
v-model="data"
5+
ref="cmRef"
6+
:extensions="extensions"
7+
:style="codemirrorStyle"
8+
:tab-size="4"
9+
:autofocus="true"
10+
v-bind="$attrs"
11+
/>
12+
13+
<div class="codemirror-editor__footer">
14+
<el-button text type="info" @click="openCodemirrorDialog" class="magnify">
15+
<AppIcon iconName="app-magnify" style="font-size: 16px"></AppIcon>
16+
</el-button>
17+
</div>
18+
<!-- Codemirror 弹出层 -->
19+
<el-dialog
20+
v-model="dialogVisible"
21+
:title="$t('views.functionLib.functionForm.form.param.code')"
22+
append-to-body
23+
fullscreen
24+
>
25+
<Codemirror
26+
v-model="cloneContent"
27+
:extensions="extensions"
28+
:style="codemirrorStyle"
29+
:tab-size="4"
30+
:autofocus="true"
31+
style="
32+
height: calc(100vh - 160px) !important;
33+
border: 1px solid #bbbfc4;
34+
border-radius: 4px;
35+
"
36+
/>
37+
<template #footer>
38+
<div class="dialog-footer mt-24">
39+
<el-button type="primary" @click="submitDialog"> {{ $t('common.confirm') }}</el-button>
40+
</div>
41+
</template>
42+
</el-dialog>
43+
</div>
1044
</template>
1145

1246
<script setup lang="ts">
13-
import { ref } from 'vue'
47+
import { ref, computed, watch } from 'vue'
1448
import { Codemirror } from 'vue-codemirror'
1549
import { python } from '@codemirror/lang-python'
1650
import { oneDark } from '@codemirror/theme-one-dark'
@@ -19,6 +53,19 @@ import FunctionApi from '@/api/function-lib'
1953
2054
defineOptions({ name: 'CodemirrorEditor' })
2155
56+
const props = defineProps<{
57+
modelValue: any
58+
}>()
59+
const emit = defineEmits(['update:modelValue', 'submitDialog'])
60+
const data = computed({
61+
set: (value) => {
62+
emit('update:modelValue', value)
63+
},
64+
get: () => {
65+
return props.modelValue
66+
}
67+
})
68+
2269
function getRangeFromLineAndColumn(state: any, line: number, column: number, end_column?: number) {
2370
const l = state.doc.line(line)
2471
const form = l.from + column
@@ -52,9 +99,39 @@ const regexpLinter = linter(async (view) => {
5299
})
53100
const extensions = [python(), regexpLinter, oneDark]
54101
const codemirrorStyle = {
55-
height: '210px!important'
102+
height: '210px!important',
103+
width: '100%'
56104
}
57105
const cmRef = ref<InstanceType<typeof Codemirror>>()
106+
// 弹出框相关代码
107+
const dialogVisible = ref<boolean>(false)
108+
109+
const cloneContent = ref<string>('')
110+
111+
watch(dialogVisible, (bool) => {
112+
if (!bool) {
113+
emit('submitDialog', cloneContent.value)
114+
}
115+
})
116+
117+
const openCodemirrorDialog = () => {
118+
cloneContent.value = props.modelValue
119+
dialogVisible.value = true
120+
}
121+
122+
function submitDialog() {
123+
emit('submitDialog', cloneContent.value)
124+
dialogVisible.value = false
125+
}
58126
</script>
59127

60-
<style lang="scss"></style>
128+
<style lang="scss" scoped>
129+
.codemirror-editor {
130+
position: relative;
131+
&__footer {
132+
position: absolute;
133+
bottom: 10px;
134+
right: 10px;
135+
}
136+
}
137+
</style>

ui/src/views/document/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@
440440
<SyncWebDialog ref="SyncWebDialogRef" @refresh="refresh" />
441441
<!-- 选择知识库 -->
442442
<SelectDatasetDialog ref="SelectDatasetDialogRef" @refresh="refreshMigrate" />
443-
<GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="refresh" />
443+
<GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="getList" />
444444
</div>
445445
<div class="mul-operation w-full flex" v-if="multipleSelection.length !== 0">
446446
<el-button :disabled="multipleSelection.length === 0" @click="cancelTaskHandle(1)">

ui/src/views/function-lib/component/FunctionFormDrawer.vue

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,8 @@
133133
</el-text>
134134
</h4>
135135

136-
<div class="function-CodemirrorEditor mb-8" v-if="showEditor">
137-
<CodemirrorEditor v-model="form.code" />
138-
<div class="function-CodemirrorEditor__footer">
139-
<el-button text type="info" @click="openCodemirrorDialog" class="magnify">
140-
<AppIcon iconName="app-magnify" style="font-size: 16px"></AppIcon>
141-
</el-button>
142-
</div>
136+
<div class="mb-8" v-if="showEditor">
137+
<CodemirrorEditor v-model="form.code" @submitDialog="submitCodemirrorEditor" />
143138
</div>
144139
<h4 class="title-decoration-1 mb-16 mt-16">
145140
{{ $t('common.param.outputParam') }}
@@ -162,27 +157,6 @@
162157
</div>
163158
</template>
164159

165-
<!-- Codemirror 弹出层 -->
166-
<el-dialog
167-
v-model="dialogVisible"
168-
:title="$t('views.functionLib.functionForm.form.param.code')"
169-
append-to-body
170-
fullscreen
171-
>
172-
<CodemirrorEditor
173-
v-model="cloneContent"
174-
style="
175-
height: calc(100vh - 160px) !important;
176-
border: 1px solid #bbbfc4;
177-
border-radius: 4px;
178-
"
179-
/>
180-
<template #footer>
181-
<div class="dialog-footer mt-24">
182-
<el-button type="primary" @click="submitDialog"> {{ $t('common.confirm') }}</el-button>
183-
</div>
184-
</template>
185-
</el-dialog>
186160
<FunctionDebugDrawer ref="FunctionDebugDrawerRef" />
187161
<FieldFormDialog ref="FieldFormDialogRef" @refresh="refreshFieldList" />
188162
</el-drawer>
@@ -223,9 +197,6 @@ const form = ref<functionLibData>({
223197
permission_type: 'PRIVATE'
224198
})
225199
226-
const dialogVisible = ref(false)
227-
const cloneContent = ref<any>('')
228-
229200
watch(visible, (bool) => {
230201
if (!bool) {
231202
isEdit.value = false
@@ -259,14 +230,8 @@ const rules = reactive({
259230
]
260231
})
261232
262-
function openCodemirrorDialog() {
263-
cloneContent.value = form.value.code
264-
dialogVisible.value = true
265-
}
266-
267-
function submitDialog() {
268-
form.value.code = cloneContent.value
269-
dialogVisible.value = false
233+
function submitCodemirrorEditor(val: string) {
234+
form.value.code = val
270235
}
271236
272237
function close() {
@@ -353,13 +318,4 @@ defineExpose({
353318
open
354319
})
355320
</script>
356-
<style lang="scss" scoped>
357-
.function-CodemirrorEditor__footer {
358-
position: absolute;
359-
bottom: 10px;
360-
right: 10px;
361-
}
362-
.function-CodemirrorEditor {
363-
position: relative;
364-
}
365-
</style>
321+
<style lang="scss" scoped></style>

ui/src/workflow/icons/variable-assign-node-icon.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<AppAvatar shape="square">
2+
<AppAvatar shape="square" class="avatar-blue">
33
<img src="@/assets/icon_assigner.svg" style="width: 65%" alt="" />
44
</AppAvatar>
55
</template>

0 commit comments

Comments
 (0)