Class: GAI18n::OpenAI::Run
- Inherits:
-
Object
- Object
- GAI18n::OpenAI::Run
- Defined in:
- lib/gai18n/openai/run.rb
Instance Attribute Summary collapse
-
#assistant_id ⇒ Object
Returns the value of attribute assistant_id.
-
#cancelled_at ⇒ Object
Returns the value of attribute cancelled_at.
-
#completed_at ⇒ Object
Returns the value of attribute completed_at.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#expires_at ⇒ Object
Returns the value of attribute expires_at.
-
#failed_at ⇒ Object
Returns the value of attribute failed_at.
-
#file_ids ⇒ Object
Returns the value of attribute file_ids.
-
#id ⇒ Object
Returns the value of attribute id.
-
#instructions ⇒ Object
Returns the value of attribute instructions.
-
#last_error ⇒ Object
Returns the value of attribute last_error.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#model ⇒ Object
Returns the value of attribute model.
-
#object ⇒ Object
Returns the value of attribute object.
-
#started_at ⇒ Object
Returns the value of attribute started_at.
-
#status ⇒ Object
Returns the value of attribute status.
-
#thread_id ⇒ Object
Returns the value of attribute thread_id.
-
#tool_calls ⇒ Object
Returns the value of attribute tool_calls.
-
#tools ⇒ Object
Returns the value of attribute tools.
Class Method Summary collapse
Instance Method Summary collapse
- #accept_translations ⇒ Object
- #cancelled? ⇒ Boolean
- #completed? ⇒ Boolean
- #expired? ⇒ Boolean
- #failed? ⇒ Boolean
-
#initialize(response) ⇒ Run
constructor
A new instance of Run.
- #reload ⇒ Object
- #requires_action? ⇒ Boolean
- #wait_until_done(count = 0) ⇒ Object
Constructor Details
#initialize(response) ⇒ Run
Returns a new instance of Run.
25 26 27 |
# File 'lib/gai18n/openai/run.rb', line 25 def initialize(response) set_attributes_from(response) end |
Instance Attribute Details
#assistant_id ⇒ Object
Returns the value of attribute assistant_id.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def assistant_id @assistant_id end |
#cancelled_at ⇒ Object
Returns the value of attribute cancelled_at.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def cancelled_at @cancelled_at end |
#completed_at ⇒ Object
Returns the value of attribute completed_at.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def completed_at @completed_at end |
#created_at ⇒ Object
Returns the value of attribute created_at.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def created_at @created_at end |
#expires_at ⇒ Object
Returns the value of attribute expires_at.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def expires_at @expires_at end |
#failed_at ⇒ Object
Returns the value of attribute failed_at.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def failed_at @failed_at end |
#file_ids ⇒ Object
Returns the value of attribute file_ids.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def file_ids @file_ids end |
#id ⇒ Object
Returns the value of attribute id.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def id @id end |
#instructions ⇒ Object
Returns the value of attribute instructions.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def instructions @instructions end |
#last_error ⇒ Object
Returns the value of attribute last_error.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def last_error @last_error end |
#metadata ⇒ Object
Returns the value of attribute metadata.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def @metadata end |
#model ⇒ Object
Returns the value of attribute model.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def model @model end |
#object ⇒ Object
Returns the value of attribute object.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def object @object end |
#started_at ⇒ Object
Returns the value of attribute started_at.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def started_at @started_at end |
#status ⇒ Object
Returns the value of attribute status.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def status @status end |
#thread_id ⇒ Object
Returns the value of attribute thread_id.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def thread_id @thread_id end |
#tool_calls ⇒ Object
Returns the value of attribute tool_calls.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def tool_calls @tool_calls end |
#tools ⇒ Object
Returns the value of attribute tools.
20 21 22 |
# File 'lib/gai18n/openai/run.rb', line 20 def tools @tools end |
Class Method Details
.create(assistant_id:, thread_id:) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/gai18n/openai/run.rb', line 5 def create(assistant_id:, thread_id:) openai_client = GAI18n.config.openai_client parameters = {assistant_id: assistant_id} response = openai_client.runs.create thread_id: thread_id, parameters: parameters new response end |
Instance Method Details
#accept_translations ⇒ Object
49 50 51 52 |
# File 'lib/gai18n/openai/run.rb', line 49 def accept_translations submit_tool_outputs submit_translations end |
#cancelled? ⇒ Boolean
41 42 43 |
# File 'lib/gai18n/openai/run.rb', line 41 def cancelled? status == 'cancelled' end |
#completed? ⇒ Boolean
29 30 31 |
# File 'lib/gai18n/openai/run.rb', line 29 def completed? status == 'completed' end |
#expired? ⇒ Boolean
45 46 47 |
# File 'lib/gai18n/openai/run.rb', line 45 def expired? status == 'expired' end |
#failed? ⇒ Boolean
37 38 39 |
# File 'lib/gai18n/openai/run.rb', line 37 def failed? status == 'failed' end |
#reload ⇒ Object
54 55 56 57 58 |
# File 'lib/gai18n/openai/run.rb', line 54 def reload openai_client = GAI18n.config.openai_client response = openai_client.runs.retrieve thread_id: thread_id, id: id set_attributes_from response end |
#requires_action? ⇒ Boolean
33 34 35 |
# File 'lib/gai18n/openai/run.rb', line 33 def requires_action? status == 'requires_action' end |
#wait_until_done(count = 0) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/gai18n/openai/run.rb', line 60 def wait_until_done(count = 0) return self if count > 10 reload halt_statuses = %w[requires_action completed failed cancelled expired] return self if halt_statuses.include? status sleep 5 wait_until_done count + 1 end |