Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Commit 9043cc5

Browse files
fix import
1 parent 749692c commit 9043cc5

File tree

6 files changed

+54
-9
lines changed

6 files changed

+54
-9
lines changed

example/deno/main.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ import { App, openai } from "https://cdn.skypack.dev/@hikae/gpt?dts";
22
import "https://deno.land/x/[email protected]/load.ts";
33

44
import { negpos } from "./negpos.ts";
5+
import { resume } from "./resume.ts";
56

67
const key = Deno.env.get("OPENAI_API_KEY");
78
if (!key) {
89
throw new Error("[OPENAI_API_KEY] not found");
910
}
1011

11-
const app: App = openai.app(key);
12+
const app: App = openai.app(key, "davinci");
1213

1314
//// tasks
1415

15-
await negpos("いい一日だなあ")(app);
16+
await resume(app)();
17+
18+
// await negpos("いい一日だなあ")(app);
1619
// = 'Positive'

example/deno/resume.ts

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { App, openai } from "https://cdn.skypack.dev/@hikae/gpt?dts";
2+
3+
const noteToSummary = [
4+
"インタビューの内容からあなたの自己紹介文を作成してください:",
5+
"自己紹介",
6+
];
7+
8+
type Interview = { q: string; a: string }[];
9+
const buildQuery = (interview: Interview) => {
10+
return `${noteToSummary[0]}
11+
12+
${interview
13+
.map(
14+
({ q, a }) => `
15+
インタビュアー: ${q}
16+
あなた: ${a}
17+
`
18+
)
19+
.join("")}
20+
21+
${noteToSummary[1]}
22+
`;
23+
};
24+
25+
export const resume = (app: App) => async () => {
26+
const interview: Interview = [
27+
{ q: "趣味は何ですか?", a: "プログラミング" },
28+
{ q: "その趣味はいつからやっていますか?", a: "4年" },
29+
{
30+
q: "その趣味のどういったところが好きですか?",
31+
a: "生産性が上がるところ",
32+
},
33+
];
34+
const prompt = buildQuery(interview);
35+
36+
const res = await openai.completion({
37+
prompt,
38+
max_tokens: 100,
39+
stop: "。",
40+
})(app);
41+
console.log(`${prompt}${res.choices[0].text}`);
42+
};

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"typescript": "^4.4.2"
2525
},
2626
"name": "@hikae/gpt",
27-
"version": "0.0.10",
27+
"version": "0.1.0",
2828
"description": "A framework to build OpenAPI apps using nodejs",
2929
"keywords": [
3030
"gpt3"

src/core/classification.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { ClassificationOpts, App, Classification } from "dist";
2-
import { Options } from "ky";
1+
import { ClassificationOpts, App, Classification } from "~/mod";
32
import { classificationsURL } from "~/lib/mod";
3+
import { Options } from "ky";
44

55
/**
66
* Create Classification

src/core/completion.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { CompletionOpts, App, Completion } from "dist";
2-
import { Options } from "ky";
1+
import { App, Completion, CompletionOpts } from "~/mod";
32
import { completionURL } from "~/lib/mod";
3+
import { Options } from "ky";
44

55
/**
66
* Completion

src/core/search.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { SearchOpts, App, Search } from "dist";
2-
import { Options } from "ky";
1+
import { SearchOpts, App, Search } from "~/mod";
32
import { searchURL } from "~/lib/mod";
3+
import { Options } from "ky";
44

55
/**
66
* Search

0 commit comments

Comments
 (0)