Skip to content

Commit 471f541

Browse files
Merge pull request #146 from openai/release-please--branches--main--changes--next
release: 0.4.0-beta.1
2 parents 2dea19a + 6020d39 commit 471f541

25 files changed

+252
-20
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.1.0-beta.2"
2+
".": "0.4.0-beta.1"
33
}

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 109
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-fc64d7c2c8f51f750813375356c3f3fdfc7fc1b1b34f19c20a5410279d445d37.yml
33
openapi_spec_hash: 618285fc70199ee32b9ebe4bf72f7e4c
4-
config_hash: c497f6b750cc89c0bf2eefc0bc839c70
4+
config_hash: 535b6e5f26a295d609b259c8cb8f656c

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## 0.4.0-beta.1 (2025-05-23)
4+
5+
Full Changelog: [v0.1.0-beta.2...v0.4.0-beta.1](https://github.com/openai/openai-ruby/compare/v0.1.0-beta.2...v0.4.0-beta.1)
6+
7+
### Features
8+
9+
* structured output for responses API (text) ([#688](https://github.com/openai/openai-ruby/issues/688)) ([282ec24](https://github.com/openai/openai-ruby/commit/282ec24c89511c1cd50029fe154e10d772e23239))
10+
* structured output for responses API (tools) ([#691](https://github.com/openai/openai-ruby/issues/691)) ([5e524ea](https://github.com/openai/openai-ruby/commit/5e524ea48020125911204c8050b49e360d7513d7))
11+
12+
13+
### Chores
14+
15+
* **internal:** fix release workflows ([e1b31a6](https://github.com/openai/openai-ruby/commit/e1b31a6d6c3064f57e82aa1c3f48f2c797619b5a))
16+
* **internal:** version bump ([b2dd8dd](https://github.com/openai/openai-ruby/commit/b2dd8dd1aac3ff9acf69953a0d04c74721b47e36))
17+
* update README for public release ([#145](https://github.com/openai/openai-ruby/issues/145)) ([64e3849](https://github.com/openai/openai-ruby/commit/64e384933c2f80508002dfacf89efe74510c1330))
18+
319
## 0.1.0-beta.2 (2025-05-22)
420

521
Full Changelog: [v0.1.0-beta.1...v0.1.0-beta.2](https://github.com/openai/openai-ruby/compare/v0.1.0-beta.1...v0.1.0-beta.2)

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ GIT
1111
PATH
1212
remote: .
1313
specs:
14-
openai (0.1.0.pre.beta.2)
14+
openai (0.4.0.pre.beta.1)
1515
connection_pool
1616

1717
GEM

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ The REST API documentation can be found on [platform.openai.com](https://platfor
1010

1111
## Installation
1212

13-
ℹ️ The `openai` gem is not yet available on [rubygems.org](https://rubygems.org).
14-
1513
To use this gem, install via Bundler by adding the following to your application's `Gemfile`:
1614

1715
<!-- x-release-please-start-version -->
1816

1917
```ruby
20-
gem "openai", github: "openai/openai-ruby", branch: "main"
18+
gem "openai", "~> 0.4.0.pre.beta.1"
2119
```
2220

2321
<!-- x-release-please-end -->

bin/check-release-environment

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
errors=()
44

5+
if [ -z "${STAINLESS_API_KEY}" ]; then
6+
errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organization secrets on GitHub.")
7+
fi
8+
59
if [ -z "${GEM_HOST_API_KEY}" ]; then
610
errors+=("The OPENAI_GEM_HOST_API_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets")
711
fi

examples/structured_outputs_chat_completions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class CalendarEvent < OpenAI::BaseModel
4949

5050
chat_completion
5151
.choices
52-
.filter { !_1.message.refusal }
52+
.reject { _1.message.refusal }
5353
.each do |choice|
5454
pp(choice.message.parsed)
5555
end

examples/structured_outputs_chat_completions_function_calling.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class GetWeather < OpenAI::BaseModel
2424

2525
chat_completion
2626
.choices
27-
.filter { !_1.message.refusal }
27+
.reject { _1.message.refusal }
2828
.flat_map { _1.message.tool_calls.to_a }
2929
.each do |tool_call|
3030
pp(tool_call.function.parsed)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require_relative "../lib/openai"
5+
6+
class Location < OpenAI::BaseModel
7+
required :address, String
8+
required :city, String, doc: "City name"
9+
required :postal_code, String, nil?: true
10+
end
11+
12+
# Participant model with an optional last_name and an enum for status
13+
class Participant < OpenAI::BaseModel
14+
required :first_name, String
15+
required :last_name, String, nil?: true
16+
required :status, OpenAI::EnumOf[:confirmed, :unconfirmed, :tentative]
17+
end
18+
19+
# CalendarEvent model with a list of participants.
20+
class CalendarEvent < OpenAI::BaseModel
21+
required :name, String
22+
required :date, String
23+
required :participants, OpenAI::ArrayOf[Participant]
24+
required :is_virtual, OpenAI::Boolean
25+
required :location,
26+
OpenAI::UnionOf[String, Location],
27+
nil?: true,
28+
doc: "Event location"
29+
end
30+
31+
client = OpenAI::Client.new
32+
33+
response = client.responses.create(
34+
model: "gpt-4o-2024-08-06",
35+
input: [
36+
{role: :system, content: "Extract the event information."},
37+
{
38+
role: :user,
39+
content: <<~CONTENT
40+
Alice Shah and Lena are going to a science fair on Friday at 123 Main St. in San Diego.
41+
They have also invited Jasper Vellani and Talia Groves - Jasper has not responded and Talia said she is thinking about it.
42+
CONTENT
43+
}
44+
],
45+
text: CalendarEvent
46+
)
47+
48+
response
49+
.output
50+
.flat_map { _1.content }
51+
# filter out refusal responses
52+
.grep_v(OpenAI::Models::Responses::ResponseOutputRefusal)
53+
.each do |content|
54+
pp(content.parsed)
55+
end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require_relative "../lib/openai"
5+
6+
class GetWeather < OpenAI::BaseModel
7+
required :location, String, doc: "City and country e.g. Bogotá, Colombia"
8+
end
9+
10+
# gets API Key from environment variable `OPENAI_API_KEY`
11+
client = OpenAI::Client.new
12+
13+
response = client.responses.create(
14+
model: "gpt-4o-2024-08-06",
15+
input: [
16+
{
17+
role: :user,
18+
content: "What's the weather like in Paris today?"
19+
}
20+
],
21+
tools: [GetWeather]
22+
)
23+
24+
response
25+
.output
26+
.each do |output|
27+
pp(output.parsed)
28+
end

0 commit comments

Comments
 (0)