@veltra/ai 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/index.d.ts +2 -2
- package/dist/chat/transports/openai.js +1 -1
- package/dist/chat/transports/openai.js.map +1 -1
- package/dist/chat/types.d.ts +37 -2
- package/dist/chat/use-chat.d.ts +23 -1
- package/dist/chat/use-chat.js +91 -10
- package/dist/chat/use-chat.js.map +1 -1
- package/dist/components/ai-chat/ai-chat.js +207 -46
- package/dist/components/ai-chat/ai-chat.js.map +1 -1
- package/dist/components/ai-chat/chat-input.js +37 -12
- package/dist/components/ai-chat/chat-input.js.map +1 -1
- package/dist/components/ai-chat/di.js.map +1 -1
- package/dist/components/ai-chat/message-item.js +101 -23
- package/dist/components/ai-chat/message-item.js.map +1 -1
- package/dist/components/ai-chat/message-list.js +217 -32
- package/dist/components/ai-chat/message-list.js.map +1 -1
- package/dist/components/ai-chat/model-picker.js +69 -46
- package/dist/components/ai-chat/model-picker.js.map +1 -1
- package/dist/components/ai-chat/queue-list.js +70 -0
- package/dist/components/ai-chat/queue-list.js.map +1 -0
- package/dist/components/ai-chat/side-panel.js +96 -0
- package/dist/components/ai-chat/side-panel.js.map +1 -0
- package/dist/components/ai-chat/style.d.ts +4 -0
- package/dist/components/ai-chat/style.js +4 -0
- package/dist/components/ai-chat/style2.css +457 -74
- package/dist/components/ai-chat/tool-call.js +60 -26
- package/dist/components/ai-chat/tool-call.js.map +1 -1
- package/dist/components/ai-orb/ai-orb.js +94 -0
- package/dist/components/ai-orb/ai-orb.js.map +1 -0
- package/dist/components/ai-orb/orb-renderer.js +411 -0
- package/dist/components/ai-orb/orb-renderer.js.map +1 -0
- package/dist/components/ai-orb/style.d.ts +1 -0
- package/dist/components/ai-orb/style.js +1 -0
- package/dist/components/ai-orb/style2.css +23 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/style.js +1 -0
- package/dist/types/ai-chat.d.ts +21 -7
- package/dist/types/ai-orb.d.ts +27 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +5 -5
- package/src/chat/__test__/use-chat.test.ts +266 -13
- package/src/chat/transports/__test__/openai.test.ts +78 -0
- package/src/chat/transports/openai.ts +2 -2
- package/src/chat/types.ts +37 -1
- package/src/chat/use-chat.ts +120 -11
- package/src/components/ai-chat/__test__/ai-chat.test.ts +628 -12
- package/src/components/ai-chat/ai-chat.vue +227 -31
- package/src/components/ai-chat/chat-input.vue +41 -11
- package/src/components/ai-chat/di.ts +2 -0
- package/src/components/ai-chat/message-item.vue +98 -11
- package/src/components/ai-chat/message-list.vue +261 -21
- package/src/components/ai-chat/model-picker.vue +110 -59
- package/src/components/ai-chat/queue-list.vue +63 -0
- package/src/components/ai-chat/side-panel.vue +76 -0
- package/src/components/ai-chat/style.scss +527 -74
- package/src/components/ai-chat/style.ts +4 -0
- package/src/components/ai-chat/tool-call.vue +86 -42
- package/src/components/ai-orb/__test__/ai-orb.test.ts +251 -0
- package/src/components/ai-orb/ai-orb.vue +107 -0
- package/src/components/ai-orb/index.ts +1 -0
- package/src/components/ai-orb/orb-renderer.ts +505 -0
- package/src/components/ai-orb/style.scss +10 -0
- package/src/components/ai-orb/style.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/style.ts +1 -0
- package/src/tools/ask-question/__test__/ask-question.test.ts +1 -1
- package/src/types/ai-chat.ts +21 -6
- package/src/types/ai-orb.ts +27 -0
- package/src/types/index.ts +1 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<aside :class="cls.e('panel')">
|
|
3
|
+
<div :class="cls.e('panel-card')">
|
|
4
|
+
<div :class="cls.e('panel-header')">
|
|
5
|
+
<UIcon :class="[cls.e('panel-icon'), statusClass]">
|
|
6
|
+
<component :is="headerIcon" />
|
|
7
|
+
</UIcon>
|
|
8
|
+
<span :class="cls.e('panel-title')">{{ panelTitle }}</span>
|
|
9
|
+
<UIcon :class="cls.e('panel-close')" title="关闭面板" @click="emit('close')">
|
|
10
|
+
<Close />
|
|
11
|
+
</UIcon>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<UScroll :class="cls.e('panel-body')">
|
|
15
|
+
<!-- render 组件与工具卡片同一契约(ChatToolRenderProps),可随 toolCall 状态实时更新 -->
|
|
16
|
+
<component :is="tool.render" v-if="tool?.render" :tool-call="toolCall" />
|
|
17
|
+
<pre v-else :class="cls.e('panel-fallback')">{{ fallbackResult }}</pre>
|
|
18
|
+
</UScroll>
|
|
19
|
+
</div>
|
|
20
|
+
</aside>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script lang="ts" setup>
|
|
24
|
+
import { UIcon, UScroll } from '@veltra/desktop'
|
|
25
|
+
import { CircleCheckFilled, CircleClose, Close, Loading, WarningFilled } from '@veltra/icons/normal'
|
|
26
|
+
import { bem } from '@veltra/utils'
|
|
27
|
+
import { computed, inject, type Component } from 'vue'
|
|
28
|
+
|
|
29
|
+
import type { ChatToolCall } from '../../chat/types'
|
|
30
|
+
import { AiChatDIKey } from './di'
|
|
31
|
+
|
|
32
|
+
defineOptions({ name: 'UAiChatSidePanel' })
|
|
33
|
+
|
|
34
|
+
const props = defineProps<{ toolCall: ChatToolCall }>()
|
|
35
|
+
|
|
36
|
+
const emit = defineEmits<{ (e: 'close'): void }>()
|
|
37
|
+
|
|
38
|
+
const di = inject(AiChatDIKey)
|
|
39
|
+
const cls = di?.cls ?? bem('ai-chat')
|
|
40
|
+
|
|
41
|
+
/** 当前调用对应的工具定义(解析 icon/label/render) */
|
|
42
|
+
const tool = computed(() => di?.tools.value[props.toolCall.name])
|
|
43
|
+
|
|
44
|
+
const STATUS_META: Record<string, { icon: Component; class: string }> = {
|
|
45
|
+
pending: { icon: Loading, class: 'is-active' },
|
|
46
|
+
running: { icon: Loading, class: 'is-active' },
|
|
47
|
+
'awaiting-confirm': { icon: WarningFilled, class: 'is-warning' },
|
|
48
|
+
success: { icon: CircleCheckFilled, class: 'is-success' },
|
|
49
|
+
error: { icon: CircleClose, class: 'is-danger' },
|
|
50
|
+
rejected: { icon: Close, class: 'is-danger' }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const statusIcon = computed(() => STATUS_META[props.toolCall.status]?.icon ?? Loading)
|
|
54
|
+
const statusClass = computed(() => STATUS_META[props.toolCall.status]?.class ?? '')
|
|
55
|
+
|
|
56
|
+
/** 头部图标:工具自定义图标优先,缺省用状态图标(与工具卡片一致) */
|
|
57
|
+
const headerIcon = computed(() => tool.value?.icon ?? statusIcon.value)
|
|
58
|
+
|
|
59
|
+
/** 面板标题:优先工具定义的 panelTitle(业务对象 + 动作),缺省回落到 label ?? name */
|
|
60
|
+
const panelTitle = computed(() => {
|
|
61
|
+
const t = tool.value
|
|
62
|
+
const pt = t?.panelTitle
|
|
63
|
+
if (typeof pt === 'function') return pt(props.toolCall)
|
|
64
|
+
return pt ?? t?.label ?? props.toolCall.name
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
/** 未提供 render 时的兜底展示(面板工具通常都应提供 render) */
|
|
68
|
+
const fallbackResult = computed(() => {
|
|
69
|
+
const raw = props.toolCall.error ?? props.toolCall.result ?? ''
|
|
70
|
+
try {
|
|
71
|
+
return JSON.stringify(JSON.parse(raw), null, 2)
|
|
72
|
+
} catch {
|
|
73
|
+
return raw
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
</script>
|