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, DatabaseSwitch, Switch
Instance Attribute Summary collapse
-
#embedding ⇒ Object
readonly
Returns the value of attribute embedding.
-
#embedding_enabled ⇒ Object
readonly
Returns the value of attribute embedding_enabled.
-
#embedding_paused ⇒ Object
readonly
Returns the value of attribute embedding_paused.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#markdown ⇒ Object
readonly
Returns the value of attribute markdown.
-
#runtime_info ⇒ Object
readonly
Controls the visibility of runtime information in the chat.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
-
#think_loud ⇒ Object
readonly
Returns the value of attribute think_loud.
-
#think_strip ⇒ Object
readonly
Determines whether the ‘thinking` content is stripped from the message payload before it is sent to the Ollama API.
-
#tools_support ⇒ Object
readonly
Controls tool support (off → skip all, on → honour per‑tool state).
-
#voice ⇒ Object
readonly
Returns the value of attribute voice.
Instance Method Summary collapse
-
#setup_switches ⇒ Object
Initializes the various switches for configuring the application’s behavior.
Instance Attribute Details
#embedding ⇒ Object (readonly)
Returns the value of attribute embedding.
207 208 209 |
# File 'lib/ollama_chat/switches.rb', line 207 def @embedding end |
#embedding_enabled ⇒ Object (readonly)
Returns the value of attribute embedding_enabled.
211 212 213 |
# File 'lib/ollama_chat/switches.rb', line 211 def @embedding_enabled end |
#embedding_paused ⇒ Object (readonly)
Returns the value of attribute embedding_paused.
215 216 217 |
# File 'lib/ollama_chat/switches.rb', line 215 def @embedding_paused end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
219 220 221 |
# File 'lib/ollama_chat/switches.rb', line 219 def location @location end |
#markdown ⇒ Object (readonly)
Returns the value of attribute markdown.
184 185 186 |
# File 'lib/ollama_chat/switches.rb', line 184 def markdown @markdown end |
#runtime_info ⇒ Object (readonly)
Controls the visibility of runtime information in the chat.
225 226 227 |
# File 'lib/ollama_chat/switches.rb', line 225 def runtime_info @runtime_info end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
180 181 182 |
# File 'lib/ollama_chat/switches.rb', line 180 def stream @stream end |
#think_loud ⇒ Object (readonly)
Returns the value of attribute think_loud.
188 189 190 |
# File 'lib/ollama_chat/switches.rb', line 188 def think_loud @think_loud end |
#think_strip ⇒ Object (readonly)
Determines whether the ‘thinking` content is stripped from the message payload before it is sent to the Ollama API.
Enabling this (‘true`) optimizes payload size and prevents the model from being confused by its own internal reasoning traces from previous turns. Disabling this (`false`) preserves the model’s “chain of thought” history.
199 200 201 |
# File 'lib/ollama_chat/switches.rb', line 199 def think_strip @think_strip end |
#tools_support ⇒ Object (readonly)
Controls tool support (off → skip all, on → honour per‑tool state).
231 232 233 |
# File 'lib/ollama_chat/switches.rb', line 231 def tools_support @tools_support end |
#voice ⇒ Object (readonly)
Returns the value of attribute voice.
203 204 205 |
# File 'lib/ollama_chat/switches.rb', line 203 def voice @voice end |
Instance Method Details
#setup_switches ⇒ Object
Initializes the various switches for configuring the application’s behavior.
This method creates and configures the database and local switch objects that control streaming, thinking, markdown output, voice output, embedding, and location settings.
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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/ollama_chat/switches.rb', line 238 def setup_switches @stream = DatabaseSwitch.new( chat: self, attribute: :stream_enabled, msg: { true => "Streaming enabled.", false => "Streaming disabled.", } ) @think_loud = DatabaseSwitch.new( chat: self, attribute: :think_loud_enabled, msg: { true => "Thinking out loud, show thinking annotations.", false => "Thinking silently, don't show thinking annotations.", } ) @think_strip = DatabaseSwitch.new( chat: self, attribute: :think_strip_enabled, msg: { true => "Stripping thinking content is enabled.", false => "Stripping thinking content is disabled.", } ) @markdown = DatabaseSwitch.new( chat: self, attribute: :markdown_enabled, msg: { true => "Using #{italic{'ANSI'}} markdown to output content.", false => "Using plaintext for outputting content.", } ) @voice = DatabaseSwitch.new( chat: self, attribute: :voice_enabled, msg: { true => "Voice output enabled.", false => "Voice output disabled.", } ) @embedding_enabled = DatabaseSwitch.new( chat: self, attribute: :embedding_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 = DatabaseSwitch.new( chat: self, attribute: :location_enabled, msg: { true => "Location enabled.", false => "Location disabled.", } ) @runtime_info = DatabaseSwitch.new( chat: self, attribute: :runtime_info_enabled, msg: { true => "Runtime Information enabled.", false => "Runtime Information disabled.", } ) @tools_support = DatabaseSwitch.new( chat: self, attribute: :tools_enabled, msg: { true => "Tools support enabled.", false => "Tools support disabled.", } ) end |