Class: Brute::Middleware::Question
- Inherits:
-
Object
- Object
- Brute::Middleware::Question
- Defined in:
- lib/brute/middleware/060_questions.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Question
constructor
A new instance of Question.
Constructor Details
#initialize(app) ⇒ Question
Returns a new instance of Question.
9 10 11 |
# File 'lib/brute/middleware/060_questions.rb', line 9 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/brute/middleware/060_questions.rb', line 13 def call(env) @app.call(env).tap do #if env[:messages].last.tool_call? # questions = last_message.tool_calls.select { |_id, tc| tc.name == "question" } # if questions.any? # env[:events] << { # type: :tool_call_start, # data: questions.map { |_id, tc| { name: tc.name, call_id: tc.id, arguments: tc.arguments } } # } # questions.each do |_id, question| # result = question.call # env[:events] << { type: :tool_result, data: { name: tc.name, content: content } } # env[:messages] << RubyLLM::Message.new(role: :tool, content: content, tool_call_id: tc.id) # end # end #end end end |