Class: RubyLLM::Providers::Gemini::Chat::MessageFormatter
- Inherits:
-
Object
- Object
- RubyLLM::Providers::Gemini::Chat::MessageFormatter
- Defined in:
- lib/ruby_llm/providers/gemini/chat.rb
Overview
formats a message
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(messages, format_role:, format_parts:, format_tool_result:) ⇒ MessageFormatter
constructor
A new instance of MessageFormatter.
Constructor Details
#initialize(messages, format_role:, format_parts:, format_tool_result:) ⇒ MessageFormatter
Returns a new instance of MessageFormatter.
176 177 178 179 180 181 182 183 |
# File 'lib/ruby_llm/providers/gemini/chat.rb', line 176 def initialize(, format_role:, format_parts:, format_tool_result:) = @index = 0 @tool_call_names = {} @format_role = format_role @format_parts = format_parts @format_tool_result = format_tool_result end |
Instance Method Details
#format ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/ruby_llm/providers/gemini/chat.rb', line 185 def format formatted = [] while if () tool_parts, next_index = collect_tool_parts formatted << build_tool_response(tool_parts) @index = next_index else remember_tool_calls if .tool_call? formatted << () @index += 1 end end formatted end |