ollama_chat 0.0.84 → 0.0.86

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2439d1523f092997e86300083d46a0db7efcc3e2e6d4253c828ae83ae417043
4
- data.tar.gz: 3e946c28dc28d5b6eacd948437dbede5f7160cdad4dca205d2b9fc7f57a0f5fe
3
+ metadata.gz: ff96f5853a0c293512e72157a823fb8237bfba6b1e36b1cf17c486cd3594597d
4
+ data.tar.gz: bd23354a354c89d2526a64071a76801304e2e9ebe67e9a978f1e50d0a624c021
5
5
  SHA512:
6
- metadata.gz: 8e06a5f8362fe5760eb063eb810041449d1faeec408e40c6d806621814f148818e06e1799452c0357add7d723c512c52bc04aab768166bf8c73e8fa923ebc6d1
7
- data.tar.gz: 6194047eb8d4f3ef45b62df2d307e7f498e29b08566ea2061a73813ef1753a5554e41427f212b7381bd093b50806529ac2da255f02f35d0667dc62892984424f
6
+ metadata.gz: cea92ab75e86033f88e08bedc272e75d7151ee62eebba70328a17b7eaad6aba9d84dfcfe5e69e9757317cbb4e881e6ae9c5464b6070f4540f6bfe9d09cb19049
7
+ data.tar.gz: af5ec5db535c6baa88749a387ff3c6b08e593bb4a578f45851fa1d695c0a7fed387a9698e9e379c30561b357d529b5f77a2b26bbdfe1073d1c6bcfcc0f522945
data/CHANGES.md CHANGED
@@ -1,5 +1,71 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-04-02 v0.0.86
4
+
5
+ - Updated `play_persona_prompt` in `lib/ollama_chat/personae_management.rb` to
6
+ include “(no need to read the file)” in the roleplay prompt template string.
7
+ - Added `optional: true` to the `/links` command in `lib/ollama_chat/chat.rb`.
8
+ - Made the `edit` subcommand of `/revise` optional by adding `optional: true`
9
+ to its command definition in `lib/ollama_chat/chat.rb`.
10
+ - Added a `backup` subcommand for persona management:
11
+ - Updated the `:persona` command regex and completion options in
12
+ `lib/ollama_chat/chat.rb`.
13
+ - Added a case handler to invoke the new `backup_persona` method.
14
+ - Implemented `backup_persona` in `lib/ollama_chat/personae_management.rb`
15
+ with YARD documentation.
16
+ - Removed the redundant assignment `persona = persona` in `edit_persona`.
17
+ - Fixed the rescue exception class name in the `use_model` block of
18
+ `lib/ollama_chat/chat.rb`, changing from `OllamaChatError::UnknownModelError`
19
+ to `OllamaChat::UnknownModelError`.
20
+ - Ensured float division for duration calculations in `FollowChat` by
21
+ converting operands to float in the `eval_stats` method of
22
+ `lib/ollama_chat/follow_chat.rb`.
23
+ - Used `Pathname.new(file).expand_path.directory?` for tilde expansion in
24
+ directory checks in `lib/ollama_chat/parsing.rb`.
25
+ - Refactored command registration formatting in `lib/ollama_chat/chat.rb`.
26
+ - Added YARD documentation to the `OllamaChat::CommandConcern::Command` class
27
+ in `lib/ollama_chat/command_concern.rb`.
28
+ - Removed the deprecated `-d` flag from the `/input` command in
29
+ `lib/ollama_chat/chat.rb`.
30
+ - Removed tag support from `parse_content`:
31
+ - Updated `OllamaChat::Chat` to call `parse_content` without expecting a
32
+ `tags` array.
33
+ - Simplified handling of `@parse_content`.
34
+ - Removed tag recognition logic from `OllamaChat::Parsing`.
35
+ - Changed `parse_content` to return a single `String`.
36
+ - Deleted tag‑specific example from the spec.
37
+ - Updated the `file_context` tool description for accuracy.
38
+ - Added an interactive loop to enable/disable tools:
39
+ - Wrapped `enable_tool` and `disable_tool` in a `loop do` in
40
+ `lib/ollama_chat/tool_calling.rb`.
41
+ - Modified `select_tools` to place `[EXIT]` at the start.
42
+ - Handled user choice with `OllamaChat::Utils::Chooser.choose(select_tools)`
43
+ and exited on `[EXIT]` or `nil`.
44
+
45
+ ## 2026-03-29 v0.0.85
46
+
47
+ - Added `list` and `rename` subcommands to the `/collection` command, allowing
48
+ users to display available collections and rename them via the
49
+ `rename_collection` method in `lib/ollama_chat/dialog.rb`.
50
+ - Enhanced the `/collection` command to be optional; running `/collection`
51
+ without arguments now displays collection statistics by invoking the
52
+ `collection_stats` method.
53
+ - Updated `README.md` to reflect new command options and adjusted help text for
54
+ the `/collection` command.
55
+ - Modified tests in `spec/ollama_chat/chat_spec.rb` to accommodate new command
56
+ options and collection handling.
57
+ - Adjusted `regexp` and `complete` configurations in `lib/ollama_chat/chat.rb`
58
+ for the `/collection` command.
59
+ - Updated the `documentrix` dependency from **0.0.4** to **0.1.0**.
60
+ - Introduced progress feedback in `lib/ollama_chat/input_content.rb` within the
61
+ `provide_file_set_content` method, displaying `count/total` for batch
62
+ processing or just `count` for interactive mode.
63
+ - Optimized persona loading logic to skip setting a default persona if the
64
+ conversation already contains messages, while retaining fallbacks from
65
+ command-line options for new conversations.
66
+ - Fixed the warning condition in `OllamaChat::FollowChat` by correcting the
67
+ success check in `lib/ollama_chat/follow_chat.rb`.
68
+
3
69
  ## 2026-03-26 v0.0.84
4
70
 
5
71
  - Added `OllamaChat::Utils::ValueFormatter` with helper `format_bytes` in
data/README.md CHANGED
@@ -209,8 +209,10 @@ The following commands can be given inside the chat, if prefixed by a `/`:
209
209
  ├──────────────────┼────────────────────┼──────────────────┼──────────────────────────────────────────────────────────┤
210
210
  │ /load │ │ path │ load conversation messages │
211
211
  ├──────────────────┼────────────────────┼──────────────────┼──────────────────────────────────────────────────────────┤
212
- │ /collection │ change│ │ change (default) collection or clear
213
- │ │ clear│ │
212
+ │ /collection │ change │ │ display, clear (current), change, list, or rename
213
+ │ │ clear │ │ collection
214
+ │ │ list │ │ │
215
+ │ │ rename │ │ │
214
216
  ├──────────────────┼────────────────────┼──────────────────┼──────────────────────────────────────────────────────────┤
215
217
  │ /persona │ add │ │ manage and load/play personae for roleplay │
216
218
  │ │ delete │ │ │
data/Rakefile CHANGED
@@ -42,7 +42,7 @@ GemHadar do
42
42
 
43
43
  dependency 'excon', '~> 1.0'
44
44
  dependency 'ollama-ruby', '~> 1.21'
45
- dependency 'documentrix', '>= 0.0.4'
45
+ dependency 'documentrix', '>= 0.1.1'
46
46
  dependency 'unix_socks', '~> 0.3'
47
47
  dependency 'rss', '~> 0.3'
48
48
  dependency 'term-ansicolor', '~> 1.11'
@@ -296,7 +296,7 @@ class OllamaChat::Chat
296
296
  ) do
297
297
  begin
298
298
  use_model
299
- rescue OllamaChatError::UnknownModelError => e
299
+ rescue OllamaChat::UnknownModelError => e
300
300
  msg = "Caught #{e.class}: #{e}"
301
301
  log(:error, msg, warn: true)
302
302
  end
@@ -410,6 +410,7 @@ class OllamaChat::Chat
410
410
  name: :links,
411
411
  regexp: %r(^/links(?:\s+(clear))?$),
412
412
  complete: [ 'links', %w[ clear ] ],
413
+ optional: true,
413
414
  help: 'display (or clear) links used in the chat',
414
415
  ) do |subcommand|
415
416
  manage_links(subcommand)
@@ -420,6 +421,7 @@ class OllamaChat::Chat
420
421
  name: :revise,
421
422
  regexp: %r(^/revise(?:\s+(edit))?$),
422
423
  complete: [ 'revise', %w[ edit ] ],
424
+ optional: true,
423
425
  help: 'revise the last message (and/or edit the query)'
424
426
  ) do |subcommand|
425
427
  if content = messages.second_last&.content
@@ -479,11 +481,12 @@ class OllamaChat::Chat
479
481
 
480
482
  command(
481
483
  name: :collection,
482
- regexp: %r(^/collection(?:\s+(clear|change))?$),
483
- complete: [ 'collection', %w[ clear change ] ],
484
- help: 'change (default) collection or clear'
484
+ regexp: %r(^/collection(?:\s+(clear|change|list|rename))?$),
485
+ complete: [ 'collection', %w[ clear change list rename ] ],
486
+ optional: true,
487
+ help: 'display, clear (current), change, list, or rename collection'
485
488
  ) do |subcommand|
486
- case subcommand || 'change'
489
+ case subcommand
487
490
  when 'clear'
488
491
  loop do
489
492
  tags = @documents.tags.add('[EXIT]').add('[ALL]')
@@ -509,6 +512,14 @@ class OllamaChat::Chat
509
512
  end
510
513
  when 'change'
511
514
  choose_collection(@documents.collection)
515
+ when 'list'
516
+ current_collection = @documents.collection
517
+ puts @documents.collections.
518
+ map { |c| current_collection == c ? bold { c } : c }
519
+ when 'rename'
520
+ rename_collection(@documents.collection)
521
+ when nil
522
+ collection_stats
512
523
  end
513
524
  :next
514
525
  end
@@ -517,8 +528,8 @@ class OllamaChat::Chat
517
528
 
518
529
  command(
519
530
  name: :persona,
520
- regexp: %r(^/persona(?:\s+(add|delete|edit|file|info|list|load|play))?$),
521
- complete: [ 'persona', %w[ add delete edit file info list load play ] ],
531
+ regexp: %r(^/persona(?:\s+(add|delete|edit|backup|file|info|list|load|play))?$),
532
+ complete: [ 'persona', %w[ add delete edit backup file info list load play ] ],
522
533
  optional: true,
523
534
  help: 'manage and load/play personae for roleplay',
524
535
  ) do |subcommand|
@@ -544,6 +555,9 @@ class OllamaChat::Chat
544
555
  else
545
556
  :next
546
557
  end
558
+ when 'backup'
559
+ backup_persona
560
+ :next
547
561
  when 'file'
548
562
  if pathname = choose_filename('**/*.md')
549
563
  pathname.read
@@ -599,7 +613,7 @@ class OllamaChat::Chat
599
613
 
600
614
  command(
601
615
  name: :input,
602
- regexp: %r(^/input(?:\s+(path|summary|context|embedding)(?:\s*(?=\z))?)?((?:\s+-(?:[ad]|w\s*\d+))*)(?:\s+(pattern))?(?:\s+(.+))?$),
616
+ regexp: %r(^/input(?:\s+(path|summary|context|embedding)(?:\s*(?=\z))?)?((?:\s+-(?:[a]|w\s*\d+))*)(?:\s+(pattern))?(?:\s+(.+))?$),
603
617
  optional: true,
604
618
  complete: [ 'input', [ 'path', 'summary', 'context', 'embedding', '', ], [ 'pattern', '' ] ],
605
619
  options: '[-w|-a] [arg…]',
@@ -995,11 +1009,7 @@ class OllamaChat::Chat
995
1009
 
996
1010
  content = content.encode(invalid: :replace)
997
1011
 
998
- content, tags = if @parse_content
999
- parse_content(content, @images)
1000
- else
1001
- [ content, Documentrix::Utils::Tags.new(valid_tag: /\A#*([\w\]\[]+)/) ]
1002
- end
1012
+ @parse_content and content = parse_content(content, @images)
1003
1013
 
1004
1014
  runtime_info.on? && content and
1005
1015
  content << ?\n << {
@@ -31,8 +31,11 @@ module OllamaChat::CommandConcern
31
31
  # exists or if no block is given.
32
32
  def command(name:, regexp:, complete: nil, optional: false, options: nil, help: nil, &block)
33
33
  name = name.to_sym
34
- commands.key?(name) and raise ArgumentError, "command #{name} already registered!"
35
- commands[name] = Command.new(name:, regexp:, complete:, optional:, options:, help:, &block)
34
+ commands.key?(name) and
35
+ raise ArgumentError, "command #{name} already registered!"
36
+ commands[name] =Command.new(
37
+ name:, regexp:, complete:, optional:, options:, help:, &block
38
+ )
36
39
  end
37
40
 
38
41
  # Return an array of all available command completions.
@@ -83,6 +86,21 @@ module OllamaChat::CommandConcern
83
86
  delegate :help_message, to: self
84
87
  end
85
88
 
89
+ # Represents a registered command in the OllamaChat command DSL.
90
+ #
91
+ # A `Command` instance stores
92
+ # * the command name(s) (`@complete.first`),
93
+ # * the matching regular expression (`@regexp`),
94
+ # * optional completion hints (`@complete[1..]`),
95
+ # * help text (`@help`), and
96
+ # * the block that is executed when the command matches.
97
+ #
98
+ # It also exposes helpers for optionality (`optional?`),
99
+ # command names (`command_names`), arguments (`arguments`),
100
+ # and completions (`completions`).
101
+ #
102
+ # The `execute_if_match?` method performs a regexp match and, if
103
+ # successful, yields the execution context to the stored block.
86
104
  class Command
87
105
  # Create a new Command instance.
88
106
  #
@@ -135,6 +135,27 @@ module OllamaChat::Dialog
135
135
  info
136
136
  end
137
137
 
138
+ # Rename an existing collection to a new, user‑supplied name.
139
+ #
140
+ # This helper prompts the user to provide a new name for the collection
141
+ # identified by <code>current_collection</code>. It then renames the current
142
+ # collection to have the new_name and switches to it.
143
+ #
144
+ # @param current_collection [Symbol] the current collection name
145
+ def rename_collection(current_collection)
146
+ prompt = 'Rename collection %s to: ' % current_collection
147
+ if new_collection = ask?(prompt:).full?(:to_sym)
148
+ begin
149
+ @documents.rename_collection(new_collection)
150
+ STDOUT.puts "Renamed current collection #{current_collection} to #{new_collection}."
151
+ rescue
152
+ STDERR.puts "Renaming to #{new_collection} failed, it already exists."
153
+ end
154
+ else
155
+ STDOUT.puts "Renaming cancelled."
156
+ end
157
+ end
158
+
138
159
  # The change_system_prompt method allows the user to select or enter a new
139
160
  # system prompt for the chat session.
140
161
  # It provides an interactive chooser when multiple prompts match the given
@@ -185,7 +185,7 @@ class OllamaChat::FollowChat
185
185
  end
186
186
  warn =
187
187
  begin
188
- !!data.ask_and_send(:[], 'error') || data.ask_and_send(:[], 'success')
188
+ !!data.ask_and_send(:[], 'error') || data.ask_and_send(:[], 'success') == false
189
189
  rescue
190
190
  false
191
191
  end
@@ -348,8 +348,8 @@ class OllamaChat::FollowChat
348
348
  # the evaluation process including durations, counts, and rates, styled
349
349
  # with colors and formatting
350
350
  def eval_stats(response)
351
- eval_duration = response.eval_duration / 1e9
352
- prompt_eval_duration = response.prompt_eval_duration / 1e9
351
+ eval_duration = response.eval_duration.to_f / 1e9
352
+ prompt_eval_duration = response.prompt_eval_duration.to_f / 1e9
353
353
  stats_text = {
354
354
  eval_duration: Tins::Duration.new(eval_duration),
355
355
  eval_count: response.eval_count.to_i,
@@ -161,7 +161,16 @@ module OllamaChat::InputContent
161
161
  # @yield [filename] the block that processes each filename
162
162
  # @return [String] the concatenated result of the block applied to each file
163
163
  def provide_file_set_content(patterns, all: false, &block)
164
+ total = 0
165
+ all and file_set_each(patterns, all:) { total += 1 }
166
+ count = 0
164
167
  file_set_each(patterns, all:).each_with_object('') do |filename, result|
168
+ count += 1
169
+ if all
170
+ STDOUT.puts "Handling File (#{bold{count}}/#{bold{total}}):"
171
+ else
172
+ STDOUT.puts "Handling File (#{bold{count}}):"
173
+ end
165
174
  result << ("%s:\n\n%s\n\n" % [ filename, block.(filename) ])
166
175
  end.full?
167
176
  end
@@ -194,10 +194,6 @@ module OllamaChat::Parsing
194
194
  CONTENT_REGEXP = %r{
195
195
  (https?://\S+) # Match HTTP/HTTPS URLs
196
196
  | # OR
197
- (?<![a-zA-Z\d]) # Negative lookbehind: not part of a larger word
198
- \# # Literal # character (starts a tag)
199
- ([\w\]\[]+) # Tag content: alphanumeric, brackets, underscores
200
- | # OR
201
197
  (file://(?:[^\s#]+)) # Match file:// URLs
202
198
  | # OR
203
199
  "((?:\.\.|[~.]?)/(?:\\"|\\|[^"\\]+)+)" # Quoted file path with escaped " quotes
@@ -206,31 +202,27 @@ module OllamaChat::Parsing
206
202
  }x
207
203
  private_constant :CONTENT_REGEXP
208
204
 
209
- # Parses content and processes embedded resources based on document policy
205
+ # Parses a string for URLs, file refs, and image links, then returns
206
+ # the transformed content. Detects `http(s)` URLs, `file://` paths,
207
+ # quoted file paths, and collects any image URLs into the supplied
208
+ # `images` array.
210
209
  #
211
- # This method analyzes input content for URLs, tags, and file references,
212
- # fetches referenced resources, and processes them according to the current
213
- # document policy. It supports different processing modes for various content
214
- # types.
210
+ # @param content [String] the raw text to parse
211
+ # @param images [Array] mutable array that will be cleared
212
+ # then filled with discovered image URLs
215
213
  #
216
- # @param content [String] The input content string to parse
217
- # @param images [Array] An array to collect image references (will be cleared)
218
- # @return [Array<String, Documentrix::Utils::Tags>] Returns an array containing
219
- # the processed content string and tags object if any tags were found
214
+ # @return [String] the content after all supported transformations
215
+ # (URLs resolved, file refs expanded, image URLs collected)
220
216
  def parse_content(content, images)
221
217
  images.clear
222
- tags = Documentrix::Utils::Tags.new valid_tag: /\A#*([\w\]\[]+)/
223
218
  contents = [ content ]
224
- content.scan(CONTENT_REGEXP).each { |url, tag, file_url, quoted_file, file|
225
- if file && File.directory?(file)
219
+ content.scan(CONTENT_REGEXP).each { |url, file_url, quoted_file, file|
220
+ if file && Pathname.new(file).expand_path.directory?
226
221
  contents << generate_structure(file).to_json
227
222
  next
228
223
  end
229
224
  check_exist = false
230
225
  case
231
- when tag
232
- tags.add(tag)
233
- next
234
226
  when url
235
227
  links.add(url.to_s)
236
228
  source = url
@@ -271,7 +263,6 @@ module OllamaChat::Parsing
271
263
  end
272
264
  end
273
265
  }
274
- new_content = contents.select { _1.present? rescue nil }.compact * "\n\n"
275
- return new_content, (tags unless tags.empty?)
266
+ contents.select { _1.present? rescue nil }.compact * "\n\n"
276
267
  end
277
268
  end
@@ -40,7 +40,7 @@ module OllamaChat::PersonaeManagement
40
40
  # playing the persona file if it exists.
41
41
  def setup_persona_from_opts
42
42
  @default_persona and return
43
- @opts[?c] and return
43
+ @messages.size > 0 and return
44
44
  if persona = @opts[?p].full? { Pathname.new(_1) }
45
45
  if persona.extname == '.md'
46
46
  pathname = persona
@@ -198,7 +198,6 @@ module OllamaChat::PersonaeManagement
198
198
  # old content, and returns the result after editing.
199
199
  def edit_persona
200
200
  if persona = choose_persona
201
- persona = persona
202
201
  pathname = personae_directory + persona
203
202
  old_content = File.read(pathname)
204
203
  if edit_file(pathname)
@@ -211,6 +210,21 @@ module OllamaChat::PersonaeManagement
211
210
  end
212
211
  end
213
212
 
213
+ # Backs up the content of a selected persona file.
214
+ #
215
+ # Prompts the user to select a persona from the available list. If a persona
216
+ # is selected, its current content is read and saved to a designated backup
217
+ # location using `File.write`. This ensures a safe copy is preserved before
218
+ # any modifications are made to the original file.
219
+ def backup_persona
220
+ if persona = choose_persona
221
+ pathname = personae_directory + persona
222
+ old_content = File.read(pathname)
223
+ File.write(persona_backup_pathname(persona), old_content)
224
+ STDOUT.puts "Wrote backup of #{persona.to_s} to #{pathname.to_s.inspect}."
225
+ end
226
+ end
227
+
214
228
  # Displays detailed information about a selected persona.
215
229
  #
216
230
  # Shows the persona's profile using kramdown formatting with ansi parsing.
@@ -325,7 +339,7 @@ module OllamaChat::PersonaeManagement
325
339
  # @return [String] Formatted roleplay prompt
326
340
  def play_persona_prompt(persona:, persona_profile:)
327
341
  persona_name = persona.basename.sub_ext('')
328
- "Roleplay as persona %{persona_name} loaded from %{persona}\n\n%{persona_profile}" % {
342
+ "Roleplay as persona %{persona_name} (no nead to read the file) loaded from %{persona}\n\n%{persona_profile}" % {
329
343
  persona_name:, persona:, persona_profile:
330
344
  }
331
345
  end
@@ -119,16 +119,18 @@ module OllamaChat::ToolCalling
119
119
  # tools and handles the user's selection by adding the chosen tool to the
120
120
  # list of enabled tools and sorting the list.
121
121
  def enable_tool
122
- select_tools = configured_tools - enabled_tools
123
- select_tools += [ '[EXIT]' ]
124
- case chosen = OllamaChat::Utils::Chooser.choose(select_tools)
125
- when '[EXIT]', nil
126
- STDOUT.puts "Exiting chooser."
127
- return
128
- when *select_tools
129
- enabled_tools << chosen
130
- enabled_tools.sort!
131
- puts "Enabled tool %s" % bold { chosen }
122
+ loop do
123
+ select_tools = configured_tools - enabled_tools
124
+ select_tools = [ '[EXIT]' ] + select_tools
125
+ case chosen = OllamaChat::Utils::Chooser.choose(select_tools)
126
+ when '[EXIT]', nil
127
+ STDOUT.puts "Exiting chooser."
128
+ return
129
+ when *select_tools
130
+ enabled_tools << chosen
131
+ enabled_tools.sort!
132
+ puts "Enabled tool %s" % bold { chosen }
133
+ end
132
134
  end
133
135
  end
134
136
 
@@ -141,15 +143,17 @@ module OllamaChat::ToolCalling
141
143
  # the chosen tool from the list of enabled tools and sorting the list
142
144
  # afterwards.
143
145
  def disable_tool
144
- select_tools = enabled_tools
145
- select_tools += [ '[EXIT]' ]
146
- case chosen = OllamaChat::Utils::Chooser.choose(select_tools)
147
- when '[EXIT]', nil
148
- STDOUT.puts "Exiting chooser."
149
- return
150
- when *select_tools
151
- enabled_tools.delete chosen
152
- puts "Disabled tool %s" % bold { chosen }
146
+ loop do
147
+ select_tools = enabled_tools
148
+ select_tools = [ '[EXIT]' ] + select_tools
149
+ case chosen = OllamaChat::Utils::Chooser.choose(select_tools)
150
+ when '[EXIT]', nil
151
+ STDOUT.puts "Exiting chooser."
152
+ return
153
+ when *select_tools
154
+ enabled_tools.delete chosen
155
+ puts "Disabled tool %s" % bold { chosen }
156
+ end
153
157
  end
154
158
  end
155
159
 
@@ -27,9 +27,10 @@ class OllamaChat::Tools::FileContext
27
27
  function: Tool::Function.new(
28
28
  name:,
29
29
  description: <<~EOT,
30
- Semantic file snapshot Gathers AST‑style info (e.g., classes,
31
- methods) from all matching files (pattern) in directory. Useful for
32
- LLMs to reason about code structure
30
+ Reads all files matching a glob pattern like `lib/**/*.rb` and
31
+ returns their contents plus metadata. Provides file size, line count,
32
+ and tags. Useful for building codebase context to send to language
33
+ models or documenting project structure.
33
34
  EOT
34
35
  parameters: Tool::Function::Parameters.new(
35
36
  type: 'object',
@@ -1,6 +1,6 @@
1
1
  module OllamaChat
2
2
  # OllamaChat version
3
- VERSION = '0.0.84'
3
+ VERSION = '0.0.86'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/ollama_chat.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: ollama_chat 0.0.84 ruby lib
2
+ # stub: ollama_chat 0.0.86 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ollama_chat".freeze
6
- s.version = "0.0.84".freeze
6
+ s.version = "0.0.86".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
35
35
  s.add_development_dependency(%q<utils>.freeze, [">= 0".freeze])
36
36
  s.add_runtime_dependency(%q<excon>.freeze, ["~> 1.0".freeze])
37
37
  s.add_runtime_dependency(%q<ollama-ruby>.freeze, ["~> 1.21".freeze])
38
- s.add_runtime_dependency(%q<documentrix>.freeze, [">= 0.0.4".freeze])
38
+ s.add_runtime_dependency(%q<documentrix>.freeze, [">= 0.1.1".freeze])
39
39
  s.add_runtime_dependency(%q<unix_socks>.freeze, ["~> 0.3".freeze])
40
40
  s.add_runtime_dependency(%q<rss>.freeze, ["~> 0.3".freeze])
41
41
  s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.11".freeze])
@@ -1,6 +1,10 @@
1
1
  describe OllamaChat::Chat, protect_env: true do
2
+ let :collection do
3
+ "test-#{Random.hex}"
4
+ end
5
+
2
6
  let :argv do
3
- chat_default_config(%w[ -C test ])
7
+ chat_default_config(%w[ -C ] << collection)
4
8
  end
5
9
 
6
10
  before do
@@ -153,6 +157,10 @@ describe OllamaChat::Chat, protect_env: true do
153
157
  expect(chat).to receive(:info)
154
158
  expect(STDOUT).to receive(:puts).with(/./)
155
159
  expect(chat.handle_input("/collection change")).to eq :next
160
+ expect(STDOUT).to receive(:puts).with(array_including(:default))
161
+ expect(chat.handle_input("/collection list")).to eq :next
162
+ expect(chat).to receive(:rename_collection).with(collection.to_sym)
163
+ expect(chat.handle_input("/collection rename")).to eq :next
156
164
  end
157
165
 
158
166
  it 'returns :next when input is "/info"' do
@@ -358,7 +366,7 @@ describe OllamaChat::Chat, protect_env: true do
358
366
  connect_to_ollama_server(instantiate: false)
359
367
 
360
368
  let :argv do
361
- chat_default_config(%w[ -C test -c ] << asset('conversation.json'))
369
+ chat_default_config(%w[ -C ] << collection << '-c' << asset('conversation.json'))
362
370
  end
363
371
 
364
372
  it 'dispays the last exchange of the converstation' do
@@ -396,7 +404,7 @@ describe OllamaChat::Chat, protect_env: true do
396
404
  connect_to_ollama_server(instantiate: false)
397
405
 
398
406
  let :argv do
399
- chat_default_config(%w[ -C test -D ] << asset('example.html'))
407
+ chat_default_config(%w[ -C ] << collection << '-D' << asset('example.html'))
400
408
  end
401
409
 
402
410
  it 'Adds documents passed to app via -D option' do
@@ -421,7 +429,7 @@ describe OllamaChat::Chat, protect_env: true do
421
429
  it 'can display collection_stats' do
422
430
  chat
423
431
  expect(STDOUT).to receive(:puts).with(
424
- "Current Collection\n Name: \e[1mtest\e[0m\n #Embeddings: 0\n #Tags: 0\n Tags: \n"
432
+ "Current Collection\n Name: \e[1m#{collection}\e[0m\n #Embeddings: 0\n #Tags: 0\n Tags: \n"
425
433
  )
426
434
  expect(chat.collection_stats).to be_nil
427
435
  end
@@ -128,12 +128,6 @@ describe OllamaChat::Parsing do
128
128
  end
129
129
 
130
130
  describe '#parse_content' do
131
- it 'can parse tags' do
132
- content, tags = chat.parse_content("see #foobar …", [])
133
- expect(content).to eq 'see #foobar …'
134
- expect(tags).to include('foobar')
135
- end
136
-
137
131
  it 'can parse https URLs' do
138
132
  stub_request(:get, "https://www.example.com/foo.html").
139
133
  with(headers: { 'Host' => 'www.example.com' }).
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ollama_chat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.84
4
+ version: 0.0.86
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -169,14 +169,14 @@ dependencies:
169
169
  requirements:
170
170
  - - ">="
171
171
  - !ruby/object:Gem::Version
172
- version: 0.0.4
172
+ version: 0.1.1
173
173
  type: :runtime
174
174
  prerelease: false
175
175
  version_requirements: !ruby/object:Gem::Requirement
176
176
  requirements:
177
177
  - - ">="
178
178
  - !ruby/object:Gem::Version
179
- version: 0.0.4
179
+ version: 0.1.1
180
180
  - !ruby/object:Gem::Dependency
181
181
  name: unix_socks
182
182
  requirement: !ruby/object:Gem::Requirement