Module: Brute::Env
- Defined in:
- lib/brute/env.rb
Overview
What the turn came back with, asked of the env itself.
env = agent.start("hello")
env.extend(Brute::Env)
env.reply.content if env.has_reply?
A turn ends with whatever the last middleware left in env, and that is not always an answer: a turn that only ran tools, or that the provider failed, ends on something else. So the reply is the last message AND only when the assistant is the one who wrote it.
Instance Method Summary collapse
Instance Method Details
#has_reply? ⇒ Boolean
18 19 20 |
# File 'lib/brute/env.rb', line 18 def has_reply? !reply.nil? end |
#reply ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/brute/env.rb', line 22 def reply = self[:messages] if .respond_to?(:last) && .last&.role == :assistant .last end end |