Skip to content

Commit

Permalink
refactor: gpt-3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Apr 26, 2023
1 parent cc95dea commit d57f451
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/OpenAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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, ""),
),
)

Expand Down

0 comments on commit d57f451

Please sign in to comment.