@blueking/ai-blueking 0.3.18 → 0.3.20

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
@@ -50,6 +50,41 @@ interface ISendData {
50
50
  }
51
51
  ```
52
52
 
53
+ 以下展示了如何处理新的 handleSend 回调,完整示例请参考 [Stream 模式](#stream-模式-vue3)
54
+
55
+ ```typescript
56
+ const handleSend = (args: ISendData) => {
57
+ // 记录当前消息记录
58
+ const chatHistory = [...messages.value];
59
+
60
+ // 添加用户消息
61
+ messages.value.push({
62
+ role: 'user',
63
+ content: args.content,
64
+ cite: args.cite,
65
+ });
66
+
67
+ // 根据参数构造输入内容
68
+ const input = args.prompt
69
+ ? args.prompt // 如果有 prompt,直接使用
70
+ : args.cite
71
+ ? `${args.content}: ${args.cite}` // 如果有 cite,拼接 content 和 cite
72
+ : args.content; // 否则只使用 content
73
+
74
+ // 调用 AI 流式对话
75
+ // 注:id 是唯一标识当前流,调用 chatHelper.stop 时需要传入
76
+ chatHelper.stream(
77
+ {
78
+ inputs: {
79
+ input,
80
+ chat_history: chatHistory,
81
+ },
82
+ },
83
+ 1,
84
+ );
85
+ };
86
+ ```
87
+
53
88
  ### 模板渲染
54
89
 
55
90
  #### 知识库列表渲染