@blueking/ai-blueking 0.1.5-beta.1 → 0.1.5

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.
Files changed (2) hide show
  1. package/README.md +22 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -64,13 +64,29 @@ npm i @blueking/ai-blueking
64
64
 
65
65
  // 错误处理
66
66
  const handleError = (message: string, code: string, id: number | string) => {
67
- const currentMessage = messages.value.at(-1);
68
- currentMessage.status = 'error';
69
- currentMessage.content = message;
70
- loading.value = false;
67
+ if (message.includes('user authentication failed')) {
68
+ // 未登录,跳转登录
69
+ const loginUrl = new URL(process.env.BK_LOGIN_URL);
70
+ loginUrl.searchParams.append('c_url', location.origin);
71
+ window.location.href = loginUrl.href;
72
+ } else {
73
+ // 处理错误消息
74
+ const currentMessage = messages.value.at(-1);
75
+ currentMessage.status = 'fail';
76
+ currentMessage.content = message;
77
+ loading.value = false;
78
+ }
71
79
  };
72
80
 
73
- const chatHelper = new ChatHelper('<接口地址>', handleStart, handleReceiveMessage, handleEnd, handleError);
81
+ // 需要将 <网关名> 替换成插件部署后生成的网关名
82
+ const prefix = process.env.BK_API_URL_TMPL.replace('{api_name}', '<网关名>').replace('http', 'https');
83
+ const chatHelper = new ChatHelper(
84
+ `${prefix}/prod/bk_plugin/plugin_api/assistant/`,
85
+ handleStart,
86
+ handleReceiveMessage,
87
+ handleEnd,
88
+ handleError,
89
+ );
74
90
 
75
91
  // 清空消息
76
92
  const handleClear = () => {
@@ -90,6 +106,7 @@ npm i @blueking/ai-blueking
90
106
  chatHelper.stream(
91
107
  {
92
108
  inputs: {
109
+ input: message,
93
110
  chat_history: chatHistory,
94
111
  },
95
112
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/ai-blueking",
3
- "version": "0.1.5-beta.1",
3
+ "version": "0.1.5",
4
4
  "description": "AI 小鲸",
5
5
  "license": "MIT",
6
6
  "author": "Tencent BlueKing",