@@ -33,7 +33,7 @@ openai = OpenAI::Client.new(
33
33
)
34
34
35
35
chat_completion = openai.chat.completions.create(
36
- messages: [{role: : user , content: " Say this is a test" }],
36
+ messages: [{role: " user" , content: " Say this is a test" }],
37
37
model: :"gpt-4.1"
38
38
)
39
39
@@ -48,7 +48,7 @@ When using sorbet, it is recommended to use model classes as below. This provide
48
48
49
49
``` ruby
50
50
openai.chat.completions.create(
51
- messages: [OpenAI ::Models ::Chat ::ChatCompletionUserMessageParam .new (role: : user , content: " Say this is a test" )],
51
+ messages: [OpenAI ::Models ::Chat ::ChatCompletionUserMessageParam .new (role: " user" , content: " Say this is a test" )],
52
52
model: :"gpt-4.1"
53
53
)
54
54
```
@@ -80,7 +80,7 @@ We provide support for streaming responses using Server-Sent Events (SSE).
80
80
81
81
``` ruby
82
82
stream = openai.chat.completions.stream_raw(
83
- messages: [{role: : user , content: " Say this is a test" }],
83
+ messages: [{role: " user" , content: " Say this is a test" }],
84
84
model: :"gpt-4.1"
85
85
)
86
86
@@ -97,11 +97,11 @@ Request parameters that correspond to file uploads can be passed as `StringIO`,
97
97
require " pathname"
98
98
99
99
# using `Pathname`, the file will be lazily read, without reading everything in to memory
100
- file_object = openai.files.create(file: Pathname (" input.jsonl" ), purpose: : "fine-tune" )
100
+ file_object = openai.files.create(file: Pathname (" input.jsonl" ), purpose: " fine-tune" )
101
101
102
102
file = File .read(" input.jsonl" )
103
103
# using `StringIO`, useful if you already have the data in memory
104
- file_object = openai.files.create(file: StringIO .new (file), purpose: : "fine-tune" )
104
+ file_object = openai.files.create(file: StringIO .new (file), purpose: " fine-tune" )
105
105
106
106
puts (file_object.id)
107
107
```
@@ -150,7 +150,7 @@ openai = OpenAI::Client.new(
150
150
151
151
# Or, configure per-request:
152
152
openai.chat.completions.create(
153
- messages: [{role: : user , content: " How can I get the name of the current day in JavaScript?" }],
153
+ messages: [{role: " user" , content: " How can I get the name of the current day in JavaScript?" }],
154
154
model: :"gpt-4.1" ,
155
155
request_options: {max_retries: 5 }
156
156
)
@@ -172,7 +172,7 @@ openai = OpenAI::Client.new(
172
172
173
173
# Or, configure per-request:
174
174
openai.chat.completions.create(
175
- messages: [{role: : user , content: " How can I list all files in a directory using Python?" }],
175
+ messages: [{role: " user" , content: " How can I list all files in a directory using Python?" }],
176
176
model: :"gpt-4.1" ,
177
177
request_options: {timeout: 5 }
178
178
)
@@ -189,13 +189,13 @@ In all places where a `BaseModel` type is specified, vanilla Ruby `Hash` can als
189
189
``` ruby
190
190
# This has tooling readability, for auto-completion, static analysis, and goto definition with supported language services
191
191
params = OpenAI ::Models ::Chat ::CompletionCreateParams .new (
192
- messages: [OpenAI ::Models ::Chat ::ChatCompletionUserMessageParam .new (role: : user , content: " Say this is a test" )],
192
+ messages: [OpenAI ::Models ::Chat ::ChatCompletionUserMessageParam .new (role: " user" , content: " Say this is a test" )],
193
193
model: :"gpt-4.1"
194
194
)
195
195
196
196
# This also works
197
197
params = {
198
- messages: [{role: : user , content: " Say this is a test" }],
198
+ messages: [{role: " user" , content: " Say this is a test" }],
199
199
model: :"gpt-4.1"
200
200
}
201
201
```
@@ -257,7 +257,7 @@ It is possible to pass a compatible model / parameter class to a method that exp
257
257
258
258
``` ruby
259
259
params = OpenAI ::Models ::Chat ::CompletionCreateParams .new (
260
- messages: [OpenAI ::Models ::Chat ::ChatCompletionUserMessageParam .new (role: : user , content: " Say this is a test" )],
260
+ messages: [OpenAI ::Models ::Chat ::ChatCompletionUserMessageParam .new (role: " user" , content: " Say this is a test" )],
261
261
model: :"gpt-4.1"
262
262
)
263
263
openai.chat.completions.create(** params)
0 commit comments