@promptbook/remote-client
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
62 lines (61 loc) • 2.39 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 } from '../../types/string_markdown';
import type { string_title } from '../../types/string_title';
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;
}