Skip to content

Commit

Permalink
feat: getRuntime() context API (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Jul 11, 2024
1 parent 85abdfa commit b036399
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/react/src/context/stores/AssistantActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MutableRefObject } from "react";

export type AssistantActionsState = Readonly<{
switchToThread: (threadId: string | null) => void;
getRuntime: () => AssistantRuntime;
}>;

export const makeAssistantActionsStore = (
Expand All @@ -12,5 +13,6 @@ export const makeAssistantActionsStore = (
create<AssistantActionsState>(() =>
Object.freeze({
switchToThread: () => runtimeRef.current.switchToThread(null),
getRuntime: () => runtimeRef.current,
}),
);
2 changes: 2 additions & 0 deletions packages/react/src/context/stores/ThreadActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type ThreadActionsState = Readonly<{
cancelRun: () => void;

addToolResult: (options: AddToolResultOptions) => void;
getRuntime: () => ThreadRuntime;
}>;

export const makeThreadActionStore = (
Expand All @@ -40,6 +41,7 @@ export const makeThreadActionStore = (
append: (message) => runtimeRef.current.append(message),
cancelRun: () => runtimeRef.current.cancelRun(),
addToolResult: (options) => runtimeRef.current.addToolResult(options),
getRuntime: () => runtimeRef.current,
}),
);
};

0 comments on commit b036399

Please sign in to comment.