Skip to content

Commit 50db5c8

Browse files
committed
make default model a property on the client class
1 parent 165cb5f commit 50db5c8

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

openai/init.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ do
4949
local _class_0
5050
local _base_0 = {
5151
api_base = "https://api.openai.com/v1",
52+
default_model = "gpt-4.1",
5253
new_chat_session = function(self, ...)
5354
return ChatSession(self, ...)
5455
end,
@@ -88,7 +89,7 @@ do
8889
local test_messages = types.array_of(test_message)
8990
assert(test_messages(messages))
9091
local payload = {
91-
model = "gpt-3.5-turbo",
92+
model = self.default_model,
9293
messages = messages
9394
}
9495
if opts then
@@ -198,6 +199,7 @@ do
198199
local create_response_stream_filter
199200
create_response_stream_filter = require("openai.responses").create_response_stream_filter
200201
local payload = {
202+
model = self.default_model,
201203
input = input
202204
}
203205
if opts then

openai/init.moon

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ consume_json_head = do
6565
-- TODO: hadle appending the streaming response to the output
6666
class OpenAI
6767
api_base: "https://api.openai.com/v1"
68+
default_model: "gpt-4.1"
6869

6970
-- config: types.shape {
7071
-- http_provider: types.string\describe("HTTP module name used for requests") + types nil
@@ -116,7 +117,7 @@ class OpenAI
116117
assert test_messages messages
117118

118119
payload = {
119-
model: "gpt-3.5-turbo"
120+
model: @default_model
120121
:messages
121122
}
122123

@@ -237,7 +238,10 @@ class OpenAI
237238
create_response: (input, opts={}, stream_callback=nil) =>
238239
import create_response_stream_filter from require "openai.responses"
239240

240-
payload = { :input }
241+
payload = {
242+
model: @default_model
243+
:input
244+
}
241245

242246
if opts
243247
for k, v in pairs opts

openai/responses.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
local cjson = require("cjson")
22
local types
33
types = require("tableshape").types
4-
local DEFAULT_RESPONSES_MODEL = "gpt-4.1-mini"
54
local empty = (types["nil"] + types.literal(cjson.null)):describe("nullable")
65
local input_format = types.string + types.array_of(types.partial({
76
role = types.one_of({

openai/responses.moon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
cjson = require "cjson"
22
import types from require "tableshape"
33

4-
DEFAULT_RESPONSES_MODEL = "gpt-4.1-mini"
5-
64
empty = (types.nil + types.literal(cjson.null))\describe "nullable"
75

86
-- Schema for validating input parameter which can be string or array of messages

0 commit comments

Comments
 (0)