@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,87 @@
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
+ */ import { ref } from 'vue';
26
+ import { MessageRole, MessageStatus } from './type.ts.js';
27
+ /**
28
+ * 使用消息模块,主要做业务的组合
29
+ * @param http - HTTP 模块
30
+ * @returns 消息模块
31
+ */ export const useMessage = (http)=>{
32
+ const list = ref([]);
33
+ const isListLoading = ref(false);
34
+ const isDeleteLoading = ref(false);
35
+ const isBatchDeleteLoading = ref(false);
36
+ const getMessages = (sessionCode)=>{
37
+ isListLoading.value = true;
38
+ return http.message.getMessages(sessionCode).then((res)=>{
39
+ list.value = res;
40
+ }).finally(()=>{
41
+ isListLoading.value = false;
42
+ });
43
+ };
44
+ const plusMessage = (message)=>{
45
+ list.value.push(message);
46
+ };
47
+ const modifyMessage = (message)=>{
48
+ list.value = list.value.map((item)=>item.id === message.id ? message : item);
49
+ };
50
+ const getCurrentLoadingMessage = ()=>{
51
+ return list.value.findLast((item)=>[
52
+ MessageStatus.Pending,
53
+ MessageStatus.Streaming
54
+ ].includes(item.status) && item.role === MessageRole.Assistant);
55
+ };
56
+ const getMessageById = (id)=>{
57
+ return list.value.find((item)=>item.id === id);
58
+ };
59
+ const deleteMessage = (id)=>{
60
+ isDeleteLoading.value = true;
61
+ return http.message.deleteMessage(id).then(()=>{
62
+ list.value = list.value.filter((item)=>item.id !== id);
63
+ }).finally(()=>{
64
+ isDeleteLoading.value = false;
65
+ });
66
+ };
67
+ const batchDeleteMessages = (ids)=>{
68
+ isBatchDeleteLoading.value = true;
69
+ return http.message.batchDeleteMessages(ids).then(()=>{
70
+ list.value = list.value.filter((item)=>!ids.includes(item.id));
71
+ }).finally(()=>{
72
+ isBatchDeleteLoading.value = false;
73
+ });
74
+ };
75
+ return {
76
+ list,
77
+ isListLoading,
78
+ isDeleteLoading,
79
+ getMessages,
80
+ getCurrentLoadingMessage,
81
+ getMessageById,
82
+ plusMessage,
83
+ modifyMessage,
84
+ deleteMessage,
85
+ batchDeleteMessages
86
+ };
87
+ };
@@ -0,0 +1,2 @@
1
+ export * from './type';
2
+ export * from './use-session';
@@ -0,0 +1,26 @@
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
+ */ export * from './type.ts.js';
26
+ export * from './use-session.ts.js';
@@ -0,0 +1,61 @@
1
+ import type { IMessage } from '../message';
2
+ export interface ISession<ITool = unknown, IAnchorPathResources = unknown> {
3
+ anchorPathResources?: IAnchorPathResources;
4
+ createdAt?: string;
5
+ isTemporary?: boolean;
6
+ model?: string;
7
+ sessionCode: string;
8
+ sessionName: string;
9
+ tools?: ITool[];
10
+ updatedAt?: string;
11
+ roleInfo?: {
12
+ collectionId: number;
13
+ collectionName: string;
14
+ content: IMessage[];
15
+ variables: {
16
+ name: string;
17
+ value: IMessage[] | string;
18
+ }[];
19
+ };
20
+ sessionProperty?: {
21
+ isAutoCalcPrompt?: boolean;
22
+ isAutoClear?: boolean;
23
+ };
24
+ }
25
+ export interface ISessionApi<IToolApi = unknown, IAnchorPathResourcesApi = unknown> {
26
+ anchor_path_resources?: IAnchorPathResourcesApi;
27
+ created_at?: string;
28
+ is_temporary?: boolean;
29
+ model?: string;
30
+ session_code: string;
31
+ session_name: string;
32
+ tools?: IToolApi[];
33
+ updated_at?: string;
34
+ role_info?: {
35
+ collection_id: number;
36
+ collection_name: string;
37
+ content: IMessage[];
38
+ variables: {
39
+ name: string;
40
+ value: IMessage[] | string;
41
+ }[];
42
+ };
43
+ session_property?: {
44
+ is_auto_clac_prompt?: boolean;
45
+ is_auto_clear?: boolean;
46
+ };
47
+ }
48
+ export interface ISessionFeedback {
49
+ comment: string;
50
+ labels: string[];
51
+ rate: number;
52
+ sessionCode: string;
53
+ sessionContentIds: number[];
54
+ }
55
+ export interface ISessionFeedbackApi {
56
+ comment: string;
57
+ lables: string[];
58
+ rate: number;
59
+ session_code: string;
60
+ session_content_ids: number[];
61
+ }
@@ -0,0 +1,25 @@
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
+ */ export { };