@aizu-chat/react 0.1.3 → 0.1.5
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/index.d.mts +0 -146
- package/dist/index.d.ts +0 -146
- package/dist/index.js +162 -309
- package/dist/index.mjs +162 -309
- package/package.json +50 -50
- package/dist/chunk-33CPD3DF.mjs +0 -59
- package/dist/chunk-KLPKNMIP.mjs +0 -15
- package/dist/chunk-NBQP747C.mjs +0 -130
- package/dist/chunk-XEQE67X7.mjs +0 -1858
- package/dist/components.d.mts +0 -69
- package/dist/components.d.ts +0 -69
- package/dist/components.js +0 -1922
- package/dist/components.mjs +0 -17
- package/dist/hooks.d.mts +0 -6
- package/dist/hooks.d.ts +0 -6
- package/dist/hooks.js +0 -40
- package/dist/hooks.mjs +0 -8
- package/dist/sdk.d.mts +0 -55
- package/dist/sdk.d.ts +0 -55
- package/dist/sdk.js +0 -200
- package/dist/sdk.mjs +0 -12
package/dist/index.d.mts
CHANGED
|
@@ -39,162 +39,16 @@ declare enum TypeResponse {
|
|
|
39
39
|
START_SHOPPING = "start_shopping"
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
/**
|
|
43
|
-
* Aizu Chat API Client
|
|
44
|
-
*
|
|
45
|
-
* A client for interacting with the Aizu Chat API. Handles authentication,
|
|
46
|
-
* request timeouts, and error handling automatically.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* const client = new AizuClient({
|
|
51
|
-
* hostUrl: 'https://api.aizu.chat',
|
|
52
|
-
* apiKey: 'your-api-key',
|
|
53
|
-
* timeout: 30000
|
|
54
|
-
* });
|
|
55
|
-
*
|
|
56
|
-
* const response = await client.chat({
|
|
57
|
-
* query: 'Hello, how are you?',
|
|
58
|
-
* conversationId: 'optional-conversation-id'
|
|
59
|
-
* });
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
42
|
declare class AizuClient {
|
|
63
43
|
private hostUrl;
|
|
64
44
|
private apiKey;
|
|
65
45
|
private timeout;
|
|
66
|
-
/**
|
|
67
|
-
* Creates a new AizuClient instance
|
|
68
|
-
*
|
|
69
|
-
* @param config - Configuration options for the client
|
|
70
|
-
* @param config.hostUrl - The base URL of the Aizu API (e.g., 'https://api.aizu.chat')
|
|
71
|
-
* @param config.apiKey - Your API key for authentication
|
|
72
|
-
* @param config.timeout - Request timeout in milliseconds (default: 30000)
|
|
73
|
-
*
|
|
74
|
-
* @throws {Error} If hostUrl is not a non-empty string
|
|
75
|
-
* @throws {Error} If apiKey is not a non-empty string
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```typescript
|
|
79
|
-
* const client = new AizuClient({
|
|
80
|
-
* hostUrl: 'https://api.aizu.chat',
|
|
81
|
-
* apiKey: 'sk_test_123456',
|
|
82
|
-
* timeout: 60000 // 60 seconds
|
|
83
|
-
* });
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
46
|
constructor(config: AizuClientConfig);
|
|
87
|
-
/**
|
|
88
|
-
* Internal method for making HTTP requests to the API
|
|
89
|
-
*
|
|
90
|
-
* Handles timeout management, abort signal combination, and error handling.
|
|
91
|
-
* Supports both user-initiated cancellation and automatic timeout.
|
|
92
|
-
*
|
|
93
|
-
* @template T - The expected response type
|
|
94
|
-
* @template TBody - The request body type
|
|
95
|
-
*
|
|
96
|
-
* @param path - API endpoint path (e.g., '/chat/query')
|
|
97
|
-
* @param options - Request options including body and signal
|
|
98
|
-
*
|
|
99
|
-
* @returns Promise resolving to the API response
|
|
100
|
-
*
|
|
101
|
-
* @throws {Error} "Request cancelled by user" - If the request is cancelled via AbortSignal
|
|
102
|
-
* @throws {Error} "Request timeout: The server took too long to respond" - If the request exceeds the timeout
|
|
103
|
-
* @throws {Error} "API Error: {status} {statusText}" - If the API returns an error status
|
|
104
|
-
*
|
|
105
|
-
* @private
|
|
106
|
-
*/
|
|
107
47
|
private request;
|
|
108
|
-
/**
|
|
109
|
-
* Sends a chat query to the Aizu API
|
|
110
|
-
*
|
|
111
|
-
* @param params - Chat request parameters
|
|
112
|
-
* @param params.query - The user's message/question (required, non-empty)
|
|
113
|
-
* @param params.conversationId - Optional conversation ID to continue an existing conversation
|
|
114
|
-
* @param options - Additional options
|
|
115
|
-
* @param options.signal - Optional AbortSignal to cancel the request
|
|
116
|
-
*
|
|
117
|
-
* @returns Promise resolving to the chat response from the API
|
|
118
|
-
*
|
|
119
|
-
* @throws {Error} "Query is required" - If query is empty or whitespace only
|
|
120
|
-
* @throws {Error} "Request cancelled by user" - If the request is cancelled
|
|
121
|
-
* @throws {Error} "Request timeout: The server took too long to respond" - If the request times out
|
|
122
|
-
* @throws {Error} "API Error: {status} {statusText}" - If the API returns an error
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```typescript
|
|
126
|
-
* // Simple query
|
|
127
|
-
* const response = await client.chat({
|
|
128
|
-
* query: 'What is the weather today?'
|
|
129
|
-
* });
|
|
130
|
-
* console.log(response.answer);
|
|
131
|
-
* ```
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* ```typescript
|
|
135
|
-
* // Continue conversation
|
|
136
|
-
* const response1 = await client.chat({
|
|
137
|
-
* query: 'What is the weather today?'
|
|
138
|
-
* });
|
|
139
|
-
*
|
|
140
|
-
* const response2 = await client.chat({
|
|
141
|
-
* query: 'And tomorrow?',
|
|
142
|
-
* conversationId: response1.conversationId
|
|
143
|
-
* });
|
|
144
|
-
* ```
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```typescript
|
|
148
|
-
* // With cancellation support
|
|
149
|
-
* const controller = new AbortController();
|
|
150
|
-
*
|
|
151
|
-
* const promise = client.chat(
|
|
152
|
-
* { query: 'Long running query...' },
|
|
153
|
-
* { signal: controller.signal }
|
|
154
|
-
* );
|
|
155
|
-
*
|
|
156
|
-
* // Cancel after 5 seconds
|
|
157
|
-
* setTimeout(() => controller.abort(), 5000);
|
|
158
|
-
*
|
|
159
|
-
* try {
|
|
160
|
-
* const response = await promise;
|
|
161
|
-
* } catch (error) {
|
|
162
|
-
* console.error('Request was cancelled:', error);
|
|
163
|
-
* }
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
48
|
chat(params: ChatRequest, options?: {
|
|
167
49
|
signal?: AbortSignal;
|
|
168
50
|
}): Promise<ChatResponse>;
|
|
169
51
|
}
|
|
170
|
-
/**
|
|
171
|
-
* Factory function to create a new AizuClient instance
|
|
172
|
-
*
|
|
173
|
-
* This is a convenience function that wraps the AizuClient constructor.
|
|
174
|
-
* Use this when you prefer a functional approach over instantiating the class directly.
|
|
175
|
-
*
|
|
176
|
-
* @param config - Configuration options for the client
|
|
177
|
-
* @param config.hostUrl - The base URL of the Aizu API
|
|
178
|
-
* @param config.apiKey - Your API key for authentication
|
|
179
|
-
* @param config.timeout - Optional request timeout in milliseconds (default: 30000)
|
|
180
|
-
*
|
|
181
|
-
* @returns A new AizuClient instance
|
|
182
|
-
*
|
|
183
|
-
* @throws {Error} If hostUrl or apiKey are invalid
|
|
184
|
-
*
|
|
185
|
-
* @example
|
|
186
|
-
* ```typescript
|
|
187
|
-
* const client = createAizuClient({
|
|
188
|
-
* hostUrl: process.env.AIZU_HOST_URL!,
|
|
189
|
-
* apiKey: process.env.AIZU_API_KEY!,
|
|
190
|
-
* timeout: 45000
|
|
191
|
-
* });
|
|
192
|
-
*
|
|
193
|
-
* const response = await client.chat({
|
|
194
|
-
* query: 'Hello!'
|
|
195
|
-
* });
|
|
196
|
-
* ```
|
|
197
|
-
*/
|
|
198
52
|
declare const createAizuClient: ({ hostUrl, apiKey, timeout, }: {
|
|
199
53
|
hostUrl: string;
|
|
200
54
|
apiKey: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -39,162 +39,16 @@ declare enum TypeResponse {
|
|
|
39
39
|
START_SHOPPING = "start_shopping"
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
/**
|
|
43
|
-
* Aizu Chat API Client
|
|
44
|
-
*
|
|
45
|
-
* A client for interacting with the Aizu Chat API. Handles authentication,
|
|
46
|
-
* request timeouts, and error handling automatically.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* const client = new AizuClient({
|
|
51
|
-
* hostUrl: 'https://api.aizu.chat',
|
|
52
|
-
* apiKey: 'your-api-key',
|
|
53
|
-
* timeout: 30000
|
|
54
|
-
* });
|
|
55
|
-
*
|
|
56
|
-
* const response = await client.chat({
|
|
57
|
-
* query: 'Hello, how are you?',
|
|
58
|
-
* conversationId: 'optional-conversation-id'
|
|
59
|
-
* });
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
42
|
declare class AizuClient {
|
|
63
43
|
private hostUrl;
|
|
64
44
|
private apiKey;
|
|
65
45
|
private timeout;
|
|
66
|
-
/**
|
|
67
|
-
* Creates a new AizuClient instance
|
|
68
|
-
*
|
|
69
|
-
* @param config - Configuration options for the client
|
|
70
|
-
* @param config.hostUrl - The base URL of the Aizu API (e.g., 'https://api.aizu.chat')
|
|
71
|
-
* @param config.apiKey - Your API key for authentication
|
|
72
|
-
* @param config.timeout - Request timeout in milliseconds (default: 30000)
|
|
73
|
-
*
|
|
74
|
-
* @throws {Error} If hostUrl is not a non-empty string
|
|
75
|
-
* @throws {Error} If apiKey is not a non-empty string
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```typescript
|
|
79
|
-
* const client = new AizuClient({
|
|
80
|
-
* hostUrl: 'https://api.aizu.chat',
|
|
81
|
-
* apiKey: 'sk_test_123456',
|
|
82
|
-
* timeout: 60000 // 60 seconds
|
|
83
|
-
* });
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
46
|
constructor(config: AizuClientConfig);
|
|
87
|
-
/**
|
|
88
|
-
* Internal method for making HTTP requests to the API
|
|
89
|
-
*
|
|
90
|
-
* Handles timeout management, abort signal combination, and error handling.
|
|
91
|
-
* Supports both user-initiated cancellation and automatic timeout.
|
|
92
|
-
*
|
|
93
|
-
* @template T - The expected response type
|
|
94
|
-
* @template TBody - The request body type
|
|
95
|
-
*
|
|
96
|
-
* @param path - API endpoint path (e.g., '/chat/query')
|
|
97
|
-
* @param options - Request options including body and signal
|
|
98
|
-
*
|
|
99
|
-
* @returns Promise resolving to the API response
|
|
100
|
-
*
|
|
101
|
-
* @throws {Error} "Request cancelled by user" - If the request is cancelled via AbortSignal
|
|
102
|
-
* @throws {Error} "Request timeout: The server took too long to respond" - If the request exceeds the timeout
|
|
103
|
-
* @throws {Error} "API Error: {status} {statusText}" - If the API returns an error status
|
|
104
|
-
*
|
|
105
|
-
* @private
|
|
106
|
-
*/
|
|
107
47
|
private request;
|
|
108
|
-
/**
|
|
109
|
-
* Sends a chat query to the Aizu API
|
|
110
|
-
*
|
|
111
|
-
* @param params - Chat request parameters
|
|
112
|
-
* @param params.query - The user's message/question (required, non-empty)
|
|
113
|
-
* @param params.conversationId - Optional conversation ID to continue an existing conversation
|
|
114
|
-
* @param options - Additional options
|
|
115
|
-
* @param options.signal - Optional AbortSignal to cancel the request
|
|
116
|
-
*
|
|
117
|
-
* @returns Promise resolving to the chat response from the API
|
|
118
|
-
*
|
|
119
|
-
* @throws {Error} "Query is required" - If query is empty or whitespace only
|
|
120
|
-
* @throws {Error} "Request cancelled by user" - If the request is cancelled
|
|
121
|
-
* @throws {Error} "Request timeout: The server took too long to respond" - If the request times out
|
|
122
|
-
* @throws {Error} "API Error: {status} {statusText}" - If the API returns an error
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```typescript
|
|
126
|
-
* // Simple query
|
|
127
|
-
* const response = await client.chat({
|
|
128
|
-
* query: 'What is the weather today?'
|
|
129
|
-
* });
|
|
130
|
-
* console.log(response.answer);
|
|
131
|
-
* ```
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* ```typescript
|
|
135
|
-
* // Continue conversation
|
|
136
|
-
* const response1 = await client.chat({
|
|
137
|
-
* query: 'What is the weather today?'
|
|
138
|
-
* });
|
|
139
|
-
*
|
|
140
|
-
* const response2 = await client.chat({
|
|
141
|
-
* query: 'And tomorrow?',
|
|
142
|
-
* conversationId: response1.conversationId
|
|
143
|
-
* });
|
|
144
|
-
* ```
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```typescript
|
|
148
|
-
* // With cancellation support
|
|
149
|
-
* const controller = new AbortController();
|
|
150
|
-
*
|
|
151
|
-
* const promise = client.chat(
|
|
152
|
-
* { query: 'Long running query...' },
|
|
153
|
-
* { signal: controller.signal }
|
|
154
|
-
* );
|
|
155
|
-
*
|
|
156
|
-
* // Cancel after 5 seconds
|
|
157
|
-
* setTimeout(() => controller.abort(), 5000);
|
|
158
|
-
*
|
|
159
|
-
* try {
|
|
160
|
-
* const response = await promise;
|
|
161
|
-
* } catch (error) {
|
|
162
|
-
* console.error('Request was cancelled:', error);
|
|
163
|
-
* }
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
48
|
chat(params: ChatRequest, options?: {
|
|
167
49
|
signal?: AbortSignal;
|
|
168
50
|
}): Promise<ChatResponse>;
|
|
169
51
|
}
|
|
170
|
-
/**
|
|
171
|
-
* Factory function to create a new AizuClient instance
|
|
172
|
-
*
|
|
173
|
-
* This is a convenience function that wraps the AizuClient constructor.
|
|
174
|
-
* Use this when you prefer a functional approach over instantiating the class directly.
|
|
175
|
-
*
|
|
176
|
-
* @param config - Configuration options for the client
|
|
177
|
-
* @param config.hostUrl - The base URL of the Aizu API
|
|
178
|
-
* @param config.apiKey - Your API key for authentication
|
|
179
|
-
* @param config.timeout - Optional request timeout in milliseconds (default: 30000)
|
|
180
|
-
*
|
|
181
|
-
* @returns A new AizuClient instance
|
|
182
|
-
*
|
|
183
|
-
* @throws {Error} If hostUrl or apiKey are invalid
|
|
184
|
-
*
|
|
185
|
-
* @example
|
|
186
|
-
* ```typescript
|
|
187
|
-
* const client = createAizuClient({
|
|
188
|
-
* hostUrl: process.env.AIZU_HOST_URL!,
|
|
189
|
-
* apiKey: process.env.AIZU_API_KEY!,
|
|
190
|
-
* timeout: 45000
|
|
191
|
-
* });
|
|
192
|
-
*
|
|
193
|
-
* const response = await client.chat({
|
|
194
|
-
* query: 'Hello!'
|
|
195
|
-
* });
|
|
196
|
-
* ```
|
|
197
|
-
*/
|
|
198
52
|
declare const createAizuClient: ({ hostUrl, apiKey, timeout, }: {
|
|
199
53
|
hostUrl: string;
|
|
200
54
|
apiKey: string;
|