Skip to content

Commit

Permalink
feat: allow runtimes to signal support for attachments (#769)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Sep 7, 2024
1 parent a81b18f commit bdd3084
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/happy-eagles-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@assistant-ui/react-playground": patch
"@assistant-ui/react-ai-sdk": patch
"@assistant-ui/react": patch
---

feat: allow runtimes to signal support for attachments
14 changes: 14 additions & 0 deletions apps/docs/components/docs/parameters/runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ export const AssistantRuntimeProviderProps = () => {
description:
"Whether the runtime supports copying messages.",
},
{
name: "speak",
type: "boolean",
required: true,
description:
"Whether the runtime supports speaking messages.",
},
{
name: "attachments",
type: "boolean",
required: true,
description:
"Whether the runtime supports attachments.",
},
],
},
],
Expand Down
1 change: 1 addition & 0 deletions packages/react-playground/src/lib/playground-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const CAPABILITIES = Object.freeze({
cancel: true,
unstable_copy: false,
speak: false,
attachments: false,
});

const EMPTY_BRANCHES: readonly string[] = Object.freeze([]);
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/context/stores/Thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type RuntimeCapabilities = {
cancel: boolean;
unstable_copy: boolean;
speak: boolean;
attachments: boolean;
};

export const getThreadStateFromRuntime = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class ExternalStoreThreadRuntime implements ReactThreadRuntime {
cancel: false,
unstable_copy: false,
speak: false,
attachments: false,
};

public get capabilities() {
Expand Down Expand Up @@ -75,6 +76,7 @@ export class ExternalStoreThreadRuntime implements ReactThreadRuntime {
cancel: this._store.onCancel !== undefined,
unstable_copy: this._store.unstable_capabilities?.copy !== null,
speak: this._store.onSpeak !== undefined,
attachments: false,
};

if (oldStore) {
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/runtimes/local/LocalThreadRuntime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class LocalThreadRuntime implements ThreadRuntime {
cancel: true,
unstable_copy: true,
speak: false,
attachments: false,
};

public readonly threadId: string;
Expand Down

0 comments on commit bdd3084

Please sign in to comment.