Skip to content

Commit

Permalink
use better openai model
Browse files Browse the repository at this point in the history
michaeljguarino committed Dec 3, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent a198649 commit 49ee15e
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion apps/core/lib/core/clients/openai.ex
Original file line number Diff line number Diff line change
@@ -15,8 +15,10 @@ defmodule Core.Clients.OpenAI do
def completion(model, prompt) do
body = Jason.encode!(%{
model: model,
prompt: prompt,
prompt: String.trim(prompt),
max_tokens: 1000,
temperature: 0.7,
top_p: 1,
})

url("/completions")
2 changes: 1 addition & 1 deletion apps/core/lib/core/services/ai.ex
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ defmodule Core.Services.AI do
"""
@spec answer(binary) :: {:ok, binary} | error
def answer(prompt) do
case OpenAI.completion("davinci", prompt) do
case OpenAI.completion("text-davinci-003", prompt) do
{:ok, %OpenAI.CompletionResponse{choices: [%OpenAI.Choice{text: text} | _]}} -> {:ok, text}
{:ok, _} -> {:error, "no response found"}
error -> error

0 comments on commit 49ee15e

Please sign in to comment.