langgraph-vue3-chatbot 0.1.22 → 0.1.23
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/README.md +85 -1
- package/dist-lib/components/ai-bot/AskAiBot.vue.d.ts +5 -1
- package/dist-lib/components/ai-bot/AskAiBot.vue.d.ts.map +1 -1
- package/dist-lib/components/ai-bot/ChatBot.vue.d.ts +5 -1
- package/dist-lib/components/ai-bot/ChatBot.vue.d.ts.map +1 -1
- package/dist-lib/components/ai-bot/ChatInput.vue.d.ts +6 -2
- package/dist-lib/components/ai-bot/ChatInput.vue.d.ts.map +1 -1
- package/dist-lib/components/ai-bot/chatbot.css +1 -1
- package/dist-lib/components/ai-bot/index.d.ts +2 -2
- package/dist-lib/components/ai-bot/index.d.ts.map +1 -1
- package/dist-lib/components/ai-bot/lib/input-types.d.ts +12 -0
- package/dist-lib/components/ai-bot/lib/input-types.d.ts.map +1 -1
- package/dist-lib/index.d.ts +1 -1
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +1325 -1286
- package/dist-lib/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -178,12 +178,96 @@ const suggestions = [
|
|
|
178
178
|
| `systemPrompt` | 设置发送给模型的系统提示词 | `'你是一个有用的助手,帮用户解决各种问题。'` |
|
|
179
179
|
| `threadId` | 指定已有会话线程 id;不传时由组件内部创建线程 | `undefined` |
|
|
180
180
|
| `userId` | 标识当前用户,用于请求上下文区分 | `'user001'` |
|
|
181
|
-
| `showHeaderActions` |
|
|
181
|
+
| `showHeaderActions` | 控制是否显示聊天面板头部右侧操作按钮,例如关闭、最大化等 | `true` |
|
|
182
182
|
| `suggestions` | 配置输入区上方的建议问题列表 | `[]` |
|
|
183
183
|
| `apiUrl` | 指定 LangGraph 服务地址 | `'http://localhost:2024'` |
|
|
184
184
|
| `apiKey` | 指定 LangGraph 服务访问凭证 | `undefined` |
|
|
185
185
|
| `theme` | 设置组件主题,可选 `light` / `dark` | `'light'` |
|
|
186
186
|
|
|
187
|
+
## 组件实例 API
|
|
188
|
+
|
|
189
|
+
`ChatBot` 和 `AskAiBot` 都支持通过 `ref` 调用少量公开实例方法,目前只暴露以下 3 个能力:
|
|
190
|
+
|
|
191
|
+
- `setTextInput(text: string)`:设置输入框文本
|
|
192
|
+
- `addAttachments(attachments: PromptInputAttachment[])`:添加附件
|
|
193
|
+
- `sendMessage()`:触发现有发送流程
|
|
194
|
+
|
|
195
|
+
其中:
|
|
196
|
+
|
|
197
|
+
- `ChatBot` 会直接调用内部输入区现有逻辑
|
|
198
|
+
- `AskAiBot` 在折叠状态下调用 `sendMessage()` 时,会先自动展开再发送
|
|
199
|
+
|
|
200
|
+
### `ChatBot` 示例
|
|
201
|
+
|
|
202
|
+
```vue
|
|
203
|
+
<script setup lang="ts">
|
|
204
|
+
import { ref } from 'vue'
|
|
205
|
+
import { ChatBot, type AiBotPublicApi, type PromptInputAttachment } from 'langgraph-vue3-chatbot'
|
|
206
|
+
|
|
207
|
+
const chatBotRef = ref<AiBotPublicApi | null>(null)
|
|
208
|
+
|
|
209
|
+
function askWithAttachment() {
|
|
210
|
+
chatBotRef.value?.setTextInput('请帮我分析这个附件')
|
|
211
|
+
|
|
212
|
+
const attachments: PromptInputAttachment[] = [
|
|
213
|
+
{
|
|
214
|
+
type: 'file_url',
|
|
215
|
+
url: 'https://example.com/report.pdf',
|
|
216
|
+
filename: 'report.pdf',
|
|
217
|
+
mediaType: 'application/pdf'
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
|
|
221
|
+
chatBotRef.value?.addAttachments(attachments)
|
|
222
|
+
chatBotRef.value?.sendMessage()
|
|
223
|
+
}
|
|
224
|
+
</script>
|
|
225
|
+
|
|
226
|
+
<template>
|
|
227
|
+
<button @click="askWithAttachment">
|
|
228
|
+
发送预设问题
|
|
229
|
+
</button>
|
|
230
|
+
|
|
231
|
+
<div style="height: 600px; margin-top: 12px;">
|
|
232
|
+
<ChatBot
|
|
233
|
+
ref="chatBotRef"
|
|
234
|
+
assistant-id="research"
|
|
235
|
+
assistant-name="AI 助手"
|
|
236
|
+
api-url="http://localhost:2024"
|
|
237
|
+
/>
|
|
238
|
+
</div>
|
|
239
|
+
</template>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### `AskAiBot` 示例
|
|
243
|
+
|
|
244
|
+
```vue
|
|
245
|
+
<script setup lang="ts">
|
|
246
|
+
import { ref } from 'vue'
|
|
247
|
+
import { AskAiBot, type AskAiBotPublicApi } from 'langgraph-vue3-chatbot'
|
|
248
|
+
|
|
249
|
+
const askAiBotRef = ref<AskAiBotPublicApi | null>(null)
|
|
250
|
+
|
|
251
|
+
function quickAsk() {
|
|
252
|
+
askAiBotRef.value?.setTextInput('帮我总结今天的待办')
|
|
253
|
+
askAiBotRef.value?.sendMessage()
|
|
254
|
+
}
|
|
255
|
+
</script>
|
|
256
|
+
|
|
257
|
+
<template>
|
|
258
|
+
<button @click="quickAsk">
|
|
259
|
+
唤起并发送
|
|
260
|
+
</button>
|
|
261
|
+
|
|
262
|
+
<AskAiBot
|
|
263
|
+
ref="askAiBotRef"
|
|
264
|
+
assistant-id="research"
|
|
265
|
+
assistant-name="AI 助手"
|
|
266
|
+
api-url="http://localhost:2024"
|
|
267
|
+
/>
|
|
268
|
+
</template>
|
|
269
|
+
```
|
|
270
|
+
|
|
187
271
|
## Slots
|
|
188
272
|
|
|
189
273
|
### AskAiBot
|
|
@@ -25,7 +25,11 @@ type __VLS_Slots = {
|
|
|
25
25
|
}) => any;
|
|
26
26
|
'attachment-trigger'?: (props: AttachmentTriggerSlotProps) => any;
|
|
27
27
|
};
|
|
28
|
-
declare const __VLS_component: import("vue").DefineComponent<Props, {
|
|
28
|
+
declare const __VLS_component: import("vue").DefineComponent<Props, {
|
|
29
|
+
setTextInput: (text: string) => void;
|
|
30
|
+
addAttachments: (attachments: import("./index.ts").PromptInputAttachment[]) => void;
|
|
31
|
+
sendMessage: (options?: import("./index.ts").AiBotVisibilityOptions) => Promise<void>;
|
|
32
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
29
33
|
height: number | string;
|
|
30
34
|
width: number | string;
|
|
31
35
|
theme: AiBotTheme;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AskAiBot.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ai-bot/AskAiBot.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AskAiBot.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ai-bot/AskAiBot.vue"],"names":[],"mappings":"AA2NA,OAAO,KAAK,EAAqC,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AACtG,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAM7C,UAAU,KAAK;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,KAAK,CAAC,EAAE,UAAU,CAAA;CACnB;AAiBD,KAAK,WAAW,GAAG;IACjB,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAA;KAAE,KAAK,GAAG,CAAA;IACtF,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,aAAa,EAAE,aAAa,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,KAAK,GAAG,CAAA;IAClF,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,0BAA0B,KAAK,GAAG,CAAA;CAClE,CAAC;AAqPF,QAAA,MAAM,eAAe;;;yBAhSrB,CAjLyC;;YAqM9B,MAAM,GAAG,MAAM;WADhB,MAAM,GAAG,MAAM;WAEf,UAAU;iBALJ,MAAM,EAAE;YACb,MAAM;iBAPD,MAAM;mBACJ,MAAM;kBAEP,MAAM;YAEZ,MAAM;YAGN,MAAM;qBANG,OAAO;4EA4RzB,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAa1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -23,7 +23,11 @@ type __VLS_Slots = {
|
|
|
23
23
|
}) => any;
|
|
24
24
|
'attachment-trigger'?: (props: AttachmentTriggerSlotProps) => any;
|
|
25
25
|
};
|
|
26
|
-
declare const __VLS_component: import("vue").DefineComponent<Props, {
|
|
26
|
+
declare const __VLS_component: import("vue").DefineComponent<Props, {
|
|
27
|
+
setTextInput: (text: string) => void;
|
|
28
|
+
addAttachments: (attachments: import("./index.ts").PromptInputAttachment[]) => void;
|
|
29
|
+
sendMessage: (options?: import("./index.ts").AiBotVisibilityOptions) => Promise<void>;
|
|
30
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
27
31
|
close: () => any;
|
|
28
32
|
"update:isMaximized": (value: boolean) => any;
|
|
29
33
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBot.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ai-bot/ChatBot.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatBot.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ai-bot/ChatBot.vue"],"names":[],"mappings":"AAm6BA,OAAO,KAAK,EAAiC,0BAA0B,EAAsB,MAAM,mBAAmB,CAAA;AACtH,OAAO,KAAK,EAA2B,QAAQ,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAgB7C,UAAU,KAAK;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,UAAU,CAAA;CACnB;AAeD,KAAK,WAAW,GAAG;IACjB,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAA;KAAE,KAAK,GAAG,CAAA;IACtF,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,aAAa,EAAE,aAAa,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,KAAK,GAAG,CAAA;IAClF,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,0BAA0B,KAAK,GAAG,CAAA;CAClE,CAAC;AAq+BF,QAAA,MAAM,eAAe;;;yBAthCrB,CAt4BY;;;;;;;;uBA+5BU,OAAO;WAInB,UAAU;iBAHJ,MAAM,EAAE;YACb,MAAM;iBAPD,MAAM;mBACJ,MAAM;kBACP,MAAM;YAEZ,MAAM;YAIN,MAAM;4EAmgCf,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAa1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChatStatus } from './lib/message-types';
|
|
2
|
-
import type { AttachmentFile, AttachmentTriggerSlotProps } from './lib/input-types';
|
|
2
|
+
import type { AttachmentFile, AttachmentTriggerSlotProps, PromptInputAttachment } from './lib/input-types';
|
|
3
3
|
import { type ModelInfo } from './lib/models';
|
|
4
4
|
interface Props {
|
|
5
5
|
status: ChatStatus;
|
|
@@ -15,7 +15,11 @@ type __VLS_Slots = {
|
|
|
15
15
|
type __VLS_PublicProps = __VLS_Props & {
|
|
16
16
|
'modelSelectorOpen'?: boolean;
|
|
17
17
|
};
|
|
18
|
-
declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
18
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
19
|
+
setTextInput: (text: string) => void;
|
|
20
|
+
addAttachments: (attachments: PromptInputAttachment[]) => void;
|
|
21
|
+
sendMessage: (options?: import("./index.ts").AiBotVisibilityOptions) => Promise<void>;
|
|
22
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
19
23
|
stop: () => any;
|
|
20
24
|
submit: (message: {
|
|
21
25
|
text: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatInput.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ai-bot/ChatInput.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatInput.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ai-bot/ChatInput.vue"],"names":[],"mappings":"AA+jBA,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAGnE,OAAO,KAAK,EAAiB,cAAc,EAAE,0BAA0B,EAAE,qBAAqB,EAAsB,MAAM,mBAAmB,CAAA;AAC7I,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAQrE,UAAU,KAAK;IACb,MAAM,EAAE,UAAU,CAAA;IAClB,YAAY,EAAE,SAAS,GAAG,IAAI,CAAA;IAC9B,MAAM,EAAE,SAAS,EAAE,CAAA;IACnB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,KAAK,WAAW,GAAG,KAAK,CAAC;AAczB,KAAK,WAAW,GAAG;IACjB,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,0BAA0B,KAAK,GAAG,CAAA;CAClE,CAAC;AAuVF,KAAK,iBAAiB,GAAG,WAAW,GAAG;IACvC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAsdF,QAAA,MAAM,eAAe;;;yBAp1BrB,CAtiBiB;;;;cA+jBW,MAAM;eAAS,cAAc,EAAE;;;;;;;;;cAA/B,MAAM;eAAS,cAAc,EAAE;;;;;;kFAm0BzD,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAQ1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|