Module: RubyLLM::Providers::Ollama::Chat
- Included in:
- RubyLLM::Providers::Ollama
- Defined in:
- lib/ruby_llm/providers/ollama/chat.rb
Overview
Chat methods of the Ollama API integration
Class Method Summary collapse
- .format_message_content(msg) ⇒ Object
- .format_messages(messages) ⇒ Object
- .format_role(role) ⇒ Object
Class Method Details
.format_message_content(msg) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/ruby_llm/providers/ollama/chat.rb', line 21 def (msg) content = Ollama::Media.format_content(msg.content) return '' if content.nil? && OpenAI::Chat.(msg) content end |
.format_messages(messages) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ruby_llm/providers/ollama/chat.rb', line 10 def () .map do |msg| { role: format_role(msg.role), content: (msg), tool_calls: format_tool_calls(msg.tool_calls), tool_call_id: msg.tool_call_id }.compact.merge(OpenAI::Chat.format_thinking(msg)) end end |
.format_role(role) ⇒ Object
28 29 30 |
# File 'lib/ruby_llm/providers/ollama/chat.rb', line 28 def format_role(role) role.to_s end |