Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions lib/openai/base_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ class BaseClient
MAX_REDIRECTS = 20

# rubocop:disable Style/MutableConstant
PLATFORM_HEADERS = {
"x-stainless-arch" => OpenAI::Util.arch,
"x-stainless-lang" => "ruby",
"x-stainless-os" => OpenAI::Util.os,
"x-stainless-package-version" => OpenAI::VERSION,
"x-stainless-runtime" => ::RUBY_ENGINE,
"x-stainless-runtime-version" => ::RUBY_ENGINE_VERSION
}
PLATFORM_HEADERS =
{
"x-stainless-arch" => OpenAI::Util.arch,
"x-stainless-lang" => "ruby",
"x-stainless-os" => OpenAI::Util.os,
"x-stainless-package-version" => OpenAI::VERSION,
"x-stainless-runtime" => ::RUBY_ENGINE,
"x-stainless-runtime-version" => ::RUBY_ENGINE_VERSION
}
# rubocop:enable Style/MutableConstant

class << self
Expand Down
3 changes: 2 additions & 1 deletion lib/openai/base_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module OpenAI
#
# @example
# ```ruby
# completions = page
# completions =
# page
# .to_enum
# .lazy
# .select { _1.object_id.even? }
Expand Down
3 changes: 2 additions & 1 deletion lib/openai/base_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module OpenAI
#
# @example
# ```ruby
# chunks = stream
# chunks =
# stream
# .to_enum
# .lazy
# .select { _1.object_id.even? }
Expand Down
3 changes: 2 additions & 1 deletion lib/openai/cursor_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module OpenAI
#
# @example
# ```ruby
# completions = cursor_page
# completions =
# cursor_page
# .to_enum
# .lazy
# .select { _1.object_id.even? }
Expand Down
3 changes: 2 additions & 1 deletion lib/openai/models/beta/thread_create_and_run_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ class Message < OpenAI::BaseModel
#
# The text contents of the message.
class Content < OpenAI::Union
MessageContentPartParamArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }]
MessageContentPartParamArray =
OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }]

# The text contents of the message.
variant String
Expand Down
3 changes: 2 additions & 1 deletion lib/openai/models/beta/thread_create_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ class Message < OpenAI::BaseModel
#
# The text contents of the message.
class Content < OpenAI::Union
MessageContentPartParamArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }]
MessageContentPartParamArray =
OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }]

# The text contents of the message.
variant String
Expand Down
3 changes: 2 additions & 1 deletion lib/openai/models/beta/threads/message_create_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class MessageCreateParams < OpenAI::BaseModel
#
# The text contents of the message.
class Content < OpenAI::Union
MessageContentPartParamArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }]
MessageContentPartParamArray =
OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }]

# The text contents of the message.
variant String
Expand Down
3 changes: 2 additions & 1 deletion lib/openai/models/beta/threads/run_create_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ class AdditionalMessage < OpenAI::BaseModel
#
# The text contents of the message.
class Content < OpenAI::Union
MessageContentPartParamArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }]
MessageContentPartParamArray =
OpenAI::ArrayOf[union: -> { OpenAI::Models::Beta::Threads::MessageContentPartParam }]

# The text contents of the message.
variant String
Expand Down
3 changes: 2 additions & 1 deletion lib/openai/models/beta/threads/runs/run_step_include.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module Threads
module Runs
# @abstract
class RunStepInclude < OpenAI::Enum
STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT = :"step_details.tool_calls[*].file_search.results[*].content"
STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT =
:"step_details.tool_calls[*].file_search.results[*].content"

finalize!
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ class Audio < OpenAI::BaseModel
# The contents of the assistant message. Required unless `tool_calls` or
# `function_call` is specified.
class Content < OpenAI::Union
ArrayOfContentPartArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::ArrayOfContentPart }]
ArrayOfContentPartArray =
OpenAI::ArrayOf[union: -> { OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::ArrayOfContentPart }]

# The contents of the assistant message.
variant String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class ChatCompletionDeveloperMessageParam < OpenAI::BaseModel
#
# The contents of the developer message.
class Content < OpenAI::Union
ChatCompletionContentPartTextArray = OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }]
ChatCompletionContentPartTextArray =
OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }]

# The contents of the developer message.
variant String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class ChatCompletionPredictionContent < OpenAI::BaseModel
# generated tokens would match this content, the entire model response can be
# returned much more quickly.
class Content < OpenAI::Union
ChatCompletionContentPartTextArray = OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }]
ChatCompletionContentPartTextArray =
OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }]

# The content used for a Predicted Output. This is often the
# text of a file you are regenerating with minor changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class ChatCompletionSystemMessageParam < OpenAI::BaseModel
#
# The contents of the system message.
class Content < OpenAI::Union
ChatCompletionContentPartTextArray = OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }]
ChatCompletionContentPartTextArray =
OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }]

# The contents of the system message.
variant String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class ChatCompletionToolMessageParam < OpenAI::BaseModel
#
# The contents of the tool message.
class Content < OpenAI::Union
ChatCompletionContentPartTextArray = OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }]
ChatCompletionContentPartTextArray =
OpenAI::ArrayOf[-> { OpenAI::Models::Chat::ChatCompletionContentPartText }]

# The contents of the tool message.
variant String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class ChatCompletionUserMessageParam < OpenAI::BaseModel
#
# The contents of the user message.
class Content < OpenAI::Union
ChatCompletionContentPartArray = OpenAI::ArrayOf[union: -> { OpenAI::Models::Chat::ChatCompletionContentPart }]
ChatCompletionContentPartArray =
OpenAI::ArrayOf[union: -> { OpenAI::Models::Chat::ChatCompletionContentPart }]

# The text contents of the message.
variant String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
module OpenAI
module Models
module Responses
ResponseInputMessageContentList = OpenAI::ArrayOf[union: -> { OpenAI::Models::Responses::ResponseInputContent }]
ResponseInputMessageContentList =
OpenAI::ArrayOf[union: -> { OpenAI::Models::Responses::ResponseInputContent }]
end
end
end
3 changes: 2 additions & 1 deletion lib/openai/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module OpenAI
#
# @example
# ```ruby
# models = page
# models =
# page
# .to_enum
# .lazy
# .select { _1.object_id.even? }
Expand Down
21 changes: 12 additions & 9 deletions lib/openai/resources/beta/threads/messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ def create(thread_id, params)
# @return [OpenAI::Models::Beta::Threads::Message]
def retrieve(message_id, params)
parsed, options = OpenAI::Models::Beta::Threads::MessageRetrieveParams.dump_request(params)
thread_id = parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
thread_id =
parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :get,
path: ["threads/%0s/messages/%1s", thread_id, message_id],
Expand Down Expand Up @@ -89,9 +90,10 @@ def retrieve(message_id, params)
# @return [OpenAI::Models::Beta::Threads::Message]
def update(message_id, params)
parsed, options = OpenAI::Models::Beta::Threads::MessageUpdateParams.dump_request(params)
thread_id = parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
thread_id =
parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :post,
path: ["threads/%0s/messages/%1s", thread_id, message_id],
Expand Down Expand Up @@ -154,9 +156,10 @@ def list(thread_id, params = {})
# @return [OpenAI::Models::Beta::Threads::MessageDeleted]
def delete(message_id, params)
parsed, options = OpenAI::Models::Beta::Threads::MessageDeleteParams.dump_request(params)
thread_id = parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
thread_id =
parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :delete,
path: ["threads/%0s/messages/%1s", thread_id, message_id],
Expand Down
35 changes: 20 additions & 15 deletions lib/openai/resources/beta/threads/runs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,10 @@ def create_streaming(thread_id, params)
# @return [OpenAI::Models::Beta::Threads::Run]
def retrieve(run_id, params)
parsed, options = OpenAI::Models::Beta::Threads::RunRetrieveParams.dump_request(params)
thread_id = parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
thread_id =
parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :get,
path: ["threads/%0s/runs/%1s", thread_id, run_id],
Expand Down Expand Up @@ -314,9 +315,10 @@ def retrieve(run_id, params)
# @return [OpenAI::Models::Beta::Threads::Run]
def update(run_id, params)
parsed, options = OpenAI::Models::Beta::Threads::RunUpdateParams.dump_request(params)
thread_id = parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
thread_id =
parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :post,
path: ["threads/%0s/runs/%1s", thread_id, run_id],
Expand Down Expand Up @@ -376,9 +378,10 @@ def list(thread_id, params = {})
# @return [OpenAI::Models::Beta::Threads::Run]
def cancel(run_id, params)
parsed, options = OpenAI::Models::Beta::Threads::RunCancelParams.dump_request(params)
thread_id = parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
thread_id =
parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :post,
path: ["threads/%0s/runs/%1s/cancel", thread_id, run_id],
Expand Down Expand Up @@ -408,9 +411,10 @@ def cancel(run_id, params)
def submit_tool_outputs(run_id, params)
parsed, options = OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams.dump_request(params)
parsed.delete(:stream)
thread_id = parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
thread_id =
parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :post,
path: ["threads/%0s/runs/%1s/submit_tool_outputs", thread_id, run_id],
Expand Down Expand Up @@ -441,9 +445,10 @@ def submit_tool_outputs(run_id, params)
def submit_tool_outputs_streaming(run_id, params)
parsed, options = OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams.dump_request(params)
parsed.store(:stream, true)
thread_id = parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
thread_id =
parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :post,
path: ["threads/%0s/runs/%1s/submit_tool_outputs", thread_id, run_id],
Expand Down
21 changes: 12 additions & 9 deletions lib/openai/resources/beta/threads/runs/steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ class Steps
# @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
def retrieve(step_id, params)
parsed, options = OpenAI::Models::Beta::Threads::Runs::StepRetrieveParams.dump_request(params)
thread_id = parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
run_id = parsed.delete(:run_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
thread_id =
parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
run_id =
parsed.delete(:run_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :get,
path: ["threads/%0s/runs/%1s/steps/%2s", thread_id, run_id, step_id],
Expand Down Expand Up @@ -83,9 +85,10 @@ def retrieve(step_id, params)
# @return [OpenAI::CursorPage<OpenAI::Models::Beta::Threads::Runs::RunStep>]
def list(run_id, params)
parsed, options = OpenAI::Models::Beta::Threads::Runs::StepListParams.dump_request(params)
thread_id = parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
thread_id =
parsed.delete(:thread_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :get,
path: ["threads/%0s/runs/%1s/steps", thread_id, run_id],
Expand Down
21 changes: 12 additions & 9 deletions lib/openai/resources/vector_stores/file_batches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ def create(vector_store_id, params)
# @return [OpenAI::Models::VectorStores::VectorStoreFileBatch]
def retrieve(batch_id, params)
parsed, options = OpenAI::Models::VectorStores::FileBatchRetrieveParams.dump_request(params)
vector_store_id = parsed.delete(:vector_store_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
vector_store_id =
parsed.delete(:vector_store_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :get,
path: ["vector_stores/%0s/file_batches/%1s", vector_store_id, batch_id],
Expand All @@ -75,9 +76,10 @@ def retrieve(batch_id, params)
# @return [OpenAI::Models::VectorStores::VectorStoreFileBatch]
def cancel(batch_id, params)
parsed, options = OpenAI::Models::VectorStores::FileBatchCancelParams.dump_request(params)
vector_store_id = parsed.delete(:vector_store_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
vector_store_id =
parsed.delete(:vector_store_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :post,
path: ["vector_stores/%0s/file_batches/%1s/cancel", vector_store_id, batch_id],
Expand Down Expand Up @@ -118,9 +120,10 @@ def cancel(batch_id, params)
# @return [OpenAI::CursorPage<OpenAI::Models::VectorStores::VectorStoreFile>]
def list_files(batch_id, params)
parsed, options = OpenAI::Models::VectorStores::FileBatchListFilesParams.dump_request(params)
vector_store_id = parsed.delete(:vector_store_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
vector_store_id =
parsed.delete(:vector_store_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :get,
path: ["vector_stores/%0s/file_batches/%1s/files", vector_store_id, batch_id],
Expand Down
Loading