Class: OrchestraAI::Step::CreateTask
- Inherits:
-
Object
- Object
- OrchestraAI::Step::CreateTask
- Defined in:
- lib/orchestra_ai/step/create_task.rb
Instance Method Summary collapse
-
#initialize(instruments:, message:, results:, block: nil) ⇒ CreateTask
constructor
A new instance of CreateTask.
- #message ⇒ Object
- #metadata ⇒ Object
- #perform ⇒ Object
- #task ⇒ Object
Constructor Details
#initialize(instruments:, message:, results:, block: nil) ⇒ CreateTask
Returns a new instance of CreateTask.
6 7 8 9 10 11 12 |
# File 'lib/orchestra_ai/step/create_task.rb', line 6 def initialize(instruments:, message:, results:, block: nil) @message = @results = results @block = block @instruments = instruments @response = nil end |
Instance Method Details
#message ⇒ Object
41 42 43 |
# File 'lib/orchestra_ai/step/create_task.rb', line 41 def @response.match(/<Message>(.+)<\/Message>/m)[1] end |
#metadata ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/orchestra_ai/step/create_task.rb', line 45 def if /<Metadata>(.+)<\/Metadata>/m.match?(@response) JSON.parse(@response.match(/<Metadata>(.+)<\/Metadata>/m)[1], symbolize_names: true) else {} end end |
#perform ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/orchestra_ai/step/create_task.rb', line 14 def perform @response = @block.call( [ @message, Prompt::CreateTask.new(instruments: @instruments, results: @results).to_s ].join ) if @response.match?(/<Error>/) raise Error, "Error: #{@response.match(/<Message>(.+)<\/Message>/m)[1]}" end unless @response.match?(/<Message>(.+)<\/Message>/m) raise NoMessageError, "Error: No message found in the response" end unless @response.match?(/<Task>(.+)<\/Task>/m) raise NoTaskError, "Error: No task found in the response" end @response end |