ollama_chat 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,20 @@
1
1
  module OllamaChat::MessageFormat
2
+ # The message_type method determines the appropriate message icon based on
3
+ # whether images are present.
4
+ #
5
+ # @param images [ Array ] an array of images
6
+ #
7
+ # @return [ String ] returns 📸 if images are present, 📨 otherwise
2
8
  def message_type(images)
3
9
  images.present? ? ?📸 : ?📨
4
10
  end
5
11
 
12
+ # The think_annotate method processes a string and conditionally annotates it
13
+ # with a thinking emoji if the think feature is enabled.
14
+ #
15
+ # @param block [ Proc ] a block that returns a string to be processed
16
+ #
17
+ # @return [ String, nil ] the annotated string with a thinking emoji if enabled, otherwise nil
6
18
  def think_annotate(&block)
7
19
  string = block.()
8
20
  string.to_s.size == 0 and return
@@ -11,6 +23,12 @@ module OllamaChat::MessageFormat
11
23
  end
12
24
  end
13
25
 
26
+ # The talk_annotate method processes a string output by a block and
27
+ # conditionally adds annotation.
28
+ #
29
+ # @param block [ Proc ] a block that returns a string to be processed
30
+ #
31
+ # @return [ String, nil ] the annotated string if it has content, otherwise nil
14
32
  def talk_annotate(&block)
15
33
  string = block.()
16
34
  string.to_s.size == 0 and return
@@ -1,4 +1,12 @@
1
1
  module OllamaChat::MessageOutput
2
+ # The pipe method forwards the last assistant message to a command's standard
3
+ # input.
4
+ #
5
+ # @param cmd [ String ] the command to which the output should be piped
6
+ #
7
+ # @return [ OllamaChat::Chat ] returns self
8
+ # @return [ nil ] returns nil if the command is not provided or if there is
9
+ # no assistant message
2
10
  def pipe(cmd)
3
11
  cmd.present? or return
4
12
  if message = @messages.last and message.role == 'assistant'
@@ -21,10 +29,19 @@ module OllamaChat::MessageOutput
21
29
  end
22
30
  end
23
31
 
32
+ # The output method writes the last assistant message to a file.
33
+ #
34
+ # @param filename [ String ] the path to the file where the output should be written
35
+ #
36
+ # @return [ Chat ] returns self on success, nil on failure
37
+ #
38
+ # @see write_file_unless_exist
39
+ #
40
+ # @note If no assistant message is available, an error message is printed to stderr.
24
41
  def output(filename)
25
42
  if message = @messages.last and message.role == 'assistant'
26
43
  begin
27
- write_file_unless_exist(filename)
44
+ write_file_unless_exist(filename, message)
28
45
  STDOUT.puts "Last response was written to #{filename.inspect}."
29
46
  self
30
47
  rescue => e
@@ -37,7 +54,15 @@ module OllamaChat::MessageOutput
37
54
 
38
55
  private
39
56
 
40
- def write_file_unless_exist(filename)
57
+ # The write_file_unless_exist method creates a new file with the specified
58
+ # message content, but only if a file with that name does not already exist.
59
+ #
60
+ # @param filename [ String ] the path of the file to be created
61
+ # @param message [ Ollama::Message ] the message object containing the content to write
62
+ #
63
+ # @return [ TrueClass ] if the file was successfully created
64
+ # @return [ nil ] if the file already exists and was not created
65
+ def write_file_unless_exist(filename, message)
41
66
  if File.exist?(filename)
42
67
  STDERR.puts "File #{filename.inspect} already exists. Choose another filename."
43
68
  return
@@ -47,4 +72,4 @@ module OllamaChat::MessageOutput
47
72
  end
48
73
  true
49
74
  end
50
- end
75
+ end
@@ -1,5 +1,4 @@
1
1
  module OllamaChat::ModelHandling
2
-
3
2
  # The model_present? method checks if the specified Ollama model is available.
4
3
  #
5
4
  # @param model [ String ] the name of the Ollama model
@@ -39,6 +39,7 @@ document_policy: importing
39
39
  think: false
40
40
  embedding:
41
41
  enabled: true
42
+ paused: false
42
43
  model:
43
44
  name: mxbai-embed-large
44
45
  embedding_length: 1024
@@ -9,6 +9,15 @@ class OllamaChat::OllamaChatConfig
9
9
 
10
10
  DEFAULT_CONFIG = File.read(DEFAULT_CONFIG_PATH)
11
11
 
12
+ # The initialize method sets up the configuration file path and ensures the
13
+ # cache directory exists.
14
+ # It attempts to load configuration from the specified filename or uses a
15
+ # default path.
16
+ # If the configuration file is missing and the default path is used, it
17
+ # creates the necessary directory structure and writes a default
18
+ # configuration file.
19
+ #
20
+ # @param filename [ String, nil ] the path to the configuration file
12
21
  def initialize(filename = nil)
13
22
  @filename = filename || default_path
14
23
  unless File.directory?(cache_dir_path)
@@ -27,30 +36,62 @@ class OllamaChat::OllamaChatConfig
27
36
  end
28
37
  end
29
38
 
39
+ # The filename reader returns the name of the file associated with this instance.
30
40
  attr_reader :filename
31
41
 
42
+ # The config reader returns the configuration object for the chat instance.
43
+ #
44
+ # @return [ ComplexConfig::Settings ] the configuration object
32
45
  attr_reader :config
33
46
 
47
+ # The default_config_path method returns the path to the default
48
+ # configuration file.
49
+ #
50
+ # @return [ String ] the path to the default configuration file
34
51
  def default_config_path
35
52
  DEFAULT_CONFIG_PATH
36
53
  end
37
54
 
55
+ # The default_path method constructs the full path to the default
56
+ # configuration file.
57
+ #
58
+ # @return [ Pathname ] a Pathname object representing the path to the
59
+ # config.yml file within the configuration directory
38
60
  def default_path
39
61
  config_dir_path + 'config.yml'
40
62
  end
41
63
 
64
+ # The config_dir_path method returns the path to the ollama_chat
65
+ # configuration directory by combining the XDG config home directory with the
66
+ # 'ollama_chat' subdirectory.
67
+ #
68
+ # @return [ Pathname ] the pathname object representing the configuration
69
+ # directory
42
70
  def config_dir_path
43
71
  XDG.new.config_home + 'ollama_chat'
44
72
  end
45
73
 
74
+ # The cache_dir_path method returns the path to the ollama_chat cache
75
+ # directory within the XDG cache home directory.
76
+ #
77
+ # @return [ Pathname ] the pathname object representing the cache directory path
46
78
  def cache_dir_path
47
79
  XDG.new.cache_home + 'ollama_chat'
48
80
  end
49
81
 
82
+ # The database_path method constructs the full path to the documents database
83
+ # file by joining the cache directory path with the filename 'documents.db'.
84
+ #
85
+ # @return [ Pathname ] the full path to the documents database file
50
86
  def database_path
51
87
  cache_dir_path + 'documents.db'
52
88
  end
53
89
 
90
+ # The diff_tool method returns the preferred diff tool command.
91
+ # It checks for the DIFF_TOOL environment variable and falls back to
92
+ # 'vimdiff' if not set.
93
+ #
94
+ # @return [ String ] the command name of the diff tool to be used
54
95
  def diff_tool
55
96
  ENV.fetch('DIFF_TOOL', 'vimdiff')
56
97
  end
@@ -1,4 +1,11 @@
1
1
  module OllamaChat::Parsing
2
+ # The parse_source method processes different types of input sources and
3
+ # converts them into a standardized text representation.
4
+ #
5
+ # @param source_io [IO] the input source to be parsed
6
+ #
7
+ # @return [ String, nil ] the parsed content as a string or nil if the
8
+ # content type is not supported
2
9
  def parse_source(source_io)
3
10
  case source_io&.content_type
4
11
  when 'text/html'
@@ -28,6 +35,16 @@ module OllamaChat::Parsing
28
35
  end
29
36
  end
30
37
 
38
+ # The parse_csv method processes CSV content from an input source and
39
+ # converts it into a formatted string representation.
40
+ # It iterates through each row of the CSV, skipping empty rows, and
41
+ # constructs a structured output where each row's fields are formatted with
42
+ # indentation and separated by newlines. The resulting string includes double
43
+ # newlines between rows for readability.
44
+ #
45
+ # @param source_io [ IO ] the input source containing CSV data
46
+ #
47
+ # @return [ String ] a formatted string representation of the CSV content
31
48
  def parse_csv(source_io)
32
49
  result = +''
33
50
  CSV.table(File.new(source_io), col_sep: ?,).each do |row|
@@ -40,6 +57,18 @@ module OllamaChat::Parsing
40
57
  result
41
58
  end
42
59
 
60
+ # The parse_rss method processes an RSS feed source and converts it into a
61
+ # formatted text representation.
62
+ # It extracts the channel title and iterates through each item in the feed to
63
+ # build a structured output.
64
+ # The method uses the RSS parser to handle the source input and formats the
65
+ # title, link, publication date, and description of each item into a readable
66
+ # text format with markdown-style headers and links.
67
+ #
68
+ # @param source_io [IO] the input stream containing the RSS feed data
69
+ #
70
+ # @return [String] a formatted string representation of the RSS feed with
71
+ # channel title and item details
43
72
  def parse_rss(source_io)
44
73
  feed = RSS::Parser.parse(source_io, false, false)
45
74
  title = <<~EOT
@@ -58,6 +87,18 @@ module OllamaChat::Parsing
58
87
  end
59
88
  end
60
89
 
90
+ # The parse_atom method processes an Atom feed from the provided IO source
91
+ # and converts it into a formatted text representation.
92
+ # It extracts the feed title and iterates through each item to build a
93
+ # structured output containing titles, links, and update dates.
94
+ #
95
+ # The content of each item is converted using reverse_markdown for better
96
+ # readability.
97
+ #
98
+ # @param source_io [IO] the input stream containing the Atom feed data
99
+ #
100
+ # @return [String] a formatted string representation of the Atom feed with
101
+ # title, items, links, update dates, and content
61
102
  def parse_atom(source_io)
62
103
  feed = RSS::Parser.parse(source_io, false, false)
63
104
  title = <<~EOT
@@ -76,11 +117,26 @@ module OllamaChat::Parsing
76
117
  end
77
118
  end
78
119
 
120
+ # The pdf_read method extracts text content from a PDF file by reading all
121
+ # pages.
122
+ #
123
+ # @param io [IO] the input stream containing the PDF data
124
+ #
125
+ # @return [String] the concatenated text content from all pages in the PDF
79
126
  def pdf_read(io)
80
127
  reader = PDF::Reader.new(io)
81
128
  reader.pages.inject(+'') { |result, page| result << page.text }
82
129
  end
83
130
 
131
+
132
+ # Reads and processes PDF content using Ghostscript for conversion
133
+ #
134
+ # This method takes an IO object containing PDF data, processes it through
135
+ # Ghostscript's pdfwrite device, and returns the processed PDF content.
136
+ # If Ghostscript is not available in the system path, it outputs an error message.
137
+ #
138
+ # @param io [IO] An IO object containing PDF data to be processed
139
+ # @return [String, nil] The processed PDF content as a string, or nil if processing fails
84
140
  def ps_read(io)
85
141
  gs = `which gs`.chomp
86
142
  if gs.present?
@@ -102,6 +158,15 @@ module OllamaChat::Parsing
102
158
  end
103
159
  end
104
160
 
161
+ # The reverse_markdown method converts HTML content into Markdown format.
162
+ #
163
+ # This method processes HTML input and transforms it into equivalent
164
+ # Markdown, using specific conversion options to ensure compatibility and
165
+ # formatting.
166
+ #
167
+ # @param html [ String ] the HTML string to be converted
168
+ #
169
+ # @return [ String ] the resulting Markdown formatted string
105
170
  def reverse_markdown(html)
106
171
  ReverseMarkdown.convert(
107
172
  html,
@@ -111,6 +176,17 @@ module OllamaChat::Parsing
111
176
  )
112
177
  end
113
178
 
179
+ # Parses content and processes embedded resources based on document policy
180
+ #
181
+ # This method analyzes input content for URLs, tags, and file references,
182
+ # fetches referenced resources, and processes them according to the current
183
+ # document policy. It supports different processing modes for various content
184
+ # types.
185
+ #
186
+ # @param content [String] The input content string to parse
187
+ # @param images [Array] An array to collect image references (will be cleared)
188
+ # @return [Array<String, Documentrix::Utils::Tags>] Returns an array containing
189
+ # the processed content string and tags object if any tags were found
114
190
  def parse_content(content, images)
115
191
  images.clear
116
192
  tags = Documentrix::Utils::Tags.new valid_tag: /\A#*([\w\]\[]+)/
@@ -1,4 +1,13 @@
1
1
  module OllamaChat::SourceFetching
2
+ # The http_options method prepares HTTP options for requests based on
3
+ # configuration settings.
4
+ # It determines whether SSL peer verification should be disabled for a given
5
+ # URL and whether a proxy should be used, then returns a hash of options.
6
+ #
7
+ # @param url [ String ] the URL for which HTTP options are being prepared
8
+ #
9
+ # @return [ Hash ] a hash containing HTTP options such as ssl_verify_peer and
10
+ # proxy settings
2
11
  def http_options(url)
3
12
  options = {}
4
13
  if ssl_no_verify = config.ssl_no_verify?
@@ -11,6 +20,13 @@ module OllamaChat::SourceFetching
11
20
  options
12
21
  end
13
22
 
23
+ # The fetch_source method retrieves content from various source types
24
+ # including commands, URLs, and file paths. It processes the source based on
25
+ # its type and yields a temporary file handle for further processing.
26
+ #
27
+ # @param source [ String ] the source identifier which can be a command, URL, or file path
28
+ #
29
+ # @yield [ tmp ]
14
30
  def fetch_source(source, &block)
15
31
  case source
16
32
  when %r(\A!(.*))
@@ -36,18 +52,38 @@ module OllamaChat::SourceFetching
36
52
  block.(tmp)
37
53
  end
38
54
  else
39
- raise "invalid source"
55
+ raise "invalid source #{source.inspect}"
40
56
  end
41
57
  rescue => e
42
58
  STDERR.puts "Cannot fetch source #{source.to_s.inspect}: #{e.class} #{e}\n#{e.backtrace * ?\n}"
43
59
  end
44
60
 
61
+
62
+ # Adds an image to the images collection from the given source IO and source
63
+ # identifier.
64
+ #
65
+ # This method takes an IO object containing image data and associates it with
66
+ # a source, creating an Ollama::Image instance and adding it to the images
67
+ # array.
68
+ #
69
+ # @param images [Array] The collection of images to which the new image will be added
70
+ # @param source_io [IO] The input stream containing the image data
71
+ # @param source [String, #to_s] The identifier or path for the source of the image
45
72
  def add_image(images, source_io, source)
46
73
  STDERR.puts "Adding #{source_io&.content_type} image #{source.to_s.inspect}."
47
74
  image = Ollama::Image.for_io(source_io, path: source.to_s)
48
75
  (images << image).uniq!
49
76
  end
50
77
 
78
+ # The import_source method processes and imports content from a given source,
79
+ # displaying information about the document type and returning a formatted
80
+ # string that indicates the import result along with the parsed content.
81
+ #
82
+ # @param source_io [ IO ] the input stream containing the document content
83
+ # @param source [ String ] the source identifier or path
84
+ #
85
+ # @return [ String ] a formatted message indicating the import result and the
86
+ # parsed content
51
87
  def import_source(source_io, source)
52
88
  source = source.to_s
53
89
  document_type = source_io&.content_type.full? { |ct| italic { ct } + ' ' }
@@ -56,6 +92,16 @@ module OllamaChat::SourceFetching
56
92
  "Imported #{source.inspect}:\n\n#{source_content}\n\n"
57
93
  end
58
94
 
95
+ # Imports content from the specified source and processes it.
96
+ #
97
+ # This method fetches content from a given source (command, URL, or file) and
98
+ # passes the resulting IO object to the import_source method for processing.
99
+ #
100
+ # @param source [String] The source identifier which can be a command, URL,
101
+ # or file path
102
+ #
103
+ # @return [String, nil] A formatted message indicating the import result and
104
+ # parsed content, # or nil if the operation fails
59
105
  def import(source)
60
106
  fetch_source(source) do |source_io|
61
107
  content = import_source(source_io, source) or return
@@ -64,6 +110,16 @@ module OllamaChat::SourceFetching
64
110
  end
65
111
  end
66
112
 
113
+
114
+ # Summarizes content from the given source IO and source identifier.
115
+ #
116
+ # This method takes an IO object containing document content and generates a
117
+ # summary based on the configured prompt template and word count.
118
+ #
119
+ # @param source_io [IO] The input stream containing the document content to summarize
120
+ # @param source [String, #to_s] The identifier or path for the source of the content
121
+ # @param words [Integer, nil] The target number of words for the summary (defaults to 100)
122
+ # @return [String, nil] The formatted summary message or nil if content is empty or cannot be processed
67
123
  def summarize_source(source_io, source, words: nil)
68
124
  STDOUT.puts "Summarizing #{italic { source_io&.content_type }} document #{source.to_s.inspect} now."
69
125
  words = words.to_i
@@ -73,6 +129,15 @@ module OllamaChat::SourceFetching
73
129
  config.prompts.summarize % { source_content:, words: }
74
130
  end
75
131
 
132
+
133
+ # Summarizes content from the specified source.
134
+ #
135
+ # This method fetches content from a given source (command, URL, or file) and
136
+ # generates a summary using the summarize_source method.
137
+ #
138
+ # @param source [String] The source identifier which can be a command, URL, or file path
139
+ # @param words [Integer, nil] The target number of words for the summary (defaults to 100)
140
+ # @return [String, nil] The formatted summary message or nil if the operation fails
76
141
  def summarize(source, words: nil)
77
142
  fetch_source(source) do |source_io|
78
143
  content = summarize_source(source_io, source, words:) or return
@@ -81,6 +146,19 @@ module OllamaChat::SourceFetching
81
146
  end
82
147
  end
83
148
 
149
+
150
+ # Embeds content from the given source IO and source identifier.
151
+ #
152
+ # This method processes document content by splitting it into chunks using
153
+ # various splitting strategies (Character, RecursiveCharacter, Semantic) and
154
+ # adds the chunks to a document store for embedding.
155
+ #
156
+ # @param source_io [IO] The input stream containing the document content to embed
157
+ # @param source [String, #to_s] The identifier or path for the source of the content
158
+ # @param count [Integer, nil] An optional counter for tracking processing order
159
+ #
160
+ # @return [Array, String, nil] The embedded chunks or processed content, or
161
+ # nil if embedding is disabled or fails
84
162
  def embed_source(source_io, source, count: nil)
85
163
  @embedding.on? or return parse_source(source_io)
86
164
  m = "Embedding #{italic { source_io&.content_type }} document #{source.to_s.inspect}."
@@ -127,6 +205,18 @@ module OllamaChat::SourceFetching
127
205
  @documents.add(inputs, source:, batch_size: config.embedding.batch_size?)
128
206
  end
129
207
 
208
+
209
+ # Embeds content from the specified source.
210
+ #
211
+ # This method fetches content from a given source (command, URL, or file) and
212
+ # processes it for embedding using the embed_source method. If embedding is
213
+ # disabled, it falls back to generating a summary instead.
214
+ #
215
+ # @param source [String] The source identifier which can be a command, URL,
216
+ # or file path
217
+ #
218
+ # @return [String, nil] The formatted embedding result or summary message, or
219
+ # nil if the operation fails
130
220
  def embed(source)
131
221
  if @embedding.on?
132
222
  STDOUT.puts "Now embedding #{source.to_s.inspect}."
@@ -6,28 +6,56 @@ module OllamaChat::Switches
6
6
  alias_method :on?, :value
7
7
  end
8
8
 
9
+ # The off? method returns true if the switch is in the off state, false
10
+ # otherwise.
11
+ #
12
+ # @return [ TrueClass, FalseClass ] indicating whether the switch is off
9
13
  def off?
10
14
  !on?
11
15
  end
12
16
 
17
+ # The show method outputs the current value of the message to standard
18
+ # output.
19
+ #
20
+ # @return [ void ]
13
21
  def show
14
22
  STDOUT.puts @msg[value]
15
23
  end
16
24
  end
17
25
 
18
26
  class Switch
19
- def initialize(name, msg:, config:)
20
- @value = [ false, true ].include?(config) ? config : !!config.send("#{name}?")
27
+ # The initialize method sets up the switch with a default value and
28
+ # message.
29
+ #
30
+ # @param msg [ Hash ] a hash containing true and false messages
31
+ # @param value [ Object ] the default state of the switch
32
+ #
33
+ # @return [ void ]
34
+ def initialize(msg:, value:)
35
+ @value = !!value
21
36
  @msg = msg
22
37
  end
23
38
 
39
+ # The value reader returns the current value of the attribute.
24
40
  attr_reader :value
25
41
 
42
+ # The set method assigns a boolean value to the instance variable @value
43
+ # and optionally displays it.
44
+ #
45
+ # @param value [ Object ] the value to be converted to a boolean and
46
+ # assigned
47
+ # @param show [ TrueClass, FalseClass ] determines whether to display the
48
+ # value after setting
26
49
  def set(value, show: false)
27
50
  @value = !!value
28
51
  show && self.show
29
52
  end
30
53
 
54
+ # The toggle method switches the current value of the instance variable and
55
+ # optionally displays it.
56
+ #
57
+ # @param show [ TrueClass, FalseClass ] determines whether to show the
58
+ # value after toggling
31
59
  def toggle(show: true)
32
60
  @value = !@value
33
61
  show && self.show
@@ -37,11 +65,17 @@ module OllamaChat::Switches
37
65
  end
38
66
 
39
67
  class CombinedSwitch
68
+ # The initialize method sets up the switch with a value and message.
69
+ #
70
+ # @param value [ Object ] the value to be stored
71
+ # @param msg [ Hash ] the message hash containing true and false keys
40
72
  def initialize(value:, msg:)
41
73
  @value = value
42
74
  @msg = msg
43
75
  end
44
76
 
77
+ # The value method returns the result of calling the stored proc with no
78
+ # arguments.
45
79
  def value
46
80
  @value.()
47
81
  end
@@ -49,26 +83,61 @@ module OllamaChat::Switches
49
83
  include CheckSwitch
50
84
  end
51
85
 
86
+ # The think method returns the current state of the stream switch.
87
+ #
88
+ # @return [ OllamaChat::Switches::Switch ] the stream switch instance
52
89
  attr_reader :stream
53
90
 
91
+ # The think method returns the current state of the thinking switch.
92
+ #
93
+ # @return [ OllamaChat::Switches::Switch ] the thinking switch instance
54
94
  attr_reader :think
55
95
 
96
+ # The markdown attribute reader returns the markdown switch object.
97
+ # The voice reader returns the voice switch instance.
98
+ #
99
+ # @return [ OllamaChat::Switches::Switch ] the markdown switch instance
56
100
  attr_reader :markdown
57
101
 
102
+ # The voice reader returns the voice switch instance.
103
+ #
104
+ # @return [ OllamaChat::Switches::Switch ] the voice switch instance
58
105
  attr_reader :voice
59
106
 
107
+ # The embedding attribute reader returns the embedding switch object.
108
+ #
109
+ # @return [ OllamaChat::Switches::CombinedSwitch ] the embedding switch
110
+ # instance
60
111
  attr_reader :embedding
61
112
 
113
+ # The embedding_enabled reader returns the embedding enabled switch instance.
114
+ #
115
+ # @return [ OllamaChat::Switches::Switch ] the embedding enabled switch
116
+ # instance
62
117
  attr_reader :embedding_enabled
63
118
 
119
+ # The embedding_paused method returns the current state of the embedding pause flag.
120
+ #
121
+ # @return [ OllamaChat::Switches::Switch ] the embedding pause flag switch instance
64
122
  attr_reader :embedding_paused
65
123
 
124
+ # The location method returns the current location setting.
125
+ #
126
+ # @return [ OllamaChat::Switches::Switch ] the location setting object
66
127
  attr_reader :location
67
128
 
129
+ # The setup_switches method initializes various switches for configuring the
130
+ # application's behavior.
131
+ #
132
+ # This method creates and configures multiple switch objects that control
133
+ # different aspects of the application, such as streaming, thinking, markdown
134
+ # output, voice output, embedding, and location settings.
135
+ #
136
+ # @param config [ ComplexConfig::Settings ] the configuration object
137
+ # containing settings for the switches
68
138
  def setup_switches(config)
69
139
  @stream = Switch.new(
70
- :stream,
71
- config:,
140
+ value: config.stream,
72
141
  msg: {
73
142
  true => "Streaming enabled.",
74
143
  false => "Streaming disabled.",
@@ -76,8 +145,7 @@ module OllamaChat::Switches
76
145
  )
77
146
 
78
147
  @think = Switch.new(
79
- :think,
80
- config:,
148
+ value: config.think,
81
149
  msg: {
82
150
  true => "Thinking enabled.",
83
151
  false => "Thinking disabled.",
@@ -85,8 +153,7 @@ module OllamaChat::Switches
85
153
  )
86
154
 
87
155
  @markdown = Switch.new(
88
- :markdown,
89
- config:,
156
+ value: config.markdown,
90
157
  msg: {
91
158
  true => "Using #{italic{'ANSI'}} markdown to output content.",
92
159
  false => "Using plaintext for outputting content.",
@@ -94,8 +161,7 @@ module OllamaChat::Switches
94
161
  )
95
162
 
96
163
  @voice = Switch.new(
97
- :stream,
98
- config: config.voice,
164
+ value: config.voice.enabled,
99
165
  msg: {
100
166
  true => "Voice output enabled.",
101
167
  false => "Voice output disabled.",
@@ -103,8 +169,7 @@ module OllamaChat::Switches
103
169
  )
104
170
 
105
171
  @embedding_enabled = Switch.new(
106
- :embedding_enabled,
107
- config:,
172
+ value: config.embedding.enabled,
108
173
  msg: {
109
174
  true => "Embedding enabled.",
110
175
  false => "Embedding disabled.",
@@ -112,8 +177,7 @@ module OllamaChat::Switches
112
177
  )
113
178
 
114
179
  @embedding_paused = Switch.new(
115
- :embedding_paused,
116
- config:,
180
+ value: config.embedding.paused,
117
181
  msg: {
118
182
  true => "Embedding paused.",
119
183
  false => "Embedding resumed.",
@@ -129,8 +193,7 @@ module OllamaChat::Switches
129
193
  )
130
194
 
131
195
  @location = Switch.new(
132
- :location,
133
- config: config.location.enabled,
196
+ value: config.location.enabled,
134
197
  msg: {
135
198
  true => "Location and localtime enabled.",
136
199
  false => "Location and localtime disabled.",