import { type PartialDeep } from 'type-fest'; import { type Telemetry } from './telemetry/types.js'; import { type Model } from './types.js'; import { type CacheKey, type CacheStorage } from './utils/cache.js'; import { type Prettify } from './utils/helpers.js'; export interface ModelArgs { /** * A function that returns a cache key for the given params. * * A simple example would be: `(params) => JSON.stringify(params)` * * The default `cacheKey` function uses [hash-object](https://github.com/sindresorhus/hash-object) to create a stable sha256 hash of the params. */ cacheKey?: CacheKey; /** * Enables caching for model responses. Must implement `.get(key)` and `.set(key, value)`, both of which can be either sync or async. * * Some examples include: `new Map()`, [quick-lru](https://github.com/sindresorhus/quick-lru), or any [keyv adaptor](https://github.com/jaredwray/keyv). */ cache?: CacheStorage; client: MClient; context?: Ctx; params: MConfig & Partial; events?: Model.Events; telemetry?: Telemetry.Provider; /** Whether or not to add default `console.log` event handlers */ debug?: boolean; } export type PartialModelArgs = Prettify>, 'params'>> & Partial>, 'params'>>>; export declare abstract class AbstractModel { /** This is used to implement specific model calls */ protected abstract runModel(params: Prettify, context: CustomCtx): Promise; /** Clones the model, optionally modifying its config */ abstract extend>(args?: Args): this; abstract readonly modelType: Model.Type; abstract readonly modelProvider: Model.Provider; protected readonly cacheKey: CacheKey; protected readonly cache?: CacheStorage; readonly client: MClient; readonly context: CustomCtx; readonly debug: boolean; readonly params: MConfig & Partial; readonly events: Model.Events; readonly tokenizer: Model.ITokenizer; readonly telemetry: Telemetry.Provider; constructor(args: ModelArgs); run(params: Prettify>, context?: CustomCtx): Promise; }