Class: LLM::Function::Task
- Inherits:
-
Object
- Object
- LLM::Function::Task
- Defined in:
- lib/llm/function/task.rb
Overview
This class is the superclass that all concurrency strategies must subclass in order to implement their own Task class. It provides a common interface that is the same across all concurrency strategies.
Direct Known Subclasses
Async::Task, Fiber::Task, Fork::Task, Ractor::Task, Sequential::Task, LLM::Function::Thread::Task
Instance Attribute Summary collapse
- #function ⇒ LLM::Function readonly
-
#tracer ⇒ LLM::Tracer?
readonly
The tracer for the task.
-
#span ⇒ Object
readonly
The span returned by Tracer#on_tool_start.
-
#started_at ⇒ Float?
readonly
Returns when a task started, or nil.
-
#finished_at ⇒ Float?
readonly
Returns when a task finished, or nil.
Instance Method Summary collapse
- #interrupt! ⇒ nil (also: #cancel!) abstract
- #spawn ⇒ nil abstract
- #alive? ⇒ Boolean abstract
-
#initialize(fn, options = {}) ⇒ Task
constructor
A new instance of Task.
- #wait ⇒ LLM::Function::Return, LLM::Interrupt (also: #value) abstract
- #group_class ⇒ Class abstract
-
#intercepted? ⇒ Boolean
Returns true when an intercept has returned Return.
Constructor Details
#initialize(fn, options = {}) ⇒ Task
Returns a new instance of Task.
51 52 53 54 55 56 |
# File 'lib/llm/function/task.rb', line 51 def initialize(fn, = {}) @function = fn @intercepted = [:intercepted] @tracer = [:tracer] @finished_at = nil end |
Instance Attribute Details
#function ⇒ LLM::Function (readonly)
12 13 14 |
# File 'lib/llm/function/task.rb', line 12 def function @function end |
#tracer ⇒ LLM::Tracer? (readonly)
The tracer for the task
17 18 19 |
# File 'lib/llm/function/task.rb', line 17 def tracer @tracer end |
#span ⇒ Object (readonly)
The span returned by Tracer#on_tool_start
22 23 24 |
# File 'lib/llm/function/task.rb', line 22 def span @span end |
#started_at ⇒ Float? (readonly)
This method captures a monotonic clock time (Process::CLOCK_MONOTONIC) rather than a Time object.
Returns when a task started, or nil
31 32 33 |
# File 'lib/llm/function/task.rb', line 31 def started_at @started_at end |
#finished_at ⇒ Float? (readonly)
This method captures a monotonic clock time (Process::CLOCK_MONOTONIC) rather than a Time object.
Returns when a task finished, or nil
40 41 42 |
# File 'lib/llm/function/task.rb', line 40 def finished_at @finished_at end |
Instance Method Details
#interrupt! ⇒ nil Also known as: cancel!
75 76 77 |
# File 'lib/llm/function/task.rb', line 75 def interrupt! raise NotImplementedError end |
#spawn ⇒ nil
61 62 63 |
# File 'lib/llm/function/task.rb', line 61 def spawn raise NotImplementedError end |
#alive? ⇒ Boolean
68 69 70 |
# File 'lib/llm/function/task.rb', line 68 def alive? raise NotImplementedError end |
#wait ⇒ LLM::Function::Return, LLM::Interrupt Also known as: value
This method returns an instance of Return or Interrupt when the task has received an interrupt.
An exception that occurs inside a tool is rescued, and returned by this method as a Return object. It can be distinguished from other returns through the Return#error? method.
93 94 95 |
# File 'lib/llm/function/task.rb', line 93 def wait raise NotImplementedError end |
#group_class ⇒ Class
101 102 103 |
# File 'lib/llm/function/task.rb', line 101 def group_class raise NotImplementedError end |