Back
Version 0
10/2/2023
const sampleSequentialChain = (async () => {
const { SequentialChain, LLMChain } = await import("npm:langchain/chains");
const { PromptTemplate } = await import("npm:langchain/prompts");
const mb = await webup.getModelBuilder();
const llm = await mb();
const tb = await webup.getLangSmithBuilder();
const tracer = await tb();
// This is an LLMChain to write a synopsis given a title of a play and the era it is set in.
const template =
`You are a playwright. Given the title of play and the era it is set in, it is your job to write a synopsis for that title.
Title: {title}
Era: {era}
Playwright: This is a synopsis for the above play:`;
const promptTemplate = new PromptTemplate({
template,
inputVariables: ["title", "era"],
});
const synopsisChain = new LLMChain({
llm,
prompt: promptTemplate,
outputKey: "synopsis",
});
// This is an LLMChain to write a review of a play given a synopsis.
const reviewTemplate =
`You are a play critic from the New York Times. Given the synopsis of play, it is your job to write a review for that play.
Play Synopsis:
{synopsis}
Review from a New York Times play critic of the above play:`;
const reviewPromptTemplate = new PromptTemplate({
template: reviewTemplate,
inputVariables: ["synopsis"],
});
const reviewChain = new LLMChain({
llm,
Updated: October 23, 2023