Class: OpenAI::Models::Beta::Threads::Run

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/openai/models/beta/threads/run.rb,
sig/openai/models/beta/threads/run.rbs

Overview

See Also:

  • OpenAI::Resources::Beta::Threads::Runs#create
  • OpenAI::Resources::Beta::Threads::Runs#create_stream_raw

Defined Under Namespace

Classes: IncompleteDetails, LastError, RequiredAction, TruncationStrategy, Usage

Instance Attribute Summary collapse

Attributes inherited from Internal::Type::BaseModel

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], #_request_id, #_set_last_response, coerce, #deconstruct_keys, #deep_to_h, dump, #encode_with, fields, hash, #hash, inherited, #inspect, inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, coerce_with_error, dump, #dump, #inspect, inspect, meta_info, new_coerce_state, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initialize(tool_calls:) ⇒ Object

Parameters:

  • id —

    The identifier, which can be referenced in API endpoints.

  • assistant_id —

    The ID of the assistant used for execution of this run.

  • cancelled_at —

    The Unix timestamp (in seconds) for when the run was cancelled.

  • completed_at —

    The Unix timestamp (in seconds) for when the run was completed.

  • created_at —

    The Unix timestamp (in seconds) for when the run was created.

  • expires_at —

    The Unix timestamp (in seconds) for when the run will expire.

  • failed_at —

    The Unix timestamp (in seconds) for when the run failed.

  • incomplete_details —

    Details on why the run is incomplete. Will be null if the run is not incomplete.

  • instructions —

    The instructions that the assistant used for this run.

  • last_error —

    The last error associated with this run. Will be null if there are no errors.

  • max_completion_tokens —

    The maximum number of completion tokens specified to have been used over the course of the run.

  • max_prompt_tokens —

    The maximum number of prompt tokens specified to have been used over the course of the run.

  • metadata —

    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.

    Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

  • model —

    The model that the assistant used for this run.

  • parallel_tool_calls —

    Whether to enable parallel function calling during tool use.

  • required_action —

    Details on the action required to continue the run. Will be null if no action is required.

  • response_format —

    Specifies the format that the model must output. Compatible with GPT-4o, GPT-4 Turbo, and all GPT-3.5 Turbo models since gpt-3.5-turbo-1106.

    Setting to { "type": "json_schema", "json_schema": {...} } enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the Structured Outputs guide.

    Setting to { "type": "json_object" } enables JSON mode, which ensures the message the model generates is valid JSON.

    Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if finish_reason="length", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.

  • started_at —

    The Unix timestamp (in seconds) for when the run was started.

  • status —

    The status of the run, which can be either queued, in_progress, requires_action, cancelling, cancelled, failed, completed, incomplete, or expired.

  • thread_id —

    The ID of the thread that was executed on as a part of this run.

  • tool_choice —

    Controls which (if any) tool is called by the model. none means the model will not call any tools and instead generates a message. auto is the default value and means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools before responding to the user. Specifying a particular tool like {"type": "file_search"} or {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool.

  • tools —

    The list of tools that the assistant used for this run.

  • truncation_strategy —

    Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

  • usage —

    Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

  • temperature —

    The sampling temperature used for this run. If not set, defaults to 1.

  • top_p —

    The nucleus sampling value used for this run. If not set, defaults to 1.

  • object —

    The object type, which is always thread.run.



# File 'lib/openai/models/beta/threads/run.rb', line 223

Instance Attribute Details

#assistant_id ⇒ String

The ID of the assistant used for execution of this run.

Returns:

  • (String)


23
# File 'lib/openai/models/beta/threads/run.rb', line 23

required :assistant_id, String

#cancelled_at ⇒ Integer?

The Unix timestamp (in seconds) for when the run was cancelled.

Returns:

  • (Integer, nil)


29
# File 'lib/openai/models/beta/threads/run.rb', line 29

required :cancelled_at, Integer, nil?: true

#completed_at ⇒ Integer?

The Unix timestamp (in seconds) for when the run was completed.

Returns:

  • (Integer, nil)


35
# File 'lib/openai/models/beta/threads/run.rb', line 35

required :completed_at, Integer, nil?: true

#created_at ⇒ Integer

The Unix timestamp (in seconds) for when the run was created.

Returns:

  • (Integer)


41
# File 'lib/openai/models/beta/threads/run.rb', line 41

required :created_at, Integer

#expires_at ⇒ Integer?

The Unix timestamp (in seconds) for when the run will expire.

Returns:

  • (Integer, nil)


47
# File 'lib/openai/models/beta/threads/run.rb', line 47

required :expires_at, Integer, nil?: true

#failed_at ⇒ Integer?

The Unix timestamp (in seconds) for when the run failed.

Returns:

  • (Integer, nil)


53
# File 'lib/openai/models/beta/threads/run.rb', line 53

required :failed_at, Integer, nil?: true

#id ⇒ String

The identifier, which can be referenced in API endpoints.

Returns:

  • (String)


15
# File 'lib/openai/models/beta/threads/run.rb', line 15

required :id, String

#incomplete_details ⇒ OpenAI::Beta::Threads::Run::IncompleteDetails?

Details on why the run is incomplete. Will be null if the run is not incomplete.

Returns:

  • (OpenAI::Beta::Threads::Run::IncompleteDetails, nil)


60
# File 'lib/openai/models/beta/threads/run.rb', line 60

required :incomplete_details, -> { OpenAI::Beta::Threads::Run::IncompleteDetails }, nil?: true

#instructions ⇒ String

The instructions that the assistant used for this run.

Returns:

  • (String)


68
# File 'lib/openai/models/beta/threads/run.rb', line 68

required :instructions, String

#last_error ⇒ OpenAI::Beta::Threads::Run::LastError?

The last error associated with this run. Will be null if there are no errors.

Returns:

  • (OpenAI::Beta::Threads::Run::LastError, nil)


74
# File 'lib/openai/models/beta/threads/run.rb', line 74

required :last_error, -> { OpenAI::Beta::Threads::Run::LastError }, nil?: true

#max_completion_tokens ⇒ Integer?

The maximum number of completion tokens specified to have been used over the course of the run.

Returns:

  • (Integer, nil)


81
# File 'lib/openai/models/beta/threads/run.rb', line 81

required :max_completion_tokens, Integer, nil?: true

#max_prompt_tokens ⇒ Integer?

The maximum number of prompt tokens specified to have been used over the course of the run.

Returns:

  • (Integer, nil)


88
# File 'lib/openai/models/beta/threads/run.rb', line 88

required :max_prompt_tokens, Integer, nil?: true

#metadata ⇒ OpenAI::Models::metadata?

Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.

Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

Returns:

  • (OpenAI::Models::metadata, nil)


99
# File 'lib/openai/models/beta/threads/run.rb', line 99

required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true

#model ⇒ String

The model that the assistant used for this run.

Returns:

  • (String)


107
# File 'lib/openai/models/beta/threads/run.rb', line 107

required :model, String

#object ⇒ :"thread.run"

The object type, which is always thread.run.

Returns:

  • (:"thread.run")


113
# File 'lib/openai/models/beta/threads/run.rb', line 113

required :object, const: :"thread.run"

#parallel_tool_calls ⇒ Boolean

Whether to enable parallel function calling during tool use.

Returns:



121
# File 'lib/openai/models/beta/threads/run.rb', line 121

required :parallel_tool_calls, OpenAI::Internal::Type::Boolean

#required_action ⇒ OpenAI::Beta::Threads::Run::RequiredAction?

Details on the action required to continue the run. Will be null if no action is required.

Returns:

  • (OpenAI::Beta::Threads::Run::RequiredAction, nil)


128
# File 'lib/openai/models/beta/threads/run.rb', line 128

required :required_action, -> { OpenAI::Beta::Threads::Run::RequiredAction }, nil?: true

#response_format ⇒ OpenAI::Models::Beta::assistant_response_format_option?

Specifies the format that the model must output. Compatible with GPT-4o, GPT-4 Turbo, and all GPT-3.5 Turbo models since gpt-3.5-turbo-1106.

Setting to { "type": "json_schema", "json_schema": {...} } enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the Structured Outputs guide.

Setting to { "type": "json_object" } enables JSON mode, which ensures the message the model generates is valid JSON.

Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if finish_reason="length", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.

Returns:

  • (OpenAI::Models::Beta::assistant_response_format_option, nil)


153
# File 'lib/openai/models/beta/threads/run.rb', line 153

required :response_format, union: -> { OpenAI::Beta::AssistantResponseFormatOption }, nil?: true

#started_at ⇒ Integer?

The Unix timestamp (in seconds) for when the run was started.

Returns:

  • (Integer, nil)


159
# File 'lib/openai/models/beta/threads/run.rb', line 159

required :started_at, Integer, nil?: true

#status ⇒ OpenAI::Models::Beta::Threads::run_status

The status of the run, which can be either queued, in_progress, requires_action, cancelling, cancelled, failed, completed, incomplete, or expired.

Returns:

  • (OpenAI::Models::Beta::Threads::run_status)


167
# File 'lib/openai/models/beta/threads/run.rb', line 167

required :status, enum: -> { OpenAI::Beta::Threads::RunStatus }

#temperature ⇒ Float?

The sampling temperature used for this run. If not set, defaults to 1.

Returns:

  • (Float, nil)


215
# File 'lib/openai/models/beta/threads/run.rb', line 215

optional :temperature, Float, nil?: true

#thread_id ⇒ String

The ID of the thread that was executed on as a part of this run.

Returns:

  • (String)


175
# File 'lib/openai/models/beta/threads/run.rb', line 175

required :thread_id, String

#tool_choice ⇒ OpenAI::Models::Beta::assistant_tool_choice_option?

Controls which (if any) tool is called by the model. none means the model will not call any tools and instead generates a message. auto is the default value and means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools before responding to the user. Specifying a particular tool like {"type": "file_search"} or {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool.

Returns:

  • (OpenAI::Models::Beta::assistant_tool_choice_option, nil)


187
# File 'lib/openai/models/beta/threads/run.rb', line 187

required :tool_choice, union: -> { OpenAI::Beta::AssistantToolChoiceOption }, nil?: true

#tools ⇒ ::Array[OpenAI::Models::Beta::assistant_tool]

The list of tools that the assistant used for this run.

Returns:

  • (::Array[OpenAI::Models::Beta::assistant_tool])


195
# File 'lib/openai/models/beta/threads/run.rb', line 195

required :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::AssistantTool] }

#top_p ⇒ Float?

The nucleus sampling value used for this run. If not set, defaults to 1.

Returns:

  • (Float, nil)


221
# File 'lib/openai/models/beta/threads/run.rb', line 221

optional :top_p, Float, nil?: true

#truncation_strategy ⇒ OpenAI::Beta::Threads::Run::TruncationStrategy?

Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

Returns:

  • (OpenAI::Beta::Threads::Run::TruncationStrategy, nil)


202
# File 'lib/openai/models/beta/threads/run.rb', line 202

required :truncation_strategy, -> { OpenAI::Beta::Threads::Run::TruncationStrategy }, nil?: true

#usage ⇒ OpenAI::Beta::Threads::Run::Usage?

Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

Returns:

  • (OpenAI::Beta::Threads::Run::Usage, nil)


209
# File 'lib/openai/models/beta/threads/run.rb', line 209

required :usage, -> { OpenAI::Beta::Threads::Run::Usage }, nil?: true

Class Method Details

.values ⇒ Array<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/openai/models/beta/threads/run.rb', line 385

Instance Method Details

#to_hash ⇒ {

Returns:

  • ({)


302
# File 'sig/openai/models/beta/threads/run.rbs', line 302

def to_hash: -> {