From ce8627ea8963b7150d9eeb2e0495be00744e74ff Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Fri, 5 Apr 2024 00:48:09 +0200 Subject: [PATCH 1/4] Keep defaults for /completions parameters Ref: https://platform.openai.com/docs/api-reference/completions/create --- openai/init.moon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openai/init.moon b/openai/init.moon index 072242d..a7a8f50 100644 --- a/openai/init.moon +++ b/openai/init.moon @@ -284,8 +284,8 @@ class OpenAI payload = { model: "text-davinci-003" :prompt - temperature: 0.5 - max_tokens: 600 + -- temperature: 1 + -- max_tokens: 16 -- top_p: 1 -- frequency_penalty: 0 -- presence_penalty: 0 From d39ab68660bec487829d393a31049b612cab69c3 Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Fri, 5 Apr 2024 01:01:43 +0200 Subject: [PATCH 2/4] Keep defaults for /chat/completions parameters Ref: - https://platform.openai.com/docs/api-reference/completions/create#completions-create-temperature --- openai/init.moon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openai/init.moon b/openai/init.moon index a7a8f50..717edc4 100644 --- a/openai/init.moon +++ b/openai/init.moon @@ -265,7 +265,7 @@ class OpenAI payload = { model: "gpt-3.5-turbo" - temperature: 0.5 + -- temperature: 1 :messages } From 7252fb3d4c108805ab49261dffad07cdc58dace4 Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Mon, 8 Apr 2024 01:53:22 +0200 Subject: [PATCH 3/4] No need in defaults for model as well The models come and go, it is the client's responsibility to stay updated. P.S. We could ensure that the model is specified, but what's the point? The server returns an error without needing assistance from the library." --- openai/init.moon | 8 -------- 1 file changed, 8 deletions(-) diff --git a/openai/init.moon b/openai/init.moon index 717edc4..27c2a21 100644 --- a/openai/init.moon +++ b/openai/init.moon @@ -264,8 +264,6 @@ class OpenAI assert test_messages messages payload = { - model: "gpt-3.5-turbo" - -- temperature: 1 :messages } @@ -282,13 +280,7 @@ class OpenAI -- opts: additional parameters as described in https://platform.openai.com/docs/api-reference/completions completion: (prompt, opts) => payload = { - model: "text-davinci-003" :prompt - -- temperature: 1 - -- max_tokens: 16 - -- top_p: 1 - -- frequency_penalty: 0 - -- presence_penalty: 0 } if opts From f9a2559f42a22729569913b35e09e0ea8e005334 Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Mon, 8 Apr 2024 01:56:53 +0200 Subject: [PATCH 4/4] Host header is not in specs Ref: - https://platform.openai.com/docs/api-reference/making-requests Instead, we should implement the ability to include arbitrary headers --- openai/init.moon | 3 --- 1 file changed, 3 deletions(-) diff --git a/openai/init.moon b/openai/init.moon index 27c2a21..32d98f8 100644 --- a/openai/init.moon +++ b/openai/init.moon @@ -7,8 +7,6 @@ unpack = table.unpack or unpack import types from require "tableshape" -parse_url = require("socket.url").parse - empty = (types.nil + types.literal(cjson.null))\describe "nullable" content_format = types.string + types.array_of types.one_of { @@ -364,7 +362,6 @@ class OpenAI cjson.encode payload headers = { - "Host": parse_url(@api_base).host "Accept": "application/json" "Content-Type": "application/json" "Content-Length": body and #body or nil