Class: RubyLLM::MCP::Task
- Inherits:
-
Object
- Object
- RubyLLM::MCP::Task
- Defined in:
- lib/ruby_llm/mcp/task.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#last_updated_at ⇒ Object
readonly
Returns the value of attribute last_updated_at.
-
#poll_interval ⇒ Object
readonly
Returns the value of attribute poll_interval.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#status_message ⇒ Object
readonly
Returns the value of attribute status_message.
-
#task_id ⇒ Object
readonly
Returns the value of attribute task_id.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
Instance Method Summary collapse
- #cancel ⇒ Object
- #cancelled? ⇒ Boolean
- #completed? ⇒ Boolean
- #failed? ⇒ Boolean
-
#initialize(adapter, task_response) ⇒ Task
constructor
A new instance of Task.
- #input_required? ⇒ Boolean
- #refresh ⇒ Object
- #result ⇒ Object
- #to_h ⇒ Object
- #working? ⇒ Boolean
Constructor Details
#initialize(adapter, task_response) ⇒ Task
Returns a new instance of Task.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ruby_llm/mcp/task.rb', line 9 def initialize(adapter, task_response) @adapter = adapter @task_id = task_response["taskId"] @status = task_response["status"] @status_message = task_response["statusMessage"] @created_at = task_response["createdAt"] @last_updated_at = task_response["lastUpdatedAt"] @ttl = task_response["ttl"] @poll_interval = task_response["pollInterval"] end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
6 7 8 |
# File 'lib/ruby_llm/mcp/task.rb', line 6 def adapter @adapter end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/ruby_llm/mcp/task.rb', line 6 def created_at @created_at end |
#last_updated_at ⇒ Object (readonly)
Returns the value of attribute last_updated_at.
6 7 8 |
# File 'lib/ruby_llm/mcp/task.rb', line 6 def last_updated_at @last_updated_at end |
#poll_interval ⇒ Object (readonly)
Returns the value of attribute poll_interval.
6 7 8 |
# File 'lib/ruby_llm/mcp/task.rb', line 6 def poll_interval @poll_interval end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/ruby_llm/mcp/task.rb', line 6 def status @status end |
#status_message ⇒ Object (readonly)
Returns the value of attribute status_message.
6 7 8 |
# File 'lib/ruby_llm/mcp/task.rb', line 6 def @status_message end |
#task_id ⇒ Object (readonly)
Returns the value of attribute task_id.
6 7 8 |
# File 'lib/ruby_llm/mcp/task.rb', line 6 def task_id @task_id end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
6 7 8 |
# File 'lib/ruby_llm/mcp/task.rb', line 6 def ttl @ttl end |
Instance Method Details
#cancel ⇒ Object
44 45 46 |
# File 'lib/ruby_llm/mcp/task.rb', line 44 def cancel self.class.new(@adapter, @adapter.task_cancel(task_id: task_id).value) end |
#cancelled? ⇒ Boolean
36 37 38 |
# File 'lib/ruby_llm/mcp/task.rb', line 36 def cancelled? status == "cancelled" end |
#completed? ⇒ Boolean
28 29 30 |
# File 'lib/ruby_llm/mcp/task.rb', line 28 def completed? status == "completed" end |
#failed? ⇒ Boolean
32 33 34 |
# File 'lib/ruby_llm/mcp/task.rb', line 32 def failed? status == "failed" end |
#input_required? ⇒ Boolean
24 25 26 |
# File 'lib/ruby_llm/mcp/task.rb', line 24 def input_required? status == "input_required" end |
#refresh ⇒ Object
48 49 50 |
# File 'lib/ruby_llm/mcp/task.rb', line 48 def refresh self.class.new(@adapter, @adapter.task_get(task_id: task_id).value) end |
#result ⇒ Object
40 41 42 |
# File 'lib/ruby_llm/mcp/task.rb', line 40 def result @adapter.task_result(task_id: task_id).value end |
#to_h ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ruby_llm/mcp/task.rb', line 52 def to_h { task_id: task_id, status: status, status_message: , created_at: created_at, last_updated_at: last_updated_at, ttl: ttl, poll_interval: poll_interval } end |
#working? ⇒ Boolean
20 21 22 |
# File 'lib/ruby_llm/mcp/task.rb', line 20 def working? status == "working" end |