Skip to content

Commit

Permalink
modify: プロンプトを別ファイル化
Browse files Browse the repository at this point in the history
  • Loading branch information
kensiiwasaki committed Nov 21, 2023
1 parent f20baca commit a136f19
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
12 changes: 2 additions & 10 deletions app/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { LoaderFunction } from "@remix-run/node";
import { json } from "@remix-run/node";
import { Form, useActionData, useLoaderData } from "@remix-run/react";
import { OpenAI } from "openai";
import { NormalPrompt } from "~/util/prompt";

const prisma = new PrismaClient();

Expand All @@ -31,17 +32,8 @@ export const action = async () => {
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
const prompt = `
今日の夜ご飯の主菜を考えてください
{
"title": "string",
"ingredients": [],
"instructions": "string"
}
のJSON形式で返してください
`;
const gptResponse = await openai.chat.completions.create({
messages: [{ role: "system", content: prompt }],
messages: [{ role: "system", content: NormalPrompt }],
model: "gpt-3.5-turbo",
});
const content = gptResponse.choices[0].message.content;
Expand Down
9 changes: 9 additions & 0 deletions app/util/prompt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const NormalPrompt = `
今日の夜ご飯の主菜を考えてください
{
"title": "string",
"ingredients": [],
"instructions": "string"
}
のJSON形式で返してください
`;

0 comments on commit a136f19

Please sign in to comment.