@ai-group/chat-sdk 0.3.5 → 0.3.6
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/dist/cjs/hooks/useAgentGenerator.d.ts +2 -2
- package/dist/cjs/hooks/useAgentGenerator.js +8 -1
- package/dist/cjs/hooks/useAgentGenerator.js.map +2 -2
- package/dist/cjs/types/XAiProvider.d.ts +9 -1
- package/dist/cjs/types/XAiProvider.js +7 -0
- package/dist/cjs/types/XAiProvider.js.map +3 -3
- package/dist/esm/hooks/useAgentGenerator.d.ts +2 -2
- package/dist/esm/hooks/useAgentGenerator.js +20 -11
- package/dist/esm/hooks/useAgentGenerator.js.map +1 -1
- package/dist/esm/types/XAiProvider.d.ts +9 -1
- package/dist/esm/types/XAiProvider.js +5 -0
- package/dist/esm/types/XAiProvider.js.map +1 -1
- package/dist/umd/chat-sdk.min.js +1 -1
- package/package.json +1 -1
|
@@ -9,10 +9,18 @@ export declare enum ErrorCode {
|
|
|
9
9
|
APP_NOT_FOUND = "APP_NOT_FOUND",
|
|
10
10
|
API_ERROR = "API_ERROR"
|
|
11
11
|
}
|
|
12
|
+
export declare enum SuccessCode {
|
|
13
|
+
APP_CONFIG_INIT_SUCCESS = "APP_CONFIG_INIT_SUCCESS",
|
|
14
|
+
APP_MESSAGES_INIT_SUCCESS = "APP_CONFIG_INIT_SUCCESS"
|
|
15
|
+
}
|
|
12
16
|
export interface Error {
|
|
13
17
|
code: ErrorCode;
|
|
14
18
|
message: string;
|
|
15
19
|
}
|
|
20
|
+
export interface Success {
|
|
21
|
+
code: SuccessCode;
|
|
22
|
+
message: string;
|
|
23
|
+
}
|
|
16
24
|
export interface XAiProviderHandle {
|
|
17
25
|
chat: (content: string) => void;
|
|
18
26
|
stopChat: () => void;
|
|
@@ -35,7 +43,7 @@ export interface XAiProviderProps {
|
|
|
35
43
|
/** 应用无法正常渲染回调 */
|
|
36
44
|
onError?: (error: Error) => void;
|
|
37
45
|
/** 应用正常渲染回调 */
|
|
38
|
-
onSuccess?: (
|
|
46
|
+
onSuccess?: (success: Success) => void;
|
|
39
47
|
/** 子组件 */
|
|
40
48
|
children: ReactNode;
|
|
41
49
|
}
|
|
@@ -7,5 +7,10 @@ export var ErrorCode = /*#__PURE__*/function (ErrorCode) {
|
|
|
7
7
|
ErrorCode["API_ERROR"] = "API_ERROR";
|
|
8
8
|
return ErrorCode;
|
|
9
9
|
}({});
|
|
10
|
+
export var SuccessCode = /*#__PURE__*/function (SuccessCode) {
|
|
11
|
+
SuccessCode["APP_CONFIG_INIT_SUCCESS"] = "APP_CONFIG_INIT_SUCCESS";
|
|
12
|
+
SuccessCode["APP_MESSAGES_INIT_SUCCESS"] = "APP_CONFIG_INIT_SUCCESS";
|
|
13
|
+
return SuccessCode;
|
|
14
|
+
}({});
|
|
10
15
|
export var XAiContext = /*#__PURE__*/React.createContext(null);
|
|
11
16
|
//# sourceMappingURL=XAiProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","ErrorCode","XAiContext","createContext"],"sources":["../../../src/types/XAiProvider.ts"],"sourcesContent":["// context/ProviderContext.ts\nimport React, { ReactNode } from 'react';\nimport { AiClient } from 'src/client/base';\nimport type { ChatbotMessageFields } from './XAiChatbot';\nimport { Messages } from '@/types/XAiMessage';\n\nexport type ThemeType = 'default';\n\nexport enum ErrorCode {\n APP_NOT_ENABLE = 'APP_NOT_ENABLE',\n APP_DELETED = 'APP_DELETED',\n APP_NOT_FOUND = 'APP_NOT_FOUND',\n API_ERROR = 'API_ERROR',\n}\n\nexport interface Error {\n code: ErrorCode;\n message: string;\n}\n\nexport interface XAiProviderHandle {\n chat: (content: string) => void;\n stopChat: () => void;\n reChat: () => void;\n getAppInfo: () => any;\n getMessages: () => Messages[];\n setCurrentSession: (id: string) => void;\n}\n\nexport interface XAiProviderProps {\n /** AI 服务地址 */\n url: string;\n /** 认证 token */\n token: string;\n /** 配置信息 */\n config?: any;\n /** Provider 唯一标识,用于区分多个 Provider 实例 */\n providerId?: string;\n /** Token 刷新回调 */\n onRefreshToken?: () => Promise<string>;\n /** 应用无法正常渲染回调 */\n onError?: (error: Error) => void;\n /** 应用正常渲染回调 */\n onSuccess?: (
|
|
1
|
+
{"version":3,"names":["React","ErrorCode","SuccessCode","XAiContext","createContext"],"sources":["../../../src/types/XAiProvider.ts"],"sourcesContent":["// context/ProviderContext.ts\nimport React, { ReactNode } from 'react';\nimport { AiClient } from 'src/client/base';\nimport type { ChatbotMessageFields } from './XAiChatbot';\nimport { Messages } from '@/types/XAiMessage';\n\nexport type ThemeType = 'default';\n\nexport enum ErrorCode {\n APP_NOT_ENABLE = 'APP_NOT_ENABLE',\n APP_DELETED = 'APP_DELETED',\n APP_NOT_FOUND = 'APP_NOT_FOUND',\n API_ERROR = 'API_ERROR',\n}\n\nexport enum SuccessCode {\n APP_CONFIG_INIT_SUCCESS = 'APP_CONFIG_INIT_SUCCESS',\n APP_MESSAGES_INIT_SUCCESS = 'APP_CONFIG_INIT_SUCCESS',\n}\n\nexport interface Error {\n code: ErrorCode;\n message: string;\n}\n\nexport interface Success {\n code: SuccessCode;\n message: string;\n}\n\nexport interface XAiProviderHandle {\n chat: (content: string) => void;\n stopChat: () => void;\n reChat: () => void;\n getAppInfo: () => any;\n getMessages: () => Messages[];\n setCurrentSession: (id: string) => void;\n}\n\nexport interface XAiProviderProps {\n /** AI 服务地址 */\n url: string;\n /** 认证 token */\n token: string;\n /** 配置信息 */\n config?: any;\n /** Provider 唯一标识,用于区分多个 Provider 实例 */\n providerId?: string;\n /** Token 刷新回调 */\n onRefreshToken?: () => Promise<string>;\n /** 应用无法正常渲染回调 */\n onError?: (error: Error) => void;\n /** 应用正常渲染回调 */\n onSuccess?: (success: Success) => void;\n /** 子组件 */\n children: ReactNode;\n}\n\nexport interface XAiSDKProps extends XAiProviderProps {\n theme?: ThemeType;\n componentProps?: {\n id?: string;\n [key: string]: any; // 支持任意 CSS 属性\n };\n}\n\nexport interface XAiContextType extends Required<ChatbotMessageFields> {\n client: AiClient | null;\n token: string;\n loading: boolean;\n error: string | null;\n // ...其它全局配置\n}\n\nexport const XAiContext = React.createContext<XAiContextType | null>(null);\n"],"mappings":"AAAA;AACA,OAAOA,KAAK,MAAqB,OAAO;AAOxC,WAAYC,SAAS,0BAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAAA,OAATA,SAAS;AAAA;AAOrB,WAAYC,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AA2DvB,OAAO,IAAMC,UAAU,gBAAGH,KAAK,CAACI,aAAa,CAAwB,IAAI,CAAC"}
|