跳到主要内容

t

import {
ChatPromptTemplate,
MessagesPlaceholder,
} from "@langchain/core/prompts";
import { HumanMessage } from "@langchain/core/messages";

const promptTemplate = ChatPromptTemplate.fromMessages([
["system", "You are a helpful assistant"],
new MessagesPlaceholder("msgs"),
]);

await promptTemplate.invoke({ msgs: [new HumanMessage("hi!")] });
ChatPromptValue {
lc_serializable: true,
lc_kwargs: {
messages: [
SystemMessage {
"content": "You are a helpful assistant",
"additional_kwargs": {},
"response_metadata": {}
},
HumanMessage {
"content": "hi!",
"additional_kwargs": {},
"response_metadata": {}
}
]
},
lc_namespace: [ 'langchain_core', 'prompt_values' ],
messages: [
SystemMessage {
"content": "You are a helpful assistant",
"additional_kwargs": {},
"response_metadata": {}
},
HumanMessage {
"content": "hi!",
"additional_kwargs": {},
"response_metadata": {}
}
]
}

此页是否对您有帮助?


您也可以留下详细的反馈 在 GitHub 上.