From a136f19cb4523c0d9073285b8ebdcb081982de05 Mon Sep 17 00:00:00 2001 From: kensiiwasaki Date: Tue, 21 Nov 2023 22:44:34 +0900 Subject: [PATCH] =?UTF-8?q?modify:=20=E3=83=97=E3=83=AD=E3=83=B3=E3=83=97?= =?UTF-8?q?=E3=83=88=E3=82=92=E5=88=A5=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/index.tsx | 12 ++---------- app/util/prompt.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 app/util/prompt.ts diff --git a/app/routes/index.tsx b/app/routes/index.tsx index 5112e71..9a4c565 100644 --- a/app/routes/index.tsx +++ b/app/routes/index.tsx @@ -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(); @@ -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; diff --git a/app/util/prompt.ts b/app/util/prompt.ts new file mode 100644 index 0000000..7a69a79 --- /dev/null +++ b/app/util/prompt.ts @@ -0,0 +1,9 @@ +export const NormalPrompt = ` +今日の夜ご飯の主菜を考えてください +{ + "title": "string", + "ingredients": [], + "instructions": "string" +} +のJSON形式で返してください +`;