Skip to content

Commit 1e1e666

Browse files
committed
refactor: optimize the display of SST nodes
1 parent c000ee4 commit 1e1e666

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

apps/application/flow/step_node/document_extract_node/impl/base_document_extract_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def save_image(image_list):
7070
# 回到文件头
7171
buffer.seek(0)
7272
file_content = split_handle.get_content(buffer, save_image)
73-
content.append('## ' + doc['name'] + '\n' + file_content)
73+
content.append('### ' + doc['name'] + '\n' + file_content)
7474
break
7575

7676
return NodeResult({'content': splitter.join(content)}, {})

apps/application/flow/step_node/speech_to_text_step_node/impl/base_speech_to_text_node.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from dataset.models import File
1515
from setting.models_provider.tools import get_model_instance_by_model_user_id
1616

17-
1817
class BaseSpeechToTextNode(ISpeechToTextNode):
1918

2019
def save_context(self, details, workflow_manage):
@@ -37,25 +36,34 @@ def process_audio_item(audio_item, model):
3736
temp_mp3_path = temp_amr_file.name
3837
any_to_mp3(temp_file_path, temp_mp3_path)
3938
try:
40-
return split_and_transcribe(temp_mp3_path, model)
39+
transcription = split_and_transcribe(temp_mp3_path, model)
40+
return {file.file_name: transcription}
4141
finally:
4242
os.remove(temp_file_path)
4343
os.remove(temp_mp3_path)
4444

4545
def process_audio_items(audio_list, model):
4646
with ThreadPoolExecutor(max_workers=5) as executor:
4747
results = list(executor.map(lambda item: process_audio_item(item, model), audio_list))
48-
return '\n\n'.join(results)
48+
return results
4949

5050
result = process_audio_items(audio_list, stt_model)
51-
return NodeResult({'answer': result, 'result': result}, {})
51+
content = []
52+
result_content = []
53+
for item in result:
54+
for key, value in item.items():
55+
content.append(f'### {key}\n{value}')
56+
result_content.append(value)
57+
return NodeResult({'answer': '\n'.join(result_content), 'result': '\n'.join(result_content),
58+
'content': content}, {})
5259

5360
def get_details(self, index: int, **kwargs):
5461
return {
5562
'name': self.node.properties.get('stepName'),
5663
"index": index,
5764
'run_time': self.context.get('run_time'),
5865
'answer': self.context.get('answer'),
66+
'content': self.context.get('content'),
5967
'type': self.node.type,
6068
'status': self.status,
6169
'err_message': self.err_message,

ui/src/components/ai-chat/ExecutionDetailDialog.vue

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,22 @@
293293
<div class="card-never border-r-4">
294294
<h5 class="p-8-12">参数输出</h5>
295295
<div class="p-8-12 border-t-dashed lighter">
296-
<p class="mb-8 color-secondary">文本内容:</p>
297-
<div v-if="item.answer">
296+
<el-card
297+
shadow="never"
298+
style="--el-card-padding: 8px"
299+
v-for="(file_content, index) in item.content"
300+
:key="index"
301+
class="mb-8"
302+
>
298303
<MdPreview
304+
v-if="file_content"
299305
ref="editorRef"
300306
editorId="preview-only"
301-
:modelValue="item.answer"
307+
:modelValue="file_content"
302308
style="background: none"
303309
/>
304-
</div>
310+
<template v-else> -</template>
311+
</el-card>
305312
</div>
306313
</div>
307314
</template>
@@ -544,7 +551,7 @@
544551
:modelValue="item.answer"
545552
style="background: none"
546553
/>
547-
<template v-else> - </template>
554+
<template v-else> -</template>
548555
</div>
549556
</div>
550557
</template>

0 commit comments

Comments
 (0)