openai 0.18.1 → 0.20.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 (186) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -0
  3. data/README.md +1 -1
  4. data/lib/openai/client.rb +4 -0
  5. data/lib/openai/helpers/structured_output/boolean.rb +1 -0
  6. data/lib/openai/internal/conversation_cursor_page.rb +92 -0
  7. data/lib/openai/internal/transport/base_client.rb +1 -4
  8. data/lib/openai/internal/transport/pooled_net_requester.rb +1 -9
  9. data/lib/openai/internal/util.rb +1 -1
  10. data/lib/openai/models/audio/transcription.rb +1 -4
  11. data/lib/openai/models/audio/transcription_create_params.rb +2 -7
  12. data/lib/openai/models/audio/transcription_text_done_event.rb +1 -4
  13. data/lib/openai/models/beta/assistant_create_params.rb +6 -19
  14. data/lib/openai/models/beta/assistant_stream_event.rb +6 -24
  15. data/lib/openai/models/beta/assistant_update_params.rb +1 -4
  16. data/lib/openai/models/beta/message_stream_event.rb +1 -4
  17. data/lib/openai/models/beta/run_step_stream_event.rb +1 -4
  18. data/lib/openai/models/beta/thread_create_and_run_params.rb +10 -32
  19. data/lib/openai/models/beta/thread_create_params.rb +7 -22
  20. data/lib/openai/models/beta/threads/message.rb +3 -10
  21. data/lib/openai/models/beta/threads/message_create_params.rb +2 -7
  22. data/lib/openai/models/beta/threads/run.rb +2 -7
  23. data/lib/openai/models/beta/threads/run_create_params.rb +3 -10
  24. data/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rb +1 -3
  25. data/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rb +5 -17
  26. data/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rb +1 -3
  27. data/lib/openai/models/beta/threads/runs/file_search_tool_call.rb +4 -12
  28. data/lib/openai/models/beta/threads/runs/run_step_delta_message_delta.rb +1 -4
  29. data/lib/openai/models/beta/threads/runs/tool_calls_step_details.rb +1 -4
  30. data/lib/openai/models/beta/threads/text.rb +1 -4
  31. data/lib/openai/models/chat/chat_completion_chunk.rb +1 -3
  32. data/lib/openai/models/chat/chat_completion_custom_tool.rb +2 -7
  33. data/lib/openai/models/chat/chat_completion_message.rb +7 -5
  34. data/lib/openai/models/chat/chat_completion_message_function_tool_call.rb +7 -5
  35. data/lib/openai/models/conversations/computer_screenshot_content.rb +38 -0
  36. data/lib/openai/models/conversations/container_file_citation_body.rb +58 -0
  37. data/lib/openai/models/conversations/conversation.rb +51 -0
  38. data/lib/openai/models/conversations/conversation_create_params.rb +39 -0
  39. data/lib/openai/models/conversations/conversation_delete_params.rb +16 -0
  40. data/lib/openai/models/conversations/conversation_deleted.rb +29 -0
  41. data/lib/openai/models/conversations/conversation_deleted_resource.rb +30 -0
  42. data/lib/openai/models/conversations/conversation_item.rb +568 -0
  43. data/lib/openai/models/conversations/conversation_item_list.rb +55 -0
  44. data/lib/openai/models/conversations/conversation_retrieve_params.rb +16 -0
  45. data/lib/openai/models/conversations/conversation_update_params.rb +31 -0
  46. data/lib/openai/models/conversations/file_citation_body.rb +42 -0
  47. data/lib/openai/models/conversations/input_file_content.rb +42 -0
  48. data/lib/openai/models/conversations/input_image_content.rb +62 -0
  49. data/lib/openai/models/conversations/input_text_content.rb +26 -0
  50. data/lib/openai/models/conversations/item_create_params.rb +37 -0
  51. data/lib/openai/models/conversations/item_delete_params.rb +22 -0
  52. data/lib/openai/models/conversations/item_list_params.rb +86 -0
  53. data/lib/openai/models/conversations/item_retrieve_params.rb +36 -0
  54. data/lib/openai/models/conversations/lob_prob.rb +35 -0
  55. data/lib/openai/models/conversations/message.rb +115 -0
  56. data/lib/openai/models/conversations/output_text_content.rb +57 -0
  57. data/lib/openai/models/conversations/refusal_content.rb +26 -0
  58. data/lib/openai/models/conversations/summary_text_content.rb +23 -0
  59. data/lib/openai/models/conversations/text_content.rb +23 -0
  60. data/lib/openai/models/conversations/top_log_prob.rb +29 -0
  61. data/lib/openai/models/conversations/url_citation_body.rb +50 -0
  62. data/lib/openai/models/eval_create_params.rb +6 -20
  63. data/lib/openai/models/evals/create_eval_completions_run_data_source.rb +29 -53
  64. data/lib/openai/models/evals/create_eval_jsonl_run_data_source.rb +1 -3
  65. data/lib/openai/models/evals/run_cancel_response.rb +2 -2
  66. data/lib/openai/models/evals/run_create_params.rb +20 -56
  67. data/lib/openai/models/evals/run_create_response.rb +2 -2
  68. data/lib/openai/models/evals/run_list_response.rb +2 -2
  69. data/lib/openai/models/evals/run_retrieve_response.rb +2 -2
  70. data/lib/openai/models/fine_tuning/reinforcement_hyperparameters.rb +1 -4
  71. data/lib/openai/models/moderation.rb +5 -15
  72. data/lib/openai/models/responses/input_item_list_params.rb +1 -9
  73. data/lib/openai/models/responses/response.rb +28 -3
  74. data/lib/openai/models/responses/response_computer_tool_call.rb +2 -6
  75. data/lib/openai/models/responses/response_computer_tool_call_output_item.rb +1 -3
  76. data/lib/openai/models/responses/response_conversation_param.rb +20 -0
  77. data/lib/openai/models/responses/response_create_params.rb +38 -3
  78. data/lib/openai/models/responses/response_function_tool_call.rb +7 -5
  79. data/lib/openai/models/responses/response_function_web_search.rb +35 -1
  80. data/lib/openai/models/responses/response_includable.rb +2 -0
  81. data/lib/openai/models/responses/response_input_item.rb +2 -7
  82. data/lib/openai/models/responses/response_input_message_item.rb +1 -4
  83. data/lib/openai/models/responses/response_output_item.rb +1 -3
  84. data/lib/openai/models/responses/response_output_message.rb +1 -3
  85. data/lib/openai/models/responses/response_output_text.rb +10 -15
  86. data/lib/openai/models/responses/response_stream_event.rb +4 -16
  87. data/lib/openai/models/responses/response_text_delta_event.rb +1 -3
  88. data/lib/openai/models/responses/response_text_done_event.rb +1 -3
  89. data/lib/openai/models/responses/tool.rb +303 -35
  90. data/lib/openai/models.rb +2 -0
  91. data/lib/openai/resources/conversations/items.rb +141 -0
  92. data/lib/openai/resources/conversations.rb +112 -0
  93. data/lib/openai/resources/responses/input_items.rb +1 -3
  94. data/lib/openai/resources/responses.rb +8 -4
  95. data/lib/openai/version.rb +1 -1
  96. data/lib/openai.rb +31 -0
  97. data/rbi/openai/client.rbi +3 -0
  98. data/rbi/openai/errors.rbi +5 -5
  99. data/rbi/openai/internal/conversation_cursor_page.rbi +25 -0
  100. data/rbi/openai/models/conversations/computer_screenshot_content.rbi +60 -0
  101. data/rbi/openai/models/conversations/container_file_citation_body.rbi +82 -0
  102. data/rbi/openai/models/conversations/conversation.rbi +76 -0
  103. data/rbi/openai/models/conversations/conversation_create_params.rbi +144 -0
  104. data/rbi/openai/models/conversations/conversation_delete_params.rbi +32 -0
  105. data/rbi/openai/models/conversations/conversation_deleted.rbi +40 -0
  106. data/rbi/openai/models/conversations/conversation_deleted_resource.rbi +40 -0
  107. data/rbi/openai/models/conversations/conversation_item.rbi +835 -0
  108. data/rbi/openai/models/conversations/conversation_item_list.rbi +101 -0
  109. data/rbi/openai/models/conversations/conversation_retrieve_params.rbi +32 -0
  110. data/rbi/openai/models/conversations/conversation_update_params.rbi +56 -0
  111. data/rbi/openai/models/conversations/file_citation_body.rbi +61 -0
  112. data/rbi/openai/models/conversations/input_file_content.rbi +72 -0
  113. data/rbi/openai/models/conversations/input_image_content.rbi +113 -0
  114. data/rbi/openai/models/conversations/input_text_content.rbi +38 -0
  115. data/rbi/openai/models/conversations/item_create_params.rbi +150 -0
  116. data/rbi/openai/models/conversations/item_delete_params.rbi +40 -0
  117. data/rbi/openai/models/conversations/item_list_params.rbi +178 -0
  118. data/rbi/openai/models/conversations/item_retrieve_params.rbi +70 -0
  119. data/rbi/openai/models/conversations/lob_prob.rbi +50 -0
  120. data/rbi/openai/models/conversations/message.rbi +196 -0
  121. data/rbi/openai/models/conversations/output_text_content.rbi +110 -0
  122. data/rbi/openai/models/conversations/refusal_content.rbi +38 -0
  123. data/rbi/openai/models/conversations/summary_text_content.rbi +31 -0
  124. data/rbi/openai/models/conversations/text_content.rbi +28 -0
  125. data/rbi/openai/models/conversations/top_log_prob.rbi +41 -0
  126. data/rbi/openai/models/conversations/url_citation_body.rbi +74 -0
  127. data/rbi/openai/models/evals/create_eval_completions_run_data_source.rbi +33 -33
  128. data/rbi/openai/models/evals/run_cancel_response.rbi +2 -0
  129. data/rbi/openai/models/evals/run_create_params.rbi +4 -0
  130. data/rbi/openai/models/evals/run_create_response.rbi +2 -0
  131. data/rbi/openai/models/evals/run_list_response.rbi +2 -0
  132. data/rbi/openai/models/evals/run_retrieve_response.rbi +2 -0
  133. data/rbi/openai/models/responses/input_item_list_params.rbi +0 -11
  134. data/rbi/openai/models/responses/response.rbi +50 -0
  135. data/rbi/openai/models/responses/response_conversation_param.rbi +33 -0
  136. data/rbi/openai/models/responses/response_create_params.rbi +62 -0
  137. data/rbi/openai/models/responses/response_function_web_search.rbi +78 -2
  138. data/rbi/openai/models/responses/response_includable.rbi +2 -0
  139. data/rbi/openai/models/responses/tool.rbi +590 -31
  140. data/rbi/openai/models.rbi +2 -0
  141. data/rbi/openai/resources/conversations/items.rbi +154 -0
  142. data/rbi/openai/resources/conversations.rbi +110 -0
  143. data/rbi/openai/resources/responses/input_items.rbi +0 -3
  144. data/rbi/openai/resources/responses.rbi +32 -0
  145. data/sig/openai/client.rbs +2 -0
  146. data/sig/openai/internal/conversation_cursor_page.rbs +15 -0
  147. data/sig/openai/models/conversations/computer_screenshot_content.rbs +28 -0
  148. data/sig/openai/models/conversations/container_file_citation_body.rbs +47 -0
  149. data/sig/openai/models/conversations/conversation.rbs +37 -0
  150. data/sig/openai/models/conversations/conversation_create_params.rbs +33 -0
  151. data/sig/openai/models/conversations/conversation_delete_params.rbs +17 -0
  152. data/sig/openai/models/conversations/conversation_deleted.rbs +28 -0
  153. data/sig/openai/models/conversations/conversation_deleted_resource.rbs +28 -0
  154. data/sig/openai/models/conversations/conversation_item.rbs +403 -0
  155. data/sig/openai/models/conversations/conversation_item_list.rbs +44 -0
  156. data/sig/openai/models/conversations/conversation_retrieve_params.rbs +17 -0
  157. data/sig/openai/models/conversations/conversation_update_params.rbs +26 -0
  158. data/sig/openai/models/conversations/file_citation_body.rbs +37 -0
  159. data/sig/openai/models/conversations/input_file_content.rbs +41 -0
  160. data/sig/openai/models/conversations/input_image_content.rbs +49 -0
  161. data/sig/openai/models/conversations/input_text_content.rbs +17 -0
  162. data/sig/openai/models/conversations/item_create_params.rbs +37 -0
  163. data/sig/openai/models/conversations/item_delete_params.rbs +25 -0
  164. data/sig/openai/models/conversations/item_list_params.rbs +66 -0
  165. data/sig/openai/models/conversations/item_retrieve_params.rbs +37 -0
  166. data/sig/openai/models/conversations/lob_prob.rbs +37 -0
  167. data/sig/openai/models/conversations/message.rbs +95 -0
  168. data/sig/openai/models/conversations/output_text_content.rbs +52 -0
  169. data/sig/openai/models/conversations/refusal_content.rbs +17 -0
  170. data/sig/openai/models/conversations/summary_text_content.rbs +17 -0
  171. data/sig/openai/models/conversations/text_content.rbs +17 -0
  172. data/sig/openai/models/conversations/top_log_prob.rbs +28 -0
  173. data/sig/openai/models/conversations/url_citation_body.rbs +42 -0
  174. data/sig/openai/models/evals/create_eval_completions_run_data_source.rbs +22 -22
  175. data/sig/openai/models/responses/input_item_list_params.rbs +0 -7
  176. data/sig/openai/models/responses/response.rbs +15 -0
  177. data/sig/openai/models/responses/response_conversation_param.rbs +15 -0
  178. data/sig/openai/models/responses/response_create_params.rbs +14 -0
  179. data/sig/openai/models/responses/response_function_web_search.rbs +34 -3
  180. data/sig/openai/models/responses/tool.rbs +204 -18
  181. data/sig/openai/models.rbs +2 -0
  182. data/sig/openai/resources/conversations/items.rbs +38 -0
  183. data/sig/openai/resources/conversations.rbs +31 -0
  184. data/sig/openai/resources/responses/input_items.rbs +0 -1
  185. data/sig/openai/resources/responses.rbs +2 -0
  186. metadata +95 -2
@@ -53,6 +53,8 @@ module OpenAI
53
53
 
54
54
  Containers = OpenAI::Models::Containers
55
55
 
56
+ Conversations = OpenAI::Models::Conversations
57
+
56
58
  CreateEmbeddingResponse = OpenAI::Models::CreateEmbeddingResponse
57
59
 
58
60
  CustomToolInputFormat = OpenAI::Models::CustomToolInputFormat
@@ -0,0 +1,154 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Resources
5
+ class Conversations
6
+ class Items
7
+ # Create items in a conversation with the given ID.
8
+ sig do
9
+ params(
10
+ conversation_id: String,
11
+ items:
12
+ T::Array[
13
+ T.any(
14
+ OpenAI::Responses::EasyInputMessage::OrHash,
15
+ OpenAI::Responses::ResponseInputItem::Message::OrHash,
16
+ OpenAI::Responses::ResponseOutputMessage::OrHash,
17
+ OpenAI::Responses::ResponseFileSearchToolCall::OrHash,
18
+ OpenAI::Responses::ResponseComputerToolCall::OrHash,
19
+ OpenAI::Responses::ResponseInputItem::ComputerCallOutput::OrHash,
20
+ OpenAI::Responses::ResponseFunctionWebSearch::OrHash,
21
+ OpenAI::Responses::ResponseFunctionToolCall::OrHash,
22
+ OpenAI::Responses::ResponseInputItem::FunctionCallOutput::OrHash,
23
+ OpenAI::Responses::ResponseReasoningItem::OrHash,
24
+ OpenAI::Responses::ResponseInputItem::ImageGenerationCall::OrHash,
25
+ OpenAI::Responses::ResponseCodeInterpreterToolCall::OrHash,
26
+ OpenAI::Responses::ResponseInputItem::LocalShellCall::OrHash,
27
+ OpenAI::Responses::ResponseInputItem::LocalShellCallOutput::OrHash,
28
+ OpenAI::Responses::ResponseInputItem::McpListTools::OrHash,
29
+ OpenAI::Responses::ResponseInputItem::McpApprovalRequest::OrHash,
30
+ OpenAI::Responses::ResponseInputItem::McpApprovalResponse::OrHash,
31
+ OpenAI::Responses::ResponseInputItem::McpCall::OrHash,
32
+ OpenAI::Responses::ResponseCustomToolCallOutput::OrHash,
33
+ OpenAI::Responses::ResponseCustomToolCall::OrHash,
34
+ OpenAI::Responses::ResponseInputItem::ItemReference::OrHash
35
+ )
36
+ ],
37
+ include: T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol],
38
+ request_options: OpenAI::RequestOptions::OrHash
39
+ ).returns(OpenAI::Conversations::ConversationItemList)
40
+ end
41
+ def create(
42
+ # Path param: The ID of the conversation to add the item to.
43
+ conversation_id,
44
+ # Body param: The items to add to the conversation. You may add up to 20 items at
45
+ # a time.
46
+ items:,
47
+ # Query param: Additional fields to include in the response. See the `include`
48
+ # parameter for
49
+ # [listing Conversation items above](https://platform.openai.com/docs/api-reference/conversations/list-items#conversations_list_items-include)
50
+ # for more information.
51
+ include: nil,
52
+ request_options: {}
53
+ )
54
+ end
55
+
56
+ # Get a single item from a conversation with the given IDs.
57
+ sig do
58
+ params(
59
+ item_id: String,
60
+ conversation_id: String,
61
+ include: T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol],
62
+ request_options: OpenAI::RequestOptions::OrHash
63
+ ).returns(OpenAI::Conversations::ConversationItem::Variants)
64
+ end
65
+ def retrieve(
66
+ # Path param: The ID of the item to retrieve.
67
+ item_id,
68
+ # Path param: The ID of the conversation that contains the item.
69
+ conversation_id:,
70
+ # Query param: Additional fields to include in the response. See the `include`
71
+ # parameter for
72
+ # [listing Conversation items above](https://platform.openai.com/docs/api-reference/conversations/list-items#conversations_list_items-include)
73
+ # for more information.
74
+ include: nil,
75
+ request_options: {}
76
+ )
77
+ end
78
+
79
+ # List all items for a conversation with the given ID.
80
+ sig do
81
+ params(
82
+ conversation_id: String,
83
+ after: String,
84
+ include: T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol],
85
+ limit: Integer,
86
+ order: OpenAI::Conversations::ItemListParams::Order::OrSymbol,
87
+ request_options: OpenAI::RequestOptions::OrHash
88
+ ).returns(
89
+ OpenAI::Internal::ConversationCursorPage[
90
+ OpenAI::Conversations::ConversationItem::Variants
91
+ ]
92
+ )
93
+ end
94
+ def list(
95
+ # The ID of the conversation to list items for.
96
+ conversation_id,
97
+ # An item ID to list items after, used in pagination.
98
+ after: nil,
99
+ # Specify additional output data to include in the model response. Currently
100
+ # supported values are:
101
+ #
102
+ # - `web_search_call.action.sources`: Include the sources of the web search tool
103
+ # call.
104
+ # - `code_interpreter_call.outputs`: Includes the outputs of python code execution
105
+ # in code interpreter tool call items.
106
+ # - `computer_call_output.output.image_url`: Include image urls from the computer
107
+ # call output.
108
+ # - `file_search_call.results`: Include the search results of the file search tool
109
+ # call.
110
+ # - `message.input_image.image_url`: Include image urls from the input message.
111
+ # - `message.output_text.logprobs`: Include logprobs with assistant messages.
112
+ # - `reasoning.encrypted_content`: Includes an encrypted version of reasoning
113
+ # tokens in reasoning item outputs. This enables reasoning items to be used in
114
+ # multi-turn conversations when using the Responses API statelessly (like when
115
+ # the `store` parameter is set to `false`, or when an organization is enrolled
116
+ # in the zero data retention program).
117
+ include: nil,
118
+ # A limit on the number of objects to be returned. Limit can range between 1 and
119
+ # 100, and the default is 20.
120
+ limit: nil,
121
+ # The order to return the input items in. Default is `desc`.
122
+ #
123
+ # - `asc`: Return the input items in ascending order.
124
+ # - `desc`: Return the input items in descending order.
125
+ order: nil,
126
+ request_options: {}
127
+ )
128
+ end
129
+
130
+ # Delete an item from a conversation with the given IDs.
131
+ sig do
132
+ params(
133
+ item_id: String,
134
+ conversation_id: String,
135
+ request_options: OpenAI::RequestOptions::OrHash
136
+ ).returns(OpenAI::Conversations::Conversation)
137
+ end
138
+ def delete(
139
+ # The ID of the item to delete.
140
+ item_id,
141
+ # The ID of the conversation that contains the item.
142
+ conversation_id:,
143
+ request_options: {}
144
+ )
145
+ end
146
+
147
+ # @api private
148
+ sig { params(client: OpenAI::Client).returns(T.attached_class) }
149
+ def self.new(client:)
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,110 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Resources
5
+ class Conversations
6
+ sig { returns(OpenAI::Resources::Conversations::Items) }
7
+ attr_reader :items
8
+
9
+ # Create a conversation.
10
+ sig do
11
+ params(
12
+ items:
13
+ T.nilable(
14
+ T::Array[
15
+ T.any(
16
+ OpenAI::Responses::EasyInputMessage::OrHash,
17
+ OpenAI::Responses::ResponseInputItem::Message::OrHash,
18
+ OpenAI::Responses::ResponseOutputMessage::OrHash,
19
+ OpenAI::Responses::ResponseFileSearchToolCall::OrHash,
20
+ OpenAI::Responses::ResponseComputerToolCall::OrHash,
21
+ OpenAI::Responses::ResponseInputItem::ComputerCallOutput::OrHash,
22
+ OpenAI::Responses::ResponseFunctionWebSearch::OrHash,
23
+ OpenAI::Responses::ResponseFunctionToolCall::OrHash,
24
+ OpenAI::Responses::ResponseInputItem::FunctionCallOutput::OrHash,
25
+ OpenAI::Responses::ResponseReasoningItem::OrHash,
26
+ OpenAI::Responses::ResponseInputItem::ImageGenerationCall::OrHash,
27
+ OpenAI::Responses::ResponseCodeInterpreterToolCall::OrHash,
28
+ OpenAI::Responses::ResponseInputItem::LocalShellCall::OrHash,
29
+ OpenAI::Responses::ResponseInputItem::LocalShellCallOutput::OrHash,
30
+ OpenAI::Responses::ResponseInputItem::McpListTools::OrHash,
31
+ OpenAI::Responses::ResponseInputItem::McpApprovalRequest::OrHash,
32
+ OpenAI::Responses::ResponseInputItem::McpApprovalResponse::OrHash,
33
+ OpenAI::Responses::ResponseInputItem::McpCall::OrHash,
34
+ OpenAI::Responses::ResponseCustomToolCallOutput::OrHash,
35
+ OpenAI::Responses::ResponseCustomToolCall::OrHash,
36
+ OpenAI::Responses::ResponseInputItem::ItemReference::OrHash
37
+ )
38
+ ]
39
+ ),
40
+ metadata: T.nilable(T::Hash[Symbol, String]),
41
+ request_options: OpenAI::RequestOptions::OrHash
42
+ ).returns(OpenAI::Conversations::Conversation)
43
+ end
44
+ def create(
45
+ # Initial items to include in the conversation context. You may add up to 20 items
46
+ # at a time.
47
+ items: nil,
48
+ # Set of 16 key-value pairs that can be attached to an object. Useful for storing
49
+ # additional information about the object in a structured format.
50
+ metadata: nil,
51
+ request_options: {}
52
+ )
53
+ end
54
+
55
+ # Get a conversation with the given ID.
56
+ sig do
57
+ params(
58
+ conversation_id: String,
59
+ request_options: OpenAI::RequestOptions::OrHash
60
+ ).returns(OpenAI::Conversations::Conversation)
61
+ end
62
+ def retrieve(
63
+ # The ID of the conversation to retrieve.
64
+ conversation_id,
65
+ request_options: {}
66
+ )
67
+ end
68
+
69
+ # Update a conversation's metadata with the given ID.
70
+ sig do
71
+ params(
72
+ conversation_id: String,
73
+ metadata: T::Hash[Symbol, String],
74
+ request_options: OpenAI::RequestOptions::OrHash
75
+ ).returns(OpenAI::Conversations::Conversation)
76
+ end
77
+ def update(
78
+ # The ID of the conversation to update.
79
+ conversation_id,
80
+ # Set of 16 key-value pairs that can be attached to an object. This can be useful
81
+ # for storing additional information about the object in a structured format, and
82
+ # querying for objects via API or the dashboard. Keys are strings with a maximum
83
+ # length of 64 characters. Values are strings with a maximum length of 512
84
+ # characters.
85
+ metadata:,
86
+ request_options: {}
87
+ )
88
+ end
89
+
90
+ # Delete a conversation with the given ID.
91
+ sig do
92
+ params(
93
+ conversation_id: String,
94
+ request_options: OpenAI::RequestOptions::OrHash
95
+ ).returns(OpenAI::Conversations::ConversationDeletedResource)
96
+ end
97
+ def delete(
98
+ # The ID of the conversation to delete.
99
+ conversation_id,
100
+ request_options: {}
101
+ )
102
+ end
103
+
104
+ # @api private
105
+ sig { params(client: OpenAI::Client).returns(T.attached_class) }
106
+ def self.new(client:)
107
+ end
108
+ end
109
+ end
110
+ end
@@ -9,7 +9,6 @@ module OpenAI
9
9
  params(
10
10
  response_id: String,
11
11
  after: String,
12
- before: String,
13
12
  include: T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol],
14
13
  limit: Integer,
15
14
  order: OpenAI::Responses::InputItemListParams::Order::OrSymbol,
@@ -25,8 +24,6 @@ module OpenAI
25
24
  response_id,
26
25
  # An item ID to list items after, used in pagination.
27
26
  after: nil,
28
- # An item ID to list items before, used in pagination.
29
- before: nil,
30
27
  # Additional fields to include in the response. See the `include` parameter for
31
28
  # Response creation above for more information.
32
29
  include: nil,
@@ -22,6 +22,13 @@ module OpenAI
22
22
  sig do
23
23
  params(
24
24
  background: T.nilable(T::Boolean),
25
+ conversation:
26
+ T.nilable(
27
+ T.any(
28
+ String,
29
+ OpenAI::Responses::ResponseConversationParam::OrHash
30
+ )
31
+ ),
25
32
  include:
26
33
  T.nilable(
27
34
  T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol]
@@ -78,6 +85,7 @@ module OpenAI
78
85
  OpenAI::Responses::Tool::ImageGeneration::OrHash,
79
86
  OpenAI::Responses::Tool::LocalShell::OrHash,
80
87
  OpenAI::Responses::CustomTool::OrHash,
88
+ OpenAI::Responses::Tool::WebSearchTool::OrHash,
81
89
  OpenAI::Responses::WebSearchTool::OrHash
82
90
  )
83
91
  ],
@@ -96,9 +104,16 @@ module OpenAI
96
104
  # Whether to run the model response in the background.
97
105
  # [Learn more](https://platform.openai.com/docs/guides/background).
98
106
  background: nil,
107
+ # The conversation that this response belongs to. Items from this conversation are
108
+ # prepended to `input_items` for this response request. Input items and output
109
+ # items from this response are automatically added to this conversation after this
110
+ # response completes.
111
+ conversation: nil,
99
112
  # Specify additional output data to include in the model response. Currently
100
113
  # supported values are:
101
114
  #
115
+ # - `web_search_call.action.sources`: Include the sources of the web search tool
116
+ # call.
102
117
  # - `code_interpreter_call.outputs`: Includes the outputs of python code execution
103
118
  # in code interpreter tool call items.
104
119
  # - `computer_call_output.output.image_url`: Include image urls from the computer
@@ -156,6 +171,7 @@ module OpenAI
156
171
  # The unique ID of the previous response to the model. Use this to create
157
172
  # multi-turn conversations. Learn more about
158
173
  # [conversation state](https://platform.openai.com/docs/guides/conversation-state).
174
+ # Cannot be used in conjunction with `conversation`.
159
175
  previous_response_id: nil,
160
176
  # Reference to a prompt template and its variables.
161
177
  # [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
@@ -274,6 +290,13 @@ module OpenAI
274
290
  sig do
275
291
  params(
276
292
  background: T.nilable(T::Boolean),
293
+ conversation:
294
+ T.nilable(
295
+ T.any(
296
+ String,
297
+ OpenAI::Responses::ResponseConversationParam::OrHash
298
+ )
299
+ ),
277
300
  include:
278
301
  T.nilable(
279
302
  T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol]
@@ -332,6 +355,7 @@ module OpenAI
332
355
  OpenAI::Responses::Tool::ImageGeneration::OrHash,
333
356
  OpenAI::Responses::Tool::LocalShell::OrHash,
334
357
  OpenAI::Responses::CustomTool::OrHash,
358
+ OpenAI::Responses::Tool::WebSearchTool::OrHash,
335
359
  OpenAI::Responses::WebSearchTool::OrHash
336
360
  )
337
361
  ],
@@ -354,9 +378,16 @@ module OpenAI
354
378
  # Whether to run the model response in the background.
355
379
  # [Learn more](https://platform.openai.com/docs/guides/background).
356
380
  background: nil,
381
+ # The conversation that this response belongs to. Items from this conversation are
382
+ # prepended to `input_items` for this response request. Input items and output
383
+ # items from this response are automatically added to this conversation after this
384
+ # response completes.
385
+ conversation: nil,
357
386
  # Specify additional output data to include in the model response. Currently
358
387
  # supported values are:
359
388
  #
389
+ # - `web_search_call.action.sources`: Include the sources of the web search tool
390
+ # call.
360
391
  # - `code_interpreter_call.outputs`: Includes the outputs of python code execution
361
392
  # in code interpreter tool call items.
362
393
  # - `computer_call_output.output.image_url`: Include image urls from the computer
@@ -414,6 +445,7 @@ module OpenAI
414
445
  # The unique ID of the previous response to the model. Use this to create
415
446
  # multi-turn conversations. Learn more about
416
447
  # [conversation state](https://platform.openai.com/docs/guides/conversation-state).
448
+ # Cannot be used in conjunction with `conversation`.
417
449
  previous_response_id: nil,
418
450
  # Reference to a prompt template and its variables.
419
451
  # [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
@@ -46,6 +46,8 @@ module OpenAI
46
46
 
47
47
  attr_reader responses: OpenAI::Resources::Responses
48
48
 
49
+ attr_reader conversations: OpenAI::Resources::Conversations
50
+
49
51
  attr_reader evals: OpenAI::Resources::Evals
50
52
 
51
53
  attr_reader containers: OpenAI::Resources::Containers
@@ -0,0 +1,15 @@
1
+ module OpenAI
2
+ module Internal
3
+ class ConversationCursorPage[Elem]
4
+ include OpenAI::Internal::Type::BasePage[Elem]
5
+
6
+ attr_accessor data: ::Array[Elem]?
7
+
8
+ attr_accessor has_more: bool
9
+
10
+ attr_accessor last_id: String
11
+
12
+ def inspect: -> String
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,28 @@
1
+ module OpenAI
2
+ module Models
3
+ module Conversations
4
+ type computer_screenshot_content =
5
+ { file_id: String?, image_url: String?, type: :computer_screenshot }
6
+
7
+ class ComputerScreenshotContent < OpenAI::Internal::Type::BaseModel
8
+ attr_accessor file_id: String?
9
+
10
+ attr_accessor image_url: String?
11
+
12
+ attr_accessor type: :computer_screenshot
13
+
14
+ def initialize: (
15
+ file_id: String?,
16
+ image_url: String?,
17
+ ?type: :computer_screenshot
18
+ ) -> void
19
+
20
+ def to_hash: -> {
21
+ file_id: String?,
22
+ image_url: String?,
23
+ type: :computer_screenshot
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,47 @@
1
+ module OpenAI
2
+ module Models
3
+ module Conversations
4
+ type container_file_citation_body =
5
+ {
6
+ container_id: String,
7
+ end_index: Integer,
8
+ file_id: String,
9
+ filename: String,
10
+ start_index: Integer,
11
+ type: :container_file_citation
12
+ }
13
+
14
+ class ContainerFileCitationBody < OpenAI::Internal::Type::BaseModel
15
+ attr_accessor container_id: String
16
+
17
+ attr_accessor end_index: Integer
18
+
19
+ attr_accessor file_id: String
20
+
21
+ attr_accessor filename: String
22
+
23
+ attr_accessor start_index: Integer
24
+
25
+ attr_accessor type: :container_file_citation
26
+
27
+ def initialize: (
28
+ container_id: String,
29
+ end_index: Integer,
30
+ file_id: String,
31
+ filename: String,
32
+ start_index: Integer,
33
+ ?type: :container_file_citation
34
+ ) -> void
35
+
36
+ def to_hash: -> {
37
+ container_id: String,
38
+ end_index: Integer,
39
+ file_id: String,
40
+ filename: String,
41
+ start_index: Integer,
42
+ type: :container_file_citation
43
+ }
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,37 @@
1
+ module OpenAI
2
+ module Models
3
+ module Conversations
4
+ type conversation =
5
+ {
6
+ id: String,
7
+ created_at: Integer,
8
+ metadata: top,
9
+ object: :conversation
10
+ }
11
+
12
+ class Conversation < OpenAI::Internal::Type::BaseModel
13
+ attr_accessor id: String
14
+
15
+ attr_accessor created_at: Integer
16
+
17
+ attr_accessor metadata: top
18
+
19
+ attr_accessor object: :conversation
20
+
21
+ def initialize: (
22
+ id: String,
23
+ created_at: Integer,
24
+ metadata: top,
25
+ ?object: :conversation
26
+ ) -> void
27
+
28
+ def to_hash: -> {
29
+ id: String,
30
+ created_at: Integer,
31
+ metadata: top,
32
+ object: :conversation
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,33 @@
1
+ module OpenAI
2
+ module Models
3
+ module Conversations
4
+ type conversation_create_params =
5
+ {
6
+ items: ::Array[OpenAI::Models::Responses::response_input_item]?,
7
+ metadata: OpenAI::Models::metadata?
8
+ }
9
+ & OpenAI::Internal::Type::request_parameters
10
+
11
+ class ConversationCreateParams < OpenAI::Internal::Type::BaseModel
12
+ extend OpenAI::Internal::Type::RequestParameters::Converter
13
+ include OpenAI::Internal::Type::RequestParameters
14
+
15
+ attr_accessor items: ::Array[OpenAI::Models::Responses::response_input_item]?
16
+
17
+ attr_accessor metadata: OpenAI::Models::metadata?
18
+
19
+ def initialize: (
20
+ ?items: ::Array[OpenAI::Models::Responses::response_input_item]?,
21
+ ?metadata: OpenAI::Models::metadata?,
22
+ ?request_options: OpenAI::request_opts
23
+ ) -> void
24
+
25
+ def to_hash: -> {
26
+ items: ::Array[OpenAI::Models::Responses::response_input_item]?,
27
+ metadata: OpenAI::Models::metadata?,
28
+ request_options: OpenAI::RequestOptions
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,17 @@
1
+ module OpenAI
2
+ module Models
3
+ module Conversations
4
+ type conversation_delete_params =
5
+ { } & OpenAI::Internal::Type::request_parameters
6
+
7
+ class ConversationDeleteParams < OpenAI::Internal::Type::BaseModel
8
+ extend OpenAI::Internal::Type::RequestParameters::Converter
9
+ include OpenAI::Internal::Type::RequestParameters
10
+
11
+ def initialize: (?request_options: OpenAI::request_opts) -> void
12
+
13
+ def to_hash: -> { request_options: OpenAI::RequestOptions }
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,28 @@
1
+ module OpenAI
2
+ module Models
3
+ module Conversations
4
+ type conversation_deleted =
5
+ { id: String, deleted: bool, object: :"conversation.deleted" }
6
+
7
+ class ConversationDeleted < OpenAI::Internal::Type::BaseModel
8
+ attr_accessor id: String
9
+
10
+ attr_accessor deleted: bool
11
+
12
+ attr_accessor object: :"conversation.deleted"
13
+
14
+ def initialize: (
15
+ id: String,
16
+ deleted: bool,
17
+ ?object: :"conversation.deleted"
18
+ ) -> void
19
+
20
+ def to_hash: -> {
21
+ id: String,
22
+ deleted: bool,
23
+ object: :"conversation.deleted"
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ module OpenAI
2
+ module Models
3
+ module Conversations
4
+ type conversation_deleted_resource =
5
+ { id: String, deleted: bool, object: :"conversation.deleted" }
6
+
7
+ class ConversationDeletedResource < OpenAI::Internal::Type::BaseModel
8
+ attr_accessor id: String
9
+
10
+ attr_accessor deleted: bool
11
+
12
+ attr_accessor object: :"conversation.deleted"
13
+
14
+ def initialize: (
15
+ id: String,
16
+ deleted: bool,
17
+ ?object: :"conversation.deleted"
18
+ ) -> void
19
+
20
+ def to_hash: -> {
21
+ id: String,
22
+ deleted: bool,
23
+ object: :"conversation.deleted"
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end