Module: OllamaChat::MessageFormat

Included in:
Chat, FollowChat, MessageList
Defined in:
lib/ollama_chat/message_format.rb

Instance Method Summary collapse

Instance Method Details

#message_type(images) ⇒ String

The message_type method determines the appropriate message icon based on whether images are present.

Parameters:

  • images (Array)

    an array of images

Returns:

  • (String)

    returns 📸 if images are present, 📨 otherwise



8
9
10
# File 'lib/ollama_chat/message_format.rb', line 8

def message_type(images)
  images.present? ? ?

#talk_annotate(&block) ⇒ String?

The talk_annotate method processes a string output by a block and conditionally adds annotation.

Parameters:

  • block (Proc)

    a block that returns a string to be processed

Returns:

  • (String, nil)

    the annotated string if it has content, otherwise nil



32
33
34
35
36
37
38
39
40
# File 'lib/ollama_chat/message_format.rb', line 32

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.

Parameters:

  • block (Proc)

    a block that returns a string to be processed

Returns:

  • (String, nil)

    the annotated string with a thinking emoji if enabled, otherwise nil



18
19
20
21
22
23
24
# File 'lib/ollama_chat/message_format.rb', line 18

def think_annotate(&block)
  string = block.()
  string.to_s.size == 0 and return
  if @chat.think.on?
    "💭\n#{string}\n"
  end
end