@ragbits/api-client 0.0.3 → 1.3.0
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/README.md +51 -101
- package/__tests__/mocks/handlers.ts +98 -0
- package/__tests__/setup.ts +23 -0
- package/__tests__/utils.ts +45 -0
- package/dist/autogen.types.d.ts +426 -0
- package/dist/index.cjs +147 -51
- package/dist/index.d.ts +14 -5
- package/dist/index.js +146 -51
- package/dist/types.d.ts +37 -198
- package/package.json +6 -2
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated TypeScript interfaces from Python Pydantic models
|
|
3
|
+
* Generated by scripts/generate_typescript_from_json_schema.py
|
|
4
|
+
* DO NOT EDIT MANUALLY
|
|
5
|
+
*/
|
|
6
|
+
import type { RJSFSchema } from '@rjsf/utils';
|
|
7
|
+
export type TypeFrom<T> = T[keyof T];
|
|
8
|
+
/**
|
|
9
|
+
* Represents the ChatResponseType enum
|
|
10
|
+
*/
|
|
11
|
+
export declare const ChatResponseType: {
|
|
12
|
+
readonly Text: "text";
|
|
13
|
+
readonly Reference: "reference";
|
|
14
|
+
readonly StateUpdate: "state_update";
|
|
15
|
+
readonly MessageId: "message_id";
|
|
16
|
+
readonly ConversationId: "conversation_id";
|
|
17
|
+
readonly LiveUpdate: "live_update";
|
|
18
|
+
readonly FollowupMessages: "followup_messages";
|
|
19
|
+
readonly Image: "image";
|
|
20
|
+
readonly ChunkedContent: "chunked_content";
|
|
21
|
+
readonly ClearMessage: "clear_message";
|
|
22
|
+
readonly Usage: "usage";
|
|
23
|
+
};
|
|
24
|
+
export type ChatResponseType = TypeFrom<typeof ChatResponseType>;
|
|
25
|
+
/**
|
|
26
|
+
* Represents the FeedbackType enum
|
|
27
|
+
*/
|
|
28
|
+
export declare const FeedbackType: {
|
|
29
|
+
readonly Like: "like";
|
|
30
|
+
readonly Dislike: "dislike";
|
|
31
|
+
};
|
|
32
|
+
export type FeedbackType = TypeFrom<typeof FeedbackType>;
|
|
33
|
+
/**
|
|
34
|
+
* Represents the LiveUpdateType enum
|
|
35
|
+
*/
|
|
36
|
+
export declare const LiveUpdateType: {
|
|
37
|
+
readonly Start: "START";
|
|
38
|
+
readonly Finish: "FINISH";
|
|
39
|
+
};
|
|
40
|
+
export type LiveUpdateType = TypeFrom<typeof LiveUpdateType>;
|
|
41
|
+
/**
|
|
42
|
+
* Represents the MessageRole enum
|
|
43
|
+
*/
|
|
44
|
+
export declare const MessageRole: {
|
|
45
|
+
readonly User: "user";
|
|
46
|
+
readonly Assistant: "assistant";
|
|
47
|
+
readonly System: "system";
|
|
48
|
+
};
|
|
49
|
+
export type MessageRole = TypeFrom<typeof MessageRole>;
|
|
50
|
+
/**
|
|
51
|
+
* Represents the AuthType enum
|
|
52
|
+
*/
|
|
53
|
+
export declare const AuthType: {
|
|
54
|
+
readonly Credentials: "credentials";
|
|
55
|
+
};
|
|
56
|
+
export type AuthType = TypeFrom<typeof AuthType>;
|
|
57
|
+
/**
|
|
58
|
+
* Represents the context of a chat conversation.
|
|
59
|
+
*/
|
|
60
|
+
export interface ChatContext {
|
|
61
|
+
conversation_id: string | null;
|
|
62
|
+
message_id: string | null;
|
|
63
|
+
state: {
|
|
64
|
+
[k: string]: unknown;
|
|
65
|
+
};
|
|
66
|
+
user: User | null;
|
|
67
|
+
session_id: string | null;
|
|
68
|
+
[k: string]: unknown;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Represents a chunk of large content being transmitted.
|
|
72
|
+
*/
|
|
73
|
+
export interface ChunkedContent {
|
|
74
|
+
id: string;
|
|
75
|
+
content_type: string;
|
|
76
|
+
chunk_index: number;
|
|
77
|
+
total_chunks: number;
|
|
78
|
+
mime_type: string;
|
|
79
|
+
data: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Represents an live update performed by an agent.
|
|
83
|
+
*/
|
|
84
|
+
export interface LiveUpdate {
|
|
85
|
+
update_id: string;
|
|
86
|
+
type: LiveUpdateType;
|
|
87
|
+
content: LiveUpdateContent;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Represents content of a live update.
|
|
91
|
+
*/
|
|
92
|
+
export interface LiveUpdateContent {
|
|
93
|
+
label: string;
|
|
94
|
+
description: string | null;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Represents a single message in the conversation history.
|
|
98
|
+
*/
|
|
99
|
+
export interface Message {
|
|
100
|
+
role: MessageRole;
|
|
101
|
+
content: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Represents a document used as reference for the response.
|
|
105
|
+
*/
|
|
106
|
+
export interface Reference {
|
|
107
|
+
title: string;
|
|
108
|
+
content: string;
|
|
109
|
+
url: string | null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Represents an update to conversation state.
|
|
113
|
+
*/
|
|
114
|
+
export interface ServerState {
|
|
115
|
+
state: {
|
|
116
|
+
[k: string]: unknown;
|
|
117
|
+
};
|
|
118
|
+
signature: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Individual feedback configuration (like/dislike).
|
|
122
|
+
*/
|
|
123
|
+
export interface FeedbackItem {
|
|
124
|
+
/**
|
|
125
|
+
* Whether this feedback type is enabled
|
|
126
|
+
*/
|
|
127
|
+
enabled: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Form schema for this feedback type
|
|
130
|
+
*/
|
|
131
|
+
form: RJSFSchema | null;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Represents an image in the conversation.
|
|
135
|
+
*/
|
|
136
|
+
export interface Image {
|
|
137
|
+
id: string;
|
|
138
|
+
url: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Represents usage for a message. Reflects `Usage` computed properties.
|
|
142
|
+
*/
|
|
143
|
+
export interface MessageUsage {
|
|
144
|
+
n_requests: number;
|
|
145
|
+
estimated_cost: number;
|
|
146
|
+
prompt_tokens: number;
|
|
147
|
+
completion_tokens: number;
|
|
148
|
+
total_tokens: number;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Customization for the header section of the UI.
|
|
152
|
+
*/
|
|
153
|
+
export interface HeaderCustomization {
|
|
154
|
+
/**
|
|
155
|
+
* Custom title to be displayed instead of 'Ragbits Chat'
|
|
156
|
+
*/
|
|
157
|
+
title: string | null;
|
|
158
|
+
/**
|
|
159
|
+
* Custom subtitle to be displayed instead of 'by deepsense.ai'
|
|
160
|
+
*/
|
|
161
|
+
subtitle: string | null;
|
|
162
|
+
/**
|
|
163
|
+
* Custom logo URL or content. The logo can also be served from 'static' directory inside 'ui-buid'
|
|
164
|
+
*/
|
|
165
|
+
logo: string | null;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Customization for the UI.
|
|
169
|
+
*/
|
|
170
|
+
export interface UICustomization {
|
|
171
|
+
/**
|
|
172
|
+
* Custom header configuration
|
|
173
|
+
*/
|
|
174
|
+
header: HeaderCustomization | null;
|
|
175
|
+
/**
|
|
176
|
+
* Custom welcome message to be displayed on the UI. It supports Markdown.
|
|
177
|
+
*/
|
|
178
|
+
welcome_message: string | null;
|
|
179
|
+
/**
|
|
180
|
+
* Custom meta properties customization
|
|
181
|
+
*/
|
|
182
|
+
meta: PageMetaCustomization | null;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Customization for the meta properites of the UI
|
|
186
|
+
*/
|
|
187
|
+
export interface PageMetaCustomization {
|
|
188
|
+
/**
|
|
189
|
+
* Custom favicon URL or content. If `None` logo is used.The favicon can also be serverd from 'static' directory inside 'ui-build'
|
|
190
|
+
*/
|
|
191
|
+
favicon: string | null;
|
|
192
|
+
/**
|
|
193
|
+
* Custom title for the page displayed in the browser's bar. If `None` header title is used.
|
|
194
|
+
*/
|
|
195
|
+
page_title: string | null;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Configuration for chat options.
|
|
199
|
+
*/
|
|
200
|
+
export interface UserSettings {
|
|
201
|
+
/**
|
|
202
|
+
* The form to use for chat options. Use Pydantic models to define form objects, that would get converted to JSONSchema and rendered in the UI.
|
|
203
|
+
*/
|
|
204
|
+
form: RJSFSchema | null;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Feedback configuration containing like and dislike settings.
|
|
208
|
+
*/
|
|
209
|
+
export interface FeedbackConfig {
|
|
210
|
+
like: FeedbackItem;
|
|
211
|
+
dislike: FeedbackItem;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Configuration response from the API.
|
|
215
|
+
*/
|
|
216
|
+
export interface ConfigResponse {
|
|
217
|
+
feedback: FeedbackConfig;
|
|
218
|
+
/**
|
|
219
|
+
* UI customization
|
|
220
|
+
*/
|
|
221
|
+
customization: UICustomization | null;
|
|
222
|
+
user_settings: UserSettings;
|
|
223
|
+
/**
|
|
224
|
+
* Debug mode flag
|
|
225
|
+
*/
|
|
226
|
+
debug_mode: boolean;
|
|
227
|
+
/**
|
|
228
|
+
* Flag to enable conversation history
|
|
229
|
+
*/
|
|
230
|
+
conversation_history: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Flag to enable usage statistics
|
|
233
|
+
*/
|
|
234
|
+
show_usage: boolean;
|
|
235
|
+
authentication: AuthenticationConfig;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Response from feedback submission.
|
|
239
|
+
*/
|
|
240
|
+
export interface FeedbackResponse {
|
|
241
|
+
/**
|
|
242
|
+
* Status of the feedback submission
|
|
243
|
+
*/
|
|
244
|
+
status: string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Client-side chat request interface.
|
|
248
|
+
*/
|
|
249
|
+
export interface ChatRequest {
|
|
250
|
+
/**
|
|
251
|
+
* The current user message
|
|
252
|
+
*/
|
|
253
|
+
message: string;
|
|
254
|
+
/**
|
|
255
|
+
* Previous message history
|
|
256
|
+
*/
|
|
257
|
+
history: Message[];
|
|
258
|
+
/**
|
|
259
|
+
* User context information
|
|
260
|
+
*/
|
|
261
|
+
context: {
|
|
262
|
+
[k: string]: unknown;
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Request body for feedback submission
|
|
267
|
+
*/
|
|
268
|
+
export interface FeedbackRequest {
|
|
269
|
+
/**
|
|
270
|
+
* ID of the message receiving feedback
|
|
271
|
+
*/
|
|
272
|
+
message_id: string;
|
|
273
|
+
/**
|
|
274
|
+
* Type of feedback (like or dislike)
|
|
275
|
+
*/
|
|
276
|
+
feedback: 'like' | 'dislike';
|
|
277
|
+
/**
|
|
278
|
+
* Additional feedback details
|
|
279
|
+
*/
|
|
280
|
+
payload: {
|
|
281
|
+
[k: string]: unknown;
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Configuration for authentication.
|
|
286
|
+
*/
|
|
287
|
+
export interface AuthenticationConfig {
|
|
288
|
+
/**
|
|
289
|
+
* Enable/disable authentication
|
|
290
|
+
*/
|
|
291
|
+
enabled: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* List of available authentication types
|
|
294
|
+
*/
|
|
295
|
+
auth_types: AuthType[];
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Request body for user login
|
|
299
|
+
*/
|
|
300
|
+
export interface CredentialsLoginRequest {
|
|
301
|
+
/**
|
|
302
|
+
* Username
|
|
303
|
+
*/
|
|
304
|
+
username: string;
|
|
305
|
+
/**
|
|
306
|
+
* Password
|
|
307
|
+
*/
|
|
308
|
+
password: string;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Represents a JWT authentication jwt_token.
|
|
312
|
+
*/
|
|
313
|
+
export interface JWTToken {
|
|
314
|
+
access_token: string;
|
|
315
|
+
token_type: string;
|
|
316
|
+
expires_in: number;
|
|
317
|
+
refresh_token: string | null;
|
|
318
|
+
user: User;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Request body for user login
|
|
322
|
+
*/
|
|
323
|
+
export interface LoginRequest {
|
|
324
|
+
/**
|
|
325
|
+
* Username
|
|
326
|
+
*/
|
|
327
|
+
username: string;
|
|
328
|
+
/**
|
|
329
|
+
* Password
|
|
330
|
+
*/
|
|
331
|
+
password: string;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Response body for successful login
|
|
335
|
+
*/
|
|
336
|
+
export interface LoginResponse {
|
|
337
|
+
/**
|
|
338
|
+
* Whether login was successful
|
|
339
|
+
*/
|
|
340
|
+
success: boolean;
|
|
341
|
+
/**
|
|
342
|
+
* User information
|
|
343
|
+
*/
|
|
344
|
+
user: User | null;
|
|
345
|
+
/**
|
|
346
|
+
* Error message if login failed
|
|
347
|
+
*/
|
|
348
|
+
error_message: string | null;
|
|
349
|
+
/**
|
|
350
|
+
* Access jwt_token
|
|
351
|
+
*/
|
|
352
|
+
jwt_token: JWTToken | null;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Request body for user logout
|
|
356
|
+
*/
|
|
357
|
+
export interface LogoutRequest {
|
|
358
|
+
/**
|
|
359
|
+
* Session ID to logout
|
|
360
|
+
*/
|
|
361
|
+
token: string;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Represents an authenticated user.
|
|
365
|
+
*/
|
|
366
|
+
export interface User {
|
|
367
|
+
user_id: string;
|
|
368
|
+
username: string;
|
|
369
|
+
email: string | null;
|
|
370
|
+
full_name: string | null;
|
|
371
|
+
roles: string[];
|
|
372
|
+
metadata: {
|
|
373
|
+
[k: string]: unknown;
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Specific chat response types
|
|
378
|
+
*/
|
|
379
|
+
export interface TextChatResponse {
|
|
380
|
+
type: 'text';
|
|
381
|
+
content: string;
|
|
382
|
+
}
|
|
383
|
+
export interface ReferenceChatResponse {
|
|
384
|
+
type: 'reference';
|
|
385
|
+
content: Reference;
|
|
386
|
+
}
|
|
387
|
+
export interface MessageIdChatResponse {
|
|
388
|
+
type: 'message_id';
|
|
389
|
+
content: string;
|
|
390
|
+
}
|
|
391
|
+
export interface ConversationIdChatResponse {
|
|
392
|
+
type: 'conversation_id';
|
|
393
|
+
content: string;
|
|
394
|
+
}
|
|
395
|
+
export interface StateUpdateChatResponse {
|
|
396
|
+
type: 'state_update';
|
|
397
|
+
content: ServerState;
|
|
398
|
+
}
|
|
399
|
+
export interface LiveUpdateChatResponse {
|
|
400
|
+
type: 'live_update';
|
|
401
|
+
content: LiveUpdate;
|
|
402
|
+
}
|
|
403
|
+
export interface FollowupMessagesChatResponse {
|
|
404
|
+
type: 'followup_messages';
|
|
405
|
+
content: string[];
|
|
406
|
+
}
|
|
407
|
+
export interface ImageChatResponse {
|
|
408
|
+
type: 'image';
|
|
409
|
+
content: Image;
|
|
410
|
+
}
|
|
411
|
+
export interface ClearMessageResponse {
|
|
412
|
+
type: 'clear_message';
|
|
413
|
+
content: never;
|
|
414
|
+
}
|
|
415
|
+
export interface MessageUsageChatResponse {
|
|
416
|
+
type: 'usage';
|
|
417
|
+
content: Record<string, MessageUsage>;
|
|
418
|
+
}
|
|
419
|
+
export interface ChunkedChatResponse {
|
|
420
|
+
type: 'chunked_content';
|
|
421
|
+
content: ChunkedContent;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Typed chat response union
|
|
425
|
+
*/
|
|
426
|
+
export type ChatResponse = TextChatResponse | ReferenceChatResponse | MessageIdChatResponse | ConversationIdChatResponse | StateUpdateChatResponse | LiveUpdateChatResponse | FollowupMessagesChatResponse | ImageChatResponse | ClearMessageResponse | MessageUsageChatResponse;
|