openai 0.102.0 → 0.104.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 (426) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +88 -0
  3. data/README.md +23 -1
  4. data/lib/openai/client.rb +3 -386
  5. data/lib/openai/helpers/admin/organization/projects/api_keys.rb +42 -0
  6. data/lib/openai/helpers/agents/session_stream_resource.rb +60 -0
  7. data/lib/openai/helpers/beta/agents/artifacts.rb +18 -0
  8. data/lib/openai/helpers/beta/agents/files.rb +41 -0
  9. data/lib/openai/helpers/client_runtime.rb +391 -0
  10. data/lib/openai/helpers/files.rb +47 -0
  11. data/lib/openai/helpers/live/websocket.rb +8 -57
  12. data/lib/openai/helpers/models/chat/parsed.rb +32 -0
  13. data/lib/openai/helpers/models/responses/parsed.rb +30 -0
  14. data/lib/openai/helpers/models/responses/response.rb +32 -0
  15. data/lib/openai/helpers/models/webhooks/webhook_endpoint_with_secret.rb +20 -0
  16. data/lib/openai/helpers/realtime/client_extension.rb +1 -2
  17. data/lib/openai/helpers/realtime/connection_manager.rb +1 -1
  18. data/lib/openai/helpers/realtime/translation.rb +7 -50
  19. data/lib/openai/helpers/responses_websocket/client_extension.rb +1 -2
  20. data/lib/openai/helpers/streaming/chat_completion_resource.rb +36 -0
  21. data/lib/openai/helpers/streaming/response_stream.rb +1 -16
  22. data/lib/openai/helpers/streaming/response_stream_resource.rb +78 -0
  23. data/lib/openai/helpers/vector_stores/file_batches.rb +188 -0
  24. data/lib/openai/helpers/vector_stores/files.rb +198 -0
  25. data/lib/openai/helpers/websocket/client_request.rb +31 -6
  26. data/lib/openai/helpers/websocket/connection.rb +58 -0
  27. data/lib/openai/helpers/websocket/connection_manager.rb +4 -2
  28. data/lib/openai/helpers/websocket/protocol.rb +2 -1
  29. data/lib/openai/helpers/websocket/resource.rb +54 -0
  30. data/lib/openai/helpers/websocket/typed_connection.rb +95 -0
  31. data/lib/openai/helpers/websocket.rb +4 -0
  32. data/lib/openai/models/admin/organization/audit_log_list_response.rb +5 -3
  33. data/lib/openai/models/admin/organization/external_storage_configuration.rb +5 -3
  34. data/lib/openai/models/admin/organization/external_storage_create_params.rb +33 -3
  35. data/lib/openai/models/admin/organization/oci_external_storage_provider.rb +37 -0
  36. data/lib/openai/models/admin/organization/project_residency.rb +3 -0
  37. data/lib/openai/models/admin/organization/projects/api_key_update_params.rb +64 -0
  38. data/lib/openai/models/admin/organization/projects/api_key_update_scopes_params.rb +34 -0
  39. data/lib/openai/models/admin/organization/usage_decisions_params.rb +177 -0
  40. data/lib/openai/models/admin/organization/usage_decisions_response.rb +351 -0
  41. data/lib/openai/models/audio/speech_create_params.rb +6 -3
  42. data/lib/openai/models/audio/translation_create_response.rb +0 -1
  43. data/lib/openai/models/audio/voice.rb +17 -2
  44. data/lib/openai/models/audio/voice_create_params.rb +100 -3
  45. data/lib/openai/models/beta/agent_create_params.rb +4 -2
  46. data/lib/openai/models/beta/agent_list_params.rb +4 -4
  47. data/lib/openai/models/beta/agent_session.rb +37 -1
  48. data/lib/openai/models/beta/agent_session_environment_expired_event.rb +57 -0
  49. data/lib/openai/models/beta/agent_session_environment_state.rb +6 -0
  50. data/lib/openai/models/beta/agent_session_environment_suspended_event.rb +57 -0
  51. data/lib/openai/models/beta/agent_session_event.rb +7 -1
  52. data/lib/openai/models/beta/agent_update_params.rb +4 -2
  53. data/lib/openai/models/beta/agents/environment_info.rb +3 -0
  54. data/lib/openai/models/beta/agents/environment_list_params.rb +7 -7
  55. data/lib/openai/models/beta/agents/session_create_params.rb +39 -3
  56. data/lib/openai/models/beta/agents/session_list_params.rb +7 -10
  57. data/lib/openai/models/beta/agents/session_update_params.rb +33 -1
  58. data/lib/openai/models/beta/agents/sessions/artifact_list_params.rb +11 -11
  59. data/lib/openai/models/beta/agents/vault_list_params.rb +23 -13
  60. data/lib/openai/models/beta/agents/vault_status_filter.rb +1 -3
  61. data/lib/openai/models/beta/agents/vault_update_params.rb +47 -0
  62. data/lib/openai/models/beta/agents/vaults/credential_list_params.rb +23 -13
  63. data/lib/openai/models/beta/beta_response.rb +23 -2
  64. data/lib/openai/models/beta/beta_response_error.rb +19 -1
  65. data/lib/openai/models/beta/beta_response_input_item.rb +107 -1
  66. data/lib/openai/models/beta/beta_response_item.rb +107 -1
  67. data/lib/openai/models/beta/beta_response_output_item.rb +107 -1
  68. data/lib/openai/models/beta/beta_responses_client_event.rb +23 -2
  69. data/lib/openai/models/beta/response_compact_params.rb +21 -0
  70. data/lib/openai/models/beta/response_create_params.rb +23 -2
  71. data/lib/openai/models/beta/session_turn_error.rb +3 -0
  72. data/lib/openai/models/chat/chat_completion_audio_param.rb +3 -3
  73. data/lib/openai/models/chat/chat_completion_message.rb +0 -8
  74. data/lib/openai/models/chat/chat_completion_message_function_tool_call.rb +0 -8
  75. data/lib/openai/models/chat/completion_create_params.rb +5 -12
  76. data/lib/openai/models/chat_model.rb +21 -0
  77. data/lib/openai/models/conversations/conversation_item.rb +107 -1
  78. data/lib/openai/models/decision.rb +17 -2
  79. data/lib/openai/models/decision_create_params.rb +29 -12
  80. data/lib/openai/models/decision_input_image.rb +4 -3
  81. data/lib/openai/models/decision_input_message.rb +4 -4
  82. data/lib/openai/models/decision_input_part.rb +3 -2
  83. data/lib/openai/models/image_edit_completed_event.rb +1 -2
  84. data/lib/openai/models/image_edit_partial_image_event.rb +1 -2
  85. data/lib/openai/models/image_gen_completed_event.rb +1 -2
  86. data/lib/openai/models/image_gen_partial_image_event.rb +1 -2
  87. data/lib/openai/models/images_response.rb +1 -2
  88. data/lib/openai/models/live/built_in_voice.rb +1 -0
  89. data/lib/openai/models/live/client_event.rb +14 -2
  90. data/lib/openai/models/live/decision_create_event.rb +26 -0
  91. data/lib/openai/models/live/decision_event.rb +117 -0
  92. data/lib/openai/models/live/decision_item_create_event.rb +194 -0
  93. data/lib/openai/models/live/decision_item_created_event.rb +202 -0
  94. data/lib/openai/models/live/decision_item_delete_event.rb +38 -0
  95. data/lib/openai/models/live/decision_item_deleted_event.rb +46 -0
  96. data/lib/openai/models/live/decision_trigger.rb +244 -0
  97. data/lib/openai/models/live/decisions_delegation_config.rb +201 -0
  98. data/lib/openai/models/live/decisions_delegation_update_config.rb +208 -0
  99. data/lib/openai/models/live/delegation_created_event.rb +10 -10
  100. data/lib/openai/models/live/fork_client_event.rb +14 -2
  101. data/lib/openai/models/live/fork_server_event.rb +17 -2
  102. data/lib/openai/models/live/media_session_config.rb +47 -11
  103. data/lib/openai/models/live/output_audio_fixture_play_event.rb +48 -0
  104. data/lib/openai/models/live/output_audio_fixture_played_event.rb +42 -0
  105. data/lib/openai/models/live/output_audio_fixture_playing_event.rb +41 -0
  106. data/lib/openai/models/live/server_event.rb +17 -2
  107. data/lib/openai/models/live/session_accept_params.rb +47 -11
  108. data/lib/openai/models/live/session_config.rb +47 -11
  109. data/lib/openai/models/live/session_resource.rb +47 -11
  110. data/lib/openai/models/live/session_update_config.rb +38 -6
  111. data/lib/openai/models/live/session_update_event.rb +8 -8
  112. data/lib/openai/models/live/sideband_client_event.rb +57 -0
  113. data/lib/openai/models/live/sideband_server_event.rb +78 -0
  114. data/lib/openai/models/realtime/realtime_audio_config_output.rb +6 -3
  115. data/lib/openai/models/realtime/realtime_response_create_audio_output.rb +6 -3
  116. data/lib/openai/models/realtime/realtime_response_status.rb +10 -1
  117. data/lib/openai/models/response_format_json_schema.rb +1 -1
  118. data/lib/openai/models/responses/function_tool.rb +8 -6
  119. data/lib/openai/models/responses/response.rb +2 -23
  120. data/lib/openai/models/responses/response_compact_params.rb +21 -0
  121. data/lib/openai/models/responses/response_create_params.rb +3 -6
  122. data/lib/openai/models/responses/response_error.rb +19 -1
  123. data/lib/openai/models/responses/response_format_text_config.rb +0 -4
  124. data/lib/openai/models/responses/response_function_tool_call.rb +0 -8
  125. data/lib/openai/models/responses/response_input_item.rb +107 -1
  126. data/lib/openai/models/responses/response_item.rb +107 -1
  127. data/lib/openai/models/responses/response_output_item.rb +107 -1
  128. data/lib/openai/models/responses/response_output_text.rb +0 -8
  129. data/lib/openai/models/responses/responses_client_event.rb +2 -2
  130. data/lib/openai/models/safety/safety_alert.rb +12 -1
  131. data/lib/openai/models/video_create_error.rb +19 -1
  132. data/lib/openai/models/webhooks/agent_environment_expired_webhook_event.rb +72 -0
  133. data/lib/openai/models/webhooks/agent_environment_suspended_webhook_event.rb +72 -0
  134. data/lib/openai/models/webhooks/unwrap_webhook_event.rb +8 -3
  135. data/lib/openai/models/webhooks/webhook_create_params.rb +2 -0
  136. data/lib/openai/models/webhooks/webhook_endpoint_with_secret.rb +0 -9
  137. data/lib/openai/models/webhooks/webhook_test_params.rb +2 -0
  138. data/lib/openai/models/webhooks/webhook_update_params.rb +2 -0
  139. data/lib/openai/resources/admin/organization/external_storage.rb +1 -1
  140. data/lib/openai/resources/admin/organization/projects/api_keys.rb +61 -0
  141. data/lib/openai/resources/admin/organization/usage.rb +67 -0
  142. data/lib/openai/resources/audio/speech.rb +2 -1
  143. data/lib/openai/resources/audio/voices.rb +10 -10
  144. data/lib/openai/resources/beta/agents/environments/files.rb +3 -31
  145. data/lib/openai/resources/beta/agents/environments.rb +3 -3
  146. data/lib/openai/resources/beta/agents/sessions/artifacts.rb +5 -11
  147. data/lib/openai/resources/beta/agents/sessions/events.rb +1 -1
  148. data/lib/openai/resources/beta/agents/sessions.rb +20 -56
  149. data/lib/openai/resources/beta/agents/vaults/credentials.rb +10 -6
  150. data/lib/openai/resources/beta/agents/vaults.rb +45 -6
  151. data/lib/openai/resources/beta/agents.rb +6 -4
  152. data/lib/openai/resources/beta/responses.rb +2 -2
  153. data/lib/openai/resources/chat/completions.rb +11 -37
  154. data/lib/openai/resources/decisions.rb +9 -15
  155. data/lib/openai/resources/files.rb +0 -39
  156. data/lib/openai/resources/live/forks.rb +19 -0
  157. data/lib/openai/resources/live/sideband.rb +19 -0
  158. data/lib/openai/resources/live.rb +19 -0
  159. data/lib/openai/resources/realtime/translations.rb +19 -0
  160. data/lib/openai/resources/realtime.rb +19 -0
  161. data/lib/openai/resources/responses.rb +44 -95
  162. data/lib/openai/resources/vector_stores/file_batches.rb +0 -178
  163. data/lib/openai/resources/vector_stores/files.rb +0 -188
  164. data/lib/openai/resources/webhooks.rb +13 -29
  165. data/lib/openai/version.rb +1 -1
  166. data/lib/openai.rb +35 -0
  167. data/rbi/openai/client.rbi +0 -103
  168. data/rbi/openai/helpers/admin/organization/projects/api_keys.rbi +25 -0
  169. data/rbi/openai/helpers/beta/agents/artifacts.rbi +25 -0
  170. data/rbi/openai/helpers/beta/agents/files.rbi +48 -0
  171. data/rbi/openai/helpers/client_runtime.rbi +108 -0
  172. data/rbi/openai/helpers/files.rbi +25 -0
  173. data/rbi/openai/helpers/models/chat/parsed.rbi +21 -0
  174. data/rbi/openai/helpers/models/responses/parsed.rbi +19 -0
  175. data/rbi/openai/helpers/models/responses/response.rbi +15 -0
  176. data/rbi/openai/helpers/streaming/response_stream.rbi +301 -0
  177. data/rbi/openai/helpers/vector_stores/file_batches.rbi +102 -0
  178. data/rbi/openai/helpers/vector_stores/files.rbi +122 -0
  179. data/rbi/openai/helpers/websocket.rbi +82 -0
  180. data/rbi/openai/models/admin/organization/audit_log_list_response.rbi +6 -3
  181. data/rbi/openai/models/admin/organization/external_storage_configuration.rbi +4 -2
  182. data/rbi/openai/models/admin/organization/external_storage_create_params.rbi +63 -4
  183. data/rbi/openai/models/admin/organization/oci_external_storage_provider.rbi +71 -0
  184. data/rbi/openai/models/admin/organization/project_residency.rbi +12 -0
  185. data/rbi/openai/models/admin/organization/projects/api_key_update_params.rbi +110 -0
  186. data/rbi/openai/models/admin/organization/projects/api_key_update_scopes_params.rbi +72 -0
  187. data/rbi/openai/models/admin/organization/usage_decisions_params.rbi +229 -0
  188. data/rbi/openai/models/admin/organization/usage_decisions_response.rbi +479 -0
  189. data/rbi/openai/models/audio/speech_create_params.rbi +6 -3
  190. data/rbi/openai/models/audio/voice.rbi +21 -2
  191. data/rbi/openai/models/audio/voice_create_params.rbi +149 -4
  192. data/rbi/openai/models/beta/agent_create_params.rbi +4 -2
  193. data/rbi/openai/models/beta/agent_list_params.rbi +8 -5
  194. data/rbi/openai/models/beta/agent_session.rbi +64 -1
  195. data/rbi/openai/models/beta/agent_session_environment_expired_event.rbi +95 -0
  196. data/rbi/openai/models/beta/agent_session_environment_state.rbi +6 -0
  197. data/rbi/openai/models/beta/agent_session_environment_suspended_event.rbi +95 -0
  198. data/rbi/openai/models/beta/agent_session_event.rbi +2 -0
  199. data/rbi/openai/models/beta/agent_update_params.rbi +4 -2
  200. data/rbi/openai/models/beta/agents/environment_info.rbi +3 -0
  201. data/rbi/openai/models/beta/agents/environment_list_params.rbi +7 -7
  202. data/rbi/openai/models/beta/agents/session_create_params.rbi +62 -2
  203. data/rbi/openai/models/beta/agents/session_list_params.rbi +11 -11
  204. data/rbi/openai/models/beta/agents/session_update_params.rbi +56 -0
  205. data/rbi/openai/models/beta/agents/sessions/artifact_list_params.rbi +19 -13
  206. data/rbi/openai/models/beta/agents/vault_list_params.rbi +30 -13
  207. data/rbi/openai/models/beta/agents/vault_status_filter.rbi +1 -3
  208. data/rbi/openai/models/beta/agents/vault_update_params.rbi +87 -0
  209. data/rbi/openai/models/beta/agents/vaults/credential_list_params.rbi +30 -13
  210. data/rbi/openai/models/beta/beta_response.rbi +2 -2
  211. data/rbi/openai/models/beta/beta_response_error.rbi +24 -3
  212. data/rbi/openai/models/beta/beta_response_input_item.rbi +191 -0
  213. data/rbi/openai/models/beta/beta_response_item.rbi +189 -0
  214. data/rbi/openai/models/beta/beta_response_output_item.rbi +191 -0
  215. data/rbi/openai/models/beta/beta_responses_client_event.rbi +2 -2
  216. data/rbi/openai/models/beta/response_create_params.rbi +2 -2
  217. data/rbi/openai/models/beta/session_turn_error.rbi +3 -0
  218. data/rbi/openai/models/chat/chat_completion_audio_param.rbi +3 -3
  219. data/rbi/openai/models/chat/chat_completion_message.rbi +0 -4
  220. data/rbi/openai/models/chat/chat_completion_message_function_tool_call.rbi +0 -4
  221. data/rbi/openai/models/chat/completion_create_params.rbi +63 -78
  222. data/rbi/openai/models/conversations/conversation_item.rbi +191 -0
  223. data/rbi/openai/models/decision.rbi +14 -1
  224. data/rbi/openai/models/decision_create_params.rbi +23 -12
  225. data/rbi/openai/models/decision_input_image.rbi +4 -3
  226. data/rbi/openai/models/decision_input_message.rbi +4 -4
  227. data/rbi/openai/models/decision_input_part.rbi +2 -1
  228. data/rbi/openai/models/image_edit_completed_event.rbi +1 -0
  229. data/rbi/openai/models/image_edit_partial_image_event.rbi +1 -0
  230. data/rbi/openai/models/image_gen_completed_event.rbi +1 -0
  231. data/rbi/openai/models/image_gen_partial_image_event.rbi +1 -0
  232. data/rbi/openai/models/images_response.rbi +1 -0
  233. data/rbi/openai/models/live/built_in_voice.rbi +1 -0
  234. data/rbi/openai/models/live/client_event.rbi +4 -0
  235. data/rbi/openai/models/live/decision_create_event.rbi +55 -0
  236. data/rbi/openai/models/live/decision_event.rbi +185 -0
  237. data/rbi/openai/models/live/decision_item_create_event.rbi +338 -0
  238. data/rbi/openai/models/live/decision_item_created_event.rbi +354 -0
  239. data/rbi/openai/models/live/decision_item_delete_event.rbi +66 -0
  240. data/rbi/openai/models/live/decision_item_deleted_event.rbi +77 -0
  241. data/rbi/openai/models/live/decision_trigger.rbi +465 -0
  242. data/rbi/openai/models/live/decisions_delegation_config.rbi +393 -0
  243. data/rbi/openai/models/live/decisions_delegation_update_config.rbi +412 -0
  244. data/rbi/openai/models/live/delegation_created_event.rbi +8 -10
  245. data/rbi/openai/models/live/fork_client_event.rbi +4 -0
  246. data/rbi/openai/models/live/fork_server_event.rbi +5 -0
  247. data/rbi/openai/models/live/media_session_config.rbi +95 -14
  248. data/rbi/openai/models/live/output_audio_fixture_play_event.rbi +76 -0
  249. data/rbi/openai/models/live/output_audio_fixture_played_event.rbi +73 -0
  250. data/rbi/openai/models/live/output_audio_fixture_playing_event.rbi +72 -0
  251. data/rbi/openai/models/live/server_event.rbi +5 -0
  252. data/rbi/openai/models/live/session_accept_params.rbi +88 -12
  253. data/rbi/openai/models/live/session_config.rbi +100 -14
  254. data/rbi/openai/models/live/session_resource.rbi +81 -10
  255. data/rbi/openai/models/live/session_update_config.rbi +86 -9
  256. data/rbi/openai/models/live/session_update_event.rbi +8 -8
  257. data/rbi/openai/models/live/sideband_client_event.rbi +40 -0
  258. data/rbi/openai/models/live/sideband_server_event.rbi +47 -0
  259. data/rbi/openai/models/realtime/realtime_audio_config_output.rbi +6 -3
  260. data/rbi/openai/models/realtime/realtime_response_create_audio_output.rbi +6 -3
  261. data/rbi/openai/models/realtime/realtime_response_status.rbi +13 -1
  262. data/rbi/openai/models/realtime/realtime_translation_input_audio_buffer_append_event.rbi +1 -1
  263. data/rbi/openai/models/realtime/realtime_translation_output_audio_delta_event.rbi +3 -3
  264. data/rbi/openai/models/realtime/realtime_translation_session_close_event.rbi +1 -1
  265. data/rbi/openai/models/realtime/realtime_translation_session_update_event.rbi +5 -1
  266. data/rbi/openai/models/responses/response.rbi +2 -7
  267. data/rbi/openai/models/responses/response_create_params.rbi +5 -9
  268. data/rbi/openai/models/responses/response_error.rbi +24 -3
  269. data/rbi/openai/models/responses/response_function_tool_call.rbi +0 -4
  270. data/rbi/openai/models/responses/response_function_web_search.rbi +21 -17
  271. data/rbi/openai/models/responses/response_input_item.rbi +191 -0
  272. data/rbi/openai/models/responses/response_item.rbi +189 -0
  273. data/rbi/openai/models/responses/response_output_item.rbi +191 -0
  274. data/rbi/openai/models/responses/response_output_text.rbi +0 -4
  275. data/rbi/openai/models/responses/responses_client_event.rbi +2 -2
  276. data/rbi/openai/models/safety/safety_alert.rbi +13 -1
  277. data/rbi/openai/models/video_create_error.rbi +24 -3
  278. data/rbi/openai/models/webhooks/agent_environment_expired_webhook_event.rbi +133 -0
  279. data/rbi/openai/models/webhooks/agent_environment_suspended_webhook_event.rbi +133 -0
  280. data/rbi/openai/models/webhooks/unwrap_webhook_event.rbi +3 -2
  281. data/rbi/openai/models/webhooks/webhook_create_params.rbi +8 -0
  282. data/rbi/openai/models/webhooks/webhook_test_params.rbi +8 -0
  283. data/rbi/openai/models/webhooks/webhook_update_params.rbi +8 -0
  284. data/rbi/openai/resources/admin/organization/external_storage.rbi +2 -1
  285. data/rbi/openai/resources/admin/organization/projects/api_keys.rbi +48 -0
  286. data/rbi/openai/resources/admin/organization/usage.rbi +56 -0
  287. data/rbi/openai/resources/audio/speech.rbi +2 -1
  288. data/rbi/openai/resources/audio/voices.rbi +13 -10
  289. data/rbi/openai/resources/beta/agents/environments/files.rbi +3 -33
  290. data/rbi/openai/resources/beta/agents/environments.rbi +3 -3
  291. data/rbi/openai/resources/beta/agents/sessions/artifacts.rbi +5 -13
  292. data/rbi/openai/resources/beta/agents/sessions.rbi +15 -4
  293. data/rbi/openai/resources/beta/agents/vaults/credentials.rbi +9 -5
  294. data/rbi/openai/resources/beta/agents/vaults.rbi +34 -5
  295. data/rbi/openai/resources/beta/agents.rbi +6 -4
  296. data/rbi/openai/resources/beta/responses.rbi +2 -2
  297. data/rbi/openai/resources/chat/completions.rbi +26 -29
  298. data/rbi/openai/resources/decisions.rbi +9 -15
  299. data/rbi/openai/resources/files.rbi +0 -18
  300. data/rbi/openai/resources/live/forks.rbi +17 -0
  301. data/rbi/openai/resources/live/sideband.rbi +17 -0
  302. data/rbi/openai/resources/live.rbi +17 -0
  303. data/rbi/openai/resources/realtime/translations.rbi +17 -0
  304. data/rbi/openai/resources/realtime.rbi +17 -0
  305. data/rbi/openai/resources/responses.rbi +41 -333
  306. data/rbi/openai/resources/vector_stores/file_batches.rbi +0 -93
  307. data/rbi/openai/resources/vector_stores/files.rbi +0 -113
  308. data/rbi/openai/resources/webhooks.rbi +2 -0
  309. data/sig/openai/client.rbs +0 -50
  310. data/sig/openai/helpers/admin/organization/projects/api_keys.rbs +18 -0
  311. data/sig/openai/helpers/beta/agents/artifacts.rbs +17 -0
  312. data/sig/openai/helpers/beta/agents/files.rbs +30 -0
  313. data/sig/openai/helpers/client_runtime.rbs +53 -0
  314. data/sig/openai/helpers/files.rbs +12 -0
  315. data/sig/openai/helpers/models/responses/response.rbs +9 -0
  316. data/sig/openai/helpers/streaming/response_stream.rbs +37 -0
  317. data/sig/openai/helpers/vector_stores/file_batches.rbs +38 -0
  318. data/sig/openai/helpers/vector_stores/files.rbs +43 -0
  319. data/sig/openai/helpers/websocket.rbs +40 -0
  320. data/sig/openai/models/admin/organization/audit_log_list_response.rbs +1 -0
  321. data/sig/openai/models/admin/organization/external_storage_configuration.rbs +1 -0
  322. data/sig/openai/models/admin/organization/external_storage_create_params.rbs +33 -0
  323. data/sig/openai/models/admin/organization/oci_external_storage_provider.rbs +34 -0
  324. data/sig/openai/models/admin/organization/project_residency.rbs +6 -0
  325. data/sig/openai/models/admin/organization/projects/api_key_update_params.rbs +77 -0
  326. data/sig/openai/models/admin/organization/projects/api_key_update_scopes_params.rbs +38 -0
  327. data/sig/openai/models/admin/organization/usage_decisions_params.rbs +170 -0
  328. data/sig/openai/models/admin/organization/usage_decisions_response.rbs +319 -0
  329. data/sig/openai/models/audio/speech_create_params.rbs +4 -2
  330. data/sig/openai/models/audio/voice.rbs +21 -3
  331. data/sig/openai/models/audio/voice_create_params.rbs +90 -1
  332. data/sig/openai/models/beta/agent_create_params.rbs +4 -2
  333. data/sig/openai/models/beta/agent_list_params.rbs +9 -6
  334. data/sig/openai/models/beta/agent_session.rbs +36 -2
  335. data/sig/openai/models/beta/agent_session_environment_expired_event.rbs +57 -0
  336. data/sig/openai/models/beta/agent_session_environment_state.rbs +14 -1
  337. data/sig/openai/models/beta/agent_session_environment_suspended_event.rbs +57 -0
  338. data/sig/openai/models/beta/agent_session_event.rbs +2 -0
  339. data/sig/openai/models/beta/agent_update_params.rbs +4 -2
  340. data/sig/openai/models/beta/agents/environment_info.rbs +11 -1
  341. data/sig/openai/models/beta/agents/environment_list_params.rbs +9 -9
  342. data/sig/openai/models/beta/agents/session_create_params.rbs +29 -2
  343. data/sig/openai/models/beta/agents/session_list_params.rbs +12 -12
  344. data/sig/openai/models/beta/agents/session_update_params.rbs +23 -0
  345. data/sig/openai/models/beta/agents/sessions/artifact_list_params.rbs +21 -15
  346. data/sig/openai/models/beta/agents/vault_list_params.rbs +32 -14
  347. data/sig/openai/models/beta/agents/vault_update_params.rbs +54 -0
  348. data/sig/openai/models/beta/agents/vaults/credential_list_params.rbs +32 -14
  349. data/sig/openai/models/beta/beta_response.rbs +2 -2
  350. data/sig/openai/models/beta/beta_response_error.rbs +19 -3
  351. data/sig/openai/models/beta/beta_response_input_item.rbs +110 -0
  352. data/sig/openai/models/beta/beta_response_item.rbs +110 -0
  353. data/sig/openai/models/beta/beta_response_output_item.rbs +110 -0
  354. data/sig/openai/models/beta/beta_responses_client_event.rbs +2 -2
  355. data/sig/openai/models/beta/response_create_params.rbs +2 -2
  356. data/sig/openai/models/beta/session_turn_error.rbs +4 -0
  357. data/sig/openai/models/chat/chat_completion_audio_param.rbs +2 -2
  358. data/sig/openai/models/chat/completion_create_params.rbs +2 -2
  359. data/sig/openai/models/conversations/conversation_item.rbs +110 -0
  360. data/sig/openai/models/decision.rbs +13 -0
  361. data/sig/openai/models/decision_create_params.rbs +19 -8
  362. data/sig/openai/models/decision_input_image.rbs +2 -2
  363. data/sig/openai/models/decision_input_message.rbs +2 -2
  364. data/sig/openai/models/live/built_in_voice.rbs +2 -0
  365. data/sig/openai/models/live/client_event.rbs +4 -0
  366. data/sig/openai/models/live/decision_create_event.rbs +18 -0
  367. data/sig/openai/models/live/decision_event.rbs +102 -0
  368. data/sig/openai/models/live/decision_item_create_event.rbs +183 -0
  369. data/sig/openai/models/live/decision_item_created_event.rbs +195 -0
  370. data/sig/openai/models/live/decision_item_delete_event.rbs +33 -0
  371. data/sig/openai/models/live/decision_item_deleted_event.rbs +49 -0
  372. data/sig/openai/models/live/decision_trigger.rbs +234 -0
  373. data/sig/openai/models/live/decisions_delegation_config.rbs +195 -0
  374. data/sig/openai/models/live/decisions_delegation_update_config.rbs +202 -0
  375. data/sig/openai/models/live/delegation_created_event.rbs +6 -7
  376. data/sig/openai/models/live/fork_client_event.rbs +4 -0
  377. data/sig/openai/models/live/fork_server_event.rbs +5 -0
  378. data/sig/openai/models/live/media_session_config.rbs +58 -11
  379. data/sig/openai/models/live/output_audio_fixture_play_event.rbs +42 -0
  380. data/sig/openai/models/live/output_audio_fixture_played_event.rbs +44 -0
  381. data/sig/openai/models/live/output_audio_fixture_playing_event.rbs +44 -0
  382. data/sig/openai/models/live/server_event.rbs +5 -0
  383. data/sig/openai/models/live/session_accept_params.rbs +57 -10
  384. data/sig/openai/models/live/session_config.rbs +58 -11
  385. data/sig/openai/models/live/session_resource.rbs +57 -10
  386. data/sig/openai/models/live/session_update_config.rbs +54 -3
  387. data/sig/openai/models/live/session_update_event.rbs +6 -6
  388. data/sig/openai/models/live/sideband_client_event.rbs +26 -0
  389. data/sig/openai/models/live/sideband_server_event.rbs +33 -0
  390. data/sig/openai/models/realtime/realtime_audio_config_output.rbs +6 -3
  391. data/sig/openai/models/realtime/realtime_response_create_audio_output.rbs +6 -3
  392. data/sig/openai/models/realtime/realtime_response_status.rbs +15 -3
  393. data/sig/openai/models/responses/response.rbs +2 -4
  394. data/sig/openai/models/responses/response_create_params.rbs +2 -2
  395. data/sig/openai/models/responses/response_error.rbs +19 -3
  396. data/sig/openai/models/responses/response_input_item.rbs +110 -0
  397. data/sig/openai/models/responses/response_item.rbs +110 -0
  398. data/sig/openai/models/responses/response_output_item.rbs +110 -0
  399. data/sig/openai/models/responses/responses_client_event.rbs +2 -2
  400. data/sig/openai/models/safety/safety_alert.rbs +12 -2
  401. data/sig/openai/models/video_create_error.rbs +19 -3
  402. data/sig/openai/models/webhooks/agent_environment_expired_webhook_event.rbs +70 -0
  403. data/sig/openai/models/webhooks/agent_environment_suspended_webhook_event.rbs +70 -0
  404. data/sig/openai/models/webhooks/unwrap_webhook_event.rbs +3 -1
  405. data/sig/openai/models/webhooks/webhook_create_params.rbs +4 -0
  406. data/sig/openai/models/webhooks/webhook_test_params.rbs +4 -0
  407. data/sig/openai/models/webhooks/webhook_update_params.rbs +4 -0
  408. data/sig/openai/resources/admin/organization/projects/api_keys.rbs +8 -0
  409. data/sig/openai/resources/admin/organization/usage.rbs +15 -0
  410. data/sig/openai/resources/beta/agents/environments/files.rbs +0 -17
  411. data/sig/openai/resources/beta/agents/sessions/artifacts.rbs +2 -6
  412. data/sig/openai/resources/beta/agents/sessions.rbs +4 -1
  413. data/sig/openai/resources/beta/agents/vaults/credentials.rbs +2 -1
  414. data/sig/openai/resources/beta/agents/vaults.rbs +9 -1
  415. data/sig/openai/resources/beta/agents.rbs +1 -1
  416. data/sig/openai/resources/files.rbs +0 -7
  417. data/sig/openai/resources/live/forks.rbs +8 -0
  418. data/sig/openai/resources/live/sideband.rbs +8 -0
  419. data/sig/openai/resources/live.rbs +7 -0
  420. data/sig/openai/resources/realtime/translations.rbs +7 -0
  421. data/sig/openai/resources/realtime.rbs +7 -0
  422. data/sig/openai/resources/responses.rbs +7 -31
  423. data/sig/openai/resources/vector_stores/file_batches.rbs +0 -31
  424. data/sig/openai/resources/vector_stores/files.rbs +0 -36
  425. data/sig/openai/resources/webhooks.rbs +3 -1
  426. metadata +101 -1
@@ -1,11 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "../helpers/streaming/response_stream_resource"
4
+ require_relative "../helpers/websocket/resource"
3
5
  require_relative "../helpers/structured_output/response_parser"
4
6
 
5
7
  module OpenAI
6
8
  module Resources
7
9
  # Create and manage model responses.
8
10
  class Responses
11
+ include OpenAI::WebSocket::Resource
12
+
13
+ # @api private
14
+ def __websocket_request(query: {})
15
+ {method: :get, path: "responses", query: query, security: {bearer_auth: true}}
16
+ end
17
+
18
+ # @api private
19
+ def __websocket_client_event
20
+ OpenAI::Models::Responses::ResponsesClientEvent
21
+ end
22
+
23
+ # @api private
24
+ def __websocket_server_event
25
+ OpenAI::Models::Responses::ResponsesServerEvent
26
+ end
27
+
9
28
  # Create and manage model responses.
10
29
  # @return [OpenAI::Resources::Responses::InputItems]
11
30
  attr_reader :input_items
@@ -168,7 +187,7 @@ module OpenAI
168
187
  # @param safety_identifier [String, nil]
169
188
  # A stable identifier used to help detect users of your application that may be
170
189
  # violating OpenAI's usage policies. The IDs should be a string that uniquely
171
- # identifies each user, with a maximum length of 64 characters. We recommend
190
+ # identifies each user, with a maximum length of 128 characters. We recommend
172
191
  # hashing their username or email address, in order to avoid sending us any
173
192
  # identifying information.
174
193
  # [Learn more](https://developers.openai.com/api/docs/guides/safety-best-practices#implement-safety-identifiers).
@@ -307,61 +326,6 @@ module OpenAI
307
326
  )
308
327
  end
309
328
 
310
- # Creates or resumes a streaming response and parses structured outputs.
311
- # @overload stream(access_programs: nil, **params)
312
- # @param access_programs [OpenAI::Models::Responses::ResponseCreateParams::AccessPrograms]
313
- # Domain-specific access programs to use for this request.
314
- # @param params [Hash{Symbol=>Object}] Other response creation or retrieval parameters.
315
- def stream(params)
316
- parsed, options = OpenAI::Responses::ResponseCreateParams.dump_request(params)
317
- starting_after, response_id = parsed.values_at(:starting_after, :response_id)
318
-
319
- if starting_after && !response_id
320
- raise ArgumentError, "starting_after can only be used with response_id"
321
- end
322
-
323
- model, tool_models = get_structured_output_models(parsed)
324
-
325
- unwrap = -> (raw) do
326
- if raw[:type] == "response.completed" && raw[:response]
327
- parse_structured_outputs!(raw[:response], model, tool_models)
328
- end
329
-
330
- raw
331
- end
332
-
333
- if response_id
334
- retrieve_params = parsed.slice(:include, :starting_after)
335
- retrieve_params[:request_options] = options
336
-
337
- raw_stream = retrieve_streaming_internal(
338
- response_id,
339
- params: retrieve_params,
340
- unwrap: unwrap
341
- )
342
- else
343
- parsed[:stream] = true
344
-
345
- raw_stream = @client.request(
346
- method: :post,
347
- path: "responses",
348
- headers: {"accept" => "text/event-stream"},
349
- body: parsed,
350
- stream: OpenAI::Internal::Stream,
351
- model: OpenAI::Models::Responses::ResponseStreamEvent,
352
- unwrap: unwrap,
353
- security: {bearer_auth: true},
354
- options: options
355
- )
356
- end
357
-
358
- OpenAI::Streaming::ResponseStream.new(
359
- raw_stream: raw_stream,
360
- text_format: model,
361
- starting_after: starting_after
362
- )
363
- end
364
-
365
329
  # See {OpenAI::Resources::Responses#create} for non-streaming counterpart.
366
330
  #
367
331
  # Creates a model response. Provide
@@ -376,7 +340,10 @@ module OpenAI
376
340
  # [file search](https://developers.openai.com/api/docs/guides/tools-file-search)
377
341
  # to use your own data as input for the model's response.
378
342
  #
379
- # @overload stream(background: nil, context_management: nil, conversation: nil, include: nil, input: nil, instructions: nil, max_output_tokens: nil, max_tool_calls: nil, metadata: nil, model: nil, moderation: nil, parallel_tool_calls: nil, previous_response_id: nil, prompt: nil, prompt_cache_key: nil, prompt_cache_options: nil, prompt_cache_retention: nil, reasoning: nil, response_id: nil, safety_identifier: nil, service_tier: nil, starting_after: nil, store: nil, stream_options: nil, temperature: nil, text: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, truncation: nil, user: nil, request_options: {})
343
+ # @overload stream_raw(access_programs: nil, background: nil, context_management: nil, conversation: nil, include: nil, input: nil, instructions: nil, max_output_tokens: nil, max_tool_calls: nil, metadata: nil, model: nil, moderation: nil, parallel_tool_calls: nil, previous_response_id: nil, prompt: nil, prompt_cache_key: nil, prompt_cache_options: nil, prompt_cache_retention: nil, reasoning: nil, safety_identifier: nil, service_tier: nil, store: nil, stream_options: nil, temperature: nil, text: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, truncation: nil, user: nil, request_options: {})
344
+ #
345
+ # @param access_programs [OpenAI::Models::Responses::ResponseCreateParams::AccessPrograms]
346
+ # Domain-specific access programs to use for this request.
380
347
  #
381
348
  # @param background [Boolean, nil]
382
349
  # Whether to run the model response in the background.
@@ -513,7 +480,7 @@ module OpenAI
513
480
  # @param safety_identifier [String, nil]
514
481
  # A stable identifier used to help detect users of your application that may be
515
482
  # violating OpenAI's usage policies. The IDs should be a string that uniquely
516
- # identifies each user, with a maximum length of 64 characters. We recommend
483
+ # identifies each user, with a maximum length of 128 characters. We recommend
517
484
  # hashing their username or email address, in order to avoid sending us any
518
485
  # identifying information.
519
486
  # [Learn more](https://developers.openai.com/api/docs/guides/safety-best-practices#implement-safety-identifiers).
@@ -672,13 +639,13 @@ module OpenAI
672
639
  # @param starting_after [Integer]
673
640
  # The sequence number of the event after which to start streaming.
674
641
  #
675
- # @param text [OpenAI::Responses::ResponseTextConfig, OpenAI::StructuredOutput::JsonSchemaConverter, Hash, nil] The structured-output model,
676
- # or the same typed/hash text configuration accepted by creation, used to parse retrieved text output. This is a local parsing hint and is not
677
- # sent to the API.
642
+ # @param text [OpenAI::Responses::ResponseTextConfig, OpenAI::StructuredOutput::JsonSchemaConverter, Hash, nil]
643
+ # The structured-output model used to parse retrieved text output. This is a local
644
+ # parsing hint and is not sent to the API.
678
645
  #
679
- # @param tools [Array<OpenAI::Responses::FunctionTool, OpenAI::StructuredOutput::JsonSchemaConverter, Hash>, nil] Structured-output models, or
680
- # the same typed/hash function-tool definitions accepted by creation, used to parse retrieved function tool calls. These are local parsing hints
681
- # and are not sent to the API.
646
+ # @param tools [Array<OpenAI::Responses::FunctionTool, OpenAI::StructuredOutput::JsonSchemaConverter, Hash>, nil]
647
+ # Structured-output models used to parse retrieved function tool calls. These are
648
+ # local parsing hints and are not sent to the API.
682
649
  #
683
650
  # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
684
651
  #
@@ -765,22 +732,6 @@ module OpenAI
765
732
  )
766
733
  end
767
734
 
768
- private def retrieve_streaming_internal(response_id, params:, unwrap:)
769
- parsed, options = OpenAI::Responses::ResponseRetrieveParams.dump_request(params)
770
- parsed.store(:stream, true)
771
- @client.request(
772
- method: :get,
773
- path: ["responses/%1$s", response_id],
774
- query: parsed,
775
- headers: {"accept" => "text/event-stream"},
776
- stream: OpenAI::Internal::Stream,
777
- model: OpenAI::Responses::ResponseStreamEvent,
778
- security: {bearer_auth: true},
779
- options: options,
780
- unwrap: unwrap
781
- )
782
- end
783
-
784
735
  # Deletes a model response with the given ID.
785
736
  #
786
737
  # @overload delete(response_id, request_options: {})
@@ -910,32 +861,30 @@ module OpenAI
910
861
  )
911
862
  end
912
863
 
913
- # @api private
914
- #
915
- # @param client [OpenAI::Client]
916
- def initialize(client:)
917
- @client = client
918
- @input_items = OpenAI::Resources::Responses::InputItems.new(client: client)
919
- @input_tokens = OpenAI::Resources::Responses::InputTokens.new(client: client)
920
- end
921
-
922
- private
923
-
924
- def parse_structured_outputs!(raw, model, tool_models)
864
+ private def parse_structured_outputs!(raw, model, tool_models)
925
865
  OpenAI::Helpers::StructuredOutput::ResponseParser.parse!(raw, model, tool_models)
926
866
  end
927
867
 
928
- def parse_retrieved_structured_outputs!(raw, model, tool_models)
868
+ private def parse_retrieved_structured_outputs!(raw, model, tool_models)
929
869
  OpenAI::Helpers::StructuredOutput::ResponseParser.parse_retrieved!(raw, model, tool_models)
930
870
  end
931
871
 
932
- def get_structured_output_models(parsed)
872
+ private def get_structured_output_models(parsed)
933
873
  OpenAI::Helpers::StructuredOutput::ResponseParser.get_models(parsed)
934
874
  end
935
875
 
936
- def get_retrieval_structured_output_models(parsed)
876
+ private def get_retrieval_structured_output_models(parsed)
937
877
  OpenAI::Helpers::StructuredOutput::ResponseParser.get_retrieval_models(parsed)
938
878
  end
879
+
880
+ # @api private
881
+ #
882
+ # @param client [OpenAI::Client]
883
+ def initialize(client:)
884
+ @client = client
885
+ @input_items = OpenAI::Resources::Responses::InputItems.new(client: client)
886
+ @input_tokens = OpenAI::Resources::Responses::InputTokens.new(client: client)
887
+ end
939
888
  end
940
889
  end
941
890
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../helpers/resource_polling"
4
-
5
3
  module OpenAI
6
4
  module Resources
7
5
  class VectorStores
@@ -58,63 +56,6 @@ module OpenAI
58
56
  )
59
57
  end
60
58
 
61
- # Create a vector store file batch and wait for processing to finish.
62
- #
63
- # The returned batch may have a `failed` or `cancelled` status; callers should
64
- # inspect its status and file counts. Polling intervals and the overall timeout
65
- # are in seconds. Finite timeouts include authentication and request replay
66
- # time and disable transport retries so the deadline remains strict. Set
67
- # `timeout` to `nil` to wait indefinitely and retain configured transport retries.
68
- #
69
- # @overload create_and_poll(vector_store_id, attributes: nil, chunking_strategy: nil, file_ids: nil, files: nil, poll_interval: nil, timeout: 1800.0, request_options: {})
70
- #
71
- # @param vector_store_id [String] The ID of the vector store for which to create a File Batch.
72
- #
73
- # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Attributes to apply to each file in `file_ids`.
74
- #
75
- # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the files.
76
- #
77
- # @param file_ids [Array<String>] File IDs to add to the vector store.
78
- #
79
- # @param files [Array<OpenAI::Models::VectorStores::FileBatchCreateParams::File>] File IDs with per-file attributes or chunking strategies.
80
- #
81
- # @param poll_interval [Integer, Float, nil] How often to retrieve the batch. When omitted, the SDK honors the server's
82
- # polling hint and otherwise waits 5 seconds.
83
- #
84
- # @param timeout [Integer, Float, nil] Maximum total time to poll. Defaults to 30 minutes. Set to `nil` to wait
85
- # indefinitely.
86
- #
87
- # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
88
- #
89
- # @raise [ArgumentError, OpenAI::Errors::PollingError]
90
- # @return [OpenAI::Models::VectorStores::VectorStoreFileBatch]
91
- def create_and_poll(
92
- vector_store_id,
93
- attributes: nil,
94
- chunking_strategy: nil,
95
- file_ids: nil,
96
- files: nil,
97
- poll_interval: nil,
98
- timeout: OpenAI::Internal::Poller::DEFAULT_TIMEOUT,
99
- request_options: {}
100
- )
101
- OpenAI::Internal::Poller.validate!(poll_interval: poll_interval, timeout: timeout)
102
-
103
- params = {request_options: request_options}
104
- params[:attributes] = attributes unless attributes.nil?
105
- params[:chunking_strategy] = chunking_strategy unless chunking_strategy.nil?
106
- params[:file_ids] = file_ids unless file_ids.nil?
107
- params[:files] = files unless files.nil?
108
- batch = create(vector_store_id, params)
109
- poll(
110
- batch.id,
111
- vector_store_id: vector_store_id,
112
- poll_interval: poll_interval,
113
- timeout: timeout,
114
- request_options: request_options
115
- )
116
- end
117
-
118
59
  # Retrieves a vector store file batch.
119
60
  #
120
61
  # @overload retrieve(batch_id, vector_store_id:, request_options: {})
@@ -236,125 +177,6 @@ module OpenAI
236
177
  )
237
178
  end
238
179
 
239
- # Wait for a vector store file batch to finish processing.
240
- #
241
- # The returned batch may have a `failed` or `cancelled` status; callers should
242
- # inspect its status and file counts. Polling intervals and the overall timeout
243
- # are in seconds. Set `timeout` to `nil` to wait indefinitely.
244
- #
245
- # @overload poll(batch_id, vector_store_id:, poll_interval: nil, timeout: 1800.0, request_options: {})
246
- #
247
- # @param batch_id [String] The ID of the file batch being retrieved.
248
- #
249
- # @param vector_store_id [String] The ID of the vector store that the file batch belongs to.
250
- #
251
- # @param poll_interval [Integer, Float, nil] How often to retrieve the batch. When omitted, the SDK honors the server's
252
- # polling hint and otherwise waits 5 seconds.
253
- #
254
- # @param timeout [Integer, Float, nil] Maximum total time to poll. Defaults to 30 minutes. Set to `nil` to wait
255
- # indefinitely.
256
- #
257
- # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
258
- #
259
- # @raise [ArgumentError, OpenAI::Errors::PollingError]
260
- # @return [OpenAI::Models::VectorStores::VectorStoreFileBatch]
261
- def poll(
262
- batch_id,
263
- vector_store_id:,
264
- poll_interval: nil,
265
- timeout: OpenAI::Internal::Poller::DEFAULT_TIMEOUT,
266
- request_options: {}
267
- )
268
- OpenAI::Helpers::ResourcePolling.poll_vector_store_file_batch(
269
- self,
270
- batch_id,
271
- vector_store_id: vector_store_id,
272
- poll_interval: poll_interval,
273
- timeout: timeout,
274
- request_options: request_options
275
- )
276
- end
277
-
278
- # Upload files concurrently, create a vector store file batch, and wait for
279
- # processing to finish.
280
- #
281
- # Existing file IDs can be included alongside new uploads. Upload concurrency is
282
- # bounded and defaults to 5. Set `max_concurrency` to 1 for sequential uploads.
283
- # Inputs are enumerated before requests begin so the 2,000-file API limit can be
284
- # checked without orphaning uploads. Stream-backed inputs are safely spooled during
285
- # enumeration, including IO objects yielded from block-scoped enumerators.
286
- #
287
- # @overload upload_and_poll(vector_store_id, files:, file_ids: [], max_concurrency: 5, attributes: nil, chunking_strategy: nil, poll_interval: nil, timeout: 1800.0, request_options: {})
288
- #
289
- # @param vector_store_id [String] The ID of the vector store for which to create a File Batch.
290
- #
291
- # @param files [Enumerable<Pathname, StringIO, IO, String, OpenAI::FilePart>] Files to upload.
292
- #
293
- # @param file_ids [Array<String>] IDs of files that have already been uploaded.
294
- #
295
- # @param max_concurrency [Integer] Maximum number of simultaneous file uploads.
296
- #
297
- # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Attributes to apply to every file.
298
- #
299
- # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the files.
300
- #
301
- # @param poll_interval [Integer, Float, nil] How often to retrieve the batch. When omitted, the SDK honors the server's
302
- # polling hint and otherwise waits 5 seconds.
303
- #
304
- # @param timeout [Integer, Float, nil] Maximum total time to poll. Defaults to 30 minutes. Set to `nil` to wait
305
- # indefinitely.
306
- #
307
- # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] Applied to every upload and to the
308
- # batch creation and polling requests. Idempotency keys are scoped to each
309
- # upload and the batch creation.
310
- #
311
- # @raise [ArgumentError, OpenAI::Errors::PollingError]
312
- # @return [OpenAI::Models::VectorStores::VectorStoreFileBatch]
313
- def upload_and_poll(
314
- vector_store_id,
315
- files:,
316
- file_ids: [],
317
- max_concurrency: 5,
318
- attributes: nil,
319
- chunking_strategy: nil,
320
- poll_interval: nil,
321
- timeout: OpenAI::Internal::Poller::DEFAULT_TIMEOUT,
322
- request_options: {}
323
- )
324
- OpenAI::Internal::Poller.validate!(poll_interval: poll_interval, timeout: timeout)
325
- request_options_scope = OpenAI::Internal::RequestOptionsScope.new(request_options)
326
-
327
- max_files = OpenAI::Internal::VectorStoreFileUploader::MAX_FILES_PER_BATCH
328
- if file_ids.length > max_files
329
- raise ArgumentError, "`file_ids` cannot contain more than #{max_files} entries"
330
- end
331
-
332
- uploaded = OpenAI::Internal::VectorStoreFileUploader
333
- .new(
334
- client: @client,
335
- max_concurrency: max_concurrency,
336
- request_options: request_options
337
- )
338
- .upload(files, max_files: max_files - file_ids.length)
339
-
340
- if uploaded.empty?
341
- raise(
342
- ArgumentError,
343
- "No `files` provided. Use `create_and_poll` when all files are already uploaded."
344
- )
345
- end
346
-
347
- create_and_poll(
348
- vector_store_id,
349
- file_ids: [*file_ids, *uploaded.map(&:id)],
350
- attributes: attributes,
351
- chunking_strategy: chunking_strategy,
352
- poll_interval: poll_interval,
353
- timeout: timeout,
354
- request_options: request_options_scope.child("file-batch")
355
- )
356
- end
357
-
358
180
  # @api private
359
181
  #
360
182
  # @param client [OpenAI::Client]
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../helpers/resource_polling"
4
-
5
3
  module OpenAI
6
4
  module Resources
7
5
  class VectorStores
@@ -51,58 +49,6 @@ module OpenAI
51
49
  )
52
50
  end
53
51
 
54
- # Attach a file to a vector store and wait for processing to finish.
55
- #
56
- # The returned file may have a `failed` or `cancelled` status; callers should
57
- # inspect the status and `last_error`. Polling intervals and the overall timeout
58
- # are in seconds. Finite timeouts include authentication and request replay
59
- # time and disable transport retries so the deadline remains strict. Set
60
- # `timeout` to `nil` to wait indefinitely and retain configured transport retries.
61
- #
62
- # @overload create_and_poll(vector_store_id, file_id:, attributes: nil, chunking_strategy: nil, poll_interval: nil, timeout: 1800.0, request_options: {})
63
- #
64
- # @param vector_store_id [String] The ID of the vector store for which to create a File.
65
- #
66
- # @param file_id [String] A File ID to attach to the vector store.
67
- #
68
- # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Attributes to attach to the vector store file.
69
- #
70
- # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the file.
71
- #
72
- # @param poll_interval [Integer, Float, nil] How often to retrieve the file. When omitted, the SDK honors the server's
73
- # polling hint and otherwise waits 5 seconds.
74
- #
75
- # @param timeout [Integer, Float, nil] Maximum total time to poll. Defaults to 30 minutes. Set to `nil` to wait
76
- # indefinitely.
77
- #
78
- # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
79
- #
80
- # @raise [ArgumentError, OpenAI::Errors::PollingError]
81
- # @return [OpenAI::Models::VectorStores::VectorStoreFile]
82
- def create_and_poll(
83
- vector_store_id,
84
- file_id:,
85
- attributes: nil,
86
- chunking_strategy: nil,
87
- poll_interval: nil,
88
- timeout: OpenAI::Internal::Poller::DEFAULT_TIMEOUT,
89
- request_options: {}
90
- )
91
- OpenAI::Internal::Poller.validate!(poll_interval: poll_interval, timeout: timeout)
92
-
93
- params = {file_id: file_id, request_options: request_options}
94
- params[:attributes] = attributes unless attributes.nil?
95
- params[:chunking_strategy] = chunking_strategy unless chunking_strategy.nil?
96
- file = create(vector_store_id, params)
97
- poll(
98
- file.id,
99
- vector_store_id: vector_store_id,
100
- poll_interval: poll_interval,
101
- timeout: timeout,
102
- request_options: request_options
103
- )
104
- end
105
-
106
52
  # Retrieves a vector store file.
107
53
  #
108
54
  # @overload retrieve(file_id, vector_store_id:, request_options: {})
@@ -257,140 +203,6 @@ module OpenAI
257
203
  )
258
204
  end
259
205
 
260
- # Wait for a vector store file to finish processing.
261
- #
262
- # The returned file may have a `failed` or `cancelled` status; callers should
263
- # inspect the status and `last_error`. Polling intervals and the overall timeout
264
- # are in seconds. Set `timeout` to `nil` to wait indefinitely.
265
- #
266
- # @overload poll(file_id, vector_store_id:, poll_interval: nil, timeout: 1800.0, request_options: {})
267
- #
268
- # @param file_id [String] The ID of the file being retrieved.
269
- #
270
- # @param vector_store_id [String] The ID of the vector store that the file belongs to.
271
- #
272
- # @param poll_interval [Integer, Float, nil] How often to retrieve the file. When omitted, the SDK honors the server's
273
- # polling hint and otherwise waits 5 seconds.
274
- #
275
- # @param timeout [Integer, Float, nil] Maximum total time to poll. Defaults to 30 minutes. Set to `nil` to wait
276
- # indefinitely.
277
- #
278
- # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
279
- #
280
- # @raise [ArgumentError, OpenAI::Errors::PollingError]
281
- # @return [OpenAI::Models::VectorStores::VectorStoreFile]
282
- def poll(
283
- file_id,
284
- vector_store_id:,
285
- poll_interval: nil,
286
- timeout: OpenAI::Internal::Poller::DEFAULT_TIMEOUT,
287
- request_options: {}
288
- )
289
- OpenAI::Helpers::ResourcePolling.poll_vector_store_file(
290
- self,
291
- file_id,
292
- vector_store_id: vector_store_id,
293
- poll_interval: poll_interval,
294
- timeout: timeout,
295
- request_options: request_options
296
- )
297
- end
298
-
299
- # Upload a file and attach it to a vector store.
300
- #
301
- # Processing continues asynchronously; use {#upload_and_poll} to wait until the
302
- # file is ready.
303
- #
304
- # @overload upload(vector_store_id, file:, attributes: nil, chunking_strategy: nil, request_options: {})
305
- #
306
- # @param vector_store_id [String] The ID of the vector store to attach the file to.
307
- #
308
- # @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The file to upload.
309
- #
310
- # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Attributes to attach to the vector store file.
311
- #
312
- # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the file.
313
- #
314
- # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] Applied to the upload and attach
315
- # requests. Idempotency keys are scoped to each operation.
316
- #
317
- # @return [OpenAI::Models::VectorStores::VectorStoreFile]
318
- def upload(
319
- vector_store_id,
320
- file:,
321
- attributes: nil,
322
- chunking_strategy: nil,
323
- request_options: {}
324
- )
325
- request_options_scope = OpenAI::Internal::RequestOptionsScope.new(request_options)
326
- uploaded = @client.files.create(
327
- file: file,
328
- purpose: :assistants,
329
- request_options: request_options_scope.child("file-upload")
330
- )
331
- params = {
332
- file_id: uploaded.id,
333
- request_options: request_options_scope.child("vector-store-file")
334
- }
335
- params[:attributes] = attributes unless attributes.nil?
336
- params[:chunking_strategy] = chunking_strategy unless chunking_strategy.nil?
337
- create(vector_store_id, params)
338
- end
339
-
340
- # Upload a file, attach it to a vector store, and wait for processing to
341
- # finish.
342
- #
343
- # The returned file may have a `failed` or `cancelled` status; callers should
344
- # inspect the status and `last_error`.
345
- #
346
- # @overload upload_and_poll(vector_store_id, file:, attributes: nil, chunking_strategy: nil, poll_interval: nil, timeout: 1800.0, request_options: {})
347
- #
348
- # @param vector_store_id [String] The ID of the vector store to attach the file to.
349
- #
350
- # @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The file to upload.
351
- #
352
- # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Attributes to attach to the vector store file.
353
- #
354
- # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the file.
355
- #
356
- # @param poll_interval [Integer, Float, nil] How often to retrieve the file. When omitted, the SDK honors the server's
357
- # polling hint and otherwise waits 5 seconds.
358
- #
359
- # @param timeout [Integer, Float, nil] Maximum total time to poll. Defaults to 30 minutes. Set to `nil` to wait
360
- # indefinitely.
361
- #
362
- # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] Applied to the upload, attach,
363
- # and polling requests. Idempotency keys are scoped to each write.
364
- #
365
- # @raise [ArgumentError, OpenAI::Errors::PollingError]
366
- # @return [OpenAI::Models::VectorStores::VectorStoreFile]
367
- def upload_and_poll(
368
- vector_store_id,
369
- file:,
370
- attributes: nil,
371
- chunking_strategy: nil,
372
- poll_interval: nil,
373
- timeout: OpenAI::Internal::Poller::DEFAULT_TIMEOUT,
374
- request_options: {}
375
- )
376
- OpenAI::Internal::Poller.validate!(poll_interval: poll_interval, timeout: timeout)
377
-
378
- attached = upload(
379
- vector_store_id,
380
- file: file,
381
- attributes: attributes,
382
- chunking_strategy: chunking_strategy,
383
- request_options: request_options
384
- )
385
- poll(
386
- attached.id,
387
- vector_store_id: vector_store_id,
388
- poll_interval: poll_interval,
389
- timeout: timeout,
390
- request_options: request_options
391
- )
392
- end
393
-
394
206
  # Retrieve the parsed contents of a vector store file.
395
207
  #
396
208
  # @overload content(file_id, vector_store_id:, request_options: {})