0aff31e2d3
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
741 B
741 B
layout
| layout |
|---|
| default |
Partial Templates
Partial: Pre-rellenar algunas variables, completar otras después
import { ChatPromptTemplate } from "@langchain/core/prompts";
const template = ChatPromptTemplate.fromMessages([
["system", "Eres un experto en {topic} que habla {language}"],
["human", "{question}"]
]);
// Pre-configurar topic y language
const spanishJSTemplate = await template.partial({
topic: "JavaScript",
language: "español"
});
// Ahora solo necesitas la pregunta
const response = await model.invoke(
await spanishJSTemplate.invoke({ question: "¿Qué es async/await?" })
);