UNPKG

@rexdug7005/nvidia-llama4

Version:

Integración de NVIDIA Llama4 con LangChain.js

72 lines (71 loc) 2.1 kB
import { AIMessage, BaseMessage } from "@langchain/core/messages"; import { z } from "zod"; /** * 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[]; } /** * 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[]; /** * Convierte la respuesta de NVIDIA a un mensaje de LangChain */ export declare function convertResponseToLangChainMessage(response: unknown): AIMessage;