Skip to content

Commit

Permalink
chore: Update useInferableRuntime auth options (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjcsmith authored Dec 11, 2024
1 parent 5a69c45 commit 759d2da
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
6 changes: 4 additions & 2 deletions adapters/assistant-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import { AssistantRuntimeProvider, Thread } from "@assistant-ui/react";

const { runtime, run } = useInferableRuntime({
clusterId: '<YOUR_CLUSTER_ID>',
apiSecret: '<YOUR_API_SECRET>',
customAuthToken: 'your-custom-auth-token',
// apiSecret: 'your-api-secret', // Not recommended
onError: (error) => {
console.error(error);
}
Expand All @@ -63,7 +64,8 @@ You can handle errors by providing an `onError` callback:
```typescript
const { runtime, run } = useInferableRuntime({
clusterId: '<YOUR_CLUSTER_ID>',
apiSecret: '<YOUR_API_SECRET>',
customAuthToken: 'your-custom-auth-token',
// apiSecret: 'your-api-secret', // Not recommended
onError: (error) => {
console.error(error);
}
Expand Down
8 changes: 4 additions & 4 deletions adapters/assistant-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion adapters/assistant-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"vite": "^6.0.3"
},
"dependencies": {
"@inferable/react": "^0.0.7"
"@inferable/react": "^0.0.8"
}
}
19 changes: 11 additions & 8 deletions adapters/assistant-ui/src/inferable-provider-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -39,15 +42,15 @@ type RuntimeOptions = {
export function useInferableRuntime({
clusterId,
apiSecret,
authType,
customAuthToken,
runId,
onError
}: RuntimeOptions) {

const { messages, run, createMessage, start } = useRun({
clusterId,
apiSecret,
authType,
customAuthToken,
onError,
});

Expand Down

0 comments on commit 759d2da

Please sign in to comment.