UNPKG

@promptbook/remote-server

Version:

Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action

64 lines (63 loc) 2.45 kB
import OpenAI from 'openai'; import type { ChatPromptResult } from '../../execution/PromptResult'; import type { Prompt } from '../../types/Prompt'; import type { string_date_iso8601, string_token } from '../../types/string_token'; import { OpenAiAssistantExecutionToolsProgressReporter } from './OpenAiAssistantExecutionToolsProgressReporter'; /** * Shared context for one assistant chat call after prompt preparation finishes. * * @private helper of `OpenAiAssistantExecutionToolsStreamRunner` */ type AssistantChatCallContext = { readonly client: OpenAI; readonly prompt: Prompt; readonly rawPromptContent: string; readonly threadMessages: ReadonlyArray<OpenAI.Beta.ThreadCreateAndRunParams.Thread.Message>; readonly start: string_date_iso8601; readonly onProgress: (chunk: ChatPromptResult) => void; }; /** * Runs streaming assistant requests that do not require hosted tool execution. * * @private helper of `OpenAiAssistantExecutionTools` */ export declare class OpenAiAssistantExecutionToolsStreamRunner { private readonly options; /** * Creates one stream runner instance. */ constructor(options: { readonly assistantId: string_token; readonly isVerbose: boolean; readonly progressReporter: OpenAiAssistantExecutionToolsProgressReporter; }); /** * Runs assistant calls without tools through the streaming Assistants API. */ callChatModelStreamWithoutTools(context: AssistantChatCallContext): Promise<ChatPromptResult>; /** * Builds the streaming assistant request payload used when no tool execution flow is needed. */ private createAssistantStreamingRequest; /** * Registers verbose stream diagnostics plus incremental text progress forwarding. */ private attachAssistantStreamListeners; /** * Resolves the final visible assistant text from a streaming response. */ private resolveAssistantStreamingResultContent; /** * Extracts the single text content block returned by the assistant stream. */ private extractSingleAssistantTextContentBlock; /** * Rewrites file citation markers to use retrieved filenames instead of generic source labels. */ private replaceAssistantFileCitationMarkers; /** * Returns one citation filename, caching OpenAI file lookups across annotations. */ private retrieveAssistantCitationFilename; } export {};