@blueking/ai-blueking 0.2.15-beta.3 → 0.3.0
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 +22 -3
- package/dist/vue2/index.es.min.js +203 -202
- package/dist/vue2/index.iife.min.js +2 -2
- package/dist/vue2/index.umd.min.js +2 -2
- package/dist/vue2/style.css +1 -1
- package/dist/vue3/index.es.min.js +5 -4
- package/dist/vue3/index.iife.min.js +2 -2
- package/dist/vue3/index.umd.min.js +4 -4
- package/dist/vue3/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,6 +63,12 @@ npm i @blueking/ai-blueking
|
|
|
63
63
|
import AIBlueking, { ChatHelper, RoleType, MessageStatus } from '@blueking/ai-blueking';
|
|
64
64
|
import '@blueking/ai-blueking/dist/vue3/style.css';
|
|
65
65
|
|
|
66
|
+
interface ISendData {
|
|
67
|
+
content: string; // 用户输入的内容
|
|
68
|
+
cite?: string; // 引用的内容
|
|
69
|
+
prompt?: string; // 使用的 prompt 模板
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
const loading = ref(false);
|
|
67
73
|
const messages = ref([]);
|
|
68
74
|
|
|
@@ -131,19 +137,28 @@ npm i @blueking/ai-blueking
|
|
|
131
137
|
};
|
|
132
138
|
|
|
133
139
|
// 发送消息
|
|
134
|
-
const handleSend = (
|
|
140
|
+
const handleSend = (args: ISendData) => {
|
|
135
141
|
// 记录当前消息记录
|
|
136
142
|
const chatHistory = [...messages.value];
|
|
137
143
|
// 添加一条消息
|
|
138
144
|
messages.value.push({
|
|
139
145
|
role: 'user',
|
|
140
|
-
content:
|
|
146
|
+
content: args.content,
|
|
147
|
+
cite: args.cite,
|
|
141
148
|
});
|
|
149
|
+
|
|
150
|
+
// 根据参数构造输入内容
|
|
151
|
+
const input = args.prompt
|
|
152
|
+
? args.prompt // 如果有 prompt,直接使用
|
|
153
|
+
: args.cite
|
|
154
|
+
? `${args.content}: ${args.cite}` // 如果有 cite,拼接 content 和 cite
|
|
155
|
+
: args.content; // 否则只使用 content
|
|
156
|
+
|
|
142
157
|
// ai 消息,id是唯一标识当前流,调用 chatHelper.stop 的时候需要传入
|
|
143
158
|
chatHelper.stream(
|
|
144
159
|
{
|
|
145
160
|
inputs: {
|
|
146
|
-
input
|
|
161
|
+
input,
|
|
147
162
|
chat_history: chatHistory,
|
|
148
163
|
},
|
|
149
164
|
},
|
|
@@ -273,6 +288,10 @@ npm i @blueking/ai-blueking
|
|
|
273
288
|
|
|
274
289
|
const handleSend = (val: string) => {
|
|
275
290
|
console.log('trigger send', val);
|
|
291
|
+
// args 包含:
|
|
292
|
+
// - content: 用户输入的内容
|
|
293
|
+
// - cite: 引用的内容(可选)
|
|
294
|
+
// - prompt: 使用的 prompt 模板(可选)
|
|
276
295
|
};
|
|
277
296
|
|
|
278
297
|
const handleStop = () => {
|