@chainlit/react-client 0.1.2 → 0.2.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.
- package/dist/index.d.mts +57 -42
- package/dist/index.d.ts +57 -42
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +304 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -6
package/dist/index.d.mts
CHANGED
|
@@ -22,8 +22,8 @@ interface ICallFn {
|
|
|
22
22
|
args: Record<string, any>;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
type IElement = IImageElement | ITextElement | IPdfElement | ITasklistElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement;
|
|
26
|
-
type IMessageElement = IImageElement | ITextElement | IPdfElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement;
|
|
25
|
+
type IElement = IImageElement | ITextElement | IPdfElement | ITasklistElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement;
|
|
26
|
+
type IMessageElement = IImageElement | ITextElement | IPdfElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement;
|
|
27
27
|
type ElementType = IElement['type'];
|
|
28
28
|
type IElementSize = 'small' | 'medium' | 'large';
|
|
29
29
|
interface TElement<T> {
|
|
@@ -58,10 +58,9 @@ interface IVideoElement extends TMessageElement<'video'> {
|
|
|
58
58
|
interface IFileElement extends TMessageElement<'file'> {
|
|
59
59
|
type: 'file';
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
61
|
+
type IPlotlyElement = TMessageElement<'plotly'>;
|
|
62
|
+
type ITasklistElement = TElement<'tasklist'>;
|
|
63
|
+
type IDataframeElement = TMessageElement<'dataframe'>;
|
|
65
64
|
|
|
66
65
|
interface IFeedback {
|
|
67
66
|
id?: string;
|
|
@@ -86,11 +85,11 @@ interface IStep {
|
|
|
86
85
|
createdAt: number | string;
|
|
87
86
|
start?: number | string;
|
|
88
87
|
end?: number | string;
|
|
89
|
-
disableFeedback?: boolean;
|
|
90
88
|
feedback?: IFeedback;
|
|
91
89
|
language?: string;
|
|
92
90
|
streaming?: boolean;
|
|
93
91
|
steps?: IStep[];
|
|
92
|
+
metadata?: Record<string, any>;
|
|
94
93
|
indent?: number;
|
|
95
94
|
}
|
|
96
95
|
|
|
@@ -111,6 +110,7 @@ interface IAsk {
|
|
|
111
110
|
type: 'text' | 'file' | 'action';
|
|
112
111
|
timeout: number;
|
|
113
112
|
} & FileSpec & ActionSpec;
|
|
113
|
+
parentId?: string;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
type AuthProvider = 'credentials' | 'header' | 'github' | 'google' | 'azure-ad' | 'azure-ad-hybrid';
|
|
@@ -122,6 +122,7 @@ interface IUserMetadata extends Record<string, any> {
|
|
|
122
122
|
interface IUser {
|
|
123
123
|
id: string;
|
|
124
124
|
identifier: string;
|
|
125
|
+
display_name?: string;
|
|
125
126
|
metadata: IUserMetadata;
|
|
126
127
|
}
|
|
127
128
|
|
|
@@ -163,17 +164,21 @@ interface ChatProfile {
|
|
|
163
164
|
}
|
|
164
165
|
interface IAudioConfig {
|
|
165
166
|
enabled: boolean;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
167
|
+
sample_rate: number;
|
|
168
|
+
}
|
|
169
|
+
interface IAuthConfig {
|
|
170
|
+
requireLogin: boolean;
|
|
171
|
+
passwordAuth: boolean;
|
|
172
|
+
headerAuth: boolean;
|
|
173
|
+
cookieAuth: boolean;
|
|
174
|
+
oauthProviders: string[];
|
|
171
175
|
}
|
|
172
176
|
interface IChainlitConfig {
|
|
173
177
|
markdown?: string;
|
|
174
178
|
ui: {
|
|
175
179
|
name: string;
|
|
176
180
|
description?: string;
|
|
181
|
+
cot: 'hidden' | 'tool_call' | 'full';
|
|
177
182
|
default_collapse_content?: boolean;
|
|
178
183
|
github?: string;
|
|
179
184
|
theme: any;
|
|
@@ -192,6 +197,7 @@ interface IChainlitConfig {
|
|
|
192
197
|
audio: IAudioConfig;
|
|
193
198
|
unsafe_allow_html?: boolean;
|
|
194
199
|
latex?: boolean;
|
|
200
|
+
edit_message?: boolean;
|
|
195
201
|
};
|
|
196
202
|
debugUrl?: string;
|
|
197
203
|
userEnv: string[];
|
|
@@ -239,8 +245,11 @@ declare const useChatInteract: () => {
|
|
|
239
245
|
clear: () => void;
|
|
240
246
|
replyMessage: (message: IStep) => void;
|
|
241
247
|
sendMessage: (message: PartialBy<IStep, 'createdAt' | 'id'>, fileReferences?: IFileRef[]) => void;
|
|
242
|
-
|
|
243
|
-
|
|
248
|
+
editMessage: (message: IStep) => void;
|
|
249
|
+
windowMessage: (data: any) => void;
|
|
250
|
+
startAudioStream: () => void;
|
|
251
|
+
sendAudioChunk: (isStart: boolean, mimeType: string, elapsedTime: number, data: Int16Array) => void;
|
|
252
|
+
endAudioStream: () => void;
|
|
244
253
|
stopTask: () => void;
|
|
245
254
|
setIdToResume: recoil.SetterOrUpdater<string | undefined>;
|
|
246
255
|
updateChatSettings: (values: object) => void;
|
|
@@ -265,6 +274,10 @@ declare const messagesState: recoil.RecoilState<IStep[]>;
|
|
|
265
274
|
declare const tokenCountState: recoil.RecoilState<number>;
|
|
266
275
|
declare const loadingState: recoil.RecoilState<boolean>;
|
|
267
276
|
declare const askUserState: recoil.RecoilState<IAsk | undefined>;
|
|
277
|
+
declare const wavRecorderState: recoil.RecoilState<any>;
|
|
278
|
+
declare const wavStreamPlayerState: recoil.RecoilState<any>;
|
|
279
|
+
declare const audioConnectionState: recoil.RecoilState<"connecting" | "on" | "off">;
|
|
280
|
+
declare const isAiSpeakingState: recoil.RecoilState<boolean>;
|
|
268
281
|
declare const callFnState: recoil.RecoilState<ICallFn | undefined>;
|
|
269
282
|
declare const chatSettingsInputsState: recoil.RecoilState<any>;
|
|
270
283
|
declare const chatSettingsDefaultValueSelector: recoil.RecoilValueReadOnly<any>;
|
|
@@ -275,12 +288,14 @@ declare const firstUserInteraction: recoil.RecoilState<string | undefined>;
|
|
|
275
288
|
declare const accessTokenState: recoil.RecoilState<string | undefined>;
|
|
276
289
|
declare const userState: recoil.RecoilState<IUser | null>;
|
|
277
290
|
declare const configState: recoil.RecoilState<IChainlitConfig | undefined>;
|
|
291
|
+
declare const authState: recoil.RecoilState<IAuthConfig | undefined>;
|
|
278
292
|
declare const threadHistoryState: recoil.RecoilState<ThreadHistory | undefined>;
|
|
279
293
|
declare const sideViewState: recoil.RecoilState<IMessageElement | undefined>;
|
|
280
294
|
declare const currentThreadIdState: recoil.RecoilState<string | undefined>;
|
|
281
295
|
|
|
282
296
|
declare const useChatSession: () => {
|
|
283
|
-
connect: lodash.DebouncedFunc<({ userEnv, accessToken }: {
|
|
297
|
+
connect: lodash.DebouncedFunc<({ transports, userEnv, accessToken }: {
|
|
298
|
+
transports?: string[] | undefined;
|
|
284
299
|
userEnv: Record<string, string>;
|
|
285
300
|
accessToken?: string | undefined;
|
|
286
301
|
}) => void>;
|
|
@@ -292,14 +307,13 @@ declare const useChatSession: () => {
|
|
|
292
307
|
setChatProfile: recoil.SetterOrUpdater<string | undefined>;
|
|
293
308
|
};
|
|
294
309
|
|
|
295
|
-
declare const useAudio: (
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
error: string | undefined;
|
|
310
|
+
declare const useAudio: () => {
|
|
311
|
+
startConversation: () => Promise<void>;
|
|
312
|
+
endConversation: () => Promise<void>;
|
|
313
|
+
audioConnection: "connecting" | "on" | "off";
|
|
314
|
+
isAiSpeaking: boolean;
|
|
315
|
+
wavRecorder: any;
|
|
316
|
+
wavStreamPlayer: any;
|
|
303
317
|
};
|
|
304
318
|
|
|
305
319
|
declare const useConfig: (accessToken?: string) => {
|
|
@@ -310,31 +324,25 @@ declare const useConfig: (accessToken?: string) => {
|
|
|
310
324
|
};
|
|
311
325
|
|
|
312
326
|
declare const useAuth: () => {
|
|
313
|
-
data:
|
|
314
|
-
requireLogin: boolean;
|
|
315
|
-
passwordAuth: boolean;
|
|
316
|
-
headerAuth: boolean;
|
|
317
|
-
oauthProviders: string[];
|
|
318
|
-
};
|
|
327
|
+
data: IAuthConfig;
|
|
319
328
|
user: null;
|
|
320
329
|
isReady: boolean;
|
|
321
330
|
isAuthenticated: boolean;
|
|
322
331
|
accessToken: string;
|
|
323
|
-
logout: () => void
|
|
332
|
+
logout: () => Promise<void>;
|
|
324
333
|
setAccessToken: () => void;
|
|
334
|
+
setUserFromAPI: () => Promise<void>;
|
|
335
|
+
cookieAuth: boolean | undefined;
|
|
325
336
|
} | {
|
|
326
|
-
data:
|
|
327
|
-
requireLogin: boolean;
|
|
328
|
-
passwordAuth: boolean;
|
|
329
|
-
headerAuth: boolean;
|
|
330
|
-
oauthProviders: string[];
|
|
331
|
-
} | undefined;
|
|
337
|
+
data: IAuthConfig | undefined;
|
|
332
338
|
user: IUser | null;
|
|
333
|
-
isAuthenticated: boolean;
|
|
334
339
|
isReady: boolean;
|
|
340
|
+
isAuthenticated: boolean;
|
|
335
341
|
accessToken: string | undefined;
|
|
336
|
-
logout: () => Promise<void>;
|
|
337
|
-
setAccessToken: (token: string
|
|
342
|
+
logout: (reload?: boolean) => Promise<void>;
|
|
343
|
+
setAccessToken: (token: string) => void;
|
|
344
|
+
setUserFromAPI: swr__internal.KeyedMutator<IUser>;
|
|
345
|
+
cookieAuth: boolean | undefined;
|
|
338
346
|
};
|
|
339
347
|
|
|
340
348
|
declare const fetcher: (client: ChainlitAPI, endpoint: string, token?: string) => Promise<any>;
|
|
@@ -355,8 +363,9 @@ interface IPagination {
|
|
|
355
363
|
cursor?: string | number;
|
|
356
364
|
}
|
|
357
365
|
declare class ClientError extends Error {
|
|
366
|
+
status: number;
|
|
358
367
|
detail?: string;
|
|
359
|
-
constructor(message: string, detail?: string);
|
|
368
|
+
constructor(message: string, status: number, detail?: string);
|
|
360
369
|
toString(): string;
|
|
361
370
|
}
|
|
362
371
|
type Payload = FormData | any;
|
|
@@ -367,7 +376,8 @@ declare class APIBase {
|
|
|
367
376
|
onError?: ((error: ClientError) => void) | undefined;
|
|
368
377
|
constructor(httpEndpoint: string, type: 'webapp' | 'copilot' | 'teams' | 'slack' | 'discord', on401?: (() => void) | undefined, onError?: ((error: ClientError) => void) | undefined);
|
|
369
378
|
buildEndpoint(path: string): string;
|
|
370
|
-
|
|
379
|
+
private getDetailFromErrorResponse;
|
|
380
|
+
private handleRequestError;
|
|
371
381
|
fetch(method: string, path: string, token?: string, data?: Payload, signal?: AbortSignal): Promise<Response>;
|
|
372
382
|
get(endpoint: string, token?: string): Promise<Response>;
|
|
373
383
|
post(endpoint: string, data: Payload, token?: string, signal?: AbortSignal): Promise<Response>;
|
|
@@ -378,6 +388,7 @@ declare class APIBase {
|
|
|
378
388
|
declare class ChainlitAPI extends APIBase {
|
|
379
389
|
headerAuth(): Promise<any>;
|
|
380
390
|
passwordAuth(data: FormData): Promise<any>;
|
|
391
|
+
getUser(accessToken?: string): Promise<IUser>;
|
|
381
392
|
logout(): Promise<any>;
|
|
382
393
|
setFeedback(feedback: IFeedback, accessToken?: string): Promise<{
|
|
383
394
|
success: boolean;
|
|
@@ -414,4 +425,8 @@ declare const updateMessageById: (messages: IStep[], messageId: string, updatedM
|
|
|
414
425
|
declare const deleteMessageById: (messages: IStep[], messageId: string) => IStep[];
|
|
415
426
|
declare const updateMessageContentById: (messages: IStep[], messageId: number | string, updatedContent: string, isSequence: boolean, isInput: boolean) => IStep[];
|
|
416
427
|
|
|
417
|
-
|
|
428
|
+
declare const WavRenderer: {
|
|
429
|
+
drawBars: (ctx: CanvasRenderingContext2D, data: Float32Array, cssWidth: number, cssHeight: number, color: string, pointCount?: number, barWidth?: number, barSpacing?: number, center?: boolean) => void;
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
export { APIBase, ActionSpec, AuthProvider, ChainlitAPI, ChainlitContext, ChatProfile, ClientError, ElementType, FileSpec, IAction, IAsk, IAudioConfig, IAudioElement, IAuthConfig, ICallFn, IChainlitConfig, IDataframeElement, IElement, IElementSize, IFeedback, IFileElement, IFileRef, IImageElement, IMessageElement, IPageInfo, IPagination, IPdfElement, IPlotlyElement, ISession, IStarter, IStep, ITasklistElement, ITextElement, IThread, IThreadFilters, IToken, IUser, IUserMetadata, IVideoElement, ThreadHistory, UserInput, WavRenderer, accessTokenState, actionState, addMessage, addMessageToParent, askUserState, audioConnectionState, authState, callFnState, chatProfileState, chatSettingsDefaultValueSelector, chatSettingsInputsState, chatSettingsValueState, configState, currentThreadIdState, defaultChainlitContext, deleteMessageById, elementState, fetcher, firstUserInteraction, hasMessageById, isAiSpeakingState, isLastMessage, loadingState, messagesState, nestMessages, sessionIdState, sessionState, sideViewState, tasklistState, threadHistoryState, threadIdToResumeState, tokenCountState, updateMessageById, updateMessageContentById, useApi, useAudio, useAuth, useChatData, useChatInteract, useChatMessages, useChatSession, useConfig, userState, wavRecorderState, wavStreamPlayerState };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,8 +22,8 @@ interface ICallFn {
|
|
|
22
22
|
args: Record<string, any>;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
type IElement = IImageElement | ITextElement | IPdfElement | ITasklistElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement;
|
|
26
|
-
type IMessageElement = IImageElement | ITextElement | IPdfElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement;
|
|
25
|
+
type IElement = IImageElement | ITextElement | IPdfElement | ITasklistElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement;
|
|
26
|
+
type IMessageElement = IImageElement | ITextElement | IPdfElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement;
|
|
27
27
|
type ElementType = IElement['type'];
|
|
28
28
|
type IElementSize = 'small' | 'medium' | 'large';
|
|
29
29
|
interface TElement<T> {
|
|
@@ -58,10 +58,9 @@ interface IVideoElement extends TMessageElement<'video'> {
|
|
|
58
58
|
interface IFileElement extends TMessageElement<'file'> {
|
|
59
59
|
type: 'file';
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
61
|
+
type IPlotlyElement = TMessageElement<'plotly'>;
|
|
62
|
+
type ITasklistElement = TElement<'tasklist'>;
|
|
63
|
+
type IDataframeElement = TMessageElement<'dataframe'>;
|
|
65
64
|
|
|
66
65
|
interface IFeedback {
|
|
67
66
|
id?: string;
|
|
@@ -86,11 +85,11 @@ interface IStep {
|
|
|
86
85
|
createdAt: number | string;
|
|
87
86
|
start?: number | string;
|
|
88
87
|
end?: number | string;
|
|
89
|
-
disableFeedback?: boolean;
|
|
90
88
|
feedback?: IFeedback;
|
|
91
89
|
language?: string;
|
|
92
90
|
streaming?: boolean;
|
|
93
91
|
steps?: IStep[];
|
|
92
|
+
metadata?: Record<string, any>;
|
|
94
93
|
indent?: number;
|
|
95
94
|
}
|
|
96
95
|
|
|
@@ -111,6 +110,7 @@ interface IAsk {
|
|
|
111
110
|
type: 'text' | 'file' | 'action';
|
|
112
111
|
timeout: number;
|
|
113
112
|
} & FileSpec & ActionSpec;
|
|
113
|
+
parentId?: string;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
type AuthProvider = 'credentials' | 'header' | 'github' | 'google' | 'azure-ad' | 'azure-ad-hybrid';
|
|
@@ -122,6 +122,7 @@ interface IUserMetadata extends Record<string, any> {
|
|
|
122
122
|
interface IUser {
|
|
123
123
|
id: string;
|
|
124
124
|
identifier: string;
|
|
125
|
+
display_name?: string;
|
|
125
126
|
metadata: IUserMetadata;
|
|
126
127
|
}
|
|
127
128
|
|
|
@@ -163,17 +164,21 @@ interface ChatProfile {
|
|
|
163
164
|
}
|
|
164
165
|
interface IAudioConfig {
|
|
165
166
|
enabled: boolean;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
167
|
+
sample_rate: number;
|
|
168
|
+
}
|
|
169
|
+
interface IAuthConfig {
|
|
170
|
+
requireLogin: boolean;
|
|
171
|
+
passwordAuth: boolean;
|
|
172
|
+
headerAuth: boolean;
|
|
173
|
+
cookieAuth: boolean;
|
|
174
|
+
oauthProviders: string[];
|
|
171
175
|
}
|
|
172
176
|
interface IChainlitConfig {
|
|
173
177
|
markdown?: string;
|
|
174
178
|
ui: {
|
|
175
179
|
name: string;
|
|
176
180
|
description?: string;
|
|
181
|
+
cot: 'hidden' | 'tool_call' | 'full';
|
|
177
182
|
default_collapse_content?: boolean;
|
|
178
183
|
github?: string;
|
|
179
184
|
theme: any;
|
|
@@ -192,6 +197,7 @@ interface IChainlitConfig {
|
|
|
192
197
|
audio: IAudioConfig;
|
|
193
198
|
unsafe_allow_html?: boolean;
|
|
194
199
|
latex?: boolean;
|
|
200
|
+
edit_message?: boolean;
|
|
195
201
|
};
|
|
196
202
|
debugUrl?: string;
|
|
197
203
|
userEnv: string[];
|
|
@@ -239,8 +245,11 @@ declare const useChatInteract: () => {
|
|
|
239
245
|
clear: () => void;
|
|
240
246
|
replyMessage: (message: IStep) => void;
|
|
241
247
|
sendMessage: (message: PartialBy<IStep, 'createdAt' | 'id'>, fileReferences?: IFileRef[]) => void;
|
|
242
|
-
|
|
243
|
-
|
|
248
|
+
editMessage: (message: IStep) => void;
|
|
249
|
+
windowMessage: (data: any) => void;
|
|
250
|
+
startAudioStream: () => void;
|
|
251
|
+
sendAudioChunk: (isStart: boolean, mimeType: string, elapsedTime: number, data: Int16Array) => void;
|
|
252
|
+
endAudioStream: () => void;
|
|
244
253
|
stopTask: () => void;
|
|
245
254
|
setIdToResume: recoil.SetterOrUpdater<string | undefined>;
|
|
246
255
|
updateChatSettings: (values: object) => void;
|
|
@@ -265,6 +274,10 @@ declare const messagesState: recoil.RecoilState<IStep[]>;
|
|
|
265
274
|
declare const tokenCountState: recoil.RecoilState<number>;
|
|
266
275
|
declare const loadingState: recoil.RecoilState<boolean>;
|
|
267
276
|
declare const askUserState: recoil.RecoilState<IAsk | undefined>;
|
|
277
|
+
declare const wavRecorderState: recoil.RecoilState<any>;
|
|
278
|
+
declare const wavStreamPlayerState: recoil.RecoilState<any>;
|
|
279
|
+
declare const audioConnectionState: recoil.RecoilState<"connecting" | "on" | "off">;
|
|
280
|
+
declare const isAiSpeakingState: recoil.RecoilState<boolean>;
|
|
268
281
|
declare const callFnState: recoil.RecoilState<ICallFn | undefined>;
|
|
269
282
|
declare const chatSettingsInputsState: recoil.RecoilState<any>;
|
|
270
283
|
declare const chatSettingsDefaultValueSelector: recoil.RecoilValueReadOnly<any>;
|
|
@@ -275,12 +288,14 @@ declare const firstUserInteraction: recoil.RecoilState<string | undefined>;
|
|
|
275
288
|
declare const accessTokenState: recoil.RecoilState<string | undefined>;
|
|
276
289
|
declare const userState: recoil.RecoilState<IUser | null>;
|
|
277
290
|
declare const configState: recoil.RecoilState<IChainlitConfig | undefined>;
|
|
291
|
+
declare const authState: recoil.RecoilState<IAuthConfig | undefined>;
|
|
278
292
|
declare const threadHistoryState: recoil.RecoilState<ThreadHistory | undefined>;
|
|
279
293
|
declare const sideViewState: recoil.RecoilState<IMessageElement | undefined>;
|
|
280
294
|
declare const currentThreadIdState: recoil.RecoilState<string | undefined>;
|
|
281
295
|
|
|
282
296
|
declare const useChatSession: () => {
|
|
283
|
-
connect: lodash.DebouncedFunc<({ userEnv, accessToken }: {
|
|
297
|
+
connect: lodash.DebouncedFunc<({ transports, userEnv, accessToken }: {
|
|
298
|
+
transports?: string[] | undefined;
|
|
284
299
|
userEnv: Record<string, string>;
|
|
285
300
|
accessToken?: string | undefined;
|
|
286
301
|
}) => void>;
|
|
@@ -292,14 +307,13 @@ declare const useChatSession: () => {
|
|
|
292
307
|
setChatProfile: recoil.SetterOrUpdater<string | undefined>;
|
|
293
308
|
};
|
|
294
309
|
|
|
295
|
-
declare const useAudio: (
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
error: string | undefined;
|
|
310
|
+
declare const useAudio: () => {
|
|
311
|
+
startConversation: () => Promise<void>;
|
|
312
|
+
endConversation: () => Promise<void>;
|
|
313
|
+
audioConnection: "connecting" | "on" | "off";
|
|
314
|
+
isAiSpeaking: boolean;
|
|
315
|
+
wavRecorder: any;
|
|
316
|
+
wavStreamPlayer: any;
|
|
303
317
|
};
|
|
304
318
|
|
|
305
319
|
declare const useConfig: (accessToken?: string) => {
|
|
@@ -310,31 +324,25 @@ declare const useConfig: (accessToken?: string) => {
|
|
|
310
324
|
};
|
|
311
325
|
|
|
312
326
|
declare const useAuth: () => {
|
|
313
|
-
data:
|
|
314
|
-
requireLogin: boolean;
|
|
315
|
-
passwordAuth: boolean;
|
|
316
|
-
headerAuth: boolean;
|
|
317
|
-
oauthProviders: string[];
|
|
318
|
-
};
|
|
327
|
+
data: IAuthConfig;
|
|
319
328
|
user: null;
|
|
320
329
|
isReady: boolean;
|
|
321
330
|
isAuthenticated: boolean;
|
|
322
331
|
accessToken: string;
|
|
323
|
-
logout: () => void
|
|
332
|
+
logout: () => Promise<void>;
|
|
324
333
|
setAccessToken: () => void;
|
|
334
|
+
setUserFromAPI: () => Promise<void>;
|
|
335
|
+
cookieAuth: boolean | undefined;
|
|
325
336
|
} | {
|
|
326
|
-
data:
|
|
327
|
-
requireLogin: boolean;
|
|
328
|
-
passwordAuth: boolean;
|
|
329
|
-
headerAuth: boolean;
|
|
330
|
-
oauthProviders: string[];
|
|
331
|
-
} | undefined;
|
|
337
|
+
data: IAuthConfig | undefined;
|
|
332
338
|
user: IUser | null;
|
|
333
|
-
isAuthenticated: boolean;
|
|
334
339
|
isReady: boolean;
|
|
340
|
+
isAuthenticated: boolean;
|
|
335
341
|
accessToken: string | undefined;
|
|
336
|
-
logout: () => Promise<void>;
|
|
337
|
-
setAccessToken: (token: string
|
|
342
|
+
logout: (reload?: boolean) => Promise<void>;
|
|
343
|
+
setAccessToken: (token: string) => void;
|
|
344
|
+
setUserFromAPI: swr__internal.KeyedMutator<IUser>;
|
|
345
|
+
cookieAuth: boolean | undefined;
|
|
338
346
|
};
|
|
339
347
|
|
|
340
348
|
declare const fetcher: (client: ChainlitAPI, endpoint: string, token?: string) => Promise<any>;
|
|
@@ -355,8 +363,9 @@ interface IPagination {
|
|
|
355
363
|
cursor?: string | number;
|
|
356
364
|
}
|
|
357
365
|
declare class ClientError extends Error {
|
|
366
|
+
status: number;
|
|
358
367
|
detail?: string;
|
|
359
|
-
constructor(message: string, detail?: string);
|
|
368
|
+
constructor(message: string, status: number, detail?: string);
|
|
360
369
|
toString(): string;
|
|
361
370
|
}
|
|
362
371
|
type Payload = FormData | any;
|
|
@@ -367,7 +376,8 @@ declare class APIBase {
|
|
|
367
376
|
onError?: ((error: ClientError) => void) | undefined;
|
|
368
377
|
constructor(httpEndpoint: string, type: 'webapp' | 'copilot' | 'teams' | 'slack' | 'discord', on401?: (() => void) | undefined, onError?: ((error: ClientError) => void) | undefined);
|
|
369
378
|
buildEndpoint(path: string): string;
|
|
370
|
-
|
|
379
|
+
private getDetailFromErrorResponse;
|
|
380
|
+
private handleRequestError;
|
|
371
381
|
fetch(method: string, path: string, token?: string, data?: Payload, signal?: AbortSignal): Promise<Response>;
|
|
372
382
|
get(endpoint: string, token?: string): Promise<Response>;
|
|
373
383
|
post(endpoint: string, data: Payload, token?: string, signal?: AbortSignal): Promise<Response>;
|
|
@@ -378,6 +388,7 @@ declare class APIBase {
|
|
|
378
388
|
declare class ChainlitAPI extends APIBase {
|
|
379
389
|
headerAuth(): Promise<any>;
|
|
380
390
|
passwordAuth(data: FormData): Promise<any>;
|
|
391
|
+
getUser(accessToken?: string): Promise<IUser>;
|
|
381
392
|
logout(): Promise<any>;
|
|
382
393
|
setFeedback(feedback: IFeedback, accessToken?: string): Promise<{
|
|
383
394
|
success: boolean;
|
|
@@ -414,4 +425,8 @@ declare const updateMessageById: (messages: IStep[], messageId: string, updatedM
|
|
|
414
425
|
declare const deleteMessageById: (messages: IStep[], messageId: string) => IStep[];
|
|
415
426
|
declare const updateMessageContentById: (messages: IStep[], messageId: number | string, updatedContent: string, isSequence: boolean, isInput: boolean) => IStep[];
|
|
416
427
|
|
|
417
|
-
|
|
428
|
+
declare const WavRenderer: {
|
|
429
|
+
drawBars: (ctx: CanvasRenderingContext2D, data: Float32Array, cssWidth: number, cssHeight: number, color: string, pointCount?: number, barWidth?: number, barSpacing?: number, center?: boolean) => void;
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
export { APIBase, ActionSpec, AuthProvider, ChainlitAPI, ChainlitContext, ChatProfile, ClientError, ElementType, FileSpec, IAction, IAsk, IAudioConfig, IAudioElement, IAuthConfig, ICallFn, IChainlitConfig, IDataframeElement, IElement, IElementSize, IFeedback, IFileElement, IFileRef, IImageElement, IMessageElement, IPageInfo, IPagination, IPdfElement, IPlotlyElement, ISession, IStarter, IStep, ITasklistElement, ITextElement, IThread, IThreadFilters, IToken, IUser, IUserMetadata, IVideoElement, ThreadHistory, UserInput, WavRenderer, accessTokenState, actionState, addMessage, addMessageToParent, askUserState, audioConnectionState, authState, callFnState, chatProfileState, chatSettingsDefaultValueSelector, chatSettingsInputsState, chatSettingsValueState, configState, currentThreadIdState, defaultChainlitContext, deleteMessageById, elementState, fetcher, firstUserInteraction, hasMessageById, isAiSpeakingState, isLastMessage, loadingState, messagesState, nestMessages, sessionIdState, sessionState, sideViewState, tasklistState, threadHistoryState, threadIdToResumeState, tokenCountState, updateMessageById, updateMessageContentById, useApi, useAudio, useAuth, useChatData, useChatInteract, useChatMessages, useChatSession, useConfig, userState, wavRecorderState, wavStreamPlayerState };
|