Class: LLM::Shell::Formatter

Inherits:
Object
  • Object
show all
Includes:
Command::Utils
Defined in:
lib/llm/shell/formatter.rb

Constant Summary collapse

FormatError =
Class.new(RuntimeError)

Instance Method Summary collapse

Constructor Details

#initialize(messages) ⇒ Formatter

Returns a new instance of Formatter.



8
9
10
# File 'lib/llm/shell/formatter.rb', line 8

def initialize(messages)
  @messages = messages.reject(&:tool_call?)
end

Instance Method Details

#format!(role) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/llm/shell/formatter.rb', line 12

def format!(role)
  case role
  when :user then format_user(messages)
  when :assistant then format_assistant(messages)
  else raise FormatError.new("#{role} is not known")
  end
end