assistan-ts
Version:
A typesafe and code-first library to define and run OpenAI assistants
28 lines • 1.21 kB
TypeScript
import { ToolBox } from "./toolbox";
import { Run, OpenAI } from "./types/openai";
import { RequiredActionFunctionToolCall } from "openai/resources/beta/threads/runs/runs";
import { FunctionTool } from "./definition";
export interface RunOptions {
/** ms wait between polling for run completion. Default 1000 */
interval?: number;
/** Abort controller to abort the run */
abortSignal?: AbortSignal;
onStatusChange?: (run: Run, previous: Run["status"]) => void;
}
type RunParams<T extends Record<string, FunctionTool>> = {
toolbox: ToolBox<T>;
openai: OpenAI;
} & RunOptions;
export declare const waitForComplete: (run: Run, params: RunParams<any>, timeout?: number) => Promise<Run>;
/** Action */
export type ToolsRequired = {
toolCalls: RequiredActionFunctionToolCall[];
execute: (responseOverrides?: Record<string, string>) => Promise<ToolsRequiredResponse>;
};
export type ToolsRequiredResponse = {
run: Run;
toolsRequest: ToolsRequired | null;
};
export declare const waitForRequiredAction: <T extends Record<string, FunctionTool>>(run: Run, params: RunParams<T>, timeout?: number) => Promise<ToolsRequiredResponse>;
export {};
//# sourceMappingURL=run.d.ts.map