import { FileDownloadStatus } from '@isdk/ai-tool-downloader'; import { AIResult, AIModelNameRules, AIModelNameRule, ToolFunc, ServerFuncParams, AIChatMessageParam } from '@isdk/ai-tool'; import { AIPromptType, AIPromptResult, AIPromptSettings } from '@isdk/ai-tool-prompt'; interface AIOptions { [name: string]: any; } declare const AIResponseFormatTypes: readonly ["text", "json_object", "json_array", "json_schema"]; type AIResponseFormatType = typeof AIResponseFormatTypes[number] | (string & {}); interface AIResponseFormat { type: AIResponseFormatType; schema?: any; name?: string; description?: string; } interface AITextGenerationOptions extends AIOptions { /** * Adjust the randomness of the generated text. */ temperature?: number; /** * Specifies the maximum number of tokens (words, punctuation, parts of words) that the model can generate in a single response. * It helps to control the length of the output. * * Does nothing if the model does not support this setting. * * Example: `max_tokens: 1000` */ max_tokens?: number | undefined; /** * Specify the context window size of the model that you have loaded. * */ content_size?: number; /** * Stop sequences to use. * Stop sequences are an array of strings or a single string that the model will recognize as end-of-text indicators. * The model stops generating more content when it encounters any of these strings. * This is particularly useful in scripted or formatted text generation, where a specific end point is required. * Stop sequences not included in the generated text. * * Does nothing if the model does not support this setting. * * Example: `stop_words: ['\n', 'END']` */ stop_words?: string | string[] | undefined; /** * the alias of stop_words */ stop?: string | string[] | undefined; /** * Number of texts to generate. * * Specifies the number of responses or completions the model should generate for a given prompt. * This is useful when you need multiple different outputs or ideas for a single prompt. * The model will generate 'n' distinct responses, each based on the same initial prompt. * In a streaming model this will result in both responses streamed back in real time. * * Does nothing if the model does not support this setting. * * Example: `gen_count: 3` // The model will produce 3 different responses. */ gen_count?: number; /** * When true, the leading and trailing white space and line terminator characters * are removed from the generated text. * * Default: true. */ trim?: boolean; stream?: boolean; response_format?: AIResponseFormat; frequency_penalty?: number; presence_penalty?: number; seed?: number; top_p?: number; top_k?: number; } interface LLMArguments { model?: string; value?: any; options?: AIOptions; provider?: string; onlyTokenizer?: boolean; } type AITextGenerationResult = AIResult; /** * Maps properties from the provided options object to a new object according to the mappings defined in AIOptionsMap. * Supports both simple property names and paths (e.g., 'foo.bar') for nested properties. * * @param {TAIOptions | undefined} opts - The original options object whose properties (including nested ones) will be copied to the new object based on the mapping. * @param {Record | undefined} AIOptionsMap - A mapping table defining how properties (or paths) in opts map to properties in the target object. * * @returns {TAIOptions} A new object containing properties copied from opts based on the defined mappings, including support for nested properties. * * @example * const originalOpts = { user: { name: 'Alice', age: 30 }, active: true }; * const mapping = { 'user.name': 'userName', 'active': 'isActive' }; * const mappedOpts = mapApiOptions(originalOpts, mapping); * // mappedOpts is now { userName: 'Alice', isActive: true } */ declare function mapApiOptions(opts?: TAIOptions, AIOptionsMap?: Record): TAIOptions; declare const flip: (data: Record, ignoreKeys?: string[]) => Record; /** Types and definitions for skills within the Language Model (LLM) system. */ declare const AIModelSkillTypes: readonly ["internal", "public"]; type AIModelSkillType = typeof AIModelSkillTypes[number]; /** Defines types of skill scores, indicating whether they are rated by an external authority or users. */ declare const AIModelSkillScoreTypes: readonly ["open_llm", "user"]; type AIModelSkillScoreType = typeof AIModelSkillScoreTypes[number]; /** Represents a skill score, including its type and numerical value. */ interface AIModelSkillScore { /** The source or authority that rated this skill (e.g., an open_llm benchmark or user feedback). */ type: AIModelSkillScoreType; /** A numeric value representing the quality of the skill, as determined by its rating source. */ score: number; } /** Lists the names of publicly recognized skills known to users. */ declare const AIModelPublicSkillNames: readonly ["Knowledge", "Reasoning", "Roleplay", "Coding", "Math", "History", "Science", "Tool"]; type AIModelPublicSkillName = typeof AIModelPublicSkillNames[number]; /** Lists the names of skills that are internal to the system and not directly observable by users. */ declare const AIModelInternalSKillNames: readonly ["Extract", "Embeddings", "Summary"]; type AIModelInternalSkillName = typeof AIModelInternalSKillNames[number]; /** Combines both public and internal skills into a single namespace for convenience. */ type AIModelSkillName = AIModelPublicSkillName | AIModelInternalSkillName; /** Defines the structure of an individual skill, including its name, description (optional), type, and scores (if available). */ interface AIModelSkill { /** The name of the skill as recognized by users or internal to the system. */ name: AIModelSkillName; /** An optional textual description providing additional context about the skill's function or purpose. */ description?: string; /** Indicates whether this skill is internal (system-specific) or public (user-facing). Defaults to 'public'. */ type?: AIModelSkillType; /** An array of scores associated with this skill, reflecting evaluations by different authorities or user feedback. */ score?: AIModelSkillScore[]; } declare const AIModelSources: readonly ["huggingface"]; type AIModelSource = (typeof AIModelSources[number]) & string; declare enum AIModelType { chat = 0,// text to text vision = 1,// image to text stt = 2,// audio to text drawing = 3,// text to image tts = 4,// text to audio embedding = 5, infill = 6 } interface AIProviderSettings { rule: AIModelNameRules; prior: number; supports: AIModelType | AIModelType[]; apiKey?: string; apiUrl?: string; } declare enum AIModelQuantType { F32 = 0, F16 = 1,// except 1d tensors Q4_0 = 2,// except 1d tensors Q4_1 = 3,// except 1d tensors Q4_1_SOME_F16 = 4,// tok_embeddings.weight and output.weight are F16 Q8_0 = 7,// except 1d tensors Q5_0 = 8,// except 1d tensors Q5_1 = 9,// except 1d tensors Q2_K = 10,// except 1d tensors Q3_K_S = 11,// except 1d tensors Q3_K_M = 12,// except 1d tensors Q3_K_L = 13,// except 1d tensors Q4_K_S = 14,// except 1d tensors Q4_K_M = 15,// except 1d tensors Q5_K_S = 16,// except 1d tensors Q5_K_M = 17,// except 1d tensors Q6_K = 18,// except 1d tensors IQ2_XXS = 19,// except 1d tensors IQ2_XS = 20,// except 1d tensors Q2_K_S = 21,// except 1d tensors IQ3_XS = 22,// except 1d tensors IQ3_XXS = 23,// except 1d tensors IQ1_S = 24,// except 1d tensors IQ4_NL = 25,// except 1d tensors IQ3_S = 26,// except 1d tensors IQ3_M = 27,// except 1d tensors IQ2_S = 28,// except 1d tensors IQ2_M = 29,// except 1d tensors IQ4_XS = 30,// except 1d tensors IQ1_M = 31,// except 1d tensors BF16 = 32,// except 1d tensors Q4_0_4_4 = 33,// except 1d tensors Q4_0_4_8 = 34,// except 1d tensors Q4_0_8_8 = 35,// except 1d tensors GUESSED = 1024,// not specified in the model file Q4_K_L = 1025, Q3_K_XL = 1026, Q2_K_L = 1027 } interface AIModelFileSettings { /** * the model unique name, include extension name */ file_name?: string; /** * the quanted model size in bytes */ size?: number; file_size?: number; quant?: AIModelQuantType; location?: string; index?: number; count?: number; url?: string; hf_path?: string; downloaded?: boolean; downloading?: FileDownloadStatus; [name: string]: any; } interface AIModelSimpleSettings { _id?: string; /** * the model unique name, but not the unique in db */ name?: string; type?: AIModelType; supports?: AIModelType | AIModelType[]; source?: AIModelSource; /** * the model params size in bytes */ params_size?: number; /** * the content length in train */ content_size?: number; scale?: string; /** * the remote url to download the model */ url?: string; /** * hugging-face repo name */ hf_repo?: string; skills?: AIModelSkillName[]; provider?: string; featured?: boolean; likes?: number; downloads?: number; title?: string; description?: string; author?: string; license?: string; logo?: string; chat_template?: string; config?: AIOptions; language?: string[]; createdAt?: Date; updatedAt?: Date; downloaded?: boolean; [name: string]: any; } type AIModelParams = AIModelSimpleSettings & AIModelFileSettings; interface AIModelSettings extends AIModelSimpleSettings { files?: AIModelFileSettings[]; } interface AILavaModelSettings extends AIModelSettings { model: AIModelNameRule | AIModelNameRule[]; } declare const LLMProviderSchema: { rule: { type: string[]; }; enabled: { type: string; value: boolean; }; apiUrl: { type: string; }; apiKey: { type: string; }; supports: { type: string; anyOf: ({ type: string; items?: undefined; } | { type: string; items: { type: string; }; })[]; }; prior: { type: string; }; model: { type: string; }; }; interface AITokenizeOptions extends AIOptions { model?: string; } declare const LLMProviderName = "llm"; interface LLMProvider extends AIProviderSettings { listModels?(): Promise; updateModel?(modelName: string, model: any): Promise; addModel?(modelName: string, model: any): Promise; deleteModel?(modelName: string): Promise; model?: string; } declare class LLMProvider extends ToolFunc { static current?: string; static items: { [name: string]: LLMProvider; }; description: string; params: { model: { name: string; type: string; description: string; }; value: { name: string; type: string; description: string; }; options: { name: string; type: string; description: string; }; }; result: string; depends: { [name: string]: ToolFunc; }; static getByModel(modelName?: string): LLMProvider | undefined; static getCurrentProvider(): LLMProvider | undefined; static setCurrentProvider(name: string): void; static unregister(name: string): ToolFunc | undefined; isModelNameMatched(modelName: string, rule?: AIModelNameRules): string | RegExpExecArray | undefined; isStream(params: ServerFuncParams): any; func(input: LLMArguments): Promise; listProviders(options?: { filter?: AIModelNameRules; all?: boolean; }): { [name: string]: LLMProvider; }; getProvider(name: string): ToolFunc; getCurrentProvider(): LLMProvider | undefined; setCurrentProvider(name: string): void; getModelInfo(modelName?: string, options?: any): Promise; _getChatTemplate(modelInfo?: AIModelParams | string, options?: { defaultTemplate?: boolean; type?: AIPromptType; provider?: string; }): Promise; getChatTemplate(chatTemplate?: string | AIPromptResult, options?: { modelInfo?: AIModelParams | string; defaultTemplate?: boolean; type?: AIPromptType; provider?: string; }): Promise; formatPrompt(messages: AIChatMessageParam[], modelInfo?: AIModelParams | string, options?: { defaultTemplate?: boolean; add_generation_prompt?: boolean; chatTemplate?: AIPromptResult; type?: AIPromptType; prompt?: any; SystemTemplate?: AIPromptResult; }): Promise; getDefaultParameters(chatTemplate: AIPromptSettings, model: string): any; tokenize(text: string | AIChatMessageParam[], options?: AITokenizeOptions): Promise; countTokens(text: string | AIChatMessageParam[], options?: AITokenizeOptions): Promise; } declare function joinUrl(baseUrl: string, url: string): string; declare const llm: LLMProvider; export { type AILavaModelSettings, type AIModelFileSettings, AIModelInternalSKillNames, type AIModelInternalSkillName, type AIModelParams, type AIModelPublicSkillName, AIModelPublicSkillNames, AIModelQuantType, type AIModelSettings, type AIModelSimpleSettings, type AIModelSkill, type AIModelSkillName, type AIModelSkillScore, type AIModelSkillScoreType, AIModelSkillScoreTypes, type AIModelSkillType, AIModelSkillTypes, type AIModelSource, AIModelSources, AIModelType, type AIOptions, type AIProviderSettings, type AIResponseFormat, type AIResponseFormatType, type AITextGenerationOptions, type AITextGenerationResult, type AITokenizeOptions, type LLMArguments, LLMProvider, LLMProviderName, LLMProviderSchema, flip, joinUrl, llm, mapApiOptions };