From d57f451c3bdee1ce45caec644efe42cfb578ee37 Mon Sep 17 00:00:00 2001 From: Tim Smart Date: Thu, 27 Apr 2023 00:06:46 +1200 Subject: [PATCH] refactor: gpt-3.5 --- src/OpenAI.ts | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/OpenAI.ts b/src/OpenAI.ts index c77b467..900f99e 100644 --- a/src/OpenAI.ts +++ b/src/OpenAI.ts @@ -33,14 +33,17 @@ const make = (params: OpenAIOptions) => { const generateTitle = (prompt: string) => Effect.flatMap( call((_, signal) => - _.createCompletion( + _.createChatCompletion( { - model: "text-davinci-003", - prompt: `Create a short title summarizing the following text: + model: "gpt-3.5-turbo", + messages: [ + { + role: "user", + content: `Create a short title summarizing the following text: -${prompt.split("\n")[0].trim()} - -`, +${prompt.split("\n")[0].trim()}`, + }, + ], temperature: 0.25, max_tokens: 64, top_p: 1, @@ -51,10 +54,12 @@ ${prompt.split("\n")[0].trim()} ), ), _ => - Option.map(Option.fromNullable(_.data.choices[0]?.text), _ => - _.trim() - .split("\n")[0] - .replace(/(^"|"$)/g, ""), + Option.map( + Option.fromNullable(_.data.choices[0]?.message?.content), + _ => + _.trim() + .split("\n")[0] + .replace(/(^"|"$)/g, ""), ), )