import { Message, AssistantMessage, MessageContentPart } from './backend/message.cjs'; import { MiddlewareType, Run, GetRunContext } from './context.cjs'; import { Serializable } from './internals/serializable.cjs'; import { E as Emitter, C as Callback } from './emitter-D4OcelZ9.cjs'; import { FrameworkError } from './errors.cjs'; import { Task } from 'promise-based-task'; import { BaseCache } from './cache/base.cjs'; import { ClassConstructor } from './internals/types.cjs'; import { ProviderName, ProviderDef } from './backend/constants.cjs'; import { AnyTool } from './tools/base.cjs'; import { ZodSchema, z, ZodType } from 'zod'; import { SchemaObject } from 'ajv'; import { PromptTemplate } from './template.cjs'; import { Logger } from './logger/logger.cjs'; import { ToolCallPart } from 'ai'; /** * Copyright 2025 © BeeAI a Series of LF Projects, LLC * SPDX-License-Identifier: Apache-2.0 */ type FullModelName = `${ProviderName}:${string}`; declare function parseModel(name: string): { providerId: "openai" | "azure" | "watsonx" | "ollama" | "google-vertex" | "amazon-bedrock" | "groq" | "xai" | "dummy" | "anthropic" | "minimax"; modelId: string; providerDef: ProviderDef; }; declare function loadModel(name: ProviderName | FullModelName, type: "embedding" | "chat"): Promise>; declare function generateToolUnionSchema(tools: AnyTool[]): Promise; declare function filterToolsByToolChoice(tools: AnyTool[], value?: ChatModelToolChoice): AnyTool[]; interface ChatModelParameters { maxTokens?: number; topP?: number; frequencyPenalty?: number; temperature?: number; topK?: number; n?: number; presencePenalty?: number; seed?: number; stopSequences?: string[]; stream?: boolean; } interface ResponseObjectJson { type: "object-json"; schema?: SchemaObject; name?: string; description?: string; } interface ChatModelObjectInput extends ChatModelParameters { schema: z.ZodSchema | ResponseObjectJson; systemPromptTemplate?: PromptTemplate>; messages: Message[]; abortSignal?: AbortSignal; maxRetries?: number; } interface ChatModelObjectOutput { object: T; output: ChatModelOutput; } type ChatModelToolChoice = "auto" | "none" | "required" | AnyTool; interface ChatModelInput extends ChatModelParameters { tools?: AnyTool[]; abortSignal?: AbortSignal; stopSequences?: string[]; responseFormat?: ZodSchema | ResponseObjectJson; toolChoice?: ChatModelToolChoice; messages: Message[]; streamPartialToolCalls?: boolean; maxRetries?: number; } type ChatModelFinishReason = "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other" | "unknown"; interface ChatModelUsage { promptTokens: number; completionTokens: number; totalTokens: number; reasoningTokens?: number; cachedPromptTokens?: number; } interface ChatModelEvents { newToken?: Callback<{ value: ChatModelOutput; callbacks: { abort: () => void; }; }>; success?: Callback<{ value: ChatModelOutput; }>; start?: Callback<{ input: ChatModelInput; }>; error?: Callback<{ input: ChatModelInput; error: FrameworkError; }>; finish?: Callback; } type ChatModelEmitter> = Emitter>; type ChatModelCache = BaseCache>; type ConfigFn = (value: T) => T; interface ChatConfig { cache?: ChatModelCache | ConfigFn; parameters?: ChatModelParameters | ConfigFn; } type ChatModelToolChoiceSupport = "required" | "none" | "single" | "auto"; declare abstract class ChatModel extends Serializable { abstract readonly emitter: Emitter; cache: ChatModelCache; parameters: ChatModelParameters; readonly middlewares: MiddlewareType[]; protected readonly logger: Logger; readonly toolChoiceSupport: ChatModelToolChoiceSupport[]; toolCallFallbackViaResponseFormat: boolean; readonly modelSupportsToolCalling: boolean; readonly fixInvalidToolCalls: boolean; readonly retryOnEmptyResponse: boolean; abstract get modelId(): string; abstract get providerId(): string; create(input: ChatModelInput): Run; createStructure(input: ChatModelObjectInput): Run, this, readonly [ChatModelObjectInput]>; config({ cache, parameters }: ChatConfig): void; static fromName(name: FullModelName | ProviderName, options?: ChatModelParameters): Promise; protected abstract _create(input: ChatModelInput, run: GetRunContext): Promise; protected abstract _createStream(input: ChatModelInput, run: GetRunContext): AsyncGenerator; protected _createStructure(input: ChatModelObjectInput, run: GetRunContext): Promise>; createSnapshot(): { cache: ChatModelCache; emitter: Emitter; middlewares: MiddlewareType[]; parameters: ChatModelParameters; logger: Logger; toolChoiceSupport: ChatModelToolChoiceSupport[]; toolCallFallbackViaResponseFormat: boolean; modelSupportsToolCalling: boolean; retryOnEmptyResponse: boolean; fixInvalidToolCalls: boolean; }; destroy(): void; protected createCacheAccessor({ abortSignal: _, messages, tools, ...input }: ChatModelInput): Promise<{ key: string; value: ChatModelOutput[] | undefined; resolve: (value: T2[]) => void; reject: (error: Error) => Promise; }>; protected shouldForceToolCallViaResponseFormat({ tools, toolChoice, responseFormat, }: ChatModelInput): boolean; protected isToolChoiceSupported(choice?: ChatModelToolChoice): boolean; } declare class ChatModelOutput extends Serializable { readonly messages: Message[]; usage?: ChatModelUsage | undefined; finishReason?: ChatModelFinishReason | undefined; constructor(messages: Message[], usage?: ChatModelUsage | undefined, finishReason?: ChatModelFinishReason | undefined); static fromChunks(chunks: ChatModelOutput[]): ChatModelOutput; isEmpty(): boolean; merge(other: ChatModelOutput): void; dedupe(): void; getToolCalls(): ToolCallPart[]; getTextMessages(): AssistantMessage[]; getTextContent(): string; toString(): string; createSnapshot(): { messages: Message[]; usage: ChatModelUsage | undefined; finishReason: ChatModelFinishReason | undefined; }; loadSnapshot(snapshot: ReturnType): void; } export { type ChatConfig as C, type FullModelName as F, ChatModel as a, type ChatModelCache as b, type ChatModelEmitter as c, type ChatModelEvents as d, type ChatModelFinishReason as e, type ChatModelInput as f, type ChatModelObjectInput as g, type ChatModelObjectOutput as h, ChatModelOutput as i, type ChatModelParameters as j, type ChatModelToolChoice as k, type ChatModelToolChoiceSupport as l, type ChatModelUsage as m, type ConfigFn as n, filterToolsByToolChoice as o, generateToolUnionSchema as p, loadModel as q, parseModel as r };