Class: LLM::MessageFilter::DeleteBacktrace

Inherits:
LLM::MessageFilter show all
Defined in:
lib/llm/message_filter/delete_backtrace.rb

Overview

The DeleteBacktrace class removes the backtrace that the runtime includes with a Function::Return that represents an unrescued exception raised by a tool.

See Also:

Instance Attribute Summary

Attributes inherited from LLM::MessageFilter

#ctx

Instance Method Summary collapse

Methods inherited from LLM::MessageFilter

inherited, #initialize, multi

Constructor Details

This class inherits a constructor from LLM::MessageFilter

Instance Method Details

#call(message:, **opts) ⇒ LLM::Message

Parameters:

  • message (LLM::Message) —

    The message to filter

  • opts (Hash) —

    Per-call options

Returns:



15
16
17
18
19
20
21
22
# File 'lib/llm/message_filter/delete_backtrace.rb', line 15

def call(message:, **opts)
  returns = [*message.content].flatten.grep(LLM::Function::Return)
  returns.each do
    next unless it.error?
    it.value.delete(:backtrace)
  end
  message
end