-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
38 lines (30 loc) · 999 Bytes
/
main.ts
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
37
38
import { load } from "https://deno.land/[email protected]/dotenv/mod.ts";
import { OpenAI } from "https://esm.sh/[email protected]/llms/openai";
import { PromptTemplate, LLMChain } from "https://esm.sh/[email protected]";
const env = await load();
template();
// llm();
export async function template() {
const model = new OpenAI({
openAIApiKey: env["OPENAI_API_KEY"],
temperature: 0.9,
});
const template = "{product}を販売する素敵な会社名は何ですか?";
const prompt = new PromptTemplate({
template: template,
inputVariables: ["product"],
});
const chain = new LLMChain({ llm: model, prompt });
const res = await chain.call({ product: "カラフルな靴下" });
console.log(res);
}
export async function llm() {
const model = new OpenAI({
openAIApiKey: env["OPENAI_API_KEY"],
temperature: 0.9,
});
const res = await model.call(
"カラフルな靴下を販売する素敵な会社名は何ですか?"
);
console.log(res);
}