@ai-group/chat-sdk 1.0.11 → 1.0.12

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 (114) hide show
  1. package/dist/cjs/components/DislikeFeedback.js +79 -0
  2. package/dist/cjs/components/DislikeFeedback.js.map +7 -0
  3. package/dist/cjs/components/FeedbackTags.js +62 -0
  4. package/dist/cjs/components/FeedbackTags.js.map +7 -0
  5. package/dist/cjs/components/XAiChatbot/index.js +5 -3
  6. package/dist/cjs/components/XAiChatbot/index.js.map +2 -2
  7. package/dist/cjs/components/XAiProvider/index.js +142 -45
  8. package/dist/cjs/components/XAiProvider/index.js.map +3 -3
  9. package/dist/cjs/hooks/useAgentGenerator.js +20 -25
  10. package/dist/cjs/hooks/useAgentGenerator.js.map +2 -2
  11. package/dist/cjs/services/api.js +15 -0
  12. package/dist/cjs/services/api.js.map +2 -2
  13. package/dist/cjs/types/XAiMessage.js.map +1 -1
  14. package/dist/esm/components/DislikeFeedback.js +97 -0
  15. package/dist/esm/components/DislikeFeedback.js.map +1 -0
  16. package/dist/esm/components/FeedbackTags.js +34 -0
  17. package/dist/esm/components/FeedbackTags.js.map +1 -0
  18. package/dist/esm/components/XAiChatbot/index.js +2 -2
  19. package/dist/esm/components/XAiChatbot/index.js.map +1 -1
  20. package/dist/esm/components/XAiProvider/index.js +215 -84
  21. package/dist/esm/components/XAiProvider/index.js.map +1 -1
  22. package/dist/esm/hooks/useAgentGenerator.js +3 -1
  23. package/dist/esm/hooks/useAgentGenerator.js.map +1 -1
  24. package/dist/esm/services/api.js +32 -0
  25. package/dist/esm/services/api.js.map +1 -1
  26. package/dist/esm/types/XAiMessage.js.map +1 -1
  27. package/dist/umd/chat-sdk.min.js +1 -1
  28. package/package.json +16 -13
  29. package/dist/cjs/assets/svg/AddChatIcon.d.ts +0 -3
  30. package/dist/cjs/client/base.d.ts +0 -9
  31. package/dist/cjs/client/restClient.d.ts +0 -0
  32. package/dist/cjs/client/wsClient.d.ts +0 -0
  33. package/dist/cjs/components/XAiChatbot/XAiChatbot.stories.d.ts +0 -10
  34. package/dist/cjs/components/XAiChatbot/index.d.ts +0 -9
  35. package/dist/cjs/components/XAiChatbot/styles.d.ts +0 -67
  36. package/dist/cjs/components/XAiConversations/XAiConversations.stories.d.ts +0 -6
  37. package/dist/cjs/components/XAiConversations/index.d.ts +0 -4
  38. package/dist/cjs/components/XAiConversations/styles.d.ts +0 -49
  39. package/dist/cjs/components/XAiProvider/XAiProvider.stories.d.ts +0 -8
  40. package/dist/cjs/components/XAiProvider/demo.styles.d.ts +0 -37
  41. package/dist/cjs/components/XAiProvider/index.d.ts +0 -4
  42. package/dist/cjs/components/XAiSDK.d.ts +0 -10
  43. package/dist/cjs/components/XAiSender/XAiSender.stories.d.ts +0 -6
  44. package/dist/cjs/components/XAiSender/index.d.ts +0 -4
  45. package/dist/cjs/components/XAiSender/styles.d.ts +0 -47
  46. package/dist/cjs/components/XAiWebSDKWrapper.d.ts +0 -9
  47. package/dist/cjs/constants/index.d.ts +0 -2
  48. package/dist/cjs/context/AiProviderContext.d.ts +0 -14
  49. package/dist/cjs/context/ThemeContext.d.ts +0 -20
  50. package/dist/cjs/hooks/useAgentGenerator.d.ts +0 -93
  51. package/dist/cjs/hooks/useEventStreamRequest.d.ts +0 -30
  52. package/dist/cjs/hooks/useProviderContext.d.ts +0 -33
  53. package/dist/cjs/hooks/useXAiSDK.d.ts +0 -14
  54. package/dist/cjs/index.d.ts +0 -10
  55. package/dist/cjs/services/api.d.ts +0 -130
  56. package/dist/cjs/styles/common.d.ts +0 -73
  57. package/dist/cjs/styles/markdown.d.ts +0 -3
  58. package/dist/cjs/types/XAiChatbot.d.ts +0 -156
  59. package/dist/cjs/types/XAiConversations.d.ts +0 -20
  60. package/dist/cjs/types/XAiMessage.d.ts +0 -108
  61. package/dist/cjs/types/XAiProvider.d.ts +0 -347
  62. package/dist/cjs/types/XAiSender.d.ts +0 -13
  63. package/dist/cjs/types/index.d.ts +0 -5
  64. package/dist/cjs/types/node.d.ts +0 -10
  65. package/dist/cjs/utils/chat.d.ts +0 -34
  66. package/dist/cjs/utils/index.d.ts +0 -2
  67. package/dist/cjs/utils/providerManager.d.ts +0 -22
  68. package/dist/cjs/utils/request.d.ts +0 -78
  69. package/dist/cjs/utils/request.example.d.ts +0 -39
  70. package/dist/cjs/utils/umdEntry.d.ts +0 -26
  71. package/dist/cjs/utils/workflowNode.d.ts +0 -2
  72. package/dist/esm/assets/svg/AddChatIcon.d.ts +0 -3
  73. package/dist/esm/client/base.d.ts +0 -9
  74. package/dist/esm/client/restClient.d.ts +0 -0
  75. package/dist/esm/client/wsClient.d.ts +0 -0
  76. package/dist/esm/components/XAiChatbot/XAiChatbot.stories.d.ts +0 -10
  77. package/dist/esm/components/XAiChatbot/index.d.ts +0 -9
  78. package/dist/esm/components/XAiChatbot/styles.d.ts +0 -67
  79. package/dist/esm/components/XAiConversations/XAiConversations.stories.d.ts +0 -6
  80. package/dist/esm/components/XAiConversations/index.d.ts +0 -4
  81. package/dist/esm/components/XAiConversations/styles.d.ts +0 -49
  82. package/dist/esm/components/XAiProvider/XAiProvider.stories.d.ts +0 -8
  83. package/dist/esm/components/XAiProvider/demo.styles.d.ts +0 -37
  84. package/dist/esm/components/XAiProvider/index.d.ts +0 -4
  85. package/dist/esm/components/XAiSDK.d.ts +0 -10
  86. package/dist/esm/components/XAiSender/XAiSender.stories.d.ts +0 -6
  87. package/dist/esm/components/XAiSender/index.d.ts +0 -4
  88. package/dist/esm/components/XAiSender/styles.d.ts +0 -47
  89. package/dist/esm/components/XAiWebSDKWrapper.d.ts +0 -9
  90. package/dist/esm/constants/index.d.ts +0 -2
  91. package/dist/esm/context/AiProviderContext.d.ts +0 -14
  92. package/dist/esm/context/ThemeContext.d.ts +0 -20
  93. package/dist/esm/hooks/useAgentGenerator.d.ts +0 -93
  94. package/dist/esm/hooks/useEventStreamRequest.d.ts +0 -30
  95. package/dist/esm/hooks/useProviderContext.d.ts +0 -33
  96. package/dist/esm/hooks/useXAiSDK.d.ts +0 -14
  97. package/dist/esm/index.d.ts +0 -10
  98. package/dist/esm/services/api.d.ts +0 -130
  99. package/dist/esm/styles/common.d.ts +0 -73
  100. package/dist/esm/styles/markdown.d.ts +0 -3
  101. package/dist/esm/types/XAiChatbot.d.ts +0 -156
  102. package/dist/esm/types/XAiConversations.d.ts +0 -20
  103. package/dist/esm/types/XAiMessage.d.ts +0 -108
  104. package/dist/esm/types/XAiProvider.d.ts +0 -347
  105. package/dist/esm/types/XAiSender.d.ts +0 -13
  106. package/dist/esm/types/index.d.ts +0 -5
  107. package/dist/esm/types/node.d.ts +0 -10
  108. package/dist/esm/utils/chat.d.ts +0 -34
  109. package/dist/esm/utils/index.d.ts +0 -2
  110. package/dist/esm/utils/providerManager.d.ts +0 -22
  111. package/dist/esm/utils/request.d.ts +0 -78
  112. package/dist/esm/utils/request.example.d.ts +0 -39
  113. package/dist/esm/utils/umdEntry.d.ts +0 -26
  114. package/dist/esm/utils/workflowNode.d.ts +0 -2
@@ -1,67 +0,0 @@
1
- import React from 'react';
2
- export declare const useStyles: () => {
3
- wrapper: string;
4
- navbar: string;
5
- userAvatar: string;
6
- avatar: string;
7
- title: string;
8
- subtitle: string;
9
- messageContainer: string;
10
- messageList: string;
11
- emptyWrapper: string;
12
- emptyImg: string;
13
- message: string;
14
- messageRight: string;
15
- quickReplies: string;
16
- replyItem: string;
17
- highlight: string;
18
- inputBar: string;
19
- input: string;
20
- actionDetailContent: string;
21
- actionHeaderWrapper: string;
22
- actionHeaderIcon: string;
23
- actionHeaderDetail: string;
24
- actionDetailTitle: string;
25
- executeHeaderIcon: string;
26
- actionTitle: string;
27
- actionHeaderDetailItem: string;
28
- actionHeaderCost: string;
29
- executeHiddenWrapper: string;
30
- executeTitle: string;
31
- executeContent: string;
32
- executeWrapper: string;
33
- } & {
34
- w: (width: string | number) => string;
35
- h: (height: string | number) => string;
36
- p: (padding: string) => string;
37
- pb: (padding: string | number) => string;
38
- pt: (padding: string | number) => string;
39
- pl: (padding: string | number) => string;
40
- pr: (padding: string | number) => string;
41
- m: (margin: string) => string;
42
- mb: (margin: string | number) => string;
43
- mt: (margin: string | number) => string;
44
- ml: (margin: string | number) => string;
45
- mr: (margin: string | number) => string;
46
- text: (size: string | number) => string;
47
- weight: (size: number) => string;
48
- textColor: (c: string) => string;
49
- bg: (c: string) => string;
50
- rs: (radius: string | number) => string;
51
- gap: (g: string | number) => string;
52
- flex: string;
53
- flexCenter: string;
54
- flexBetween: string;
55
- flexColumn: string;
56
- flex1: string;
57
- cursor: (type: string) => string;
58
- border: (color: string, width?: string) => string;
59
- boxShadow: (shadow: string) => string;
60
- transition: (property?: string, duration?: string) => string;
61
- overflow: (type: string) => string;
62
- position: (type: string) => string;
63
- zIndex: (index: number) => string;
64
- flexCenterGap2: string;
65
- flexCenterGap4: string;
66
- };
67
- export declare const GlobalStyle: React.FC;
@@ -1,6 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import XAiConversations from '.';
3
- declare const meta: Meta<typeof XAiConversations>;
4
- export default meta;
5
- type Story = StoryObj<typeof meta>;
6
- export declare const 基础用法: Story;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { type XAiConversationsProps } from "../../types/XAiConversations";
3
- declare const XAiConversations: React.FC<XAiConversationsProps>;
4
- export default XAiConversations;
@@ -1,49 +0,0 @@
1
- import React from 'react';
2
- export declare const useStyles: () => {
3
- capWrapper: string;
4
- capShape: string;
5
- capIcon: string;
6
- addChatBtn: string;
7
- tipTitle: string;
8
- fWrapper: string;
9
- nWrapper: string;
10
- mask: string;
11
- fheaderWrapper: string;
12
- scrollList: string;
13
- slideIn: string;
14
- slideOut: string;
15
- } & {
16
- w: (width: string | number) => string;
17
- h: (height: string | number) => string;
18
- p: (padding: string) => string;
19
- pb: (padding: string | number) => string;
20
- pt: (padding: string | number) => string;
21
- pl: (padding: string | number) => string;
22
- pr: (padding: string | number) => string;
23
- m: (margin: string) => string;
24
- mb: (margin: string | number) => string;
25
- mt: (margin: string | number) => string;
26
- ml: (margin: string | number) => string;
27
- mr: (margin: string | number) => string;
28
- text: (size: string | number) => string;
29
- weight: (size: number) => string;
30
- textColor: (c: string) => string;
31
- bg: (c: string) => string;
32
- rs: (radius: string | number) => string;
33
- gap: (g: string | number) => string;
34
- flex: string;
35
- flexCenter: string;
36
- flexBetween: string;
37
- flexColumn: string;
38
- flex1: string;
39
- cursor: (type: string) => string;
40
- border: (color: string, width?: string) => string;
41
- boxShadow: (shadow: string) => string;
42
- transition: (property?: string, duration?: string) => string;
43
- overflow: (type: string) => string;
44
- position: (type: string) => string;
45
- zIndex: (index: number) => string;
46
- flexCenterGap2: string;
47
- flexCenterGap4: string;
48
- };
49
- export declare const GlobalStyle: React.FC;
@@ -1,8 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import XAiProvider from './index';
3
- declare const meta: Meta<typeof XAiProvider>;
4
- export default meta;
5
- type Story = StoryObj<typeof meta>;
6
- export declare const 单聊天窗口实例: Story;
7
- export declare const 多容器示例: Story;
8
- export declare const 携带历史记录示例: Story;
@@ -1,37 +0,0 @@
1
- declare const useStyles: () => {
2
- wrapper: string;
3
- } & {
4
- w: (width: string | number) => string;
5
- h: (height: string | number) => string;
6
- p: (padding: string) => string;
7
- pb: (padding: string | number) => string;
8
- pt: (padding: string | number) => string;
9
- pl: (padding: string | number) => string;
10
- pr: (padding: string | number) => string;
11
- m: (margin: string) => string;
12
- mb: (margin: string | number) => string;
13
- mt: (margin: string | number) => string;
14
- ml: (margin: string | number) => string;
15
- mr: (margin: string | number) => string;
16
- text: (size: string | number) => string;
17
- weight: (size: number) => string;
18
- textColor: (c: string) => string;
19
- bg: (c: string) => string;
20
- rs: (radius: string | number) => string;
21
- gap: (g: string | number) => string;
22
- flex: string;
23
- flexCenter: string;
24
- flexBetween: string;
25
- flexColumn: string;
26
- flex1: string;
27
- cursor: (type: string) => string;
28
- border: (color: string, width?: string) => string;
29
- boxShadow: (shadow: string) => string;
30
- transition: (property?: string, duration?: string) => string;
31
- overflow: (type: string) => string;
32
- position: (type: string) => string;
33
- zIndex: (index: number) => string;
34
- flexCenterGap2: string;
35
- flexCenterGap4: string;
36
- };
37
- export default useStyles;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { XAiProviderProps, XAiProviderHandle } from "../../types/XAiProvider";
3
- declare const XAiProvider: import("react").ForwardRefExoticComponent<XAiProviderProps & import("react").RefAttributes<XAiProviderHandle>>;
4
- export default XAiProvider;
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import { XAiProviderProps } from "../types/XAiProvider";
3
- export interface XAiSDKProps extends XAiProviderProps {
4
- width?: string | number;
5
- height?: string | number;
6
- className?: string;
7
- style?: React.CSSProperties;
8
- }
9
- declare const XAiSDK: React.FC<XAiSDKProps>;
10
- export default XAiSDK;
@@ -1,6 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import XAiSender from '.';
3
- declare const meta: Meta<typeof XAiSender>;
4
- export default meta;
5
- type Story = StoryObj<typeof meta>;
6
- export declare const 基础用法: Story;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { XAiSenderProps } from "../../types";
3
- declare const XAiSender: React.FC<XAiSenderProps>;
4
- export default XAiSender;
@@ -1,47 +0,0 @@
1
- export declare const useStyles: () => {
2
- chatFooter: string;
3
- footerTips: string;
4
- popoverFooter: string;
5
- sendButton: string;
6
- uploadBtn: string;
7
- clearBtn: string;
8
- stopButton: string;
9
- divider: string;
10
- sendWrapper: string;
11
- iconHuihuarenqun: string;
12
- iconZengjiaDisabled: string;
13
- iconZengjiaNormal: string;
14
- } & {
15
- w: (width: string | number) => string;
16
- h: (height: string | number) => string;
17
- p: (padding: string) => string;
18
- pb: (padding: string | number) => string;
19
- pt: (padding: string | number) => string;
20
- pl: (padding: string | number) => string;
21
- pr: (padding: string | number) => string;
22
- m: (margin: string) => string;
23
- mb: (margin: string | number) => string;
24
- mt: (margin: string | number) => string;
25
- ml: (margin: string | number) => string;
26
- mr: (margin: string | number) => string;
27
- text: (size: string | number) => string;
28
- weight: (size: number) => string;
29
- textColor: (c: string) => string;
30
- bg: (c: string) => string;
31
- rs: (radius: string | number) => string;
32
- gap: (g: string | number) => string;
33
- flex: string;
34
- flexCenter: string;
35
- flexBetween: string;
36
- flexColumn: string;
37
- flex1: string;
38
- cursor: (type: string) => string;
39
- border: (color: string, width?: string) => string;
40
- boxShadow: (shadow: string) => string;
41
- transition: (property?: string, duration?: string) => string;
42
- overflow: (type: string) => string;
43
- position: (type: string) => string;
44
- zIndex: (index: number) => string;
45
- flexCenterGap2: string;
46
- flexCenterGap4: string;
47
- };
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { XAiSDKProps } from "../types/XAiProvider";
3
- import XAiWebSDK from "../utils/umdEntry";
4
- export interface XAiWebSDKWrapperProps extends XAiSDKProps {
5
- onInit?: (sdk: XAiWebSDK) => void;
6
- onDestroy?: () => void;
7
- }
8
- declare const XAiWebSDKWrapper: React.FC<XAiWebSDKWrapperProps>;
9
- export default XAiWebSDKWrapper;
@@ -1,2 +0,0 @@
1
- export declare const SESSION_PAGE_SIZE = 50;
2
- export declare const MOBILE_MAX_WIDTH = 760;
@@ -1,14 +0,0 @@
1
- /// <reference types="react" />
2
- import type { XAiChatbotProps, XAiConversationsProps } from "../types";
3
- export interface XAiContextType extends Omit<XAiChatbotProps, 'onScroll'>, Omit<XAiConversationsProps, 'onScroll'> {
4
- onScroll?: (event: React.UIEvent<HTMLDivElement>) => void;
5
- providerId?: string;
6
- token: string;
7
- error: string | null;
8
- loadMoreSessions?: () => void;
9
- isInProvider?: boolean;
10
- }
11
- declare const XAiContext: React.Context<XAiContextType>;
12
- export { XAiContext };
13
- export declare const useXAi: () => XAiContextType | undefined;
14
- export declare const useXAiProviders: () => string[];
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- export interface XThemeConfig {
3
- mode?: 'light' | 'dark';
4
- primaryColor?: string;
5
- bubble?: {
6
- className?: string;
7
- style?: React.CSSProperties;
8
- classNames?: Record<string, string>;
9
- styles?: Record<string, React.CSSProperties>;
10
- };
11
- sender?: {
12
- className?: string;
13
- style?: React.CSSProperties;
14
- classNames?: Record<string, string>;
15
- styles?: Record<string, React.CSSProperties>;
16
- };
17
- }
18
- export declare const ThemeContext: React.Context<XThemeConfig>;
19
- export declare const useTheme: () => XThemeConfig;
20
- export declare const ThemeProvider: React.Provider<XThemeConfig>;
@@ -1,93 +0,0 @@
1
- /// <reference types="react" />
2
- import { Messages } from "../types/XAiMessage";
3
- import { Error, Success, sessionData } from "../types";
4
- export type ContentType = 'TEXT' | 'IMAGE' | 'FILE';
5
- export interface ImageUrl {
6
- url: string;
7
- name: string;
8
- }
9
- export interface FileUrl {
10
- url: string;
11
- fileName: string;
12
- suffix: string;
13
- }
14
- export interface Content {
15
- text?: string;
16
- imageUrl?: ImageUrl;
17
- fileUrl?: FileUrl;
18
- }
19
- export interface ContentDef {
20
- description: string;
21
- contentType: ContentType;
22
- content: Content;
23
- }
24
- export type Contents = ContentDef[];
25
- export declare enum ActionType {
26
- recallKnowledgeStart = "RECALL_KNOWLEDGE_START",
27
- recallKnowledgeEnd = "RECALL_KNOWLEDGE_END",
28
- invokeToolStart = "INVOKE_AGENT_TOOL_START",
29
- invokeToolEnd = "INVOKE_AGENT_TOOL_END",
30
- reasoning = "REASONING",
31
- reasoningStart = "REASONING_START",
32
- reasoningEnd = "REASONING_END",
33
- componentStart = "COMPONENT_START",
34
- componentStream = "COMPONENT_STREAM",
35
- componentEnd = "COMPONENT_END",
36
- suggest = "FOLLOW_UP",
37
- response = "RESPONSE",
38
- finish = "FINISHED"
39
- }
40
- export declare enum ProcessStatus {
41
- start = "START",
42
- end = "END"
43
- }
44
- export declare enum ActionAvailability {
45
- disabled = "disabled",
46
- enabled = "enabled",
47
- remote = "remote"
48
- }
49
- export type ThinkStep = any;
50
- export interface Action {
51
- name: string;
52
- description: string;
53
- jsonSchema: string;
54
- available?: ActionAvailability;
55
- }
56
- export interface BaseFields {
57
- textSpeed?: number;
58
- onChatDone?: () => void;
59
- }
60
- export interface UseAgentGeneratorProps {
61
- url: string;
62
- token: string;
63
- config: any;
64
- onError?: (error: Error) => void;
65
- onSuccess?: (data: Success) => void;
66
- onMessage?: (content: string, data: Messages) => void;
67
- }
68
- declare const useAgentGenerator: (params: UseAgentGeneratorProps) => {
69
- appInfo: any;
70
- messages: Messages[];
71
- loading: boolean;
72
- content: any;
73
- sessionList: sessionData[];
74
- currentSessionId: string;
75
- sessionPagination: {
76
- total: number;
77
- pageNum: number;
78
- pageSize: number;
79
- };
80
- initAppConversations: (fetchDetail?: boolean) => Promise<void>;
81
- reChat: () => void;
82
- chat: <T = any>(content: T, extra?: any, insert?: boolean) => Promise<void>;
83
- createNewChat: () => void;
84
- setCurrentSessionId: import("react").Dispatch<import("react").SetStateAction<string>>;
85
- setCurrentSessionDetail: (sessionId: string) => Promise<void>;
86
- updateSession: (sessionId: string, title: string) => Promise<void>;
87
- deleteSession: (sessionId: string) => Promise<void>;
88
- setMessage: (messageType: string, content: any) => Promise<void>;
89
- setMessages: import("react").Dispatch<import("react").SetStateAction<Messages[]>>;
90
- stopChat: () => void;
91
- initPrologue: () => Promise<void>;
92
- };
93
- export default useAgentGenerator;
@@ -1,30 +0,0 @@
1
- interface IResponseData {
2
- code: string;
3
- httpCode?: number;
4
- data: string | {
5
- message: string;
6
- };
7
- message: string;
8
- content: string;
9
- requestId: string;
10
- sessionId: string;
11
- error?: boolean;
12
- success?: boolean;
13
- }
14
- interface UseEventStreamProps {
15
- streaming: boolean;
16
- options?: RequestInit;
17
- onOpen?: (response: Response) => void;
18
- onError?: (error: Error) => void;
19
- onClose?: () => void;
20
- textSpeed?: number;
21
- }
22
- interface UseEventStreamReturn {
23
- responseData: IResponseData | Record<any, any>;
24
- loading: boolean;
25
- start: (url: string, values?: any, headers?: Record<string, string>) => void;
26
- stop: () => void;
27
- onError?: (error: Error) => void;
28
- }
29
- export declare const useEventStreamRequest: ({ onOpen, onError, streaming, onClose, textSpeed, }: UseEventStreamProps) => UseEventStreamReturn;
30
- export default useEventStreamRequest;
@@ -1,33 +0,0 @@
1
- import type { XAiContextType } from "../context/AiProviderContext";
2
- export interface UseProviderContextOptions<T> {
3
- props: T;
4
- providerProps?: (keyof XAiContextType)[];
5
- mergeLogic?: (props: T, context: XAiContextType | undefined) => T;
6
- }
7
- export interface UseProviderContextReturn<T> {
8
- mergedProps: T;
9
- isInProvider: boolean;
10
- context: XAiContextType | undefined;
11
- getProviderValue: <K extends keyof XAiContextType>(key: K) => XAiContextType[K] | undefined;
12
- }
13
- export type MethodCaller<T extends any[] = any[], R = any> = (...args: T) => R;
14
- export interface ProviderMethods {
15
- isInProvider: boolean;
16
- sendMessage: MethodCaller<[string], void>;
17
- stopGeneration: MethodCaller<[], void>;
18
- clearMessages: MethodCaller<[], void>;
19
- regenerateLastMessage: MethodCaller<[string], void>;
20
- }
21
- /**
22
- * 通用的 Provider 上下文 Hook
23
- * 用于判断组件是否在 XAiProvider 中,并合并相关属性
24
- */
25
- export declare const useProviderContext: <T extends Record<string, any>>(options: UseProviderContextOptions<T>) => UseProviderContextReturn<T>;
26
- /**
27
- * 专门为 XAiChatbot 设计的 Hook
28
- */
29
- export declare const useChatbotContext: (componentProps: any) => UseProviderContextReturn<any>;
30
- /**
31
- * 通用的 Provider 方法调用 Hook
32
- */
33
- export declare const useProviderMethods: () => ProviderMethods;
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { XAiProviderProps } from "../types/XAiProvider";
3
- export interface UseXAiSDKOptions extends XAiProviderProps {
4
- containerId?: string;
5
- width?: string | number;
6
- height?: string | number;
7
- className?: string;
8
- style?: React.CSSProperties;
9
- }
10
- export declare const useXAiSDK: (options: UseXAiSDKOptions) => {
11
- containerRef: React.RefObject<HTMLDivElement | null>;
12
- render: () => import("react/jsx-runtime").JSX.Element;
13
- };
14
- export default useXAiSDK;
@@ -1,10 +0,0 @@
1
- import { useXAi } from './context/AiProviderContext';
2
- import XAiProvider from './components/XAiProvider';
3
- import XAiChatbot from './components/XAiChatbot';
4
- import XAiSDK from './components/XAiSDK';
5
- import XAiWebSDKWrapper from './components/XAiWebSDKWrapper';
6
- import XAiSender from './components/XAiSender';
7
- import useXAiSDK from './hooks/useXAiSDK';
8
- import request from './utils/request';
9
- export * from './types';
10
- export { useXAi, XAiProvider, XAiChatbot, XAiSDK, XAiWebSDKWrapper, XAiSender, useXAiSDK, request, };
@@ -1,130 +0,0 @@
1
- export interface ServerApiResponse<T = unknown> {
2
- data: T;
3
- code: string;
4
- success: boolean;
5
- message: string;
6
- serverTime: number;
7
- traceId: string;
8
- }
9
- export interface ApiResponse<T> {
10
- success: boolean;
11
- data: T;
12
- message?: string;
13
- code: string;
14
- }
15
- export interface ChatConfig {
16
- botNo: string;
17
- appNo: string;
18
- appName: string;
19
- appTheme: string;
20
- description: string;
21
- icon: string;
22
- onboardingInfo: {
23
- prologue: string;
24
- suggested_questions: string[];
25
- };
26
- appVersionNo: string;
27
- publishDTO: {
28
- id: number;
29
- tenantId: string;
30
- botNo: string;
31
- publishNo: string;
32
- publishTime: string;
33
- publishVersionNo: string;
34
- publishVersionDesc: string;
35
- publishAppType: string;
36
- platformConfigInfo: string;
37
- appNo: string;
38
- appVersionNo: string;
39
- gmtCreated: string;
40
- enableFlag: number;
41
- gmtModified: string;
42
- creator: string;
43
- modifier: string;
44
- isDeleted: string;
45
- authLoginInfoDTO: Record<string, unknown>;
46
- shareLink: string;
47
- };
48
- }
49
- export interface sessionData {
50
- data: {
51
- sessionId: string;
52
- gmtCreated: string;
53
- userId: string;
54
- title: string;
55
- botNo: string;
56
- appNo: string;
57
- }[];
58
- pageNum: number;
59
- pageSize: number;
60
- totalCount: number;
61
- }
62
- /**
63
- * 获取聊天配置
64
- * 使用request,会自动添加token
65
- */
66
- export declare const fetchAppConfig: ({ url, appNo, pt, tc }: {
67
- url: string;
68
- appNo: string;
69
- pt: string;
70
- tc: string;
71
- }) => Promise<ApiResponse<ChatConfig>>;
72
- /**
73
- * 发送消息
74
- * 使用request,会自动添加token
75
- */
76
- export declare const sendMessage: ({ url, appNo, pt, tc, msg }: {
77
- url: string;
78
- appNo: string;
79
- pt: string;
80
- tc: string;
81
- msg: string;
82
- }) => Promise<ApiResponse<ChatConfig>>;
83
- /**
84
- * 获取会话列表
85
- */
86
- export declare const fetchSessionList: ({ url, appNo, pt, tc, pageSize, pageNum, token }: {
87
- url: string;
88
- appNo: string;
89
- pt: string;
90
- tc: string;
91
- pageSize?: number | undefined;
92
- pageNum?: number | undefined;
93
- token: string;
94
- }) => Promise<ApiResponse<sessionData>>;
95
- /**
96
- * 获取会话明细
97
- */
98
- export declare const fetchSessionDetail: ({ url, appNo, pt, tc, sessionId, pageSize, pageNum, token }: {
99
- url: string;
100
- appNo: string;
101
- pt: string;
102
- tc: string;
103
- sessionId: string;
104
- pageSize?: number | undefined;
105
- pageNum?: number | undefined;
106
- token: string;
107
- }) => Promise<ApiResponse<sessionData[]>>;
108
- /**
109
- * 删除会话
110
- */
111
- export declare const delSessionId: ({ url, appNo, pt, tc, sessionId, token }: {
112
- url: string;
113
- appNo: string;
114
- pt: string;
115
- tc: string;
116
- sessionId: string;
117
- token: string;
118
- }) => Promise<ApiResponse<boolean>>;
119
- /**
120
- * 修改会话标题
121
- */
122
- export declare const updateSessionTitle: ({ url, appNo, pt, tc, sessionId, title, token }: {
123
- url: string;
124
- appNo: string;
125
- pt: string;
126
- tc: string;
127
- sessionId: string;
128
- title: string;
129
- token: string;
130
- }) => Promise<ApiResponse<boolean>>;