@promptbook/remote-server
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
58 lines (57 loc) • 2.52 kB
TypeScript
import type OpenAI from 'openai';
import type { ChatPromptResult } from '../../../execution/PromptResult';
import type { Usage } from '../../../execution/Usage';
import type { Prompt } from '../../../types/Prompt';
import type { string_date_iso8601 } from '../../../types/string_token';
import type { OpenAiCompatibleExecutionToolsNonProxiedOptions } from '../OpenAiCompatibleExecutionToolsOptions';
import { OpenAiCompatibleChatProgressReporter } from './OpenAiCompatibleChatProgressReporter';
/**
* Type describing streamed tool call.
*/
type StreamedToolCall = NonNullable<ChatPromptResult['toolCalls']>[number];
/**
* Dependencies required to execute tool calls requested by an OpenAI-compatible chat response.
*/
type OpenAiCompatibleChatToolCallerOptions = {
readonly executionToolsOptions: OpenAiCompatibleExecutionToolsNonProxiedOptions;
readonly progressReporter: OpenAiCompatibleChatProgressReporter;
};
/**
* Executes chat-requested tools and keeps their progress snapshots in sync with streamed progress updates.
*
* @private helper of `callOpenAiCompatibleChatModel`
*/
export declare class OpenAiCompatibleChatToolCaller {
private readonly options;
constructor(options: OpenAiCompatibleChatToolCallerOptions);
/**
* Executes all tool calls requested in one assistant response and appends their results to the conversation.
*/
handleToolCalls(options: {
readonly prompt: Prompt;
readonly start: string_date_iso8601;
readonly turnComplete: string_date_iso8601;
readonly rawPromptContent: string;
readonly responseMessage: OpenAI.Chat.Completions.ChatCompletionMessage;
readonly rawRequest: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming;
readonly rawResponse: OpenAI.Chat.Completions.ChatCompletion;
readonly modelName: string;
readonly usage: Usage;
readonly toolCalls: Array<StreamedToolCall>;
readonly messages: Array<OpenAI.Chat.Completions.ChatCompletionMessageParam>;
readonly onProgress: (chunk: ChatPromptResult) => void;
}): Promise<void>;
/**
* Executes one tool call requested by the chat response and appends the tool message.
*/
private executeToolCall;
/**
* Resolves the configured script tools for chat tool execution.
*/
private resolveScriptTools;
/**
* Executes the configured script tool for one chat-requested function call.
*/
private executeFunctionTool;
}
export {};