Back

Version 2

9/16/2023
const untitled_violetGibbon = (async () => {
const { ChatOpenAI } = await import(
"https://esm.sh/langchain@0.0.150/chat_models/openai"
);
const { LLMChain } = await import("https://esm.sh/langchain@0.0.150/chains");
const { ChatPromptTemplate } = await import(
"https://esm.sh/langchain@0.0.150/prompts"
);
const { StringOutputParser } = await import(
"https://esm.sh/langchain@0.0.150/schema/output_parser"
);
const { RunnableSequence } = await import(
"https://esm.sh/langchain@0.0.150/schema/runnable"
);
const questionPrompt = ChatPromptTemplate.fromPromptMessages([
["user", "Generate 5 questions about the following paragraph: {paragraph}"],
]);
const questionChain = questionPrompt
.pipe(new ChatOpenAI({
openAIApiKey: @me.secrets.OPENAI_API_KEY,
})
.pipe(new StringOutputParser()));
const stylePrompt = ChatPromptTemplate.fromPromptMessages([
[
"user",
"Transform the following questions to meet the guidelines:\n\nQuestions:\n\n{questions}\n\nGuidelines:{guidelines}",
],
]);
const styleChain = stylePrompt
.pipe(
new ChatOpenAI({
openAIApiKey: @me.secrets.OPENAI_API_KEY,
}),
)
.pipe(new StringOutputParser());
const questionStyleChain = RunnableSequence.from([{
Updated: October 23, 2023