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
-
#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.
-
#stream ⇒ OllamaChat::Switches::Switch
readonly
The think method returns the current state of the stream switch.
-
#think ⇒ OllamaChat::Switches::Switch
readonly
The think method returns the current state of the thinking switch.
-
#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.
instance
111 112 113 |
# File 'lib/ollama_chat/switches.rb', line 111 def @embedding end |
#embedding_enabled ⇒ OllamaChat::Switches::Switch (readonly)
The embedding_enabled reader returns the embedding enabled switch instance.
instance
117 118 119 |
# File 'lib/ollama_chat/switches.rb', line 117 def @embedding_enabled end |
#embedding_paused ⇒ OllamaChat::Switches::Switch (readonly)
The embedding_paused method returns the current state of the embedding pause flag.
122 123 124 |
# File 'lib/ollama_chat/switches.rb', line 122 def @embedding_paused end |
#location ⇒ OllamaChat::Switches::Switch (readonly)
The location method returns the current location setting.
127 128 129 |
# File 'lib/ollama_chat/switches.rb', line 127 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.
100 101 102 |
# File 'lib/ollama_chat/switches.rb', line 100 def markdown @markdown end |
#stream ⇒ OllamaChat::Switches::Switch (readonly)
The think method returns the current state of the stream switch.
89 90 91 |
# File 'lib/ollama_chat/switches.rb', line 89 def stream @stream end |
#think ⇒ OllamaChat::Switches::Switch (readonly)
The think method returns the current state of the thinking switch.
94 95 96 |
# File 'lib/ollama_chat/switches.rb', line 94 def think @think end |
#voice ⇒ OllamaChat::Switches::Switch (readonly)
The voice reader returns the voice switch instance.
105 106 107 |
# File 'lib/ollama_chat/switches.rb', line 105 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.
containing settings for the switches
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/ollama_chat/switches.rb', line 138 def setup_switches(config) @stream = Switch.new( value: config.stream, msg: { true => "Streaming enabled.", false => "Streaming disabled.", } ) @think = Switch.new( value: config.think, msg: { true => "Thinking enabled.", false => "Thinking disabled.", } ) @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 and localtime enabled.", false => "Location and localtime disabled.", } ) end |