UNPKG

@juspay/neurolink

Version:

The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002

96 lines (95 loc) • 3.89 kB
/** * ThinkingConfig utility functions for constructing thinking configuration objects. * * This module provides helper functions to create thinkingConfig objects consistently * across the codebase, reducing duplication in CLI and providers. */ import type { ThinkingLevel, ThinkingConfig, CreateThinkingConfigOptions, NativeThinkingConfig } from "../types/index.js"; /** * Default token budget for thinking operations */ export declare const DEFAULT_THINKING_BUDGET_TOKENS = 10000; /** * Default thinking level for Gemini 3 models */ export declare const DEFAULT_THINKING_LEVEL: ThinkingLevel; /** * Creates a thinkingConfig object from CLI-style options. * * This helper consolidates the pattern used in CLI command handlers * to convert simple CLI flags into the full thinkingConfig structure. * * @param options - CLI-style options with thinking, thinkingBudget, thinkingLevel * @returns ThinkingConfig object or undefined if thinking is not enabled * * @example * ```typescript * // From CLI options * const config = createThinkingConfig({ * thinking: true, * thinkingBudget: 15000, * thinkingLevel: "high" * }); * // Returns: { enabled: true, budgetTokens: 15000, thinkingLevel: "high" } * ``` */ export declare function createThinkingConfig(options: CreateThinkingConfigOptions): ThinkingConfig | undefined; /** * Creates a thinkingConfig from record-style options (useful for CLI handlers). * * This handles the type casting that's commonly needed when working with * CLI argument records. * * @param options - Record-style options from CLI argv * @returns ThinkingConfig object or undefined if thinking is not enabled * * @example * ```typescript * const config = createThinkingConfigFromRecord(argv as Record<string, unknown>); * ``` */ export declare function createThinkingConfigFromRecord(options: Record<string, unknown>): ThinkingConfig | undefined; /** * Maps a qualitative ThinkingLevel onto a numeric thinkingBudget within a * model's verified [min, max] range (see `getGemini25ThinkingBudgetRange`). * Exported for deterministic testing of the level->budget mapping. */ export declare function mapThinkingLevelToBudget(level: ThinkingLevel, range: { min: number; max: number; }): number; /** * Creates thinkingConfig for native Gemini SDK (not AI SDK). * * This is used for direct calls to the Gemini SDK where the config * structure is different from the AI SDK providerOptions. * * @param config - The thinkingConfig from options * @param modelName - Resolved model id, used to pick the right wire shape. * Gemini 3 accepts `thinkingLevel` directly. Gemini 2.5 rejects that field * with HTTP 400 INVALID_ARGUMENT "thinking_level not supported by this * model" (verified live against Vertex for gemini-2.5-pro, -flash and * -flash-lite) and needs a numeric `thinkingBudget` instead — so when * `modelName` identifies a Gemini 2.5 model, the requested level is * translated into a budget via `mapThinkingLevelToBudget` and * `thinkingLevel` is omitted from the result entirely. Omitting * `modelName` (or passing a Gemini 3 / unrecognized model) preserves the * original behavior of forwarding `thinkingLevel` as-is. * @returns NativeThinkingConfig object or undefined * * @example * ```typescript * const nativeConfig = createNativeThinkingConfig(options.thinkingConfig, modelName); * if (nativeConfig) { * sdkConfig.thinkingConfig = nativeConfig; * } * ``` */ export declare function createNativeThinkingConfig(config: ThinkingConfig | undefined, modelName?: string): NativeThinkingConfig | undefined; /** * Checks if thinkingConfig should be applied based on options. * * @param config - The thinkingConfig from options * @returns true if thinking should be enabled */ export declare function shouldEnableThinking(config: ThinkingConfig | undefined): boolean;