/** * @license * Copyright 2025 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import type { IRunConfig, TaskConfig } from "@workglow/task-graph"; import { CreateWorkflow } from "@workglow/task-graph"; import { DataPortSchema } from "@workglow/util/schema"; import type { ModelConfig } from "../model/ModelSchema"; import { AiTask } from "./base/AiTask"; export declare const CountTokensInputSchema: { readonly type: "object"; readonly properties: { readonly text: { readonly type: "string"; readonly title: "Text"; readonly description: "The text to count tokens for"; }; readonly model: { readonly oneOf: readonly [{ readonly title: "Model"; readonly description: `The model ${string}`; } & Record & { readonly format: import(".").TypeModelSemantic; readonly type: "string"; }, { readonly type: "object"; readonly properties: { readonly model_id: { readonly type: "string"; }; readonly capabilities: { readonly type: "array"; readonly items: { readonly type: "string"; }; readonly "x-ui-editor": "multiselect"; }; readonly title: { readonly type: "string"; }; readonly description: { readonly type: "string"; readonly "x-ui-editor": "textarea"; }; readonly provider: { readonly type: "string"; }; readonly provider_config: { readonly type: "object"; readonly properties: { readonly credential_key: { readonly type: "string"; readonly format: "credential"; readonly "x-ui-hidden": true; }; readonly native_dimensions: { readonly type: "integer"; readonly description: "Native output vector dimensions for embedding models"; }; readonly mrl: { readonly type: "boolean"; readonly description: "Whether the model supports Matryoshka Representation Learning"; }; }; readonly additionalProperties: true; readonly default: {}; }; readonly metadata: { readonly type: "object"; readonly default: {}; readonly "x-ui-hidden": true; }; }; readonly required: readonly ["provider", "provider_config"]; readonly format: "model"; readonly additionalProperties: true; } & Record & { readonly format: import(".").TypeModelSemantic; }]; } & Record & { readonly format: import(".").TypeModelSemantic; }; }; readonly required: readonly ["text", "model"]; readonly additionalProperties: false; }; export declare const CountTokensOutputSchema: { readonly type: "object"; readonly properties: { readonly count: { readonly type: "number"; readonly title: "Token Count"; readonly description: "The number of tokens in the text"; }; }; readonly required: readonly ["count"]; readonly additionalProperties: false; }; export type CountTokensTaskInput = { model: string | ModelConfig; text: string; }; export type CountTokensTaskOutput = { count: number; }; export type CountTokensTaskConfig = TaskConfig; /** * A task that counts the number of tokens in a text string using a specified model's tokenizer. * Token counts are model-specific and are useful for managing context window limits and * budgeting token usage in RAG pipelines. * * @extends AiTask */ export declare class CountTokensTask extends AiTask { static type: string; /** Capability required of the model; gated in {@link AiTask.execute}. */ static readonly requires: ["model.count-tokens"]; static category: string; static title: string; static description: string; static cacheable: boolean; static inputSchema(): DataPortSchema; static outputSchema(): DataPortSchema; } export declare const countTokens: (input: CountTokensTaskInput, config?: CountTokensTaskConfig, runConfig?: Partial) => Promise; declare module "@workglow/task-graph" { interface Workflow { countTokens: CreateWorkflow; } } //# sourceMappingURL=CountTokensTask.d.ts.map