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.
258 259 260 261 262 263 264 265 |
# File 'lib/ruby_llm/providers/gemini/chat.rb', line 258 def initialize(, format_role:, format_parts:, format_tool_result:) @messages = @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
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/ruby_llm/providers/gemini/chat.rb', line 267 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 |