Inject metadata into the prompt with createStuffDocumentsChain #4063
Replies: 1 comment 2 replies
-
🤖 Hello @codinginflow! I'm Dosu, a friendly bot here to assist while we wait for a human maintainer. I can help you solve bugs, answer questions, and guide you to become a contributor. Feel free to ask me anything and I'll do my best to assist. The If you want to include Here's an example of how you can do this: import { BasePromptTemplate } from "@langchain/core/prompts";
const customDocumentPrompt = new BasePromptTemplate({
template: "{page_content} {page_url}",
inputVariables: ["page_content", "page_url"],
});
createStuffDocumentsChain({
llm: yourLanguageModel,
prompt: yourPrompt,
documentPrompt: customDocumentPrompt,
}); In this example, You can find more details about this in the langchain/src/chains/combine_documents/stuff.ts file in the langchainjs repository. I hope this helps! If you have any other questions, feel free to ask. -Dosu SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Any idea why the
page_url
is not available? According to the documentation ofcreateStuffDocumentsChain
, this should automatically be populated from the documents' metadata. And the value definitely exists in the metadata.Beta Was this translation helpful? Give feedback.
All reactions