@gram-ai/elements 1.18.2 → 1.18.4
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/elements.cjs +32 -32
- package/dist/elements.css +1 -1
- package/dist/elements.js +2818 -2830
- package/dist/hooks/useSession.d.ts +2 -1
- package/dist/lib/auth.d.ts +5 -0
- package/dist/types/index.d.ts +19 -3
- package/package.json +1 -1
|
@@ -3,7 +3,8 @@ import { GetSessionFn } from '../types';
|
|
|
3
3
|
* Hook to fetch or retrieve the session token for the chat.
|
|
4
4
|
* @returns The session token string or null
|
|
5
5
|
*/
|
|
6
|
-
export declare const useSession: ({ getSession, projectSlug, }: {
|
|
6
|
+
export declare const useSession: ({ getSession, projectSlug, enabled, }: {
|
|
7
7
|
getSession: GetSessionFn | null;
|
|
8
8
|
projectSlug: string;
|
|
9
|
+
enabled: boolean;
|
|
9
10
|
}) => string | null;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -243,7 +243,7 @@ export interface ElementsConfig {
|
|
|
243
243
|
url?: string;
|
|
244
244
|
} & AuthConfig;
|
|
245
245
|
}
|
|
246
|
-
export type
|
|
246
|
+
export type SessionAuthConfig = {
|
|
247
247
|
/**
|
|
248
248
|
* The function to use to retrieve the session token from the backend endpoint.
|
|
249
249
|
* By default, this will attempt to fetch the session token from `/chat/session`.
|
|
@@ -257,8 +257,23 @@ export type AuthConfig = {
|
|
|
257
257
|
* },
|
|
258
258
|
* }
|
|
259
259
|
*/
|
|
260
|
-
sessionFn
|
|
261
|
-
}
|
|
260
|
+
sessionFn: GetSessionFn;
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* The API key auth config is used to authenticate the Elements library using an API key only.
|
|
264
|
+
*
|
|
265
|
+
* NOTE: This is not recommended for production use, and a warning
|
|
266
|
+
* will be displayed in the chat interface if you use this config.
|
|
267
|
+
* Define a session endpoint instead to avoid this warning.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* const config: ElementsConfig = {
|
|
271
|
+
* api: {
|
|
272
|
+
* UNSAFE_apiKey: 'your-api-key',
|
|
273
|
+
* },
|
|
274
|
+
* }
|
|
275
|
+
*/
|
|
276
|
+
export type ApiKeyAuthConfig = {
|
|
262
277
|
/**
|
|
263
278
|
* The API key to use if you haven't yet configured a session endpoint.
|
|
264
279
|
* Do not use this in production.
|
|
@@ -272,6 +287,7 @@ export type AuthConfig = {
|
|
|
272
287
|
*/
|
|
273
288
|
UNSAFE_apiKey: string;
|
|
274
289
|
};
|
|
290
|
+
export type AuthConfig = SessionAuthConfig | ApiKeyAuthConfig | undefined;
|
|
275
291
|
/**
|
|
276
292
|
* The LLM model to use for the Elements library.
|
|
277
293
|
*
|
package/package.json
CHANGED