@blueking/chat-x 0.0.47-beta.4 → 0.0.49-beta.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/ag-ui/types/file.d.ts +23 -0
- package/dist/ag-ui/types/index.d.ts +1 -0
- package/dist/ag-ui/types/messages.d.ts +2 -0
- package/dist/components/chat-input/chat-input.vue.d.ts +15 -2
- package/dist/components/chat-input/input-attachment/input-attachment.vue.d.ts +4 -2
- package/dist/components/chat-input/model-selector/capabilities.d.ts +3 -0
- package/dist/components/chat-input/model-selector/index.d.ts +3 -0
- package/dist/components/chat-input/model-selector/model-selector-panel.vue.d.ts +26 -0
- package/dist/components/chat-input/model-selector/model-selector-trigger.vue.d.ts +14 -0
- package/dist/components/chat-input/model-selector/model-selector.vue.d.ts +39 -0
- package/dist/components/chat-input/model-selector/types.d.ts +61 -0
- package/dist/components/chat-input/model-selector/use-model-selector.d.ts +17 -0
- package/dist/components/chat-message/assistant-message/message-artifacts/artifact-file-card.vue.d.ts +14 -0
- package/dist/components/chat-message/assistant-message/message-artifacts/artifact-preview/artifact-preview-host.vue.d.ts +8 -0
- package/dist/components/chat-message/assistant-message/message-artifacts/artifact-preview/preview-strategy.d.ts +9 -0
- package/dist/components/chat-message/assistant-message/message-artifacts/artifact-preview/renderers/html-preview.vue.d.ts +6 -0
- package/dist/components/chat-message/assistant-message/message-artifacts/artifact-preview/renderers/markdown-preview.vue.d.ts +6 -0
- package/dist/components/chat-message/assistant-message/message-artifacts/artifact-preview/renderers/txt-preview.vue.d.ts +6 -0
- package/dist/components/chat-message/assistant-message/message-artifacts/artifact-preview/renderers/url-iframe-preview.vue.d.ts +6 -0
- package/dist/components/chat-message/assistant-message/message-artifacts/artifact-preview/use-artifact-preview-loader.d.ts +21 -0
- package/dist/components/chat-message/assistant-message/message-artifacts/file-artifact-panel.vue.d.ts +12 -0
- package/dist/components/chat-message/assistant-message/message-artifacts/file-icon.d.ts +29 -0
- package/dist/components/chat-message/assistant-message/message-artifacts/message-artifacts.vue.d.ts +10 -0
- package/dist/components/chat-message/message-container/message-container.vue.d.ts +2 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/use-artifact-preview.d.ts +59 -0
- package/dist/composables/use-message-group.d.ts +434 -0
- package/dist/icons/file.d.ts +24 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/input.d.ts +7 -0
- package/dist/index.css +1 -1
- package/dist/index.js +2761 -1984
- package/dist/index.js.map +1 -1
- package/dist/lang/lang.d.ts +10 -1
- package/dist/mcp/generated/docs/activity-message.md +122 -97
- package/dist/mcp/generated/docs/assistant-message.md +125 -62
- package/dist/mcp/generated/docs/chat-container.md +269 -76
- package/dist/mcp/generated/docs/chat-input.md +57 -0
- package/dist/mcp/generated/docs/file-artifact-panel.md +279 -0
- package/dist/mcp/generated/docs/info-message.md +23 -7
- package/dist/mcp/generated/docs/input-attachment.md +1 -0
- package/dist/mcp/generated/docs/loading-message.md +36 -17
- package/dist/mcp/generated/docs/message-container.md +47 -0
- package/dist/mcp/generated/docs/message-render.md +44 -33
- package/dist/mcp/generated/docs/message-tools.md +5 -1
- package/dist/mcp/generated/docs/model-selector.md +157 -0
- package/dist/mcp/generated/docs/reasoning-message.md +15 -11
- package/dist/mcp/generated/docs/tool-btn.md +33 -4
- package/dist/mcp/generated/docs/tool-message.md +61 -45
- package/dist/mcp/generated/docs/use-artifact-preview.md +237 -0
- package/dist/mcp/generated/docs/use-message-group.md +24 -0
- package/dist/mcp/generated/docs/user-message.md +185 -121
- package/dist/mcp/generated/index.json +109 -11
- package/dist/types/tool.d.ts +6 -2
- package/package.json +2 -2
|
@@ -1,54 +1,61 @@
|
|
|
1
1
|
<!-- AI SUMMARY -->
|
|
2
2
|
## 快速了解
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
渲染助手 Markdown 正文、ToolCallRender 工具调用列表,以及 property.artifacts 文件卡片; 默认插槽仅覆盖正文。源码位置:src/components/chat-message/assistant-message/assistant-message.vue。
|
|
5
5
|
|
|
6
6
|
### 关联组件
|
|
7
7
|
- **message-render** — 由 MessageRender 在 role 为 assistant 时创建
|
|
8
8
|
- **tool-message** — 工具结果通过 toolCall.toolMessage 内联或独立 tool 消息关联展示
|
|
9
9
|
- **toolcall-render** — 多条工具调用由 ToolcallRender 统一渲染
|
|
10
|
+
- **file-artifact-panel** — property.artifacts 文件产物点击后在侧栏预览
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
<!-- FULL DOC -->
|
|
13
14
|
|
|
14
15
|
# AssistantMessage AI 助手消息
|
|
16
|
+
|
|
15
17
|
## 源码事实
|
|
16
18
|
|
|
17
19
|
- **源码位置**:`src/components/chat-message/assistant-message/assistant-message.vue`
|
|
18
20
|
- **能力域**:消息系统
|
|
19
|
-
-
|
|
21
|
+
- **能力说明**:渲染助手 Markdown 正文、工具调用列表与 `property.artifacts` 文件产物。
|
|
20
22
|
|
|
21
|
-
>
|
|
23
|
+
> **导出说明**:`AssistantMessage` **未**从 `@blueking/chat-x` 包入口导出(入口同名是 TS interface)。消费方请用 `MessageRender` / `MessageContainer`。下文 `AssistantMessageComp` 为文档站内部相对路径示例。
|
|
22
24
|
|
|
23
|
-
AI
|
|
25
|
+
AI 助手消息展示组件:正文(Markdown)、工具调用(Tool Calls)、文件产物卡片。
|
|
24
26
|
|
|
25
27
|
## 渲染管线
|
|
26
28
|
|
|
27
29
|
```
|
|
28
30
|
AssistantMessage(根类名:ai-assistant-message)
|
|
29
|
-
├── ai-assistant-message-content
|
|
30
|
-
│ └── [default slot] 或 ContentRender → MarkdownContent
|
|
31
|
-
|
|
31
|
+
├── ai-assistant-message-content(内容区,v-if content)
|
|
32
|
+
│ └── [default slot { content }] 或 ContentRender → MarkdownContent
|
|
33
|
+
├── ToolCallRender × N(toolCalls,不受 slot 影响)
|
|
34
|
+
└── MessageArtifacts(v-if property.artifacts 非空)
|
|
35
|
+
└── ArtifactFileCard × N(点击 → useArtifactPreview → 侧栏 FileArtifactPanel → ArtifactPreviewHost)
|
|
32
36
|
```
|
|
33
37
|
|
|
34
|
-
- **内容区**:`content`
|
|
35
|
-
-
|
|
38
|
+
- **内容区**:`content` 经 `ContentRender`(`MessageContentType.Text`)由 `MarkdownContent` 渲染;default slot 仅收到 `{ content }`
|
|
39
|
+
- **工具调用区**:每个 `toolCall` 渲染一个 `ToolCallRender`,位于内容区下方
|
|
40
|
+
- **文件产物区**:读取 `property.artifacts`,用 `uid ?? String(id)` 作为 `messageUid` 传给 `MessageArtifacts`
|
|
36
41
|
|
|
37
42
|
## 基础用法
|
|
38
43
|
|
|
39
44
|
```vue
|
|
40
45
|
<template>
|
|
41
|
-
<
|
|
42
|
-
:content="content"
|
|
43
|
-
:status="status"
|
|
44
|
-
/>
|
|
46
|
+
<MessageRender :message="message" />
|
|
45
47
|
</template>
|
|
46
48
|
|
|
47
49
|
<script setup lang="ts">
|
|
48
|
-
import {
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
import { MessageRender, MessageRole, MessageStatus } from '@blueking/chat-x';
|
|
51
|
+
|
|
52
|
+
const message = {
|
|
53
|
+
id: '1',
|
|
54
|
+
messageId: '1',
|
|
55
|
+
role: MessageRole.Assistant,
|
|
56
|
+
content: '你好!我是 AI 助手,有什么可以帮助你的吗?',
|
|
57
|
+
status: MessageStatus.Complete,
|
|
58
|
+
};
|
|
52
59
|
</script>
|
|
53
60
|
```
|
|
54
61
|
|
|
@@ -60,16 +67,18 @@ AssistantMessage(根类名:ai-assistant-message)
|
|
|
60
67
|
|
|
61
68
|
```vue
|
|
62
69
|
<template>
|
|
63
|
-
<
|
|
64
|
-
:content="markdownContent"
|
|
65
|
-
status="complete"
|
|
66
|
-
/>
|
|
70
|
+
<MessageRender :message="message" />
|
|
67
71
|
</template>
|
|
68
72
|
|
|
69
73
|
<script setup lang="ts">
|
|
70
|
-
import {
|
|
74
|
+
import { MessageRender, MessageRole, MessageStatus } from '@blueking/chat-x';
|
|
71
75
|
|
|
72
|
-
const
|
|
76
|
+
const message = {
|
|
77
|
+
id: '1',
|
|
78
|
+
messageId: '1',
|
|
79
|
+
role: MessageRole.Assistant,
|
|
80
|
+
status: MessageStatus.Complete,
|
|
81
|
+
content: `## Vue 3 核心特性
|
|
73
82
|
|
|
74
83
|
Vue 3 引入了多项重要更新:
|
|
75
84
|
|
|
@@ -84,7 +93,8 @@ const count = ref(0);
|
|
|
84
93
|
const doubled = computed(() => count.value * 2);
|
|
85
94
|
\\\`\\\`\\\`
|
|
86
95
|
|
|
87
|
-
> 更多详情请参考 [Vue 3 官方文档](https://vuejs.org)
|
|
96
|
+
> 更多详情请参考 [Vue 3 官方文档](https://vuejs.org)。`,
|
|
97
|
+
};
|
|
88
98
|
</script>
|
|
89
99
|
```
|
|
90
100
|
|
|
@@ -126,27 +136,30 @@ const doubled = computed(() => count.value * 2);
|
|
|
126
136
|
|
|
127
137
|
```vue
|
|
128
138
|
<template>
|
|
129
|
-
<
|
|
130
|
-
content="让我帮你查询一下天气信息。"
|
|
131
|
-
:status="MessageStatus.Complete"
|
|
132
|
-
:tool-calls="toolCalls"
|
|
133
|
-
/>
|
|
139
|
+
<MessageRender :message="message" />
|
|
134
140
|
</template>
|
|
135
141
|
|
|
136
142
|
<script setup lang="ts">
|
|
137
|
-
import {
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
import { MessageRender, MessageRole, MessageStatus } from '@blueking/chat-x';
|
|
144
|
+
|
|
145
|
+
const message = {
|
|
146
|
+
id: '1',
|
|
147
|
+
messageId: '1',
|
|
148
|
+
role: MessageRole.Assistant,
|
|
149
|
+
content: '让我帮你查询一下天气信息。',
|
|
150
|
+
status: MessageStatus.Complete,
|
|
151
|
+
toolCalls: [
|
|
152
|
+
{
|
|
153
|
+
id: 'call_1',
|
|
154
|
+
type: 'function',
|
|
155
|
+
function: {
|
|
156
|
+
name: 'get_weather',
|
|
157
|
+
arguments: '{"city": "北京", "unit": "celsius"}',
|
|
158
|
+
description: '获取指定城市的天气信息',
|
|
159
|
+
},
|
|
147
160
|
},
|
|
148
|
-
|
|
149
|
-
|
|
161
|
+
],
|
|
162
|
+
};
|
|
150
163
|
</script>
|
|
151
164
|
```
|
|
152
165
|
|
|
@@ -285,20 +298,17 @@ AI 可在一次回复中发起多个工具调用,组件依次渲染:
|
|
|
285
298
|
|
|
286
299
|
```vue
|
|
287
300
|
<template>
|
|
288
|
-
<
|
|
289
|
-
:content="content"
|
|
290
|
-
:tool-calls="toolCalls"
|
|
291
|
-
>
|
|
301
|
+
<MessageRender :message="message">
|
|
292
302
|
<template #default="{ content }">
|
|
293
303
|
<div style="padding: 12px; background: #f0f9ff; border-left: 3px solid #3a84ff; border-radius: 4px;">
|
|
294
|
-
|
|
304
|
+
{{ content }}
|
|
295
305
|
</div>
|
|
296
306
|
</template>
|
|
297
|
-
</
|
|
307
|
+
</MessageRender>
|
|
298
308
|
</template>
|
|
299
309
|
```
|
|
300
310
|
|
|
301
|
-
>
|
|
311
|
+
> **注意**:使用默认插槽后,内置 Markdown 渲染被替换,需自行处理格式化。slot 运行时仅保证 `{ content }`(见 [MessageRender](/components/message/message-render))。
|
|
302
312
|
|
|
303
313
|
**渲染效果**
|
|
304
314
|
|
|
@@ -358,28 +368,80 @@ AI 可在一次回复中发起多个工具调用,组件依次渲染:
|
|
|
358
368
|
</script>
|
|
359
369
|
```
|
|
360
370
|
|
|
371
|
+
## 文件产物
|
|
372
|
+
|
|
373
|
+
当 `property.artifacts` 非空时,在工具调用区下方渲染 `MessageArtifacts` 文件卡片列表。点击卡片会通过 `useArtifactPreview` 打开 `ChatContainer` 侧栏「文件产物」Tab(见 [FileArtifactPanel](/components/message/file-artifact-panel))。
|
|
374
|
+
|
|
375
|
+
`AIFileInfo` 仅含元信息(`name` / `outputId` / `size` / `type`);`download_url` / `preview_url` 由容器 `onArtifactClick` 异步获取。命中唯一文件依赖 `messageUid = uid ?? String(id)` + 卡片下标 + `outputId`。
|
|
376
|
+
|
|
377
|
+
侧栏预览由面板内 `ArtifactPreviewHost` 按类型分派(详见面板文档「预览机制」):
|
|
378
|
+
|
|
379
|
+
| type | 预览依赖 | 渲染 |
|
|
380
|
+
| ---- | -------- | ---- |
|
|
381
|
+
| `html` / `markdown` / `md` / `txt` / `json` | `download_url` | 正文直渲染(srcdoc / MarkdownContent / `<pre>`) |
|
|
382
|
+
| `pdf` / `jpg` 等 | `preview_url` | iframe(一般为后台转好的 PDF) |
|
|
383
|
+
|
|
384
|
+
`md` 与 `markdown` 等价(见 `AIFileType.Md` / `AIFileType.Markdown`)。
|
|
385
|
+
|
|
386
|
+
```vue
|
|
387
|
+
<template>
|
|
388
|
+
<MessageRender :message="message" />
|
|
389
|
+
</template>
|
|
390
|
+
|
|
391
|
+
<script setup lang="ts">
|
|
392
|
+
import { MessageRender, MessageRole, MessageStatus } from '@blueking/chat-x';
|
|
393
|
+
import type { AIFileInfo } from '@blueking/chat-x';
|
|
394
|
+
|
|
395
|
+
const artifacts: AIFileInfo[] = [
|
|
396
|
+
{ name: '监控大盘周报.html', outputId: 'output-html', size: 10240, type: 'html' },
|
|
397
|
+
{ name: '系统配置说明.md', outputId: 'output-md', size: 8192, type: 'md' },
|
|
398
|
+
{ name: '周例会纪要.txt', outputId: 'output-txt', size: 4096, type: 'txt' },
|
|
399
|
+
{ name: '告警策略配置.json', outputId: 'output-json', size: 2048, type: 'json' },
|
|
400
|
+
{ name: '立项说明书.pdf', outputId: 'output-pdf', size: 204800, type: 'pdf' },
|
|
401
|
+
{ name: '巡检现场照片.jpg', outputId: 'output-jpg', size: 1048576, type: 'jpg' },
|
|
402
|
+
];
|
|
403
|
+
|
|
404
|
+
const message = {
|
|
405
|
+
id: 'a1',
|
|
406
|
+
messageId: 'a1',
|
|
407
|
+
uid: 'assistant-uid-1',
|
|
408
|
+
role: MessageRole.Assistant,
|
|
409
|
+
status: MessageStatus.Complete,
|
|
410
|
+
content: '已为你生成一组评审材料,可点击卡片在侧栏预览或下载:',
|
|
411
|
+
property: { artifacts },
|
|
412
|
+
};
|
|
413
|
+
</script>
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
**渲染效果(文档站内部示例;无 Provider 时卡片不可点击预览)**
|
|
417
|
+
|
|
361
418
|
## API
|
|
362
419
|
|
|
363
420
|
### Props
|
|
364
421
|
|
|
365
422
|
组件 Props 来自 `Partial<AssistantMessage>`(所有字段均可选):
|
|
366
423
|
|
|
367
|
-
| 属性名 | 类型 | 说明
|
|
368
|
-
| --------- | ----------------------- |
|
|
369
|
-
| content | `string` | AI
|
|
370
|
-
| status | `MessageStatus` |
|
|
371
|
-
| toolCalls | `ToolCall[]` | 工具调用列表,每项渲染一个 `ToolCallRender`
|
|
372
|
-
| id | `number \| string` | 消息 ID
|
|
373
|
-
| messageId | `number \| string` | 消息唯一标识
|
|
374
|
-
|
|
|
375
|
-
|
|
|
376
|
-
|
|
|
424
|
+
| 属性名 | 类型 | 说明 |
|
|
425
|
+
| --------- | ----------------------- | ----------------------------------------------------------------------------------------- |
|
|
426
|
+
| content | `string` | AI 回复文本,支持 Markdown;空值时不渲染内容区 |
|
|
427
|
+
| status | `MessageStatus` | 影响 ContentRender / ToolCallRender 状态表现 |
|
|
428
|
+
| toolCalls | `ToolCall[]` | 工具调用列表,每项渲染一个 `ToolCallRender` |
|
|
429
|
+
| id | `number \| string` | 消息 ID;无 `uid` 时回退为 `messageUid` |
|
|
430
|
+
| messageId | `number \| string` | 消息唯一标识 |
|
|
431
|
+
| uid | `string` | 优先作为文件产物命中 / 「在对话中定位」的 `messageUid` |
|
|
432
|
+
| name | `string` | 消息发送者名称(可选) |
|
|
433
|
+
| role | `MessageRole.Assistant` | 消息角色,固定为 `'assistant'` |
|
|
434
|
+
| property | `{ artifacts?: AIFileInfo[]; extra?: ... }` | **本组件消费** `property.artifacts` 渲染文件卡片;`extra` 等由上层按需使用 |
|
|
377
435
|
|
|
378
436
|
### Slots
|
|
379
437
|
|
|
380
|
-
| 插槽名 | 参数 | 说明
|
|
381
|
-
| ------- | --------------------- |
|
|
382
|
-
| default | `{ content: string }` |
|
|
438
|
+
| 插槽名 | 参数 | 说明 |
|
|
439
|
+
| ------- | --------------------- | ----------------------------------------------------------------- |
|
|
440
|
+
| default | `{ content: string }` | 替换内容区渲染;toolCalls / MessageArtifacts 在内容区外独立渲染 |
|
|
441
|
+
|
|
442
|
+
### Events / Expose
|
|
443
|
+
|
|
444
|
+
无。
|
|
383
445
|
|
|
384
446
|
## 类型定义
|
|
385
447
|
|
|
@@ -426,4 +488,5 @@ interface ToolMessage extends BaseMessage<MessageRole.Tool, string> {
|
|
|
426
488
|
|
|
427
489
|
- [MessageRender](/components/message/message-render) — assistant 角色由其实例化
|
|
428
490
|
- [ToolMessage](/components/message/tool-message) — 工具执行结果可通过 toolCall.toolMessage 内联
|
|
429
|
-
- [ToolcallRender](/components/agent/toolcall-render) — 工具调用列表渲染
|
|
491
|
+
- [ToolcallRender](/components/agent/toolcall-render) — 工具调用列表渲染
|
|
492
|
+
- [FileArtifactPanel](/components/message/file-artifact-panel) — 文件产物侧栏列表与分类型预览 Host
|