Skip to content

Langchain JS MapReduce - how to override default combine_prompt with custom prompt template #3371

Answered by dosubot bot
poetsmeniet asked this question in Q&A
Discussion options

You must be logged in to vote

🤖

Hello @poetsmeniet! Good to see you again. Hope you're doing well with your project.

To override the default combine_prompt with a custom prompt template in LangChain JS MapReduce, you can pass your custom prompt template as a parameter when calling the loadQAMapReduceChain function.

Here's an example of how you can do this:

import { PromptTemplate } from "langchain/prompts";

// Define your custom prompt
const customPrompt = PromptTemplate.fromTemplate(`Your custom template {variable}`);

// Load the QA MapReduce chain with your custom prompt
const chain = loadQAMapReduceChain(model, { combinePrompt: customPrompt });

// Your existing code...
const docs = [
  new Document({ pageContent: 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by poetsmeniet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant