Module: OllamaChat::ThinkControl
- Included in:
- Chat
- Defined in:
- lib/ollama_chat/think_control.rb
Overview
A module that provides thinking control functionality for OllamaChat.
The ThinkControl module encapsulates methods for managing the ‘think’ mode setting in OllamaChat sessions. It handles the selection of different thinking modes, checking the current state, and displaying the current think mode status.
Instance Attribute Summary collapse
-
#think ⇒ true, ...
readonly
The think method returns the current state of the think mode.
Instance Method Summary collapse
-
#choose_think_mode ⇒ Object
The choose_think_mode method presents a menu to select a think mode.
-
#think? ⇒ TrueClass, FalseClass
The think? method checks if the think mode is enabled.
-
#think_loud? ⇒ TrueClass, FalseClass
The think_loud? method checks if both think mode and think loud mode are enabled.
-
#think_mode ⇒ String
The think_mode method returns the current think mode status as a string.
-
#think_show ⇒ Object
The think_show method displays the current think mode status.
Instance Attribute Details
#think ⇒ true, ... (readonly)
The think method returns the current state of the think mode.
11 12 13 |
# File 'lib/ollama_chat/think_control.rb', line 11 def think @think end |
Instance Method Details
#choose_think_mode ⇒ Object
The choose_think_mode method presents a menu to select a think mode.
This method displays available think modes to the user and sets the selected mode as the current think mode for the chat session.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ollama_chat/think_control.rb', line 17 def choose_think_mode think_modes = %w[ off on low medium high [EXIT] ] case chosen = OllamaChat::Utils::Chooser.choose(think_modes) when '[EXIT]', nil STDOUT.puts "Exiting chooser." when 'off' @think = false when 'on' @think = true when 'low', 'medium', 'high' @think = chosen end end |
#think? ⇒ TrueClass, FalseClass
The think? method checks if the think mode is enabled.
35 36 37 |
# File 'lib/ollama_chat/think_control.rb', line 35 def think? !!think end |
#think_loud? ⇒ TrueClass, FalseClass
The think_loud? method checks if both think mode and think loud mode are enabled.
61 62 63 |
# File 'lib/ollama_chat/think_control.rb', line 61 def think_loud? think? && think_loud.on? end |
#think_mode ⇒ String
The think_mode method returns the current think mode status as a string.
43 44 45 |
# File 'lib/ollama_chat/think_control.rb', line 43 def think_mode think == true ? 'enabled' : think || 'disabled' end |
#think_show ⇒ Object
The think_show method displays the current think mode status.
This method checks the current think mode setting and outputs a message indicating whether think mode is enabled, disabled, or set to a specific mode level (low, medium, high).
52 53 54 |
# File 'lib/ollama_chat/think_control.rb', line 52 def think_show STDOUT.puts "Think mode is #{bold(think_mode)}." end |