@blueking/chat-helper 0.0.1-beta.1

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 (51) hide show
  1. package/README.md +1112 -0
  2. package/dist/agent/index.d.ts +2 -0
  3. package/dist/agent/index.ts.js +26 -0
  4. package/dist/agent/type.d.ts +87 -0
  5. package/dist/agent/type.ts.js +25 -0
  6. package/dist/agent/use-agent.d.ts +540 -0
  7. package/dist/agent/use-agent.ts.js +102 -0
  8. package/dist/event/ag-ui.d.ts +137 -0
  9. package/dist/event/ag-ui.ts.js +434 -0
  10. package/dist/event/index.d.ts +2 -0
  11. package/dist/event/index.ts.js +26 -0
  12. package/dist/event/type.d.ts +329 -0
  13. package/dist/event/type.ts.js +64 -0
  14. package/dist/http/fetch/fetch.d.ts +84 -0
  15. package/dist/http/fetch/fetch.ts.js +503 -0
  16. package/dist/http/fetch/index.d.ts +6 -0
  17. package/dist/http/fetch/index.ts.js +41 -0
  18. package/dist/http/index.d.ts +38 -0
  19. package/dist/http/index.ts.js +36 -0
  20. package/dist/http/module/agent.d.ts +9 -0
  21. package/dist/http/module/agent.ts.js +36 -0
  22. package/dist/http/module/index.d.ts +36 -0
  23. package/dist/http/module/index.ts.js +41 -0
  24. package/dist/http/module/message.d.ts +14 -0
  25. package/dist/http/module/message.ts.js +52 -0
  26. package/dist/http/module/session.d.ts +25 -0
  27. package/dist/http/module/session.ts.js +67 -0
  28. package/dist/http/transform/agent.d.ts +7 -0
  29. package/dist/http/transform/agent.ts.js +71 -0
  30. package/dist/http/transform/index.d.ts +3 -0
  31. package/dist/http/transform/index.ts.js +27 -0
  32. package/dist/http/transform/message.d.ts +13 -0
  33. package/dist/http/transform/message.ts.js +155 -0
  34. package/dist/http/transform/session.d.ts +37 -0
  35. package/dist/http/transform/session.ts.js +100 -0
  36. package/dist/index.d.ts +3363 -0
  37. package/dist/index.ts.js +40 -0
  38. package/dist/message/index.d.ts +2 -0
  39. package/dist/message/index.ts.js +26 -0
  40. package/dist/message/type.d.ts +277 -0
  41. package/dist/message/type.ts.js +67 -0
  42. package/dist/message/use-message.d.ts +912 -0
  43. package/dist/message/use-message.ts.js +87 -0
  44. package/dist/session/index.d.ts +2 -0
  45. package/dist/session/index.ts.js +26 -0
  46. package/dist/session/type.d.ts +61 -0
  47. package/dist/session/type.ts.js +25 -0
  48. package/dist/session/use-session.d.ts +1898 -0
  49. package/dist/session/use-session.ts.js +144 -0
  50. package/dist/type.d.ts +14 -0
  51. package/package.json +27 -0
@@ -0,0 +1,100 @@
1
+ /*
2
+ * Tencent is pleased to support the open source community by making
3
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) available.
4
+ *
5
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
6
+ *
7
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.
8
+ *
9
+ * License for 蓝鲸智云PaaS平台 (BlueKing PaaS):
10
+ *
11
+ * ---------------------------------------------------
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
14
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
18
+ * the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
21
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
+ * IN THE SOFTWARE.
25
+ */ /**
26
+ * 将 API 返回的 session 数据转换为前端使用的 session 数据
27
+ * @param data API 返回的 session 数据
28
+ * @returns 前端使用的 session 数据
29
+ */ export const transferSessionApi2Session = (data)=>{
30
+ var _data_session_property, _data_session_property1;
31
+ return {
32
+ sessionCode: data.session_code,
33
+ sessionName: data.session_name,
34
+ isTemporary: data.is_temporary,
35
+ model: data.model,
36
+ updatedAt: data.updated_at,
37
+ createdAt: data.created_at,
38
+ roleInfo: data.role_info ? {
39
+ collectionId: data.role_info.collection_id,
40
+ collectionName: data.role_info.collection_name,
41
+ content: data.role_info.content,
42
+ variables: data.role_info.variables
43
+ } : undefined,
44
+ sessionProperty: {
45
+ isAutoClear: (_data_session_property = data.session_property) === null || _data_session_property === void 0 ? void 0 : _data_session_property.is_auto_clear,
46
+ isAutoCalcPrompt: (_data_session_property1 = data.session_property) === null || _data_session_property1 === void 0 ? void 0 : _data_session_property1.is_auto_clac_prompt
47
+ }
48
+ };
49
+ };
50
+ /**
51
+ * 将前端使用的 session 数据转换为 API 使用的 session 数据
52
+ * @param data 前端使用的 session 数据
53
+ * @returns API 使用的 session 数据
54
+ */ export const transferSession2SessionApi = (data)=>{
55
+ var _data_sessionProperty, _data_sessionProperty1;
56
+ return {
57
+ session_code: data.sessionCode,
58
+ session_name: data.sessionName,
59
+ is_temporary: data.isTemporary,
60
+ model: data.model || undefined,
61
+ updated_at: data.updatedAt,
62
+ created_at: data.createdAt,
63
+ role_info: data.roleInfo ? {
64
+ collection_id: data.roleInfo.collectionId,
65
+ collection_name: data.roleInfo.collectionName,
66
+ content: data.roleInfo.content,
67
+ variables: data.roleInfo.variables
68
+ } : undefined,
69
+ session_property: {
70
+ is_auto_clear: (_data_sessionProperty = data.sessionProperty) === null || _data_sessionProperty === void 0 ? void 0 : _data_sessionProperty.isAutoClear,
71
+ is_auto_clac_prompt: (_data_sessionProperty1 = data.sessionProperty) === null || _data_sessionProperty1 === void 0 ? void 0 : _data_sessionProperty1.isAutoCalcPrompt
72
+ }
73
+ };
74
+ };
75
+ /**
76
+ * 将前端使用的 session 反馈数据转换为 API 使用的 session 反馈数据
77
+ * @param data 前端使用的 session 反馈数据
78
+ * @returns API 使用的 session 反馈数据
79
+ */ export const transferSessionFeedback2SessionFeedbackApi = (data)=>{
80
+ return {
81
+ session_code: data.sessionCode,
82
+ session_content_ids: data.sessionContentIds,
83
+ rate: data.rate,
84
+ comment: data.comment,
85
+ labels: data.labels
86
+ };
87
+ };
88
+ /**
89
+ * 将 API 返回的 session 反馈数据转换为前端使用的 session 反馈数据
90
+ * @param data API 返回的 session 反馈数据
91
+ * @returns 前端使用的 session 反馈数据
92
+ */ export const transferSessionFeedbackApi2SessionFeedback = (data)=>{
93
+ return {
94
+ sessionCode: data.session_code,
95
+ sessionContentIds: data.session_content_ids,
96
+ rate: data.rate,
97
+ comment: data.comment,
98
+ labels: data.lables
99
+ };
100
+ };