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

#embeddingObject (readonly)

Returns the value of attribute embedding.



60
61
62
# File 'lib/ollama_chat/switches.rb', line 60

def embedding
  @embedding
end

#embedding_enabledObject (readonly)

Returns the value of attribute embedding_enabled.



62
63
64
# File 'lib/ollama_chat/switches.rb', line 62

def embedding_enabled
  @embedding_enabled
end

#embedding_pausedObject (readonly)

Returns the value of attribute embedding_paused.



64
65
66
# File 'lib/ollama_chat/switches.rb', line 64

def embedding_paused
  @embedding_paused
end

#locationObject (readonly)

Returns the value of attribute location.



66
67
68
# File 'lib/ollama_chat/switches.rb', line 66

def location
  @location
end

#markdownObject (readonly)

Returns the value of attribute markdown.



56
57
58
# File 'lib/ollama_chat/switches.rb', line 56

def markdown
  @markdown
end

#streamObject (readonly)

Returns the value of attribute stream.



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

def stream
  @stream
end

#thinkObject (readonly)

Returns the value of attribute think.



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

def think
  @think
end

#voiceObject (readonly)

Returns the value of attribute voice.



58
59
60
# File 'lib/ollama_chat/switches.rb', line 58

def voice
  @voice
end

Instance Method Details

#setup_switches(config) ⇒ Object



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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/ollama_chat/switches.rb', line 68

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

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

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

  @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