From 759d2da42336471078e6f78cc7feced327307a1c Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 11 Dec 2024 21:20:19 +1030 Subject: [PATCH] chore: Update useInferableRuntime auth options (#294) --- adapters/assistant-ui/README.md | 6 ++++-- adapters/assistant-ui/package-lock.json | 8 ++++---- adapters/assistant-ui/package.json | 2 +- .../src/inferable-provider-runtime.ts | 19 +++++++++++-------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/adapters/assistant-ui/README.md b/adapters/assistant-ui/README.md index 487122a1..2a6475b9 100644 --- a/adapters/assistant-ui/README.md +++ b/adapters/assistant-ui/README.md @@ -38,7 +38,8 @@ import { AssistantRuntimeProvider, Thread } from "@assistant-ui/react"; const { runtime, run } = useInferableRuntime({ clusterId: '', - apiSecret: '', + customAuthToken: 'your-custom-auth-token', + // apiSecret: 'your-api-secret', // Not recommended onError: (error) => { console.error(error); } @@ -63,7 +64,8 @@ You can handle errors by providing an `onError` callback: ```typescript const { runtime, run } = useInferableRuntime({ clusterId: '', - apiSecret: '', + customAuthToken: 'your-custom-auth-token', + // apiSecret: 'your-api-secret', // Not recommended onError: (error) => { console.error(error); } diff --git a/adapters/assistant-ui/package-lock.json b/adapters/assistant-ui/package-lock.json index 94f96976..521aa021 100644 --- a/adapters/assistant-ui/package-lock.json +++ b/adapters/assistant-ui/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.4", "license": "MIT", "dependencies": { - "@inferable/react": "^0.0.7" + "@inferable/react": "^0.0.8" }, "devDependencies": { "@babel/preset-env": "^7.26.0", @@ -2414,9 +2414,9 @@ "peer": true }, "node_modules/@inferable/react": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/@inferable/react/-/react-0.0.7.tgz", - "integrity": "sha512-lW0lZJXJtevC+F6hWeuf49KA3Q9aWb2+4qfjRQSNVMEh6g7Gq62U6XjAC3VJfW5iZxw8OGqFPycaxWwEGRyAxg==", + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/@inferable/react/-/react-0.0.8.tgz", + "integrity": "sha512-SbfX9XF6KO7rtXKKoqMgPf+B7GIF8MjPLdiykUI3fhadgxB9MkZwdhq7R82IYvq6xKQomXeckWvWbmrUKdb5bA==", "license": "MIT", "dependencies": { "@ts-rest/core": "^3.28.0", diff --git a/adapters/assistant-ui/package.json b/adapters/assistant-ui/package.json index 485bf1c2..24141ce2 100644 --- a/adapters/assistant-ui/package.json +++ b/adapters/assistant-ui/package.json @@ -31,6 +31,6 @@ "vite": "^6.0.3" }, "dependencies": { - "@inferable/react": "^0.0.7" + "@inferable/react": "^0.0.8" } } diff --git a/adapters/assistant-ui/src/inferable-provider-runtime.ts b/adapters/assistant-ui/src/inferable-provider-runtime.ts index a2abb260..83332471 100644 --- a/adapters/assistant-ui/src/inferable-provider-runtime.ts +++ b/adapters/assistant-ui/src/inferable-provider-runtime.ts @@ -13,16 +13,19 @@ type RuntimeOptions = { clusterId: string; /** - * The API secret to use for authentication. + * The cluster API secret to use for authentication. + * This is not recommended as the key will be available in the browser. + * + * @see https://docs.inferable.ai/pages/auth */ - apiSecret: string; + apiSecret?: string; /** - * The authentication mode to use. - * @default "cluster" - * @see http://docs.inferable.ai/pages/auth + * A custom auth token to use for authentication. + * + * @see https://docs.inferable.ai/pages/custom-auth */ - authType?: "custom" | "cluster"; + customAuthToken?: string; /** * Optional, provided if you want to resume an existing run. @@ -39,7 +42,7 @@ type RuntimeOptions = { export function useInferableRuntime({ clusterId, apiSecret, - authType, + customAuthToken, runId, onError }: RuntimeOptions) { @@ -47,7 +50,7 @@ export function useInferableRuntime({ const { messages, run, createMessage, start } = useRun({ clusterId, apiSecret, - authType, + customAuthToken, onError, });