openai 0.97.0 → 0.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/README.md +76 -1
  4. data/lib/openai/helpers/agents/session_stream.rb +60 -3
  5. data/lib/openai/helpers/beta/agents/artifacts.rb +72 -0
  6. data/lib/openai/helpers/beta/agents/creation_stream.rb +69 -0
  7. data/lib/openai/helpers/beta/agents/files.rb +236 -0
  8. data/lib/openai/helpers/beta/agents/function_tool.rb +65 -0
  9. data/lib/openai/helpers/beta/agents/model_adapter.rb +27 -0
  10. data/lib/openai/helpers/beta/agents/result.rb +170 -0
  11. data/lib/openai/helpers/beta/agents/typed_output.rb +191 -0
  12. data/lib/openai/helpers/live/websocket.rb +7 -1
  13. data/lib/openai/helpers/realtime/conversation_item_variant_resolver.rb +1 -1
  14. data/lib/openai/helpers/responses_websocket/connection.rb +7 -1
  15. data/lib/openai/helpers/responses_websocket/session.rb +5 -1
  16. data/lib/openai/helpers/responses_websocket/transports/async_websocket.rb +12 -2
  17. data/lib/openai/internal/transport/base_client.rb +18 -0
  18. data/lib/openai/internal/type/array_of.rb +1 -1
  19. data/lib/openai/internal/type/base_model.rb +6 -3
  20. data/lib/openai/internal/type/converter.rb +50 -3
  21. data/lib/openai/internal/type/hash_of.rb +1 -1
  22. data/lib/openai/internal/type/union.rb +6 -6
  23. data/lib/openai/models/beta/agents/sessions/session_trace.rb +64 -0
  24. data/lib/openai/models/beta/agents/sessions/trace_list_params.rb +68 -0
  25. data/lib/openai/models/beta/agents/vaults/credential.rb +8 -4
  26. data/lib/openai/models/beta/beta_response_output_text.rb +2 -2
  27. data/lib/openai/models/beta/beta_response_output_text_annotation_added_event.rb +2 -2
  28. data/lib/openai/models/beta/environment.rb +33 -1
  29. data/lib/openai/models/beta/environment_param.rb +24 -1
  30. data/lib/openai/models/beta/session_turn_error.rb +3 -0
  31. data/lib/openai/models/chat/chat_completion_content_part_image.rb +1 -0
  32. data/lib/openai/models/live/fork_server_event.rb +14 -3
  33. data/lib/openai/models/live/server_event.rb +14 -3
  34. data/lib/openai/models/realtime/translations/client_secret_create_params.rb +28 -0
  35. data/lib/openai/models/responses/response_output_text.rb +2 -2
  36. data/lib/openai/models/responses/response_output_text_annotation_added_event.rb +2 -2
  37. data/lib/openai/resources/beta/agents/environments/files.rb +31 -0
  38. data/lib/openai/resources/beta/agents/sessions/artifacts.rb +8 -0
  39. data/lib/openai/resources/beta/agents/sessions/events.rb +6 -5
  40. data/lib/openai/resources/beta/agents/sessions/traces.rb +58 -0
  41. data/lib/openai/resources/beta/agents/sessions.rb +18 -5
  42. data/lib/openai/resources/evals/runs.rb +1 -1
  43. data/lib/openai/resources/realtime/translations/client_secrets.rb +58 -0
  44. data/lib/openai/resources/realtime/translations.rb +20 -0
  45. data/lib/openai/resources/realtime.rb +4 -0
  46. data/lib/openai/version.rb +1 -1
  47. data/lib/openai.rb +9 -1
  48. data/rbi/openai/helpers/agents.rbi +20 -1
  49. data/rbi/openai/helpers/beta/agents/artifacts.rbi +29 -0
  50. data/rbi/openai/helpers/beta/agents/files.rbi +65 -0
  51. data/rbi/openai/helpers/beta/agents/function_tool.rbi +40 -0
  52. data/rbi/openai/helpers/beta/agents/model_adapter.rbi +22 -0
  53. data/rbi/openai/helpers/beta/agents.rbi +146 -0
  54. data/rbi/openai/internal/transport/base_client.rbi +12 -0
  55. data/rbi/openai/internal/type/base_model.rbi +2 -2
  56. data/rbi/openai/internal/type/converter.rbi +21 -3
  57. data/rbi/openai/internal/type/union.rbi +6 -2
  58. data/rbi/openai/models/beta/agents/sessions/session_trace.rbi +97 -0
  59. data/rbi/openai/models/beta/agents/sessions/trace_list_params.rbi +121 -0
  60. data/rbi/openai/models/beta/agents/vaults/credential.rbi +5 -5
  61. data/rbi/openai/models/beta/beta_response_output_text.rbi +2 -2
  62. data/rbi/openai/models/beta/beta_response_output_text_annotation_added_event.rbi +2 -2
  63. data/rbi/openai/models/beta/environment.rbi +29 -0
  64. data/rbi/openai/models/beta/environment_param.rbi +31 -0
  65. data/rbi/openai/models/beta/session_turn_error.rbi +3 -0
  66. data/rbi/openai/models/chat/chat_completion_content_part_image.rbi +1 -0
  67. data/rbi/openai/models/live/fork_server_event.rbi +14 -2
  68. data/rbi/openai/models/live/server_event.rbi +14 -2
  69. data/rbi/openai/models/realtime/translations/client_secret_create_params.rbi +68 -0
  70. data/rbi/openai/models/responses/response_output_text.rbi +2 -2
  71. data/rbi/openai/models/responses/response_output_text_annotation_added_event.rbi +2 -2
  72. data/rbi/openai/resources/beta/agents/environments/files.rbi +31 -0
  73. data/rbi/openai/resources/beta/agents/sessions/artifacts.rbi +8 -0
  74. data/rbi/openai/resources/beta/agents/sessions/events.rbi +6 -5
  75. data/rbi/openai/resources/beta/agents/sessions/traces.rbi +54 -0
  76. data/rbi/openai/resources/beta/agents/sessions.rbi +6 -1
  77. data/rbi/openai/resources/realtime/translations/client_secrets.rbi +54 -0
  78. data/rbi/openai/resources/realtime/translations.rbi +22 -0
  79. data/rbi/openai/resources/realtime.rbi +3 -0
  80. data/sig/openai/helpers/agents.rbs +7 -0
  81. data/sig/openai/helpers/beta/agents/artifacts.rbs +20 -0
  82. data/sig/openai/helpers/beta/agents/files.rbs +41 -0
  83. data/sig/openai/helpers/beta/agents/function_tool.rbs +24 -0
  84. data/sig/openai/helpers/beta/agents/model_adapter.rbs +16 -0
  85. data/sig/openai/helpers/beta/agents.rbs +71 -0
  86. data/sig/openai/helpers/structured_output.rbs +12 -0
  87. data/sig/openai/internal/transport/base_client.rbs +8 -0
  88. data/sig/openai/internal/type/base_model.rbs +3 -1
  89. data/sig/openai/internal/type/converter.rbs +16 -2
  90. data/sig/openai/internal/type/union.rbs +2 -1
  91. data/sig/openai/models/beta/agents/sessions/session_trace.rbs +65 -0
  92. data/sig/openai/models/beta/agents/sessions/trace_list_params.rbs +81 -0
  93. data/sig/openai/models/beta/agents/vaults/credential.rbs +5 -5
  94. data/sig/openai/models/beta/beta_response_output_text.rbs +2 -2
  95. data/sig/openai/models/beta/beta_response_output_text_annotation_added_event.rbs +2 -2
  96. data/sig/openai/models/beta/environment.rbs +22 -0
  97. data/sig/openai/models/beta/environment_param.rbs +25 -0
  98. data/sig/openai/models/beta/session_turn_error.rbs +4 -0
  99. data/sig/openai/models/chat/chat_completion_content_part_image.rbs +2 -1
  100. data/sig/openai/models/live/fork_server_event.rbs +17 -2
  101. data/sig/openai/models/live/server_event.rbs +17 -2
  102. data/sig/openai/models/realtime/translations/client_secret_create_params.rbs +39 -0
  103. data/sig/openai/models/responses/response_output_text.rbs +2 -2
  104. data/sig/openai/models/responses/response_output_text_annotation_added_event.rbs +2 -2
  105. data/sig/openai/resources/beta/agents/environments/files.rbs +17 -0
  106. data/sig/openai/resources/beta/agents/sessions/artifacts.rbs +4 -0
  107. data/sig/openai/resources/beta/agents/sessions/traces.rbs +21 -0
  108. data/sig/openai/resources/beta/agents/sessions.rbs +4 -1
  109. data/sig/openai/resources/realtime/translations/client_secrets.rbs +17 -0
  110. data/sig/openai/resources/realtime/translations.rbs +11 -0
  111. data/sig/openai/resources/realtime.rbs +2 -0
  112. metadata +37 -1
@@ -133,7 +133,7 @@ module OpenAI
133
133
  sig { returns(String) }
134
134
  attr_accessor :filename
135
135
 
136
- # The index of the file in the list of files.
136
+ # The index in the output text at which to insert the file citation.
137
137
  sig { returns(Integer) }
138
138
  attr_accessor :index
139
139
 
@@ -163,7 +163,7 @@ module OpenAI
163
163
  # The filename of the file cited.
164
164
  filename:,
165
165
 
166
- # The index of the file in the list of files.
166
+ # The index in the output text at which to insert the file citation.
167
167
  index:,
168
168
 
169
169
  # The type of the file citation. Always `file_citation`.
@@ -140,7 +140,7 @@ module OpenAI
140
140
  sig { returns(String) }
141
141
  attr_accessor :filename
142
142
 
143
- # The index of the file in the list of files.
143
+ # The index in the output text at which to insert the file citation.
144
144
  sig { returns(Integer) }
145
145
  attr_accessor :index
146
146
 
@@ -170,7 +170,7 @@ module OpenAI
170
170
  # The filename of the file cited.
171
171
  filename:,
172
172
 
173
- # The index of the file in the list of files.
173
+ # The index in the output text at which to insert the file citation.
174
174
  index:,
175
175
 
176
176
  # The type of the file citation. Always `file_citation`.
@@ -10,6 +10,37 @@ module OpenAI
10
10
  class Environments
11
11
 
12
12
  class Files
13
+ # Beta file helpers.
14
+ sig {
15
+ params(files: T::Hash[String, T.any(String, Pathname)], request_options: OpenAI::RequestOptions::OrHash)
16
+ .returns(OpenAI::Helpers::Beta::Agents::PreparedFiles)
17
+ }
18
+ def prepare(files, request_options: {})
19
+ end
20
+
21
+ sig {
22
+ params(
23
+ directory: T.any(String, Pathname),
24
+ destination: String,
25
+ include: T::Array[String],
26
+ request_options: OpenAI::RequestOptions::OrHash
27
+ )
28
+ .returns(OpenAI::Helpers::Beta::Agents::PreparedFiles)
29
+ }
30
+ def prepare_directory(directory, destination:, include:, request_options: {})
31
+ end
32
+
33
+ sig {
34
+ params(
35
+ environment_id: String,
36
+ file: T.any(String, Pathname),
37
+ path: String,
38
+ request_options: OpenAI::RequestOptions::OrHash
39
+ )
40
+ .returns(OpenAI::Helpers::Beta::Agents::PreparedFiles)
41
+ }
42
+ def upload(environment_id, file:, path:, request_options: {})
43
+ end
13
44
 
14
45
  # Copies inline bytes or a Files API file into a connected execution environment.
15
46
  # See
@@ -10,6 +10,14 @@ module OpenAI
10
10
  class Sessions
11
11
 
12
12
  class Artifacts
13
+ # Beta result-scoped downloads.
14
+ sig {
15
+ params(result: OpenAI::Helpers::Beta::Agents::TurnResult).returns(
16
+ OpenAI::Helpers::Beta::Agents::ResultArtifacts
17
+ )
18
+ }
19
+ def for_result(result)
20
+ end
13
21
 
14
22
  # Retrieves immutable metadata for one durable session artifact. See
15
23
  # [session artifacts](https://developers.openai.com/api/docs/guides/agents-api/environments/files#openai-hosted-artifacts).
@@ -11,11 +11,12 @@ module OpenAI
11
11
 
12
12
  class Events
13
13
 
14
- # Submits message, cancellation, or tool-result events to a managed agent session.
15
- # Cancellation can recover a still-open turn whose backend execution has ended by
16
- # marking it cancelled and abandoning unpublished outputs. Saved results,
17
- # published files, and existing terminal outcomes are preserved. HTTP 202 confirms
18
- # acceptance, not durable completion. See
14
+ # Submits message, cancellation, tool-result, or computer-use approval-response
15
+ # events to a managed agent session. Cancellation can recover a still-open turn
16
+ # whose backend execution has ended by marking it cancelled and abandoning
17
+ # unpublished outputs. Saved results, published files, and existing terminal
18
+ # outcomes are preserved. HTTP 202 confirms acceptance, not durable completion.
19
+ # See
19
20
  # [session events](https://developers.openai.com/api/docs/guides/agents-api/sessions/events).
20
21
  sig {
21
22
  params(
@@ -0,0 +1,54 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Resources
5
+
6
+ class Beta
7
+
8
+ class Agents
9
+
10
+ class Sessions
11
+
12
+ class Traces
13
+
14
+ # Lists published root-turn traces as OTLP JSON, ordered by turn creation time and
15
+ # ID. Unpublished traces are skipped. Each page returns data available when read;
16
+ # it does not wait for late traces. Trace reads and the JSON response are limited
17
+ # to 16 MiB per request. If the limit is exceeded, request fewer traces.
18
+ sig {
19
+ params(
20
+ session_id: String,
21
+ after: String,
22
+ limit: Integer,
23
+ order: OpenAI::Beta::Agents::Sessions::TraceListParams::Order::OrSymbol,
24
+ request_options: OpenAI::RequestOptions::OrHash
25
+ )
26
+ .returns(OpenAI::Internal::CursorPage[OpenAI::Beta::Agents::Sessions::SessionTrace])
27
+ }
28
+ def list(
29
+ # The ID of the session.
30
+ session_id,
31
+ # Return resources after this resource ID in the selected order.
32
+ after: nil,
33
+ # The maximum number of resources to return, between 1 and 100. Defaults to 20.
34
+ limit: nil,
35
+ # The order in which resources are returned. Defaults to `desc`.
36
+ order: nil,
37
+ request_options: {}
38
+ )
39
+ end
40
+
41
+ # @api private
42
+ sig { params(client: OpenAI::Client).returns(T.attached_class) }
43
+ def self.new(client:)
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+ end
@@ -21,6 +21,9 @@ module OpenAI
21
21
  sig { returns(OpenAI::Resources::Beta::Agents::Sessions::Events) }
22
22
  attr_reader :events
23
23
 
24
+ sig { returns(OpenAI::Resources::Beta::Agents::Sessions::Traces) }
25
+ attr_reader :traces
26
+
24
27
  sig { returns(OpenAI::Resources::Beta::Agents::Sessions::Turns) }
25
28
  attr_reader :turns
26
29
 
@@ -88,13 +91,14 @@ module OpenAI
88
91
  ),
89
92
  agent: OpenAI::Beta::Agents::SessionCreateParams::Agent::OrHash,
90
93
  agent_id: String,
94
+ output_type: T.nilable(T.class_of(OpenAI::Helpers::StructuredOutput::BaseModel)),
91
95
  input: T.nilable(OpenAI::Beta::Agents::SessionCreateParams::Input::Variants),
92
96
  metadata: T.nilable(T::Hash[Symbol, String]),
93
97
  vault_ids: T.nilable(T::Array[String]),
94
98
  stream: T.noreturn,
95
99
  request_options: OpenAI::RequestOptions::OrHash
96
100
  )
97
- .returns(OpenAI::Internal::Stream[OpenAI::Beta::AgentSessionEvent::Variants])
101
+ .returns(OpenAI::Helpers::Beta::Agents::CreationStream)
98
102
  }
99
103
  def create_streaming(
100
104
  # An inline execution environment or a reference to an environment template.
@@ -105,6 +109,7 @@ module OpenAI
105
109
  # The ID of a saved reusable agent. Omit `agent` to use its configuration
106
110
  # unchanged.
107
111
  agent_id: nil,
112
+ output_type: nil,
108
113
  # Initial input to submit when the session is created. A string is shorthand for a
109
114
  # single user message. Required when `environment.type` is `none`, or when
110
115
  # `stream` is `true` for an environment that is not `self_hosted`; optional for
@@ -0,0 +1,54 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Resources
5
+
6
+ class Realtime
7
+
8
+ class Translations
9
+
10
+ class ClientSecrets
11
+
12
+ # Create a Realtime translation client secret with an associated translation
13
+ # session configuration.
14
+ #
15
+ # Client secrets are short-lived tokens that can be passed to a client app, such
16
+ # as a web frontend or mobile client, which grants access to the Realtime
17
+ # Translation API without leaking your main API key. You can configure a custom
18
+ # TTL for each client secret.
19
+ #
20
+ # Returns the created client secret and the effective translation session object.
21
+ # The client secret is a string that looks like `ek_1234`.
22
+ sig {
23
+ params(
24
+ session: OpenAI::Realtime::RealtimeTranslationSessionCreateRequest::OrHash,
25
+ expires_after: OpenAI::Realtime::RealtimeTranslationClientSecretCreateRequest::ExpiresAfter::OrHash,
26
+ request_options: OpenAI::RequestOptions::OrHash
27
+ )
28
+ .returns(OpenAI::Realtime::RealtimeTranslationClientSecretCreateResponse)
29
+ }
30
+ def create(
31
+ # Realtime translation session configuration. Translation sessions stream source
32
+ # audio in and translated audio plus transcript deltas out continuously.
33
+ session:,
34
+ # Configuration for the client secret expiration. Expiration refers to the time
35
+ # after which a client secret will no longer be valid for creating sessions. The
36
+ # session itself may continue after that time once started. A secret can be used
37
+ # to create multiple sessions until it expires.
38
+ expires_after: nil,
39
+ request_options: {}
40
+ )
41
+ end
42
+
43
+ # @api private
44
+ sig { params(client: OpenAI::Client).returns(T.attached_class) }
45
+ def self.new(client:)
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,22 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Resources
5
+
6
+ class Realtime
7
+
8
+ class Translations
9
+
10
+ sig { returns(OpenAI::Resources::Realtime::Translations::ClientSecrets) }
11
+ attr_reader :client_secrets
12
+
13
+ # @api private
14
+ sig { params(client: OpenAI::Client).returns(T.attached_class) }
15
+ def self.new(client:)
16
+ end
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+ end
@@ -11,6 +11,9 @@ module OpenAI
11
11
  sig { returns(OpenAI::Resources::Realtime::Calls) }
12
12
  attr_reader :calls
13
13
 
14
+ sig { returns(OpenAI::Resources::Realtime::Translations) }
15
+ attr_reader :translations
16
+
14
17
  # @api private
15
18
  sig { params(client: OpenAI::Client).returns(T.attached_class) }
16
19
  def self.new(client:)
@@ -16,6 +16,12 @@ module OpenAI
16
16
  | -> Enumerator[OpenAI::Models::Beta::agent_session_event, self]
17
17
  def close: -> void
18
18
  def until_done: -> self
19
+
20
+ # @beta
21
+ def get_final_result: -> OpenAI::Helpers::Beta::Agents::TurnResult
22
+
23
+ # @beta
24
+ def with_result_collection: -> self
19
25
  end
20
26
  end
21
27
  end
@@ -30,6 +36,7 @@ module OpenAI
30
36
  | Hash[Symbol, untyped]],
31
37
  ?tool_handlers: Hash[String, OpenAI::Helpers::Agents::tool_handler],
32
38
  ?idempotency_key: String?,
39
+ ?output_type: singleton(OpenAI::Helpers::StructuredOutput::BaseModel)?,
33
40
  ?request_options: OpenAI::RequestOptions
34
41
  | Hash[Symbol, untyped]
35
42
  | nil
@@ -0,0 +1,20 @@
1
+ module OpenAI
2
+ module Helpers
3
+ module Beta
4
+ module Agents
5
+ class ResultArtifacts
6
+ def initialize: (
7
+ artifacts: OpenAI::Resources::Beta::Agents::Sessions::Artifacts,
8
+ client: OpenAI::Client,
9
+ result: TurnResult
10
+ ) -> void
11
+ def download: (
12
+ path: String,
13
+ to: untyped,
14
+ ?request_options: OpenAI::request_opts
15
+ ) -> OpenAI::Models::Beta::Agents::Sessions::SessionArtifact
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,41 @@
1
+ module OpenAI
2
+ module Helpers
3
+ module Beta
4
+ module Agents
5
+ class PreparedFiles
6
+ attr_reader files: Array[OpenAI::Models::Beta::HostedEnvironmentFileParam::FileID]
7
+ attr_reader upload_ids: Array[String]
8
+ def initialize: (Array[Hash[Symbol, untyped]] files) -> void
9
+ end
10
+ class FilePreparationError < OpenAI::Errors::Error
11
+ attr_reader prepared: PreparedFiles
12
+ def initialize: (prepared: PreparedFiles) -> void
13
+ end
14
+
15
+ # @api private
16
+ class FilePreparation
17
+ def initialize: (
18
+ client: OpenAI::Client,
19
+ environment_files: OpenAI::Resources::Beta::Agents::Environments::Files
20
+ ) -> void
21
+ def prepare: (
22
+ Hash[String, String | Pathname] files,
23
+ ?request_options: OpenAI::request_opts
24
+ ) -> PreparedFiles
25
+ def prepare_directory: (
26
+ String | Pathname directory,
27
+ destination: String,
28
+ include: Array[String],
29
+ ?request_options: OpenAI::request_opts
30
+ ) -> PreparedFiles
31
+ def upload: (
32
+ String environment_id,
33
+ file: String | Pathname,
34
+ path: String,
35
+ ?request_options: OpenAI::request_opts
36
+ ) -> PreparedFiles
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,24 @@
1
+ module OpenAI
2
+ module Helpers
3
+ module Beta
4
+ module Agents
5
+ class FunctionTool
6
+ attr_reader name: String
7
+
8
+ def initialize: (
9
+ name: String,
10
+ arguments: Class,
11
+ ?description: String
12
+ ) {
13
+ (untyped) -> OpenAI::Helpers::Agents::tool_output
14
+ } -> void
15
+ def definition: -> Hash[Symbol, untyped]
16
+ def handlers: -> Hash[String, OpenAI::Helpers::Agents::tool_handler]
17
+ def call: (
18
+ String | Hash[String | Symbol, untyped]
19
+ ) -> OpenAI::Helpers::Agents::tool_output
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ module OpenAI
2
+ module Helpers
3
+ module Beta
4
+ module Agents
5
+ module ModelAdapter
6
+ def self.validate!: (untyped model, parameter: String) -> void
7
+ def self.coerce: (
8
+ singleton(OpenAI::BaseModel) model,
9
+ untyped value,
10
+ ?memoize: bool
11
+ ) -> OpenAI::BaseModel?
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,71 @@
1
+ module OpenAI
2
+ module Helpers
3
+ module Beta
4
+ module Agents
5
+ class TurnResult
6
+ attr_reader turn: OpenAI::Models::Beta::Agents::Sessions::Turn
7
+ attr_reader messages: Array[OpenAI::Models::Beta::AgentSessionMessage]
8
+ def session_id: -> String
9
+ def turn_id: -> String
10
+ def output_text: -> String
11
+ def output_parsed: -> untyped
12
+ def parse: (
13
+ output_type: singleton(OpenAI::Helpers::StructuredOutput::BaseModel)
14
+ ) -> ParsedTurnResult
15
+ end
16
+
17
+ class ResultError < OpenAI::Errors::Error
18
+ attr_reader reason: Symbol
19
+ attr_reader session_id: String?
20
+ attr_reader turn: OpenAI::Models::Beta::Agents::Sessions::Turn?
21
+ attr_reader messages: Array[OpenAI::Models::Beta::AgentSessionMessage]
22
+ attr_reader required_actions: Array[OpenAI::Models::Beta::AgentSession::required_action
23
+ | Hash[Symbol, untyped]]
24
+ def turn_id: -> String?
25
+ end
26
+
27
+ # @api private
28
+ class ResultCollector
29
+ def initialize: (
30
+ ?session_id: String?,
31
+ ?handler_names: Array[String]
32
+ ) -> void
33
+ def enable: -> void
34
+ def observe: (
35
+ OpenAI::Models::Beta::agent_session_event
36
+ | Hash[Symbol, untyped] event
37
+ ) -> void
38
+ def stopped?: -> bool?
39
+ def observe_error: (StandardError error) -> void
40
+ def result: -> TurnResult
41
+ end
42
+
43
+ class ParsedTurnResult < TurnResult
44
+ attr_reader raw_result: TurnResult
45
+ attr_reader output_parsed: untyped
46
+ end
47
+
48
+ class OutputParseError < OpenAI::Errors::Error
49
+ attr_reader raw_result: TurnResult
50
+ end
51
+
52
+ # @api private
53
+ class OutputParser
54
+ def initialize: (
55
+ singleton(OpenAI::Helpers::StructuredOutput::BaseModel) model
56
+ ) -> void
57
+ def prepare_request: (Hash[Symbol, untyped] params) -> void
58
+ def parse: (TurnResult result) -> ParsedTurnResult
59
+ end
60
+
61
+ class CreationStream < OpenAI::Internal::Stream[OpenAI::Models::Beta::agent_session_event]
62
+ def get_final_result: -> TurnResult
63
+ def with_result_collection: -> self
64
+
65
+ # @api private
66
+ def configure_output_parser: (OutputParser? parser) -> self
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,12 @@
1
+ module OpenAI
2
+ module Helpers
3
+ module StructuredOutput
4
+ class BaseModel < OpenAI::Internal::Type::BaseModel
5
+ def self.optional: -> bot
6
+ def self.to_json_schema: -> Hash[Symbol, untyped]
7
+ end
8
+ end
9
+ end
10
+
11
+ class BaseModel = OpenAI::Helpers::StructuredOutput::BaseModel
12
+ end
@@ -162,6 +162,14 @@ module OpenAI
162
162
  OpenAI::Internal::Transport::BaseClient::request_components req
163
163
  ) -> top
164
164
 
165
+ # @api private
166
+ def request_streaming_body: (
167
+ request_components req,
168
+ ?(^-> untyped)? on_response
169
+ ) {
170
+ (String chunk) -> untyped
171
+ } -> void
172
+
165
173
  private def perform_request: (
166
174
  OpenAI::Internal::Transport::BaseClient::request_components req
167
175
  ) ?{
@@ -13,7 +13,9 @@ module OpenAI
13
13
  def self.known_fields: -> ::Hash[Symbol, (OpenAI::Internal::Type::BaseModel::known_field
14
14
  & { type_fn: (^-> OpenAI::Internal::Type::Converter::input) })]
15
15
 
16
- def self.fields: -> ::Hash[Symbol, (OpenAI::Internal::Type::BaseModel::known_field
16
+ def self.fields: (
17
+ ?state: OpenAI::Internal::Type::Converter::coerce_state?
18
+ ) -> ::Hash[Symbol, (OpenAI::Internal::Type::BaseModel::known_field
17
19
  & { type: OpenAI::Internal::Type::Converter::input })]
18
20
 
19
21
  private def self.add_field: (
@@ -13,7 +13,8 @@ module OpenAI
13
13
  strictness: bool,
14
14
  exactness: { yes: Integer, no: Integer, maybe: Integer },
15
15
  error: StandardError?,
16
- branched: Integer
16
+ branched: Integer,
17
+ memo: Hash[untyped, untyped]?
17
18
  }
18
19
 
19
20
  type dump_state = { can_retry: bool }
@@ -59,7 +60,8 @@ module OpenAI
59
60
 
60
61
  def self.new_coerce_state: (
61
62
  ?translate_names: bool,
62
- ?request_only: bool
63
+ ?request_only: bool,
64
+ ?memoize: bool
63
65
  ) -> OpenAI::Internal::Type::Converter::coerce_state
64
66
 
65
67
  def self.coerce: (
@@ -68,6 +70,18 @@ module OpenAI
68
70
  ?state: OpenAI::Internal::Type::Converter::coerce_state
69
71
  ) -> top
70
72
 
73
+ # @api private
74
+ def self.resolve_type: (
75
+ ^-> untyped type_fn,
76
+ ?state: coerce_state?
77
+ ) -> untyped
78
+
79
+ def self.coerce_cached: (
80
+ OpenAI::Internal::Type::Converter target,
81
+ Hash[untyped, untyped] | Array[untyped] value,
82
+ state: OpenAI::Internal::Type::Converter::coerce_state
83
+ ) -> untyped
84
+
71
85
  def self.coerce_with_error: (
72
86
  OpenAI::Internal::Type::Converter::input target,
73
87
  top value,
@@ -24,7 +24,8 @@ module OpenAI
24
24
  ) -> void
25
25
 
26
26
  private def self.resolve_variant: (
27
- top value
27
+ top value,
28
+ ?state: OpenAI::Internal::Type::Converter::coerce_state?
28
29
  ) -> OpenAI::Internal::Type::Converter::input?
29
30
 
30
31
  def ===: (top other) -> bool
@@ -0,0 +1,65 @@
1
+ module OpenAI
2
+ module Models
3
+ module Beta
4
+ module Agents
5
+ class SessionTrace = Sessions::SessionTrace
6
+
7
+ module Sessions
8
+ type session_trace =
9
+ {
10
+ id: String,
11
+ created_at: Integer,
12
+ ?object: :"agent.session.trace",
13
+ otlp: ::Hash[Symbol, top],
14
+ session_id: String
15
+ }
16
+
17
+ class SessionTrace < OpenAI::Internal::Type::BaseModel
18
+ # The root turn ID. Use this ID as the pagination anchor.
19
+ attr_accessor id: String
20
+
21
+ # The Unix timestamp in seconds when the root turn was created.
22
+ attr_accessor created_at: Integer
23
+
24
+ # The object type, which is always `agent.session.trace`.
25
+ attr_accessor object: :"agent.session.trace"
26
+
27
+ # An OTLP JSON ExportTraceServiceRequest containing resourceSpans. Only currently
28
+ # published data is returned; later trace updates are not awaited.
29
+ attr_accessor otlp: ::Hash[Symbol, top]
30
+
31
+ # The session that owns this trace.
32
+ attr_accessor session_id: String
33
+
34
+ # @param id
35
+ # The root turn ID. Use this ID as the pagination anchor.
36
+ # @param created_at
37
+ # The Unix timestamp in seconds when the root turn was created.
38
+ # @param otlp
39
+ # An OTLP JSON ExportTraceServiceRequest containing resourceSpans. Only currently
40
+ # published data is returned; later trace updates are not awaited.
41
+ # @param session_id
42
+ # The session that owns this trace.
43
+ # @param object
44
+ # The object type, which is always `agent.session.trace`.
45
+ def initialize: (
46
+ id: String,
47
+ created_at: Integer,
48
+ otlp: ::Hash[Symbol, top],
49
+ session_id: String,
50
+ ?object: :"agent.session.trace"
51
+ ) -> void
52
+
53
+ def to_hash: -> {
54
+ id: String,
55
+ created_at: Integer,
56
+ ?object: :"agent.session.trace",
57
+ otlp: ::Hash[Symbol, top],
58
+ session_id: String
59
+ }
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end