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.
242 243 244 245 246 247 248 249 |
# File 'lib/ruby_llm/providers/gemini/chat.rb', line 242 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
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/ruby_llm/providers/gemini/chat.rb', line 251 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 |