@chainlit/react-client 0.2.0 → 0.2.2

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 CHANGED
@@ -59,8 +59,7 @@ const ChatComponent = () => {
59
59
  connect({
60
60
  userEnv: {
61
61
  /* user environment variables */
62
- },
63
- accessToken: 'Bearer YOUR_ACCESS_TOKEN' // Optional Chainlit auth token
62
+ }
64
63
  });
65
64
 
66
65
  return () => {
package/dist/index.d.mts CHANGED
@@ -7,14 +7,14 @@ import * as swr__internal from 'swr/_internal';
7
7
  import { SWRConfiguration } from 'swr';
8
8
 
9
9
  interface IAction {
10
- description?: string;
10
+ label: string;
11
11
  forId: string;
12
12
  id: string;
13
- label?: string;
13
+ payload: Record<string, unknown>;
14
14
  name: string;
15
15
  onClick: () => void;
16
- value: string;
17
- collapsed: boolean;
16
+ tooltip: string;
17
+ icon?: string;
18
18
  }
19
19
  interface ICallFn {
20
20
  callback: (payload: Record<string, any>) => void;
@@ -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 | ICustomElement;
26
+ type IMessageElement = IImageElement | ITextElement | IPdfElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement | ICustomElement;
27
27
  type ElementType = IElement['type'];
28
28
  type IElementSize = 'small' | 'medium' | 'large';
29
29
  interface TElement<T> {
@@ -58,9 +58,11 @@ interface IVideoElement extends TMessageElement<'video'> {
58
58
  interface IFileElement extends TMessageElement<'file'> {
59
59
  type: 'file';
60
60
  }
61
- interface IPlotlyElement extends TMessageElement<'plotly'> {
62
- }
63
- interface ITasklistElement extends TElement<'tasklist'> {
61
+ type IPlotlyElement = TMessageElement<'plotly'>;
62
+ type ITasklistElement = TElement<'tasklist'>;
63
+ type IDataframeElement = TMessageElement<'dataframe'>;
64
+ interface ICustomElement extends TMessageElement<'custom'> {
65
+ props: Record<string, unknown>;
64
66
  }
65
67
 
66
68
  interface IFeedback {
@@ -90,6 +92,7 @@ interface IStep {
90
92
  language?: string;
91
93
  streaming?: boolean;
92
94
  steps?: IStep[];
95
+ metadata?: Record<string, any>;
93
96
  indent?: number;
94
97
  }
95
98
 
@@ -110,6 +113,7 @@ interface IAsk {
110
113
  type: 'text' | 'file' | 'action';
111
114
  timeout: number;
112
115
  } & FileSpec & ActionSpec;
116
+ parentId?: string;
113
117
  }
114
118
 
115
119
  type AuthProvider = 'credentials' | 'header' | 'github' | 'google' | 'azure-ad' | 'azure-ad-hybrid';
@@ -170,16 +174,18 @@ interface IAuthConfig {
170
174
  passwordAuth: boolean;
171
175
  headerAuth: boolean;
172
176
  oauthProviders: string[];
177
+ default_theme?: 'light' | 'dark';
173
178
  }
174
179
  interface IChainlitConfig {
175
180
  markdown?: string;
176
181
  ui: {
177
182
  name: string;
178
183
  description?: string;
184
+ font_family?: string;
185
+ default_theme?: 'light' | 'dark';
186
+ layout?: 'default' | 'wide';
179
187
  cot: 'hidden' | 'tool_call' | 'full';
180
- default_collapse_content?: boolean;
181
188
  github?: string;
182
- theme: any;
183
189
  custom_css?: string;
184
190
  custom_js?: string;
185
191
  custom_font?: string;
@@ -235,15 +241,11 @@ declare const useChatInteract: () => {
235
241
  id: string;
236
242
  }>;
237
243
  };
238
- callAction: (action: IAction) => Promise<{
239
- id: string;
240
- status: boolean;
241
- response?: string | undefined;
242
- }> | undefined;
243
244
  clear: () => void;
244
245
  replyMessage: (message: IStep) => void;
245
246
  sendMessage: (message: PartialBy<IStep, 'createdAt' | 'id'>, fileReferences?: IFileRef[]) => void;
246
247
  editMessage: (message: IStep) => void;
248
+ windowMessage: (data: any) => void;
247
249
  startAudioStream: () => void;
248
250
  sendAudioChunk: (isStart: boolean, mimeType: string, elapsedTime: number, data: Int16Array) => void;
249
251
  endAudioStream: () => void;
@@ -282,8 +284,7 @@ declare const chatSettingsValueState: recoil.RecoilState<any>;
282
284
  declare const elementState: recoil.RecoilState<IMessageElement[]>;
283
285
  declare const tasklistState: recoil.RecoilState<ITasklistElement[]>;
284
286
  declare const firstUserInteraction: recoil.RecoilState<string | undefined>;
285
- declare const accessTokenState: recoil.RecoilState<string | undefined>;
286
- declare const userState: recoil.RecoilState<IUser | null>;
287
+ declare const userState: recoil.RecoilState<IUser | null | undefined>;
287
288
  declare const configState: recoil.RecoilState<IChainlitConfig | undefined>;
288
289
  declare const authState: recoil.RecoilState<IAuthConfig | undefined>;
289
290
  declare const threadHistoryState: recoil.RecoilState<ThreadHistory | undefined>;
@@ -291,9 +292,9 @@ declare const sideViewState: recoil.RecoilState<IMessageElement | undefined>;
291
292
  declare const currentThreadIdState: recoil.RecoilState<string | undefined>;
292
293
 
293
294
  declare const useChatSession: () => {
294
- connect: lodash.DebouncedFunc<({ userEnv, accessToken }: {
295
+ connect: lodash.DebouncedFunc<({ transports, userEnv }: {
296
+ transports?: string[] | undefined;
295
297
  userEnv: Record<string, string>;
296
- accessToken?: string | undefined;
297
298
  }) => void>;
298
299
  disconnect: () => void;
299
300
  session: ISession | undefined;
@@ -312,7 +313,7 @@ declare const useAudio: () => {
312
313
  wavStreamPlayer: any;
313
314
  };
314
315
 
315
- declare const useConfig: (accessToken?: string) => {
316
+ declare const useConfig: () => {
316
317
  config: IChainlitConfig | undefined;
317
318
  error: Error | undefined;
318
319
  isLoading: boolean;
@@ -320,29 +321,23 @@ declare const useConfig: (accessToken?: string) => {
320
321
  };
321
322
 
322
323
  declare const useAuth: () => {
323
- authConfig: IAuthConfig;
324
+ data: IAuthConfig;
324
325
  user: null;
325
326
  isReady: boolean;
326
327
  isAuthenticated: boolean;
327
- accessToken: string;
328
- logout: () => void;
329
- setAccessToken: () => void;
330
- data?: undefined;
328
+ logout: () => Promise<void>;
329
+ setUserFromAPI: () => Promise<void>;
331
330
  } | {
332
331
  data: IAuthConfig | undefined;
333
- user: IUser | null;
334
- isAuthenticated: boolean;
332
+ user: IUser | null | undefined;
335
333
  isReady: boolean;
336
- accessToken: string | undefined;
334
+ isAuthenticated: boolean;
337
335
  logout: (reload?: boolean) => Promise<void>;
338
- setAccessToken: (token: string | null | undefined) => void;
339
- authConfig?: undefined;
336
+ setUserFromAPI: swr__internal.KeyedMutator<IUser>;
340
337
  };
341
338
 
342
- declare const fetcher: (client: ChainlitAPI, endpoint: string, token?: string) => Promise<any>;
343
- declare function useApi<T>(path?: string | null, { token, ...swrConfig }?: SWRConfiguration & {
344
- token?: string;
345
- }): swr__internal.SWRResponse<T, Error, Partial<swr__internal.PublicConfiguration<T, Error, swr__internal.BareFetcher<T>>> | undefined>;
339
+ declare const fetcher: (client: ChainlitAPI, endpoint: string) => Promise<any>;
340
+ declare function useApi<T>(path?: string | null, { ...swrConfig }?: SWRConfiguration): swr__internal.SWRResponse<T, Error, Partial<swr__internal.PublicConfiguration<T, Error, swr__internal.BareFetcher<T>>> | undefined>;
346
341
 
347
342
  interface IThreadFilters {
348
343
  search?: string;
@@ -357,8 +352,9 @@ interface IPagination {
357
352
  cursor?: string | number;
358
353
  }
359
354
  declare class ClientError extends Error {
355
+ status: number;
360
356
  detail?: string;
361
- constructor(message: string, detail?: string);
357
+ constructor(message: string, status: number, detail?: string);
362
358
  toString(): string;
363
359
  }
364
360
  type Payload = FormData | any;
@@ -369,36 +365,46 @@ declare class APIBase {
369
365
  onError?: ((error: ClientError) => void) | undefined;
370
366
  constructor(httpEndpoint: string, type: 'webapp' | 'copilot' | 'teams' | 'slack' | 'discord', on401?: (() => void) | undefined, onError?: ((error: ClientError) => void) | undefined);
371
367
  buildEndpoint(path: string): string;
372
- checkToken(token: string): string;
373
- fetch(method: string, path: string, token?: string, data?: Payload, signal?: AbortSignal): Promise<Response>;
374
- get(endpoint: string, token?: string): Promise<Response>;
375
- post(endpoint: string, data: Payload, token?: string, signal?: AbortSignal): Promise<Response>;
376
- put(endpoint: string, data: Payload, token?: string): Promise<Response>;
377
- patch(endpoint: string, data: Payload, token?: string): Promise<Response>;
378
- delete(endpoint: string, data: Payload, token?: string): Promise<Response>;
368
+ private getDetailFromErrorResponse;
369
+ private handleRequestError;
370
+ fetch(method: string, path: string, data?: Payload, signal?: AbortSignal, headers?: {
371
+ Authorization?: string;
372
+ 'Content-Type'?: string;
373
+ }): Promise<Response>;
374
+ get(endpoint: string): Promise<Response>;
375
+ post(endpoint: string, data: Payload, signal?: AbortSignal): Promise<Response>;
376
+ put(endpoint: string, data: Payload): Promise<Response>;
377
+ patch(endpoint: string, data: Payload): Promise<Response>;
378
+ delete(endpoint: string, data: Payload): Promise<Response>;
379
379
  }
380
380
  declare class ChainlitAPI extends APIBase {
381
381
  headerAuth(): Promise<any>;
382
+ jwtAuth(token: string): Promise<any>;
382
383
  passwordAuth(data: FormData): Promise<any>;
384
+ getUser(): Promise<IUser>;
383
385
  logout(): Promise<any>;
384
- setFeedback(feedback: IFeedback, accessToken?: string): Promise<{
386
+ setFeedback(feedback: IFeedback): Promise<{
385
387
  success: boolean;
386
388
  feedbackId: string;
387
389
  }>;
388
- deleteFeedback(feedbackId: string, accessToken?: string): Promise<{
390
+ deleteFeedback(feedbackId: string): Promise<{
389
391
  success: boolean;
390
392
  }>;
391
- listThreads(pagination: IPagination, filter: IThreadFilters, accessToken?: string): Promise<{
393
+ listThreads(pagination: IPagination, filter: IThreadFilters): Promise<{
392
394
  pageInfo: IPageInfo;
393
395
  data: IThread[];
394
396
  }>;
395
- deleteThread(threadId: string, accessToken?: string): Promise<any>;
396
- uploadFile(file: File, onProgress: (progress: number) => void, sessionId: string, token?: string): {
397
+ renameThread(threadId: string, name: string): Promise<any>;
398
+ deleteThread(threadId: string): Promise<any>;
399
+ uploadFile(file: File, onProgress: (progress: number) => void, sessionId: string): {
397
400
  xhr: XMLHttpRequest;
398
401
  promise: Promise<{
399
402
  id: string;
400
403
  }>;
401
404
  };
405
+ callAction(action: IAction, sessionId: string): Promise<any>;
406
+ updateElement(element: IElement, sessionId: string): Promise<any>;
407
+ deleteElement(element: IElement, sessionId: string): Promise<any>;
402
408
  getElementUrl(id: string, sessionId: string): string;
403
409
  getLogoEndpoint(theme: string): string;
404
410
  getOAuthEndpoint(provider: string): string;
@@ -420,4 +426,4 @@ declare const WavRenderer: {
420
426
  drawBars: (ctx: CanvasRenderingContext2D, data: Float32Array, cssWidth: number, cssHeight: number, color: string, pointCount?: number, barWidth?: number, barSpacing?: number, center?: boolean) => void;
421
427
  };
422
428
 
423
- export { APIBase, ActionSpec, AuthProvider, ChainlitAPI, ChainlitContext, ChatProfile, ClientError, ElementType, FileSpec, IAction, IAsk, IAudioConfig, IAudioElement, IAuthConfig, ICallFn, IChainlitConfig, 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 };
429
+ export { APIBase, ActionSpec, AuthProvider, ChainlitAPI, ChainlitContext, ChatProfile, ClientError, ElementType, FileSpec, IAction, IAsk, IAudioConfig, IAudioElement, IAuthConfig, ICallFn, IChainlitConfig, ICustomElement, 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, 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
@@ -7,14 +7,14 @@ import * as swr__internal from 'swr/_internal';
7
7
  import { SWRConfiguration } from 'swr';
8
8
 
9
9
  interface IAction {
10
- description?: string;
10
+ label: string;
11
11
  forId: string;
12
12
  id: string;
13
- label?: string;
13
+ payload: Record<string, unknown>;
14
14
  name: string;
15
15
  onClick: () => void;
16
- value: string;
17
- collapsed: boolean;
16
+ tooltip: string;
17
+ icon?: string;
18
18
  }
19
19
  interface ICallFn {
20
20
  callback: (payload: Record<string, any>) => void;
@@ -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 | ICustomElement;
26
+ type IMessageElement = IImageElement | ITextElement | IPdfElement | IAudioElement | IVideoElement | IFileElement | IPlotlyElement | IDataframeElement | ICustomElement;
27
27
  type ElementType = IElement['type'];
28
28
  type IElementSize = 'small' | 'medium' | 'large';
29
29
  interface TElement<T> {
@@ -58,9 +58,11 @@ interface IVideoElement extends TMessageElement<'video'> {
58
58
  interface IFileElement extends TMessageElement<'file'> {
59
59
  type: 'file';
60
60
  }
61
- interface IPlotlyElement extends TMessageElement<'plotly'> {
62
- }
63
- interface ITasklistElement extends TElement<'tasklist'> {
61
+ type IPlotlyElement = TMessageElement<'plotly'>;
62
+ type ITasklistElement = TElement<'tasklist'>;
63
+ type IDataframeElement = TMessageElement<'dataframe'>;
64
+ interface ICustomElement extends TMessageElement<'custom'> {
65
+ props: Record<string, unknown>;
64
66
  }
65
67
 
66
68
  interface IFeedback {
@@ -90,6 +92,7 @@ interface IStep {
90
92
  language?: string;
91
93
  streaming?: boolean;
92
94
  steps?: IStep[];
95
+ metadata?: Record<string, any>;
93
96
  indent?: number;
94
97
  }
95
98
 
@@ -110,6 +113,7 @@ interface IAsk {
110
113
  type: 'text' | 'file' | 'action';
111
114
  timeout: number;
112
115
  } & FileSpec & ActionSpec;
116
+ parentId?: string;
113
117
  }
114
118
 
115
119
  type AuthProvider = 'credentials' | 'header' | 'github' | 'google' | 'azure-ad' | 'azure-ad-hybrid';
@@ -170,16 +174,18 @@ interface IAuthConfig {
170
174
  passwordAuth: boolean;
171
175
  headerAuth: boolean;
172
176
  oauthProviders: string[];
177
+ default_theme?: 'light' | 'dark';
173
178
  }
174
179
  interface IChainlitConfig {
175
180
  markdown?: string;
176
181
  ui: {
177
182
  name: string;
178
183
  description?: string;
184
+ font_family?: string;
185
+ default_theme?: 'light' | 'dark';
186
+ layout?: 'default' | 'wide';
179
187
  cot: 'hidden' | 'tool_call' | 'full';
180
- default_collapse_content?: boolean;
181
188
  github?: string;
182
- theme: any;
183
189
  custom_css?: string;
184
190
  custom_js?: string;
185
191
  custom_font?: string;
@@ -235,15 +241,11 @@ declare const useChatInteract: () => {
235
241
  id: string;
236
242
  }>;
237
243
  };
238
- callAction: (action: IAction) => Promise<{
239
- id: string;
240
- status: boolean;
241
- response?: string | undefined;
242
- }> | undefined;
243
244
  clear: () => void;
244
245
  replyMessage: (message: IStep) => void;
245
246
  sendMessage: (message: PartialBy<IStep, 'createdAt' | 'id'>, fileReferences?: IFileRef[]) => void;
246
247
  editMessage: (message: IStep) => void;
248
+ windowMessage: (data: any) => void;
247
249
  startAudioStream: () => void;
248
250
  sendAudioChunk: (isStart: boolean, mimeType: string, elapsedTime: number, data: Int16Array) => void;
249
251
  endAudioStream: () => void;
@@ -282,8 +284,7 @@ declare const chatSettingsValueState: recoil.RecoilState<any>;
282
284
  declare const elementState: recoil.RecoilState<IMessageElement[]>;
283
285
  declare const tasklistState: recoil.RecoilState<ITasklistElement[]>;
284
286
  declare const firstUserInteraction: recoil.RecoilState<string | undefined>;
285
- declare const accessTokenState: recoil.RecoilState<string | undefined>;
286
- declare const userState: recoil.RecoilState<IUser | null>;
287
+ declare const userState: recoil.RecoilState<IUser | null | undefined>;
287
288
  declare const configState: recoil.RecoilState<IChainlitConfig | undefined>;
288
289
  declare const authState: recoil.RecoilState<IAuthConfig | undefined>;
289
290
  declare const threadHistoryState: recoil.RecoilState<ThreadHistory | undefined>;
@@ -291,9 +292,9 @@ declare const sideViewState: recoil.RecoilState<IMessageElement | undefined>;
291
292
  declare const currentThreadIdState: recoil.RecoilState<string | undefined>;
292
293
 
293
294
  declare const useChatSession: () => {
294
- connect: lodash.DebouncedFunc<({ userEnv, accessToken }: {
295
+ connect: lodash.DebouncedFunc<({ transports, userEnv }: {
296
+ transports?: string[] | undefined;
295
297
  userEnv: Record<string, string>;
296
- accessToken?: string | undefined;
297
298
  }) => void>;
298
299
  disconnect: () => void;
299
300
  session: ISession | undefined;
@@ -312,7 +313,7 @@ declare const useAudio: () => {
312
313
  wavStreamPlayer: any;
313
314
  };
314
315
 
315
- declare const useConfig: (accessToken?: string) => {
316
+ declare const useConfig: () => {
316
317
  config: IChainlitConfig | undefined;
317
318
  error: Error | undefined;
318
319
  isLoading: boolean;
@@ -320,29 +321,23 @@ declare const useConfig: (accessToken?: string) => {
320
321
  };
321
322
 
322
323
  declare const useAuth: () => {
323
- authConfig: IAuthConfig;
324
+ data: IAuthConfig;
324
325
  user: null;
325
326
  isReady: boolean;
326
327
  isAuthenticated: boolean;
327
- accessToken: string;
328
- logout: () => void;
329
- setAccessToken: () => void;
330
- data?: undefined;
328
+ logout: () => Promise<void>;
329
+ setUserFromAPI: () => Promise<void>;
331
330
  } | {
332
331
  data: IAuthConfig | undefined;
333
- user: IUser | null;
334
- isAuthenticated: boolean;
332
+ user: IUser | null | undefined;
335
333
  isReady: boolean;
336
- accessToken: string | undefined;
334
+ isAuthenticated: boolean;
337
335
  logout: (reload?: boolean) => Promise<void>;
338
- setAccessToken: (token: string | null | undefined) => void;
339
- authConfig?: undefined;
336
+ setUserFromAPI: swr__internal.KeyedMutator<IUser>;
340
337
  };
341
338
 
342
- declare const fetcher: (client: ChainlitAPI, endpoint: string, token?: string) => Promise<any>;
343
- declare function useApi<T>(path?: string | null, { token, ...swrConfig }?: SWRConfiguration & {
344
- token?: string;
345
- }): swr__internal.SWRResponse<T, Error, Partial<swr__internal.PublicConfiguration<T, Error, swr__internal.BareFetcher<T>>> | undefined>;
339
+ declare const fetcher: (client: ChainlitAPI, endpoint: string) => Promise<any>;
340
+ declare function useApi<T>(path?: string | null, { ...swrConfig }?: SWRConfiguration): swr__internal.SWRResponse<T, Error, Partial<swr__internal.PublicConfiguration<T, Error, swr__internal.BareFetcher<T>>> | undefined>;
346
341
 
347
342
  interface IThreadFilters {
348
343
  search?: string;
@@ -357,8 +352,9 @@ interface IPagination {
357
352
  cursor?: string | number;
358
353
  }
359
354
  declare class ClientError extends Error {
355
+ status: number;
360
356
  detail?: string;
361
- constructor(message: string, detail?: string);
357
+ constructor(message: string, status: number, detail?: string);
362
358
  toString(): string;
363
359
  }
364
360
  type Payload = FormData | any;
@@ -369,36 +365,46 @@ declare class APIBase {
369
365
  onError?: ((error: ClientError) => void) | undefined;
370
366
  constructor(httpEndpoint: string, type: 'webapp' | 'copilot' | 'teams' | 'slack' | 'discord', on401?: (() => void) | undefined, onError?: ((error: ClientError) => void) | undefined);
371
367
  buildEndpoint(path: string): string;
372
- checkToken(token: string): string;
373
- fetch(method: string, path: string, token?: string, data?: Payload, signal?: AbortSignal): Promise<Response>;
374
- get(endpoint: string, token?: string): Promise<Response>;
375
- post(endpoint: string, data: Payload, token?: string, signal?: AbortSignal): Promise<Response>;
376
- put(endpoint: string, data: Payload, token?: string): Promise<Response>;
377
- patch(endpoint: string, data: Payload, token?: string): Promise<Response>;
378
- delete(endpoint: string, data: Payload, token?: string): Promise<Response>;
368
+ private getDetailFromErrorResponse;
369
+ private handleRequestError;
370
+ fetch(method: string, path: string, data?: Payload, signal?: AbortSignal, headers?: {
371
+ Authorization?: string;
372
+ 'Content-Type'?: string;
373
+ }): Promise<Response>;
374
+ get(endpoint: string): Promise<Response>;
375
+ post(endpoint: string, data: Payload, signal?: AbortSignal): Promise<Response>;
376
+ put(endpoint: string, data: Payload): Promise<Response>;
377
+ patch(endpoint: string, data: Payload): Promise<Response>;
378
+ delete(endpoint: string, data: Payload): Promise<Response>;
379
379
  }
380
380
  declare class ChainlitAPI extends APIBase {
381
381
  headerAuth(): Promise<any>;
382
+ jwtAuth(token: string): Promise<any>;
382
383
  passwordAuth(data: FormData): Promise<any>;
384
+ getUser(): Promise<IUser>;
383
385
  logout(): Promise<any>;
384
- setFeedback(feedback: IFeedback, accessToken?: string): Promise<{
386
+ setFeedback(feedback: IFeedback): Promise<{
385
387
  success: boolean;
386
388
  feedbackId: string;
387
389
  }>;
388
- deleteFeedback(feedbackId: string, accessToken?: string): Promise<{
390
+ deleteFeedback(feedbackId: string): Promise<{
389
391
  success: boolean;
390
392
  }>;
391
- listThreads(pagination: IPagination, filter: IThreadFilters, accessToken?: string): Promise<{
393
+ listThreads(pagination: IPagination, filter: IThreadFilters): Promise<{
392
394
  pageInfo: IPageInfo;
393
395
  data: IThread[];
394
396
  }>;
395
- deleteThread(threadId: string, accessToken?: string): Promise<any>;
396
- uploadFile(file: File, onProgress: (progress: number) => void, sessionId: string, token?: string): {
397
+ renameThread(threadId: string, name: string): Promise<any>;
398
+ deleteThread(threadId: string): Promise<any>;
399
+ uploadFile(file: File, onProgress: (progress: number) => void, sessionId: string): {
397
400
  xhr: XMLHttpRequest;
398
401
  promise: Promise<{
399
402
  id: string;
400
403
  }>;
401
404
  };
405
+ callAction(action: IAction, sessionId: string): Promise<any>;
406
+ updateElement(element: IElement, sessionId: string): Promise<any>;
407
+ deleteElement(element: IElement, sessionId: string): Promise<any>;
402
408
  getElementUrl(id: string, sessionId: string): string;
403
409
  getLogoEndpoint(theme: string): string;
404
410
  getOAuthEndpoint(provider: string): string;
@@ -420,4 +426,4 @@ declare const WavRenderer: {
420
426
  drawBars: (ctx: CanvasRenderingContext2D, data: Float32Array, cssWidth: number, cssHeight: number, color: string, pointCount?: number, barWidth?: number, barSpacing?: number, center?: boolean) => void;
421
427
  };
422
428
 
423
- export { APIBase, ActionSpec, AuthProvider, ChainlitAPI, ChainlitContext, ChatProfile, ClientError, ElementType, FileSpec, IAction, IAsk, IAudioConfig, IAudioElement, IAuthConfig, ICallFn, IChainlitConfig, 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 };
429
+ export { APIBase, ActionSpec, AuthProvider, ChainlitAPI, ChainlitContext, ChatProfile, ClientError, ElementType, FileSpec, IAction, IAsk, IAudioConfig, IAudioElement, IAuthConfig, ICallFn, IChainlitConfig, ICustomElement, 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, 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 };