openai 0.27.1 → 0.28.1

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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/README.md +1 -1
  4. data/lib/openai/internal/transport/pooled_net_requester.rb +7 -10
  5. data/lib/openai/internal/type/base_stream.rb +0 -17
  6. data/lib/openai/models/batch.rb +23 -1
  7. data/lib/openai/models/batch_usage.rb +84 -0
  8. data/lib/openai/models/conversations/conversation_item.rb +37 -1
  9. data/lib/openai/models/responses/response_custom_tool_call_output.rb +47 -4
  10. data/lib/openai/models/responses/response_function_call_arguments_done_event.rb +9 -1
  11. data/lib/openai/models/responses/response_function_call_output_item.rb +26 -0
  12. data/lib/openai/models/responses/response_function_call_output_item_list.rb +11 -0
  13. data/lib/openai/models/responses/response_function_tool_call_output_item.rb +47 -4
  14. data/lib/openai/models/responses/response_input_file_content.rb +52 -0
  15. data/lib/openai/models/responses/response_input_image_content.rb +65 -0
  16. data/lib/openai/models/responses/response_input_item.rb +56 -5
  17. data/lib/openai/models/responses/response_input_text_content.rb +28 -0
  18. data/lib/openai/models/responses/response_item.rb +37 -1
  19. data/lib/openai/models/responses/response_output_item.rb +37 -1
  20. data/lib/openai/models.rb +2 -0
  21. data/lib/openai/version.rb +1 -1
  22. data/lib/openai.rb +6 -0
  23. data/rbi/openai/internal/type/base_stream.rbi +0 -15
  24. data/rbi/openai/models/batch.rbi +35 -1
  25. data/rbi/openai/models/batch_usage.rbi +139 -0
  26. data/rbi/openai/models/conversations/conversation_item.rbi +90 -1
  27. data/rbi/openai/models/responses/response_custom_tool_call_output.rbi +77 -5
  28. data/rbi/openai/models/responses/response_function_call_arguments_done_event.rbi +8 -0
  29. data/rbi/openai/models/responses/response_function_call_output_item.rbi +31 -0
  30. data/rbi/openai/models/responses/response_function_call_output_item_list.rbi +15 -0
  31. data/rbi/openai/models/responses/response_function_tool_call_output_item.rbi +72 -5
  32. data/rbi/openai/models/responses/response_input_file_content.rbi +75 -0
  33. data/rbi/openai/models/responses/response_input_image_content.rbi +125 -0
  34. data/rbi/openai/models/responses/response_input_item.rbi +126 -6
  35. data/rbi/openai/models/responses/response_input_text_content.rbi +39 -0
  36. data/rbi/openai/models/responses/response_item.rbi +86 -1
  37. data/rbi/openai/models/responses/response_output_item.rbi +90 -1
  38. data/rbi/openai/models.rbi +2 -0
  39. data/sig/openai/internal/type/base_stream.rbs +0 -4
  40. data/sig/openai/models/batch.rbs +16 -2
  41. data/sig/openai/models/batch_usage.rbs +60 -0
  42. data/sig/openai/models/conversations/conversation_item.rbs +31 -2
  43. data/sig/openai/models/responses/response_custom_tool_call_output.rbs +27 -4
  44. data/sig/openai/models/responses/response_function_call_arguments_done_event.rbs +5 -0
  45. data/sig/openai/models/responses/response_function_call_output_item.rbs +16 -0
  46. data/sig/openai/models/responses/response_function_call_output_item_list.rbs +10 -0
  47. data/sig/openai/models/responses/response_function_tool_call_output_item.rbs +27 -4
  48. data/sig/openai/models/responses/response_input_file_content.rbs +42 -0
  49. data/sig/openai/models/responses/response_input_image_content.rbs +49 -0
  50. data/sig/openai/models/responses/response_input_item.rbs +45 -6
  51. data/sig/openai/models/responses/response_input_text_content.rbs +17 -0
  52. data/sig/openai/models/responses/response_item.rbs +31 -2
  53. data/sig/openai/models/responses/response_output_item.rbs +31 -2
  54. data/sig/openai/models.rbs +2 -0
  55. metadata +20 -2
@@ -16,8 +16,13 @@ module OpenAI
16
16
  sig { returns(String) }
17
17
  attr_accessor :call_id
18
18
 
19
- # The output from the custom tool call generated by your code.
20
- sig { returns(String) }
19
+ # The output from the custom tool call generated by your code. Can be a string or
20
+ # an list of output content.
21
+ sig do
22
+ returns(
23
+ OpenAI::Responses::ResponseCustomToolCallOutput::Output::Variants
24
+ )
25
+ end
21
26
  attr_accessor :output
22
27
 
23
28
  # The type of the custom tool call output. Always `custom_tool_call_output`.
@@ -35,7 +40,8 @@ module OpenAI
35
40
  sig do
36
41
  params(
37
42
  call_id: String,
38
- output: String,
43
+ output:
44
+ OpenAI::Responses::ResponseCustomToolCallOutput::Output::Variants,
39
45
  id: String,
40
46
  type: Symbol
41
47
  ).returns(T.attached_class)
@@ -43,7 +49,8 @@ module OpenAI
43
49
  def self.new(
44
50
  # The call ID, used to map this custom tool call output to a custom tool call.
45
51
  call_id:,
46
- # The output from the custom tool call generated by your code.
52
+ # The output from the custom tool call generated by your code. Can be a string or
53
+ # an list of output content.
47
54
  output:,
48
55
  # The unique ID of the custom tool call output in the OpenAI platform.
49
56
  id: nil,
@@ -54,11 +61,76 @@ module OpenAI
54
61
 
55
62
  sig do
56
63
  override.returns(
57
- { call_id: String, output: String, type: Symbol, id: String }
64
+ {
65
+ call_id: String,
66
+ output:
67
+ OpenAI::Responses::ResponseCustomToolCallOutput::Output::Variants,
68
+ type: Symbol,
69
+ id: String
70
+ }
58
71
  )
59
72
  end
60
73
  def to_hash
61
74
  end
75
+
76
+ # The output from the custom tool call generated by your code. Can be a string or
77
+ # an list of output content.
78
+ module Output
79
+ extend OpenAI::Internal::Type::Union
80
+
81
+ Variants =
82
+ T.type_alias do
83
+ T.any(
84
+ String,
85
+ T::Array[
86
+ OpenAI::Responses::ResponseCustomToolCallOutput::Output::OutputContentList::Variants
87
+ ]
88
+ )
89
+ end
90
+
91
+ # A text input to the model.
92
+ module OutputContentList
93
+ extend OpenAI::Internal::Type::Union
94
+
95
+ Variants =
96
+ T.type_alias do
97
+ T.any(
98
+ OpenAI::Responses::ResponseInputText,
99
+ OpenAI::Responses::ResponseInputImage,
100
+ OpenAI::Responses::ResponseInputFile
101
+ )
102
+ end
103
+
104
+ sig do
105
+ override.returns(
106
+ T::Array[
107
+ OpenAI::Responses::ResponseCustomToolCallOutput::Output::OutputContentList::Variants
108
+ ]
109
+ )
110
+ end
111
+ def self.variants
112
+ end
113
+ end
114
+
115
+ sig do
116
+ override.returns(
117
+ T::Array[
118
+ OpenAI::Responses::ResponseCustomToolCallOutput::Output::Variants
119
+ ]
120
+ )
121
+ end
122
+ def self.variants
123
+ end
124
+
125
+ OutputContentListArray =
126
+ T.let(
127
+ OpenAI::Internal::Type::ArrayOf[
128
+ union:
129
+ OpenAI::Responses::ResponseCustomToolCallOutput::Output::OutputContentList
130
+ ],
131
+ OpenAI::Internal::Type::Converter
132
+ )
133
+ end
62
134
  end
63
135
  end
64
136
  end
@@ -20,6 +20,10 @@ module OpenAI
20
20
  sig { returns(String) }
21
21
  attr_accessor :item_id
22
22
 
23
+ # The name of the function that was called.
24
+ sig { returns(String) }
25
+ attr_accessor :name
26
+
23
27
  # The index of the output item.
24
28
  sig { returns(Integer) }
25
29
  attr_accessor :output_index
@@ -36,6 +40,7 @@ module OpenAI
36
40
  params(
37
41
  arguments: String,
38
42
  item_id: String,
43
+ name: String,
39
44
  output_index: Integer,
40
45
  sequence_number: Integer,
41
46
  type: Symbol
@@ -46,6 +51,8 @@ module OpenAI
46
51
  arguments:,
47
52
  # The ID of the item.
48
53
  item_id:,
54
+ # The name of the function that was called.
55
+ name:,
49
56
  # The index of the output item.
50
57
  output_index:,
51
58
  # The sequence number of this event.
@@ -59,6 +66,7 @@ module OpenAI
59
66
  {
60
67
  arguments: String,
61
68
  item_id: String,
69
+ name: String,
62
70
  output_index: Integer,
63
71
  sequence_number: Integer,
64
72
  type: Symbol
@@ -0,0 +1,31 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Responses
6
+ # A text input to the model.
7
+ module ResponseFunctionCallOutputItem
8
+ extend OpenAI::Internal::Type::Union
9
+
10
+ Variants =
11
+ T.type_alias do
12
+ T.any(
13
+ OpenAI::Responses::ResponseInputTextContent,
14
+ OpenAI::Responses::ResponseInputImageContent,
15
+ OpenAI::Responses::ResponseInputFileContent
16
+ )
17
+ end
18
+
19
+ sig do
20
+ override.returns(
21
+ T::Array[
22
+ OpenAI::Responses::ResponseFunctionCallOutputItem::Variants
23
+ ]
24
+ )
25
+ end
26
+ def self.variants
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,15 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Responses
6
+ ResponseFunctionCallOutputItemList =
7
+ T.let(
8
+ OpenAI::Internal::Type::ArrayOf[
9
+ union: OpenAI::Responses::ResponseFunctionCallOutputItem
10
+ ],
11
+ OpenAI::Internal::Type::Converter
12
+ )
13
+ end
14
+ end
15
+ end
@@ -20,8 +20,13 @@ module OpenAI
20
20
  sig { returns(String) }
21
21
  attr_accessor :call_id
22
22
 
23
- # A JSON string of the output of the function tool call.
24
- sig { returns(String) }
23
+ # The output from the function call generated by your code. Can be a string or an
24
+ # list of output content.
25
+ sig do
26
+ returns(
27
+ OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::Variants
28
+ )
29
+ end
25
30
  attr_accessor :output
26
31
 
27
32
  # The type of the function tool call output. Always `function_call_output`.
@@ -51,7 +56,8 @@ module OpenAI
51
56
  params(
52
57
  id: String,
53
58
  call_id: String,
54
- output: String,
59
+ output:
60
+ OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::Variants,
55
61
  status:
56
62
  OpenAI::Responses::ResponseFunctionToolCallOutputItem::Status::OrSymbol,
57
63
  type: Symbol
@@ -62,7 +68,8 @@ module OpenAI
62
68
  id:,
63
69
  # The unique ID of the function tool call generated by the model.
64
70
  call_id:,
65
- # A JSON string of the output of the function tool call.
71
+ # The output from the function call generated by your code. Can be a string or an
72
+ # list of output content.
66
73
  output:,
67
74
  # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
68
75
  # Populated when items are returned via API.
@@ -77,7 +84,8 @@ module OpenAI
77
84
  {
78
85
  id: String,
79
86
  call_id: String,
80
- output: String,
87
+ output:
88
+ OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::Variants,
81
89
  type: Symbol,
82
90
  status:
83
91
  OpenAI::Responses::ResponseFunctionToolCallOutputItem::Status::TaggedSymbol
@@ -87,6 +95,65 @@ module OpenAI
87
95
  def to_hash
88
96
  end
89
97
 
98
+ # The output from the function call generated by your code. Can be a string or an
99
+ # list of output content.
100
+ module Output
101
+ extend OpenAI::Internal::Type::Union
102
+
103
+ Variants =
104
+ T.type_alias do
105
+ T.any(
106
+ String,
107
+ T::Array[
108
+ OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::OutputContentList::Variants
109
+ ]
110
+ )
111
+ end
112
+
113
+ # A text input to the model.
114
+ module OutputContentList
115
+ extend OpenAI::Internal::Type::Union
116
+
117
+ Variants =
118
+ T.type_alias do
119
+ T.any(
120
+ OpenAI::Responses::ResponseInputText,
121
+ OpenAI::Responses::ResponseInputImage,
122
+ OpenAI::Responses::ResponseInputFile
123
+ )
124
+ end
125
+
126
+ sig do
127
+ override.returns(
128
+ T::Array[
129
+ OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::OutputContentList::Variants
130
+ ]
131
+ )
132
+ end
133
+ def self.variants
134
+ end
135
+ end
136
+
137
+ sig do
138
+ override.returns(
139
+ T::Array[
140
+ OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::Variants
141
+ ]
142
+ )
143
+ end
144
+ def self.variants
145
+ end
146
+
147
+ OutputContentListArray =
148
+ T.let(
149
+ OpenAI::Internal::Type::ArrayOf[
150
+ union:
151
+ OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::OutputContentList
152
+ ],
153
+ OpenAI::Internal::Type::Converter
154
+ )
155
+ end
156
+
90
157
  # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
91
158
  # Populated when items are returned via API.
92
159
  module Status
@@ -0,0 +1,75 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Responses
6
+ class ResponseInputFileContent < OpenAI::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ OpenAI::Responses::ResponseInputFileContent,
11
+ OpenAI::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ # The type of the input item. Always `input_file`.
16
+ sig { returns(Symbol) }
17
+ attr_accessor :type
18
+
19
+ # The base64-encoded data of the file to be sent to the model.
20
+ sig { returns(T.nilable(String)) }
21
+ attr_accessor :file_data
22
+
23
+ # The ID of the file to be sent to the model.
24
+ sig { returns(T.nilable(String)) }
25
+ attr_accessor :file_id
26
+
27
+ # The URL of the file to be sent to the model.
28
+ sig { returns(T.nilable(String)) }
29
+ attr_accessor :file_url
30
+
31
+ # The name of the file to be sent to the model.
32
+ sig { returns(T.nilable(String)) }
33
+ attr_accessor :filename
34
+
35
+ # A file input to the model.
36
+ sig do
37
+ params(
38
+ file_data: T.nilable(String),
39
+ file_id: T.nilable(String),
40
+ file_url: T.nilable(String),
41
+ filename: T.nilable(String),
42
+ type: Symbol
43
+ ).returns(T.attached_class)
44
+ end
45
+ def self.new(
46
+ # The base64-encoded data of the file to be sent to the model.
47
+ file_data: nil,
48
+ # The ID of the file to be sent to the model.
49
+ file_id: nil,
50
+ # The URL of the file to be sent to the model.
51
+ file_url: nil,
52
+ # The name of the file to be sent to the model.
53
+ filename: nil,
54
+ # The type of the input item. Always `input_file`.
55
+ type: :input_file
56
+ )
57
+ end
58
+
59
+ sig do
60
+ override.returns(
61
+ {
62
+ type: Symbol,
63
+ file_data: T.nilable(String),
64
+ file_id: T.nilable(String),
65
+ file_url: T.nilable(String),
66
+ filename: T.nilable(String)
67
+ }
68
+ )
69
+ end
70
+ def to_hash
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,125 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Responses
6
+ class ResponseInputImageContent < OpenAI::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ OpenAI::Responses::ResponseInputImageContent,
11
+ OpenAI::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ # The type of the input item. Always `input_image`.
16
+ sig { returns(Symbol) }
17
+ attr_accessor :type
18
+
19
+ # The detail level of the image to be sent to the model. One of `high`, `low`, or
20
+ # `auto`. Defaults to `auto`.
21
+ sig do
22
+ returns(
23
+ T.nilable(
24
+ OpenAI::Responses::ResponseInputImageContent::Detail::OrSymbol
25
+ )
26
+ )
27
+ end
28
+ attr_accessor :detail
29
+
30
+ # The ID of the file to be sent to the model.
31
+ sig { returns(T.nilable(String)) }
32
+ attr_accessor :file_id
33
+
34
+ # The URL of the image to be sent to the model. A fully qualified URL or base64
35
+ # encoded image in a data URL.
36
+ sig { returns(T.nilable(String)) }
37
+ attr_accessor :image_url
38
+
39
+ # An image input to the model. Learn about
40
+ # [image inputs](https://platform.openai.com/docs/guides/vision)
41
+ sig do
42
+ params(
43
+ detail:
44
+ T.nilable(
45
+ OpenAI::Responses::ResponseInputImageContent::Detail::OrSymbol
46
+ ),
47
+ file_id: T.nilable(String),
48
+ image_url: T.nilable(String),
49
+ type: Symbol
50
+ ).returns(T.attached_class)
51
+ end
52
+ def self.new(
53
+ # The detail level of the image to be sent to the model. One of `high`, `low`, or
54
+ # `auto`. Defaults to `auto`.
55
+ detail: nil,
56
+ # The ID of the file to be sent to the model.
57
+ file_id: nil,
58
+ # The URL of the image to be sent to the model. A fully qualified URL or base64
59
+ # encoded image in a data URL.
60
+ image_url: nil,
61
+ # The type of the input item. Always `input_image`.
62
+ type: :input_image
63
+ )
64
+ end
65
+
66
+ sig do
67
+ override.returns(
68
+ {
69
+ type: Symbol,
70
+ detail:
71
+ T.nilable(
72
+ OpenAI::Responses::ResponseInputImageContent::Detail::OrSymbol
73
+ ),
74
+ file_id: T.nilable(String),
75
+ image_url: T.nilable(String)
76
+ }
77
+ )
78
+ end
79
+ def to_hash
80
+ end
81
+
82
+ # The detail level of the image to be sent to the model. One of `high`, `low`, or
83
+ # `auto`. Defaults to `auto`.
84
+ module Detail
85
+ extend OpenAI::Internal::Type::Enum
86
+
87
+ TaggedSymbol =
88
+ T.type_alias do
89
+ T.all(
90
+ Symbol,
91
+ OpenAI::Responses::ResponseInputImageContent::Detail
92
+ )
93
+ end
94
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
95
+
96
+ LOW =
97
+ T.let(
98
+ :low,
99
+ OpenAI::Responses::ResponseInputImageContent::Detail::TaggedSymbol
100
+ )
101
+ HIGH =
102
+ T.let(
103
+ :high,
104
+ OpenAI::Responses::ResponseInputImageContent::Detail::TaggedSymbol
105
+ )
106
+ AUTO =
107
+ T.let(
108
+ :auto,
109
+ OpenAI::Responses::ResponseInputImageContent::Detail::TaggedSymbol
110
+ )
111
+
112
+ sig do
113
+ override.returns(
114
+ T::Array[
115
+ OpenAI::Responses::ResponseInputImageContent::Detail::TaggedSymbol
116
+ ]
117
+ )
118
+ end
119
+ def self.values
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end