Class: LLM::Function::Ractor::Task
- Defined in:
- lib/llm/function/ractor/task.rb
Overview
Instance Attribute Summary collapse
Attributes inherited from Task
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #group_class ⇒ Class
- #initialize(fn, options = {}) ⇒ LLM::Function::Ractor::Task constructor
- #interrupt! ⇒ nil (also: #cancel!)
- #spawn ⇒ LLM::Function::Ractor::Task
- #wait ⇒ LLM::Function::Return (also: #value)
Constructor Details
#initialize(fn, options = {}) ⇒ LLM::Function::Ractor::Task
23 24 25 26 27 28 29 30 31 |
# File 'lib/llm/function/ractor/task.rb', line 23 def initialize(fn, = {}) super @runner_class = .fetch(:runner_class) @id = .fetch(:id) @name = .fetch(:name) @arguments = .fetch(:arguments) @model = .fetch(:model, nil) @tracer = .fetch(:tracer, nil) end |
Instance Attribute Details
#mailbox ⇒ LLM::Function::Ractor::Mailbox (readonly)
11 12 13 |
# File 'lib/llm/function/ractor/task.rb', line 11 def mailbox @mailbox end |
Instance Method Details
#alive? ⇒ Boolean
46 47 48 |
# File 'lib/llm/function/ractor/task.rb', line 46 def alive? @mailbox&.alive? || false end |
#group_class ⇒ Class
71 72 73 |
# File 'lib/llm/function/ractor/task.rb', line 71 def group_class LLM::Function::Ractor::Group end |
#interrupt! ⇒ nil Also known as: cancel!
52 53 54 55 |
# File 'lib/llm/function/ractor/task.rb', line 52 def interrupt! mailbox&.interrupt! nil end |
#spawn ⇒ LLM::Function::Ractor::Task
35 36 37 38 39 40 41 42 |
# File 'lib/llm/function/ractor/task.rb', line 35 def spawn @span = @tracer&.on_tool_start( id: @id, name: @name, arguments: @arguments, model: @model ) @mailbox = Ractor::Mailbox.new(build_task) self end |
#wait ⇒ LLM::Function::Return Also known as: value
60 61 62 63 64 65 66 |
# File 'lib/llm/function/ractor/task.rb', line 60 def wait spawn unless @mailbox id, name, value = mailbox.wait result = Return.new(id, name, value) @tracer&.on_tool_finish(result:, span: @span) result end |