-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchain13g.js
More file actions
36 lines (26 loc) · 940 Bytes
/
Copy pathchain13g.js
File metadata and controls
36 lines (26 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import dotenv from "dotenv";
dotenv.config();
import {ChatGoogleGenerativeAI} from "@langchain/google-genai"
import {PromptTemplate} from "@langchain/core/prompts"
import {RunnableSequence} from "@langchain/core/runnables"
const model = new ChatGoogleGenerativeAI({
model: "gemini-1.5-flash",
apiKey: process.env.GOOGLE_API_KEY,
temperature: 0
});
const templateString = "Suggest 3 nicknames for a {pet_animal}"
const template = PromptTemplate.fromTemplate(templateString)
const templateString2 = "Which of these {pet_names} is also a good pet name for a dog"
const template2 = PromptTemplate.fromTemplate(templateString2)
const chain = template.pipe(model)
const composedChain = RunnableSequence.from([
chain,
(input) => ({pet_names : input.content}),
template2,
model
])
const response = await composedChain.invoke({
//pet_animal: "Dog",
pet_animal: "Panda"
})
console.log(response.content)