@promptbook/vercel
Version:
Promptbook: Turn your company's scattered knowledge into AI ready books
67 lines (66 loc) • 2.6 kB
TypeScript
import { OpenAIClient } from '@azure/openai';
import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
import type { AvailableModel } from '../../execution/AvailableModel';
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
import type { ChatPromptResult, CompletionPromptResult } from '../../execution/PromptResult';
import type { Prompt } from '../../types/Prompt';
import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
import type { AzureOpenAiExecutionToolsOptions } from './AzureOpenAiExecutionToolsOptions';
/**
* Execution Tools for calling Azure OpenAI API.
*
* @public exported from `@promptbook/azure-openai`
*/
export declare class AzureOpenAiExecutionTools implements LlmExecutionTools {
protected readonly options: AzureOpenAiExecutionToolsOptions;
/**
* OpenAI Azure API client.
*/
private client;
/**
* Rate limiter instance
*/
private limiter;
/**
* Creates OpenAI Execution Tools.
*
* @param options which are relevant are directly passed to the OpenAI client
*/
constructor(options: AzureOpenAiExecutionToolsOptions);
get title(): string_title & string_markdown_text;
get description(): string_markdown;
get profile(): ChatParticipant;
getClient(): Promise<OpenAIClient>;
/**
* Check the `options` passed to `constructor`
*/
checkConfiguration(): Promise<void>;
/**
* List all available Azure OpenAI models that can be used
*/
listModels(): Promise<ReadonlyArray<AvailableModel>>;
/**
* Calls OpenAI API to use a chat model.
*/
callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<ChatPromptResult>;
/**
* Calls Azure OpenAI API to use a complete model.
*/
callCompletionModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<CompletionPromptResult>;
/**
* Library `@azure/openai` has bug/weird behavior that it does not throw error but hangs forever
*
* This method wraps the promise with timeout
*/
private withTimeout;
/**
* Changes Azure error (which is not proper Error but object) to proper Error
*/
private transformAzureError;
}
/**
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
* TODO: Maybe make custom AzureOpenAiError
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
*/