@blueking/ai-blueking 0.3.0 → 0.3.2

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 CHANGED
@@ -1,5 +1,77 @@
1
1
  # AI 小鲸使用指南
2
2
 
3
+
4
+ ## 新特性
5
+
6
+ - 支持 popup 弹框唤起
7
+ - 支持引用提问功能
8
+ - 支持快捷提问(当前支持翻译、解释功能)
9
+
10
+ ## 0.3.0 重大变更(Breaking Changes)
11
+
12
+ ### 1. 组件显示/隐藏方式变更
13
+
14
+ - 不再使用 `v-if` 控制组件显示
15
+ - 需要定义一个变量并使用 `v-model:is-show` 绑定到组件
16
+
17
+ ### 2. handleSend 回调参数变更
18
+
19
+ 回调函数现在接收一个对象参数,而不是简单的字符串。参数格式如下:
20
+
21
+ ```typescript
22
+ interface ISendData {
23
+ content: string; // 用户输入的内容
24
+ cite?: string; // 引用的内容(可选)
25
+ prompt?: string; // 使用的 prompt 模板(可选)
26
+ }
27
+ ```
28
+
29
+ ## 使用示例
30
+
31
+ 以下展示了如何处理新的 handleSend 回调:
32
+
33
+ ```typescript
34
+ const handleSend = (args: ISendData) => {
35
+ // 记录当前消息记录
36
+ const chatHistory = [...messages.value];
37
+
38
+ // 添加用户消息
39
+ messages.value.push({
40
+ role: 'user',
41
+ content: args.content,
42
+ cite: args.cite,
43
+ });
44
+
45
+ // 根据参数构造输入内容
46
+ const input = args.prompt
47
+ ? args.prompt // 如果有 prompt,直接使用
48
+ : args.cite
49
+ ? `${args.content}: ${args.cite}` // 如果有 cite,拼接 content 和 cite
50
+ : args.content; // 否则只使用 content
51
+
52
+ // 调用 AI 流式对话
53
+ // 注:id 是唯一标识当前流,调用 chatHelper.stop 时需要传入
54
+ chatHelper.stream(
55
+ {
56
+ inputs: {
57
+ input,
58
+ chat_history: chatHistory,
59
+ },
60
+ },
61
+ 1,
62
+ );
63
+ };
64
+ ```
65
+
66
+ ## 注意事项
67
+
68
+ - 使用 `v-model:is-show` 时需要提前定义对应的响应式变量
69
+ - 处理 handleSend 回调时需要注意新的参数格式
70
+ - 在调用 `chatHelper.stop` 方法时需要传入正确的流 ID
71
+
72
+
73
+
74
+
3
75
  ## 安装
4
76
 
5
77
  ```bash
@@ -50,6 +122,7 @@ npm i @blueking/ai-blueking
50
122
  ```vue
51
123
  <template>
52
124
  <AIBlueking
125
+ v-model:is-show="isShow"
53
126
  :loading="loading"
54
127
  :messages="messages"
55
128
  @clear="handleClear"
@@ -71,6 +144,7 @@ npm i @blueking/ai-blueking
71
144
 
72
145
  const loading = ref(false);
73
146
  const messages = ref([]);
147
+ const isShow = ref(false);
74
148
 
75
149
  // 聊天开始
76
150
  const handleStart = (id: number | string) => {