Module: OllamaChat::Switches
- Included in:
- Chat
- Defined in:
- lib/ollama_chat/switches.rb
Overview
A module that provides switch functionality for configuring application behavior.
The Switches module encapsulates various toggle switches used throughout the OllamaChat application to control different features and settings such as streaming, thinking, markdown output, voice output, embedding, and location information. These switches allow users to dynamically enable or disable specific functionalities during a chat session.
Defined Under Namespace
Modules: CheckSwitch Classes: CombinedSwitch, Switch
Instance Attribute Summary collapse
-
#embedding ⇒ OllamaChat::Switches::CombinedSwitch
readonly
The embedding attribute reader returns the embedding switch object.
-
#embedding_enabled ⇒ OllamaChat::Switches::Switch
readonly
The embedding_enabled reader returns the embedding enabled switch instance.
-
#embedding_paused ⇒ OllamaChat::Switches::Switch
readonly
The embedding_paused method returns the current state of the embedding pause flag.
-
#location ⇒ OllamaChat::Switches::Switch
readonly
The location method returns the current location setting.
-
#markdown ⇒ OllamaChat::Switches::Switch
readonly
The markdown attribute reader returns the markdown switch object.
-
#runtime_info ⇒ Object
readonly
Provides access to the runtime_info switch controlling the visibility of runtime information in the chat.
-
#stream ⇒ OllamaChat::Switches::Switch
readonly
The think method returns the current state of the stream switch.
-
#think_loud ⇒ OllamaChat::Switches::Switch
readonly
The think_loud method returns the current state of the think loud switch.
-
#tools_support ⇒ OllamaChat::Switch
readonly
Switch tools support on/off (off → skip all, on → honour per‑tool state).
-
#voice ⇒ OllamaChat::Switches::Switch
readonly
The voice reader returns the voice switch instance.
Instance Method Summary collapse
-
#setup_switches(config) ⇒ Object
The setup_switches method initializes various switches for configuring the application’s behavior.
Instance Attribute Details
#embedding ⇒ OllamaChat::Switches::CombinedSwitch (readonly)
The embedding attribute reader returns the embedding switch object.
158 159 160 |
# File 'lib/ollama_chat/switches.rb', line 158 def @embedding end |
#embedding_enabled ⇒ OllamaChat::Switches::Switch (readonly)
The embedding_enabled reader returns the embedding enabled switch instance.
164 165 166 |
# File 'lib/ollama_chat/switches.rb', line 164 def @embedding_enabled end |
#embedding_paused ⇒ OllamaChat::Switches::Switch (readonly)
The embedding_paused method returns the current state of the embedding pause flag.
169 170 171 |
# File 'lib/ollama_chat/switches.rb', line 169 def @embedding_paused end |
#location ⇒ OllamaChat::Switches::Switch (readonly)
The location method returns the current location setting.
174 175 176 |
# File 'lib/ollama_chat/switches.rb', line 174 def location @location end |
#markdown ⇒ OllamaChat::Switches::Switch (readonly)
The markdown attribute reader returns the markdown switch object. The voice reader returns the voice switch instance.
142 143 144 |
# File 'lib/ollama_chat/switches.rb', line 142 def markdown @markdown end |
#runtime_info ⇒ Object (readonly)
Provides access to the runtime_info switch controlling the visibility of runtime information in the chat
181 182 183 |
# File 'lib/ollama_chat/switches.rb', line 181 def runtime_info @runtime_info end |
#stream ⇒ OllamaChat::Switches::Switch (readonly)
The think method returns the current state of the stream switch.
136 137 138 |
# File 'lib/ollama_chat/switches.rb', line 136 def stream @stream end |
#think_loud ⇒ OllamaChat::Switches::Switch (readonly)
The think_loud method returns the current state of the think loud switch.
147 148 149 |
# File 'lib/ollama_chat/switches.rb', line 147 def think_loud @think_loud end |
#tools_support ⇒ OllamaChat::Switch (readonly)
Switch tools support on/off (off → skip all, on → honour per‑tool state)
186 187 188 |
# File 'lib/ollama_chat/switches.rb', line 186 def tools_support @tools_support end |
#voice ⇒ OllamaChat::Switches::Switch (readonly)
The voice reader returns the voice switch instance.
152 153 154 |
# File 'lib/ollama_chat/switches.rb', line 152 def voice @voice end |
Instance Method Details
#setup_switches(config) ⇒ Object
The setup_switches method initializes various switches for configuring the application’s behavior.
This method creates and configures multiple switch objects that control different aspects of the application, such as streaming, thinking, markdown output, voice output, embedding, and location settings.
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/ollama_chat/switches.rb', line 197 def setup_switches(config) @stream = Switch.new( value: config.stream, msg: { true => "Streaming enabled.", false => "Streaming disabled.", } ) @think_loud = Switch.new( value: config.think.loud, msg: { true => "Thinking out loud, show thinking annotations.", false => "Thinking silently, don't show thinking annotations.", } ) @markdown = Switch.new( value: config.markdown, msg: { true => "Using #{italic{'ANSI'}} markdown to output content.", false => "Using plaintext for outputting content.", } ) @voice = Switch.new( value: config.voice.enabled, msg: { true => "Voice output enabled.", false => "Voice output disabled.", } ) @embedding_enabled = Switch.new( value: config..enabled, msg: { true => "Embedding enabled.", false => "Embedding disabled.", } ) @embedding_paused = Switch.new( value: config..paused, 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( value: config.location.enabled, msg: { true => "Location enabled.", false => "Location disabled.", } ) @runtime_info = Switch.new( value: config.runtime_info.enabled, msg: { true => "Runtime Information enabled.", false => "Runtime Information disabled.", } ) @tools_support = Switch.new( value: config.tools.enabled, msg: { true => "Tools support enabled.", false => "Tools support disabled.", } ) end |