import OpenAI from 'openai'; import type { AvailableModel } from '../../execution/AvailableModel'; import type { LlmExecutionTools } from '../../execution/LlmExecutionTools'; import type { ChatPromptResult } from '../../execution/PromptResult'; import type { CompletionPromptResult } from '../../execution/PromptResult'; import type { EmbeddingPromptResult } from '../../execution/PromptResult'; import type { Prompt } from '../../types/Prompt'; import type { string_markdown } from '../../types/typeAliases'; import type { string_markdown_text } from '../../types/typeAliases'; import type { string_title } from '../../types/typeAliases'; import type { string_token } from '../../types/typeAliases'; import { OpenAiAssistantExecutionTools } from './OpenAiAssistantExecutionTools'; import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions'; /** * Execution Tools for calling OpenAI API * * @public exported from `@promptbook/openai` */ export declare class OpenAiExecutionTools implements LlmExecutionTools { protected readonly options: OpenAiExecutionToolsOptions; /** * OpenAI API client. */ private client; /** * Creates OpenAI Execution Tools. * * @param options which are relevant are directly passed to the OpenAI client */ constructor(options: OpenAiExecutionToolsOptions); get title(): string_title & string_markdown_text; get description(): string_markdown; getClient(): Promise; /** * Create (sub)tools for calling OpenAI API Assistants * * @param assistantId Which assistant to use * @returns Tools for calling OpenAI API Assistants with same token */ createAssistantSubtools(assistantId: string_token): OpenAiAssistantExecutionTools; /** * Check the `options` passed to `constructor` */ checkConfiguration(): Promise; /** * List all available OpenAI models that can be used */ listModels(): ReadonlyArray; /** * Calls OpenAI API to use a chat model. */ callChatModel(prompt: Pick): Promise; /** * Calls OpenAI API to use a complete model. */ callCompletionModel(prompt: Pick): Promise; /** * Calls OpenAI API to use a embedding model */ callEmbeddingModel(prompt: Pick): Promise; /** * Get the model that should be used as default */ private getDefaultModel; /** * Default model for chat variant. */ private getDefaultChatModel; /** * Default model for completion variant. */ private getDefaultCompletionModel; /** * Default model for completion variant. */ private getDefaultEmbeddingModel; } /** * TODO: [🧠][🧙‍♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI * TODO: Maybe Create some common util for callChatModel and callCompletionModel * TODO: Maybe make custom OpenAiError * TODO: [🧠][🈁] Maybe use `isDeterministic` from options * TODO: [🧠][🌰] Allow to pass `title` for tracking purposes */