Skip to content

Commit b7ef7b9

Browse files
committed
Add JSON mode to the README
1 parent 8fa2d37 commit b7ef7b9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,20 @@ puts response.dig("choices", 0, "message", "content")
217217
# => "The image depicts a serene natural landscape featuring a long wooden boardwalk extending straight ahead"
218218
```
219219

220+
#### JSON Mode
221+
222+
You can set the response_format to ask for responses in JSON:
223+
224+
```ruby
225+
response = client.chat(
226+
parameters: {
227+
model: "gpt-3.5-turbo",
228+
response_format: { type: "json_object" },
229+
messages: [{ role: "user", content: "Hello!"}],
230+
temperature: 0.7,
231+
})
232+
```
233+
220234
### Functions
221235

222236
You can describe and pass in functions and the model will intelligently choose to output a JSON object containing arguments to call those them. For example, if you want the model to use your method `get_current_weather` to get the current weather in a given location:

0 commit comments

Comments
 (0)