Module: OllamaChat::MessageFormat
- Included in:
- Chat, FollowChat, MessageList
- Defined in:
- lib/ollama_chat/message_format.rb
Overview
A module that provides formatting functionality for chat messages.
The MessageFormat module encapsulates methods for determining message icons based on whether images are present, and for conditionally annotating content with thinking or talk indicators. It supports customizable formatting of message text for display in terminal interfaces.
Instance Method Summary collapse
-
#message_type(images) ⇒ String
The message_type method determines the appropriate message icon based on whether images are present.
-
#talk_annotate(&block) ⇒ String?
The talk_annotate method processes a string output by a block and conditionally adds annotation.
-
#think_annotate(&block) ⇒ String?
The think_annotate method processes a string and conditionally annotates it with a thinking emoji if the think feature is enabled.
Instance Method Details
#message_type(images) ⇒ String
The message_type method determines the appropriate message icon based on whether images are present.
24 25 26 |
# File 'lib/ollama_chat/message_format.rb', line 24 def (images) images.present? ? ?📸 : ?📨 end |
#talk_annotate(&block) ⇒ String?
The talk_annotate method processes a string output by a block and conditionally adds annotation.
48 49 50 51 52 53 54 55 56 |
# File 'lib/ollama_chat/message_format.rb', line 48 def talk_annotate(&block) string = block.() string.to_s.size == 0 and return if @chat.think.on? "💬\n#{string}\n" else string end end |
#think_annotate(&block) ⇒ String?
The think_annotate method processes a string and conditionally annotates it with a thinking emoji if the think feature is enabled.
34 35 36 37 38 39 40 |
# File 'lib/ollama_chat/message_format.rb', line 34 def think_annotate(&block) string = block.() string.to_s.size == 0 and return if @chat.think.on? "💭\n#{string}\n" end end |