@blueking/chat-helper 0.0.1-beta.3 → 0.0.1-beta.31
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 +962 -63
- package/dist/agent/type.d.ts +27 -2
- package/dist/agent/type.ts.js +1 -1
- package/dist/agent/use-agent.d.ts +516 -434
- package/dist/agent/use-agent.ts.js +224 -25
- package/dist/event/ag-ui.d.ts +39 -7
- package/dist/event/ag-ui.ts.js +224 -150
- package/dist/event/type.d.ts +99 -107
- package/dist/event/type.ts.js +34 -11
- package/dist/http/fetch/fetch.d.ts +40 -36
- package/dist/http/fetch/fetch.ts.js +59 -32
- package/dist/http/fetch/index.d.ts +1 -0
- package/dist/http/fetch/index.ts.js +17 -1
- package/dist/http/index.d.ts +25 -16
- package/dist/http/index.ts.js +60 -3
- package/dist/http/module/agent.d.ts +2 -2
- package/dist/http/module/index.d.ts +23 -16
- package/dist/http/module/index.ts.js +2 -1
- package/dist/http/module/message.d.ts +23 -7
- package/dist/http/module/message.ts.js +52 -7
- package/dist/http/module/session.d.ts +14 -11
- package/dist/http/module/session.ts.js +66 -4
- package/dist/http/transform/agent.ts.js +11 -8
- package/dist/http/transform/message.d.ts +6 -6
- package/dist/http/transform/message.ts.js +568 -118
- package/dist/http/transform/session.ts.js +9 -1
- package/dist/index.d.ts +2996 -2616
- package/dist/index.ts.js +26 -5
- package/dist/mediator/index.d.ts +2 -0
- package/dist/mediator/index.ts.js +26 -0
- package/dist/mediator/type.d.ts +50 -0
- package/dist/mediator/type.ts.js +28 -0
- package/dist/mediator/use-mediator.d.ts +7 -0
- package/dist/mediator/use-mediator.ts.js +47 -0
- package/dist/message/type.d.ts +280 -140
- package/dist/message/type.ts.js +16 -15
- package/dist/message/use-message.d.ts +837 -750
- package/dist/message/use-message.ts.js +226 -28
- package/dist/session/type.d.ts +10 -0
- package/dist/session/use-session.d.ts +1921 -1721
- package/dist/session/use-session.ts.js +198 -33
- package/dist/type.d.ts +4 -4
- package/package.json +2 -1
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import type { ISession, ISessionFeedback } from '../../session/type';
|
|
2
|
-
import type { FetchClient,
|
|
2
|
+
import type { FetchClient, IRequestConfig } from '../fetch';
|
|
3
3
|
/**
|
|
4
4
|
* session 相关 http 接口
|
|
5
5
|
* @param fetchClient - 请求客户端
|
|
6
6
|
* @returns session 相关 http 接口
|
|
7
7
|
*/
|
|
8
8
|
export declare const useSession: (fetchClient: FetchClient) => {
|
|
9
|
-
clearSession: (sessionCode: string, config?:
|
|
10
|
-
getSessions: (config?:
|
|
11
|
-
plusSession: (data: ISession, config?:
|
|
12
|
-
modifySession: (data: ISession, config?:
|
|
13
|
-
deleteSession: (sessionCode: string, config?:
|
|
14
|
-
batchDeleteSessions: (sessionCodes: string[], config?:
|
|
15
|
-
getSession: (sessionCode: string, config?:
|
|
16
|
-
postSessionFeedback: (data: ISessionFeedback, config?:
|
|
9
|
+
clearSession: (sessionCode: string, config?: IRequestConfig) => Promise<unknown>;
|
|
10
|
+
getSessions: (config?: IRequestConfig) => Promise<ISession<unknown, unknown>[]>;
|
|
11
|
+
plusSession: (data: ISession, config?: IRequestConfig) => Promise<ISession<unknown, unknown>>;
|
|
12
|
+
modifySession: (data: ISession, config?: IRequestConfig) => Promise<ISession<unknown, unknown>>;
|
|
13
|
+
deleteSession: (sessionCode: string, config?: IRequestConfig) => Promise<unknown>;
|
|
14
|
+
batchDeleteSessions: (sessionCodes: string[], config?: IRequestConfig) => Promise<number>;
|
|
15
|
+
getSession: (sessionCode: string, config?: IRequestConfig) => Promise<ISession<unknown, unknown>>;
|
|
16
|
+
postSessionFeedback: (data: ISessionFeedback, config?: IRequestConfig) => Promise<{
|
|
17
17
|
sessionCode: string;
|
|
18
18
|
sessionContentIds: number[];
|
|
19
19
|
rate: number;
|
|
20
20
|
comment: string;
|
|
21
21
|
labels: string[];
|
|
22
22
|
}>;
|
|
23
|
-
|
|
24
|
-
renameSession: (sessionCode: string, config?:
|
|
23
|
+
getSessionFeedbackReasons: (rate: number, config?: IRequestConfig) => Promise<string[]>;
|
|
24
|
+
renameSession: (sessionCode: string, config?: IRequestConfig) => Promise<ISession<unknown, unknown>>;
|
|
25
|
+
uploadFile: (sessionCode: string, file: File, config?: IRequestConfig) => Promise<{
|
|
26
|
+
download_url?: string;
|
|
27
|
+
}>;
|
|
25
28
|
};
|
|
@@ -22,7 +22,59 @@
|
|
|
22
22
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
23
23
|
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
24
24
|
* IN THE SOFTWARE.
|
|
25
|
-
*/
|
|
25
|
+
*/ function _define_property(obj, key, value) {
|
|
26
|
+
if (key in obj) {
|
|
27
|
+
Object.defineProperty(obj, key, {
|
|
28
|
+
value: value,
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
obj[key] = value;
|
|
35
|
+
}
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
function _object_spread(target) {
|
|
39
|
+
for(var i = 1; i < arguments.length; i++){
|
|
40
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
41
|
+
var ownKeys = Object.keys(source);
|
|
42
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
43
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
44
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
ownKeys.forEach(function(key) {
|
|
48
|
+
_define_property(target, key, source[key]);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
function ownKeys(object, enumerableOnly) {
|
|
54
|
+
var keys = Object.keys(object);
|
|
55
|
+
if (Object.getOwnPropertySymbols) {
|
|
56
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
57
|
+
if (enumerableOnly) {
|
|
58
|
+
symbols = symbols.filter(function(sym) {
|
|
59
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
keys.push.apply(keys, symbols);
|
|
63
|
+
}
|
|
64
|
+
return keys;
|
|
65
|
+
}
|
|
66
|
+
function _object_spread_props(target, source) {
|
|
67
|
+
source = source != null ? source : {};
|
|
68
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
69
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
70
|
+
} else {
|
|
71
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
72
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return target;
|
|
76
|
+
}
|
|
77
|
+
import { transferSession2SessionApi, transferSessionApi2Session, transferSessionFeedback2SessionFeedbackApi, transferSessionFeedbackApi2SessionFeedback } from '../transform/session.ts.js';
|
|
26
78
|
/**
|
|
27
79
|
* session 相关 http 接口
|
|
28
80
|
* @param fetchClient - 请求客户端
|
|
@@ -47,11 +99,20 @@
|
|
|
47
99
|
// 提交会话反馈
|
|
48
100
|
const postSessionFeedback = (data, config)=>fetchClient.post(`session_feedback/`, transferSessionFeedback2SessionFeedbackApi(data), config).then((res)=>transferSessionFeedbackApi2SessionFeedback(res));
|
|
49
101
|
// 获取反馈标签列表
|
|
50
|
-
const
|
|
102
|
+
const getSessionFeedbackReasons = (rate, config)=>fetchClient.get(`session_feedback/reasons/`, {
|
|
51
103
|
rate
|
|
52
104
|
}, config);
|
|
53
105
|
// 会话重命名
|
|
54
106
|
const renameSession = (sessionCode, config)=>fetchClient.post(`session/${sessionCode}/ai_rename/`, undefined, config).then((res)=>transferSessionApi2Session(res));
|
|
107
|
+
// 上传文件到会话
|
|
108
|
+
const uploadFile = (sessionCode, file, config)=>{
|
|
109
|
+
const fileName = encodeURIComponent(file.name);
|
|
110
|
+
return file.arrayBuffer().then((content)=>fetchClient.post(`session/${sessionCode}/upload/${fileName}/`, content, _object_spread_props(_object_spread({}, config), {
|
|
111
|
+
headers: {
|
|
112
|
+
'Content-Disposition': `attachment; filename="${file.name}"`
|
|
113
|
+
}
|
|
114
|
+
})));
|
|
115
|
+
};
|
|
55
116
|
return {
|
|
56
117
|
clearSession,
|
|
57
118
|
getSessions,
|
|
@@ -61,7 +122,8 @@
|
|
|
61
122
|
batchDeleteSessions,
|
|
62
123
|
getSession,
|
|
63
124
|
postSessionFeedback,
|
|
64
|
-
|
|
65
|
-
renameSession
|
|
125
|
+
getSessionFeedbackReasons,
|
|
126
|
+
renameSession,
|
|
127
|
+
uploadFile
|
|
66
128
|
};
|
|
67
129
|
};
|
|
@@ -22,13 +22,12 @@
|
|
|
22
22
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
23
23
|
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
24
24
|
* IN THE SOFTWARE.
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
25
|
+
*/ /**
|
|
27
26
|
* 将 API 返回的 agent 信息数据转换为前端使用的 agent 信息数据
|
|
28
27
|
* @param data API 返回的 agent 信息数据
|
|
29
28
|
* @returns 前端使用的 agent 信息数据
|
|
30
29
|
*/ export const transferAgentInfoApi2AgentInfo = (data)=>{
|
|
31
|
-
var _data_conversation_settings, _data_conversation_settings1, _data_conversation_settings_commands, _data_conversation_settings2, _data_conversation_settings3
|
|
30
|
+
var _data_conversation_settings, _data_conversation_settings1, _data_conversation_settings_commands, _data_conversation_settings2, _data_conversation_settings3;
|
|
32
31
|
return {
|
|
33
32
|
conversationSettings: {
|
|
34
33
|
openingRemark: data === null || data === void 0 ? void 0 : (_data_conversation_settings = data.conversation_settings) === null || _data_conversation_settings === void 0 ? void 0 : _data_conversation_settings.opening_remark,
|
|
@@ -36,6 +35,7 @@
|
|
|
36
35
|
commands: data === null || data === void 0 ? void 0 : (_data_conversation_settings2 = data.conversation_settings) === null || _data_conversation_settings2 === void 0 ? void 0 : (_data_conversation_settings_commands = _data_conversation_settings2.commands) === null || _data_conversation_settings_commands === void 0 ? void 0 : _data_conversation_settings_commands.map((command)=>({
|
|
37
36
|
id: command.id,
|
|
38
37
|
name: command.name,
|
|
38
|
+
alias: command.alias,
|
|
39
39
|
icon: command.icon,
|
|
40
40
|
components: command.components.map((component)=>({
|
|
41
41
|
type: component.type,
|
|
@@ -53,19 +53,22 @@
|
|
|
53
53
|
})),
|
|
54
54
|
content: command.content,
|
|
55
55
|
agentId: command.agent_id,
|
|
56
|
-
status: command.status
|
|
56
|
+
status: command.status,
|
|
57
|
+
supportUpload: command.support_upload
|
|
57
58
|
})),
|
|
58
59
|
enableChatSession: data === null || data === void 0 ? void 0 : (_data_conversation_settings3 = data.conversation_settings) === null || _data_conversation_settings3 === void 0 ? void 0 : _data_conversation_settings3.enable_chat_session
|
|
59
60
|
},
|
|
60
|
-
promptSetting: {
|
|
61
|
-
content: data
|
|
62
|
-
|
|
61
|
+
promptSetting: (data === null || data === void 0 ? void 0 : data.prompt_setting) ? {
|
|
62
|
+
content: data.prompt_setting.content,
|
|
63
|
+
supportUpload: data.prompt_setting.support_upload
|
|
64
|
+
} : undefined,
|
|
63
65
|
agentName: data === null || data === void 0 ? void 0 : data.agent_name,
|
|
64
66
|
chatGroup: (data === null || data === void 0 ? void 0 : data.chat_group) ? {
|
|
65
67
|
enabled: data.chat_group.enabled,
|
|
66
68
|
staff: data.chat_group.staff,
|
|
67
69
|
username: data.chat_group.username
|
|
68
70
|
} : undefined,
|
|
69
|
-
saasUrl: data === null || data === void 0 ? void 0 : data.saas_url
|
|
71
|
+
saasUrl: data === null || data === void 0 ? void 0 : data.saas_url,
|
|
72
|
+
resources: data === null || data === void 0 ? void 0 : data.resources
|
|
70
73
|
};
|
|
71
74
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { IMessage, IMessageApi } from '../../message/type';
|
|
2
2
|
/**
|
|
3
|
-
* 将 API
|
|
4
|
-
* @param data API
|
|
5
|
-
* @returns
|
|
3
|
+
* 将 API 返回的消息数据转换为前端使用的消息数据
|
|
4
|
+
* @param data API 返回的消息数据
|
|
5
|
+
* @returns 前端使用的消息数据
|
|
6
6
|
*/
|
|
7
7
|
export declare const transferMessageApi2Message: (data: IMessageApi) => IMessage;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @param data
|
|
11
|
-
* @returns API
|
|
9
|
+
* 将前端使用的消息数据转换为 API 使用的消息数据
|
|
10
|
+
* @param data 前端使用的消息数据
|
|
11
|
+
* @returns API 使用的消息数据
|
|
12
12
|
*/
|
|
13
13
|
export declare const transferMessage2MessageApi: (data: IMessage) => IMessageApi;
|