Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ const statusText = computed(() => {
return STATUS_TEXT[status] ?? status
})

const statusClass = computed(() => {
const statusType = computed(() => {
const status = props.toolItem.status
if (status === 'SUCCESS') return 'text-success'
if (status === 'FAIL' || status === 'FAILURE') return 'text-danger'
return 'text-N600'
if (status === 'SUCCESS') return 'success'
if (status === 'FAIL' || status === 'FAILURE') return 'danger'
return 'info'
})

// 参数为 JSON 字符串,尝试格式化展示,失败则原样展示
Expand Down Expand Up @@ -65,10 +65,10 @@ const formattedResult = computed(() => tryFormatJson(props.toolItem.content))
<span v-if="loading" class="mk-conversation-loading" />
<MkIcon name="icon_busy_outlined" />
<span class="min-w-0 max-w-[300px] truncate" :title="toolTitle">{{ toolTitle }}</span>
<span v-if="toolItem.status" class="shrink-0 rounded bg-N100 px-[6px] py-px text-[11px]" :class="statusClass">{{ statusText }}</span>
<el-tag v-if="toolItem.status" size="small" :type="statusType">{{ statusText }}</el-tag>
</template>

<div class="space-y-2">
<div class="space-y-2 pb-2">
<!-- 请求参数 -->
<div v-if="toolItem.arguments" class="mk-gray-card-lg py-3!">
<h6 class="mb-2">输入参数</h6>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ const groupStatus = computed(() => {
return childStatuses.length ? 'success' : ''
})

// const STATUS_TEXT: Dict<string> = { running: '执行中', success: '成功', error: '失败' }
// const statusText = computed(() => STATUS_TEXT[groupStatus.value] ?? '')

const manualExpanded = ref<boolean>()
const isExpanded = computed({
get: () => manualExpanded.value ?? groupStatus.value === 'running',
Expand Down Expand Up @@ -92,19 +89,21 @@ const isExpanded = computed({
<span>调用了 {{ toolItems.length }} 个工具</span>
</template>

<div v-show="toolItems.length">
<div v-show="toolItems.length" class="bg-white border rounded-xl">
<template v-for="(toolItem, index) in toolItems" :key="toolItem.id ?? index">
<div v-if="resolveToolRenderer(toolItem.name)">
<component
:is="resolveToolRenderer(toolItem.name)"
:content="toolItem"
:loading="toolItem.status === 'RUNNING'"
:expanded="isToolExpanded(toolItem, index)"
@update:expanded="manualToolExpanded[toolKey(toolItem, index)] = $event"
@toggle="toggleTool(toolItem, index)"
/>
<div class="px-4 pt-3 pb-1" :class="index !== 0 ? 'border-t' : ''">
<div v-if="resolveToolRenderer(toolItem.name)" :class="{ 'pb-2': isToolExpanded(toolItem, index) }">
<component
:is="resolveToolRenderer(toolItem.name)"
:content="toolItem"
:loading="toolItem.status === 'RUNNING'"
:expanded="isToolExpanded(toolItem, index)"
@update:expanded="manualToolExpanded[toolKey(toolItem, index)] = $event"
@toggle="toggleTool(toolItem, index)"
/>
</div>
<ToolItem v-else :tool-item="toolItem" />
</div>
<ToolItem v-else :tool-item="toolItem" />
</template>
</div>
</MkCollapse>
Expand Down
33 changes: 17 additions & 16 deletions ui/src/conversation-panel/components/content/items/tool/tool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ const loading = computed(() => props.content.status === 'RUNNING')
const toolTitle = computed(() => props.content.name || 'Tool')

// 状态文案与配色
// const statusText = computed(() => {
// const map: Dict<string> = {
// RUNNING: '执行中',
// SUCCESS: '成功',
// FAIL: '失败',
// FAILURE: '失败',
// }
// const status = props.content.status ?? ''
// return map[status] ?? status
// })
const statusText = computed(() => {
const map: Dict<string> = {
RUNNING: '执行中',
SUCCESS: '成功',
FAIL: '失败',
FAILURE: '失败',
}
const status = props.content.status ?? ''
return map[status] ?? status
})

// const statusClass = computed(() => {
// const status = props.content.status
// if (status === 'SUCCESS') return 'text-success'
// if (status === 'FAIL' || status === 'FAILURE') return 'text-danger'
// return 'text-N600'
// })
const statusType = computed(() => {
const status = props.content.status
if (status === 'SUCCESS') return 'success'
if (status === 'FAIL' || status === 'FAILURE') return 'danger'
return 'info'
})

// 参数为 JSON 字符串,尝试格式化展示,失败则原样展示
function tryFormatJson(value: unknown): string {
Expand Down Expand Up @@ -68,6 +68,7 @@ const formattedResult = computed(() => tryFormatJson(props.content.content))
<span v-if="loading" class="mk-conversation-loading" />
<MkIcon name="icon_busy_outlined" />
<span class="min-w-0 max-w-[300px] truncate" :title="toolTitle">{{ toolTitle }}</span>
<el-tag v-if="content.status" size="small" :type="statusType">{{ statusText }}</el-tag>
</template>

<div class="space-y-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ defineExpose({ validate, getStrategy })
:rules="{ required: true, message: '请选择增强工具', trigger: 'change' }"
class="mb-0! mt-4"
>
<el-select v-model="strategy.visual.tool_id" :loading="toolOptionsLoading" placeholder="请选择增强工具" filterable class="w-full">
<el-select v-model="strategy.visual.tool_id" :loading="toolOptionsLoading" placeholder="请选择增强工具" filterable clearable class="w-full">
<template #label="{ label }">
<div class="flex-align-center gap-2">
<ToolIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ defineExpose({ validate, getStrategy, setStrategy })
:rules="{ required: true, message: '请选择增强工具', trigger: 'change' }"
class="mb-0! mt-4"
>
<el-select v-model="strategy.visual.tool_id" :loading="toolOptionsLoading" placeholder="请选择增强工具" filterable class="w-full">
<el-select v-model="strategy.visual.tool_id" :loading="toolOptionsLoading" placeholder="请选择增强工具" filterable clearable class="w-full">
<template #label="{ label }">
<div class="flex-align-center gap-2">
<ToolIcon
Expand Down
Loading