import { AIMessage, BaseMessage } from "@langchain/core/messages";
import { z } from "zod";
import { Tool } from "@langchain/core/tools";
import { StructuredTool } from "@langchain/core/tools";
export interface ToolCall {
    id: string;
    type: "tool_call";
    name: string;
    args: Record<string, unknown>;
}
/**
 * Opciones en formato camelCase para la configuración de modelos NVIDIA
 */
export interface NvidiaCamelCaseOptions {
    model?: string;
    maxTokens?: number;
    temperature?: number;
    topP?: number;
    topK?: number;
    presencePenalty?: number;
    frequencyPenalty?: number;
    stop?: string[];
    images?: string[];
    tools?: Tool[] | any[] | boolean;
    toolChoice?: "auto" | "none" | {
        type: string;
        function: {
            name: string;
        };
    };
    streaming?: boolean;
}
/**
 * Opciones para la API de NVIDIA Llama4 en formato snake_case (compatible con API)
 */
export interface NvidiaSnakeCaseOptions {
    /** Modelo a utilizar */
    model?: string;
    /** Temperatura para generación (0-1) */
    temperature?: number;
    /** Máximo de tokens a generar */
    max_tokens?: number;
    /** Top-p para muestreo de tokens */
    top_p?: number;
    /** Top-k para muestreo de tokens */
    top_k?: number;
    /** Penalización por frecuencia */
    frequency_penalty?: number;
    /** Penalización por presencia */
    presence_penalty?: number;
    /** Tokens de parada */
    stop?: string[];
    /** Habilitado para streaming */
    stream?: boolean;
    /** Herramientas a utilizar */
    tools?: Tool[] | any[] | boolean;
    /** Elegir herramienta */
    tool_choice?: "auto" | "none" | {
        type: string;
        function: {
            name: string;
        };
    };
    /** Opciones de imagen/multimodal */
    images?: string[];
}
export interface OpenAITool {
    type: string;
    function: {
        name: string;
        description?: string;
        parameters: Record<string, unknown>;
    };
}
export interface NvidiaToolCall {
    id: string;
    type: string;
    function: {
        name: string;
        arguments: string;
    };
}
export interface ToolCallResponseFormat {
    role: string;
    content: string;
    tool_calls?: NvidiaToolCall[];
}
export type BindToolsInput = StructuredTool | OpenAITool | Tool;
/**
 * Intenta analizar una cadena JSON y la devuelve como objeto.
 * Si falla, devuelve un objeto con la propiedad raw conteniendo la cadena original.
 *
 * @param jsonString - Cadena JSON a analizar
 * @returns Objeto analizado o {raw: cadenaOriginal}
 */
export declare function safeJsonParse(jsonString: string): Record<string, unknown>;
/**
 * Convierte una herramienta de LangChain al formato de OpenAI
 */
export declare function convertToOpenAITool(tool: BindToolsInput): OpenAITool;
/**
 * Convierte opciones en formato camelCase a los parámetros esperados por la API de NVIDIA
 */
export declare function convertOptionsToNvidiaParams(options: NvidiaCamelCaseOptions): Record<string, unknown>;
/**
 * Definición del tipo para los mensajes en formato NVIDIA
 */
export declare const NvidiaMessageSchema: z.ZodObject<{
    role: z.ZodEnum<["system", "user", "assistant"]>;
    content: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
        type: z.ZodLiteral<"image">;
        image_url: z.ZodObject<{
            url: z.ZodString;
        }, "strip", z.ZodTypeAny, {
            url: string;
        }, {
            url: string;
        }>;
    }, "strip", z.ZodTypeAny, {
        type: "image";
        image_url: {
            url: string;
        };
    }, {
        type: "image";
        image_url: {
            url: string;
        };
    }>]>, "many">]>;
}, "strip", z.ZodTypeAny, {
    role: "system" | "user" | "assistant";
    content: string | (string | {
        type: "image";
        image_url: {
            url: string;
        };
    })[];
}, {
    role: "system" | "user" | "assistant";
    content: string | (string | {
        type: "image";
        image_url: {
            url: string;
        };
    })[];
}>;
export type NvidiaMessage = z.infer<typeof NvidiaMessageSchema>;
/**
 * Formatea los mensajes de LangChain para la API de NVIDIA
 */
export declare function formatMessagesForNvidia(messages: BaseMessage[]): NvidiaMessage[];
/**
 * Procesa las llamadas a herramientas desde el contenido de un mensaje
 * Esta función maneja tanto el formato oficial de tool_calls como contenido
 * que podría contener llamadas a herramientas en formato de texto
 */
export declare function processToolCallsFromContent(content: string): {
    processedContent: string;
    extractedToolCalls: Array<{
        id: string;
        type: string;
        name: string;
        args: Record<string, unknown>;
    }> | null;
};
/**
 * Convierte la respuesta de NVIDIA a un mensaje de LangChain
 */
export declare function convertResponseToLangChainMessage(response: unknown): AIMessage;
/**
 * Convierte opciones de snake_case a camelCase para uso interno
 */
export declare function toCamelCaseOptions(options: NvidiaSnakeCaseOptions): NvidiaCamelCaseOptions;
/**
 * Convierte opciones de camelCase a snake_case para la API de NVIDIA
 */
export declare function toSnakeCaseOptions(options: NvidiaCamelCaseOptions): NvidiaSnakeCaseOptions;
