Module: OllamaChat::Switches

Included in:
Chat
Defined in:
lib/ollama_chat/switches.rb

Defined Under Namespace

Modules: CheckSwitch Classes: CombinedSwitch, Switch

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



54
55
56
# File 'lib/ollama_chat/switches.rb', line 54

def location
  @location
end

#markdownObject (readonly)

Returns the value of attribute markdown.



52
53
54
# File 'lib/ollama_chat/switches.rb', line 52

def markdown
  @markdown
end

Instance Method Details

#setup_switches(config) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/ollama_chat/switches.rb', line 56

def setup_switches(config)
  @markdown = Switch.new(
    :markdown,
    config:,
    msg: {
      true  => "Using #{italic{'ANSI'}} markdown to output content.",
      false => "Using plaintext for outputting content.",
    }
  )

  @stream = Switch.new(
    :stream,
    config:,
    msg: {
      true  => "Streaming enabled.",
      false => "Streaming disabled.",
    }
  )

  @voice = Switch.new(
    :stream,
    config: config.voice,
    msg: {
      true  => "Voice output enabled.",
      false => "Voice output disabled.",
    }
  )

  @embedding_enabled = Switch.new(
    :embedding_enabled,
    config:,
    msg: {
      true  => "Embedding enabled.",
      false => "Embedding disabled.",
    }
  )

  @embedding_paused = Switch.new(
    :embedding_paused,
    config:,
    msg: {
      true  => "Embedding paused.",
      false => "Embedding resumed.",
    }
  )

  @embedding = CombinedSwitch.new(
    value: -> { @embedding_enabled.on? && @embedding_paused.off? },
    msg: {
      true  => "Embedding is currently performed.",
      false => "Embedding is currently not performed.",
    }
  )

  @location = Switch.new(
    :location,
    config: config.location.enabled,
    msg: {
      true  => "Location and localtime enabled.",
      false => "Location and localtime disabled.",
    }
  )
end