UNPKG

ai-utils.js

Version:

Build AI applications, chatbots, and agents with JavaScript and TypeScript.

21 lines (20 loc) 947 B
import { FunctionOptions } from "../FunctionOptions.js"; import { CallMetadata } from "../executeCall.js"; import { TextGenerationModel, TextGenerationModelSettings } from "./TextGenerationModel.js"; /** * Generates a text using a prompt. * The prompt format depends on the model. * For example, OpenAI text models expect a string prompt, and OpenAI chat models expect an array of chat messages. * * @example * const model = new OpenAITextGenerationModel(...); * * const { text } = await model.generateText( * "Write a short story about a robot learning to love:\n\n" * ); */ export declare function generateText<PROMPT, RESPONSE, SETTINGS extends TextGenerationModelSettings>(model: TextGenerationModel<PROMPT, RESPONSE, any, SETTINGS>, prompt: PROMPT, options?: FunctionOptions<SETTINGS>): Promise<{ text: string; response: RESPONSE; metadata: CallMetadata<TextGenerationModel<PROMPT, RESPONSE, unknown, SETTINGS>>; }>;