ollama_chat 0.0.82 → 0.0.83

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: 4dfcb462fdb59e2b4cf31ef8d489627982e71c88cfc9dea8c89597607311e95d
4
- data.tar.gz: 1fed1ad543d810ddf0b54b5390b8a031cf3108bd67d56a9a91b5917fc2cdd219
3
+ metadata.gz: 8947d6cdb437ce85afb32cb689bad1b16de54c2afb35da9f0eac7b1f1fff19df
4
+ data.tar.gz: 3a03448c69d3f8883e11d5de11e9f44c455a4a8e95e2d93593d945dc99a0be63
5
5
  SHA512:
6
- metadata.gz: fe1384443f22e5890a784be50a632c9a4d15e8fbf72f0084acf99016aa46a741320af818a72d3797007bced8f0f47155001a12e0103be3ac35f2fb6beba8db6d
7
- data.tar.gz: e79cd80f16e97778f6e61451b7aefbbfdf44a1a08cdce5029a21e050f78461fcf11e198ae04e9e0845d2ed9426057c5616333a09bc9d8eaf391be7a3b8c4d290
6
+ metadata.gz: 02e28130adb2881c44ea053035b5b39eb43025bf0e761063e6442a031b8b8acd88fe588850438ff0ae3c9fcf039ca4cff32bcb5abae4bcca4a349852a217580b
7
+ data.tar.gz: 1055061e111fff2384020505b467b60ab30facc7fbf5733856061adc6834401a5414ba28a6716452b5b5fe2bb8ec5a77d54fc81d2e3ed065f0b9568847ce326c
data/CHANGES.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-03-24 v0.0.83
4
+
5
+ - Added timeout support to `Dialog#confirm?`: introduced optional `timeout:`
6
+ and `default:` parameters, injected `IO.select` logic to respect the supplied
7
+ timeout and return the `default` when timed out, and updated YARD comments to
8
+ document the new parameters and return behavior.
9
+ - Normalized namespaced tool calls in `OllamaChat`: updated
10
+ `lib/ollama_chat/follow_chat.rb` to extract the basename from `name` when it
11
+ contains a slash, added a warning log `@chat.log(:warn, msg)` to inform users
12
+ when a namespaced tool call is corrected, and adjusted the `name` variable so
13
+ that `@chat.tool_configured?(name)` and subsequent logic use the corrected
14
+ tool name.
15
+ - Updated `OllamaChat::Dialog#choose_collection` to convert
16
+ `@documents.collections` to an array before concatenation, ensuring
17
+ consistent behavior when collections are not already arrays (e.g., NULL
18
+ objects).
19
+
3
20
  ## 2026-03-21 v0.0.82
4
21
 
5
22
  - Add a `before` block setting `OC::OLLAMA::CHAT::TOOLS::CTAGS_TOOL` to `ctags`
@@ -27,15 +27,31 @@ module OllamaChat::Dialog
27
27
  # from the user in raw mode, then returns that character. This is best used
28
28
  # for confirmation prompts.
29
29
  #
30
- # @param prompt [ String ] the prompt to display to the user.
31
- # @return [ String ] the character entered by the user.
32
- def confirm?(prompt:)
30
+ # @param prompt [String] the prompt to display to the user
31
+ # @param timeout [Integer, nil] optional timeout in seconds; if nil, the
32
+ # method blocks until input, if 0 the method immediatly returns the default
33
+ # value.
34
+ # @param default [Object, nil] value returned when the timeout expires
35
+ # (defaults to `nil`)
36
+ #
37
+ # @return [Object] the character entered by the user, or the `default` value
38
+ # if a timeout occurs
39
+ def confirm?(prompt:, timeout: nil, default: nil)
40
+ return default if timeout&.zero?
41
+ if prompt.include?('%s')
42
+ prompt = prompt % (timeout ? ('timeout in %us' % timeout) : 'no timeout')
43
+ end
33
44
  print prompt
34
45
  system 'stty raw'
35
- c = STDIN.getc
46
+ c = if timeout
47
+ ready = IO.select([ STDIN ], nil, nil, timeout)
48
+ ready ? STDIN.getc : nil
49
+ else
50
+ STDIN.getc
51
+ end
36
52
  system 'stty cooked'
37
53
  puts
38
- c
54
+ c || default
39
55
  end
40
56
 
41
57
  private
@@ -78,7 +94,7 @@ module OllamaChat::Dialog
78
94
  #
79
95
  # @param current_collection [ String, nil ] the name of the currently active collection
80
96
  def choose_collection(current_collection)
81
- collections = [ current_collection ] + @documents.collections
97
+ collections = [ current_collection ] + @documents.collections.to_a
82
98
  collections = collections.compact.map(&:to_s).uniq.sort
83
99
  collections.unshift('[EXIT]').unshift('[NEW]')
84
100
  collection = OllamaChat::Utils::Chooser.choose(collections) || current_collection
@@ -100,6 +100,12 @@ class OllamaChat::FollowChat
100
100
 
101
101
  response.message.tool_calls.each do |tool_call|
102
102
  name = tool_call.function.name
103
+ if name =~ %r(/)
104
+ new_name = File.basename(name.to_s)
105
+ msg = "Received namespaced tool call for #{name}, correcting to #{new_name}"
106
+ @chat.log(:warn, msg)
107
+ name = new_name
108
+ end
103
109
  unless @chat.tool_configured?(name)
104
110
  msg = "Error: Unconfigured tool named %s ignored => Skip.\n" % name
105
111
  @chat.tool_call_results[name] = msg
@@ -178,9 +184,12 @@ class OllamaChat::FollowChat
178
184
 
179
185
  if tools_used.full?
180
186
  infobar.reset
181
- puts "🔧 Tool functions returned result:",
182
- tools_used.to_yaml.sub(/\A---\s*\n/, '').gsub(/^/, ' '), ""
183
- @chat.confirm?(prompt: '⏎ Press any key to continue. ')
187
+ tools_used.each do |name, info|
188
+ puts "🔧 Tool functions #{name} returned result:",
189
+ info.to_yaml.sub(/\A---\s*\n/, '').gsub(/^/, ' '), ""
190
+ timeout = @chat.tool_function(name).result_display_timeout?
191
+ @chat.confirm?(prompt: '⏎ Press any key to continue (%s). ', timeout:)
192
+ end
184
193
  end
185
194
  end
186
195
 
@@ -156,34 +156,43 @@ tools:
156
156
  enabled: true
157
157
  functions:
158
158
  get_current_weather:
159
+ result_display_timeout: 3
159
160
  url: "https://api.pirateweather.net/forecast/KeyInHeader/%{lat},%{lon}?units=%{units}"
160
161
  default: false
161
162
  get_cve:
163
+ result_display_timeout: 3
162
164
  url: 'https://cveawg.mitre.org/api/cve/%{cve_id}'
163
165
  default: true
164
166
  get_endoflife:
167
+ result_display_timeout: 3
165
168
  url: "https://endoflife.date/api/v1/products/%{product}"
166
169
  default: false
167
170
  get_time:
171
+ result_display_timeout: 3
168
172
  default: true
169
173
  get_location:
174
+ result_display_timeout: 3
170
175
  default: true
171
176
  file_context:
172
177
  default: false
173
178
  require_confirmation: false
179
+ result_display_timeout: 3
174
180
  allowed:
175
181
  - './spec'
176
182
  directory_structure:
177
183
  default: true
178
184
  require_confirmation: false
185
+ result_display_timeout: 3
179
186
  exclude:
180
187
  - corpus
181
188
  - pkg
182
189
  execute_grep:
183
190
  default: true
191
+ result_display_timeout: 3
184
192
  cmd: |
185
193
  grep #{'-i' if ignore_case} -m #{max_results} -r #{before.full? { "-B %u " % it }}#{after.full? { "-A %u " % it }}#{context.full? { "-C %u " % it }}#{pattern} #{path}
186
194
  browse:
195
+ result_display_timeout: 3
187
196
  default: true
188
197
  write_file:
189
198
  default: true
@@ -193,6 +202,7 @@ tools:
193
202
  read_file:
194
203
  default: true
195
204
  require_confirmation: false
205
+ result_display_timeout: 3
196
206
  allowed:
197
207
  - './tmp'
198
208
  - './lib'
@@ -200,42 +210,54 @@ tools:
200
210
  search_web:
201
211
  default: true
202
212
  require_confirmation: true
213
+ result_display_timeout: 3
203
214
  max_results: 25
204
215
  get_url:
205
216
  default: true
206
217
  require_confirmation: true
218
+ result_display_timeout: 3
207
219
  schemes:
208
220
  - http
209
221
  - https
210
222
  gem_path_lookup:
223
+ result_display_timeout: 3
211
224
  default: true
212
225
  open_file_in_editor:
213
226
  default: true
214
227
  require_confirmation: true
228
+ result_display_timeout: 0
215
229
  run_tests:
216
230
  require_confirmation: true
231
+ result_display_timeout: 3
217
232
  default: true
218
233
  allowed:
219
234
  - "./spec"
220
235
  - "./test"
221
236
  - "./tests"
222
237
  get_jira_issue:
238
+ result_display_timeout: 3
223
239
  default: false
224
240
  get_rfc:
225
241
  url: "https://www.rfc-editor.org/rfc/rfc%{rfc_id}.txt"
242
+ result_display_timeout: 3
226
243
  default: true
227
244
  generate_password:
228
245
  default: true
229
246
  copy_to_clipboard:
247
+ result_display_timeout: 3
230
248
  default: true
231
249
  paste_from_clipboard:
250
+ result_display_timeout: 3
232
251
  default: true
233
252
  paste_into_editor:
253
+ result_display_timeout: 3
234
254
  require_confirmation: true
235
255
  default: true
236
256
  execute_ri:
257
+ result_display_timeout: 3
237
258
  default: true
238
259
  resolve_tag:
260
+ result_display_timeout: 3
239
261
  default: true
240
262
  patch_file:
241
263
  default: true
@@ -1,6 +1,6 @@
1
1
  module OllamaChat
2
2
  # OllamaChat version
3
- VERSION = '0.0.82'
3
+ VERSION = '0.0.83'
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.82 ruby lib
2
+ # stub: ollama_chat 0.0.83 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ollama_chat".freeze
6
- s.version = "0.0.82".freeze
6
+ s.version = "0.0.83".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]
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.82
4
+ version: 0.0.83
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank