@promptbook/remote-server
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
132 lines (131 loc) • 5.71 kB
TypeScript
import type { CallChatModelStreamOptions, LlmExecutionTools } from '../../execution/LlmExecutionTools';
import type { ChatPromptResult } from '../../execution/PromptResult';
import type { ModelRequirements } from '../../types/ModelRequirements';
import type { Prompt } from '../../types/Prompt';
import type { string_markdown, string_markdown_text } from '../../types/string_markdown';
import type { string_title } from '../../types/string_title';
import type { string_token } from '../../types/string_token';
import type { OpenAiAssistantExecutionToolsOptions } from './OpenAiAssistantExecutionToolsOptions';
import { OpenAiVectorStoreHandler } from './OpenAiVectorStoreHandler';
/**
* Execution Tools for calling OpenAI API Assistants
*
* This is useful for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
*
* Note: [🦖] There are several different things in Promptbook:
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
* - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
* - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
*
* @deprecated Use `OpenAiAgentKitExecutionTools` instead.
*
* @public exported from `@promptbook/openai`
*/
export declare class OpenAiAssistantExecutionTools extends OpenAiVectorStoreHandler implements LlmExecutionTools {
readonly assistantId: string_token;
private readonly isCreatingNewAssistantsAllowed;
private readonly promptBuilder;
private readonly progressReporter;
private readonly toolRunner;
private readonly streamRunner;
/**
* Creates OpenAI Execution Tools.
*
* @param options which are relevant are directly passed to the OpenAI client
*/
constructor(options: OpenAiAssistantExecutionToolsOptions);
get title(): string_title & string_markdown_text;
get description(): string_markdown;
/**
* Calls OpenAI API to use a chat model.
*/
callChatModel(prompt: Prompt): Promise<ChatPromptResult>;
/**
* Calls OpenAI API to use a chat model with streaming.
*/
callChatModelStream(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void, options?: CallChatModelStreamOptions): Promise<ChatPromptResult>;
/**
* Validates the subset of model requirements supported by OpenAI Assistants.
*/
private assertSupportedAssistantModelRequirements;
/**
* Returns true when the prompt exposes callable tools that require the Runs API flow.
*/
private hasAssistantTools;
/**
* Get an existing assistant tool wrapper
*/
getAssistant(assistantId: string_token): OpenAiAssistantExecutionTools;
createNewAssistant(options: {
/**
* Name of the new assistant
*/
readonly name: string_title;
/**
* Instructions for the new assistant
*/
readonly instructions: string_markdown;
/**
* Optional list of knowledge source links (URLs or file paths) to attach to the assistant via vector store
*/
readonly knowledgeSources?: ReadonlyArray<string>;
/**
* Optional list of tools to attach to the assistant
*/
readonly tools?: ModelRequirements['tools'];
}): Promise<OpenAiAssistantExecutionTools>;
updateAssistant(options: {
/**
* ID of the assistant to update
*/
readonly assistantId: string_token;
/**
* Name of the assistant
*/
readonly name?: string_title;
/**
* Instructions for the assistant
*/
readonly instructions?: string_markdown;
/**
* Optional list of knowledge source links (URLs or file paths) to attach to the assistant via vector store
*/
readonly knowledgeSources?: ReadonlyArray<string>;
/**
* Optional list of tools to attach to the assistant
*/
readonly tools?: ModelRequirements['tools'];
}): Promise<OpenAiAssistantExecutionTools>;
/**
* Ensures assistant creation/update helpers stay disabled unless explicitly enabled.
*/
private assertAssistantMutationsAllowed;
/**
* Prepares the optional vector store backing assistant file search.
*/
private prepareAssistantVectorStore;
/**
* Builds the assistant tool definition list shared by create and update flows.
*/
private createAssistantToolDefinitions;
/**
* Creates a new tools wrapper bound to one assistant id.
*/
private createAssistantWrapper;
/**
* Returns assistant-specific options with direct OpenAI execution helpers attached.
*/
private get assistantOptions();
/**
* Discriminant for type guards
*/
protected get discriminant(): string;
/**
* Type guard to check if given `LlmExecutionTools` are instanceof `OpenAiAssistantExecutionTools`
*
* Note: This is useful when you can possibly have multiple versions of `@promptbook/openai` installed
*/
static isOpenAiAssistantExecutionTools(llmExecutionTools: LlmExecutionTools): llmExecutionTools is OpenAiAssistantExecutionTools;
}