ollama_chat 0.0.75 → 0.0.76
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 +4 -4
- data/.utilsrc +10 -0
- data/CHANGES.md +50 -1
- data/lib/ollama_chat/chat.rb +35 -16
- data/lib/ollama_chat/information.rb +9 -0
- data/lib/ollama_chat/location_handling.rb +8 -0
- data/lib/ollama_chat/message_list.rb +5 -33
- data/lib/ollama_chat/ollama_chat_config/default_config.yml +2 -0
- data/lib/ollama_chat/personae_management.rb +16 -4
- data/lib/ollama_chat/tools/copy_to_clipboard.rb +2 -2
- data/lib/ollama_chat/tools/gem_path_lookup.rb +10 -10
- data/lib/ollama_chat/tools/generate_password.rb +1 -1
- data/lib/ollama_chat/tools/get_endoflife.rb +2 -2
- data/lib/ollama_chat/tools/get_rfc.rb +1 -1
- data/lib/ollama_chat/tools/insert_into_editor.rb +2 -2
- data/lib/ollama_chat/tools/open_file_in_editor.rb +6 -6
- data/lib/ollama_chat/tools/paste_from_clipboard.rb +2 -2
- data/lib/ollama_chat/tools/search_web.rb +1 -1
- data/lib/ollama_chat/version.rb +1 -1
- data/lib/ollama_chat/web_searching.rb +1 -1
- data/ollama_chat.gemspec +2 -2
- data/spec/ollama_chat/message_list_spec.rb +0 -29
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2fd2a7be9e054baac6b811b1a30fff33839905d39b4784d8aba2bbd6c5f3538
|
|
4
|
+
data.tar.gz: f1ff0f8a94cc8c55f43928a7e09153a92cfa4b8b0b890f1b52a7511c7fb18195
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fef0b8733d62c5769b4675f769a30cddec686806347b04325b7d0ec8d65c7e546e70d1829ebf423240c32683c07afd124770def3305556e395f174eb0a030c6e
|
|
7
|
+
data.tar.gz: e14e370d2391fa9d2e90b70831c389ff3edcd86b89f7cad55586125c12675bb65ab5b16eab14029f918c7478e54b7e31b1ede609110c64391b8a6376939620d4
|
data/.utilsrc
CHANGED
|
@@ -33,15 +33,25 @@ code_indexer do
|
|
|
33
33
|
verbose false
|
|
34
34
|
|
|
35
35
|
gems = %w[
|
|
36
|
+
all_images
|
|
36
37
|
amatch
|
|
37
38
|
base64
|
|
38
39
|
bigdecimal
|
|
39
40
|
complex_config
|
|
41
|
+
const_conf
|
|
42
|
+
context_spook
|
|
43
|
+
csv
|
|
40
44
|
date
|
|
41
45
|
documentrix
|
|
42
46
|
excon
|
|
47
|
+
fileutils
|
|
48
|
+
gem_hadar
|
|
49
|
+
infobar
|
|
50
|
+
irb
|
|
43
51
|
json
|
|
52
|
+
kramdown
|
|
44
53
|
kramdown-ansi
|
|
54
|
+
kramdown-parser-gfm
|
|
45
55
|
mize
|
|
46
56
|
more_math
|
|
47
57
|
ollama-ruby
|
data/CHANGES.md
CHANGED
|
@@ -1,7 +1,56 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
-
## 2026-03-
|
|
3
|
+
## 2026-03-09 v0.0.76
|
|
4
|
+
|
|
5
|
+
- Added `client:` and `current_directory:` keys to `runtime_info_values` in
|
|
6
|
+
`chat.rb`.
|
|
7
|
+
- Implemented `#client` method returning `"progname **0.0.75**"` in
|
|
8
|
+
`information.rb`.
|
|
9
|
+
- Introduced helper `location_description?` in `location_handling.rb`.
|
|
10
|
+
- Simplified `MessageList#to_ary` to return a duplicate of the internal array,
|
|
11
|
+
removing automatic system prompt + location injection.
|
|
12
|
+
- Updated default config placeholders for `%{client}` and
|
|
13
|
+
`%{current_directory}` in `default_config.yml`.
|
|
14
|
+
- Adjusted web searching logic to use `location_description?` instead of
|
|
15
|
+
deprecated methods.
|
|
16
|
+
- Removed tests that expected location‑augmented system prompts from
|
|
17
|
+
`spec/ollama_chat/message_list_spec.rb`.
|
|
18
|
+
- Standardized JSON output formatting across tools: aligned JSON keys, added
|
|
19
|
+
spaces after commas, and added trailing commas in tool responses such as
|
|
20
|
+
`copy_to_clipboard`, `gem_path_lookup`, `generate_password`, `get_endoflife`,
|
|
21
|
+
`get_rfc`, `insert_into_editor`, `open_file_in_editor`,
|
|
22
|
+
`paste_from_clipboard`, and `search_web`.
|
|
23
|
+
- Added trailing commas to JSON objects for consistency and easier future
|
|
24
|
+
edits.
|
|
25
|
+
- Standardized error field formatting, ensuring each error block includes a
|
|
26
|
+
space after the colon and a trailing comma where appropriate.
|
|
27
|
+
- Added helper `disable_content_parsing` in `chat.rb` that sets `@parse_content
|
|
28
|
+
= false`.
|
|
29
|
+
- Refactored command handlers to call `disable_content_parsing` instead of
|
|
30
|
+
assigning directly to `@parse_content`.
|
|
31
|
+
- Updated persona setup logic so that a returned persona result triggers
|
|
32
|
+
`disable_content_parsing`; otherwise parsing is enabled with
|
|
33
|
+
`enable_command_completion`.
|
|
34
|
+
- Added explanatory comments around the new helper for clarity.
|
|
35
|
+
- Improved clean flow: captured return value of `clean` and set `@parse_content
|
|
36
|
+
= true` when a persona profile is returned.
|
|
37
|
+
- Replaced old flag `@persona_setup` with `@default_persona`; ensured it
|
|
38
|
+
defaults to `:none` in an `ensure` block after setup.
|
|
39
|
+
- Added new method `reload_default_persona` that prompts for confirmation
|
|
40
|
+
before reloading the default persona file if one exists.
|
|
41
|
+
- Modified `clean(what)` to return the result of `reload_default_persona`,
|
|
42
|
+
enabling the caller to react to a reload.
|
|
43
|
+
- Adjusted `/clear` command handling in the chat loop to use the returned value
|
|
44
|
+
from `clean` and only proceed when nothing is returned.
|
|
45
|
+
- Renamed local variable `runtime_info` to `runtime_info_values` in `chat.rb`
|
|
46
|
+
for clarity.
|
|
47
|
+
- Updated runtime info prompt interpolation to use `runtime_info_values`
|
|
48
|
+
instead of `runtime_info`.
|
|
49
|
+
- Updated `/.utilsrc` by adding gems to the `code_indexer` configuration:
|
|
50
|
+
`all_images`, `const_conf`, `context_spook`, `csv`, `fileutils`, `gem_hadar`,
|
|
51
|
+
`infobar`, `irb`, `kramdown`, and `kramdown-parser-gfm`.
|
|
4
52
|
|
|
53
|
+
## 2026-03-08 v0.0.75
|
|
5
54
|
|
|
6
55
|
- Added runtime reporting of tool allowed paths by introducing
|
|
7
56
|
`tool_paths_allowed` method and including it in chat output, updating config
|
data/lib/ollama_chat/chat.rb
CHANGED
|
@@ -192,6 +192,15 @@ class OllamaChat::Chat
|
|
|
192
192
|
@links ||= Set.new
|
|
193
193
|
end
|
|
194
194
|
|
|
195
|
+
# The disable_content_parsing method turns off content parsing by setting
|
|
196
|
+
# @parse_content to false.
|
|
197
|
+
#
|
|
198
|
+
# This prevents automatic parsing of user input content during chat
|
|
199
|
+
# processing.
|
|
200
|
+
def disable_content_parsing
|
|
201
|
+
@parse_content = false
|
|
202
|
+
end
|
|
203
|
+
|
|
195
204
|
# Handles user input commands and processes chat interactions.
|
|
196
205
|
#
|
|
197
206
|
# @param content [String] The input content to process
|
|
@@ -208,7 +217,7 @@ class OllamaChat::Chat
|
|
|
208
217
|
copy_to_clipboard
|
|
209
218
|
:next
|
|
210
219
|
when %r(^/paste$)
|
|
211
|
-
|
|
220
|
+
disable_content_parsing
|
|
212
221
|
paste_from_clipboard
|
|
213
222
|
when %r(^/markdown$)
|
|
214
223
|
markdown.toggle
|
|
@@ -238,8 +247,12 @@ class OllamaChat::Chat
|
|
|
238
247
|
messages.show_last(n)
|
|
239
248
|
:next
|
|
240
249
|
when %r(^/clear(?:\s+(messages|links|history|tags|all))?$)
|
|
241
|
-
clean($1)
|
|
242
|
-
|
|
250
|
+
if result = clean($1)
|
|
251
|
+
disable_content_parsing
|
|
252
|
+
content = result
|
|
253
|
+
else
|
|
254
|
+
:next
|
|
255
|
+
end
|
|
243
256
|
when %r(^/clobber$)
|
|
244
257
|
clean('all')
|
|
245
258
|
:next
|
|
@@ -275,7 +288,7 @@ class OllamaChat::Chat
|
|
|
275
288
|
STDOUT.puts "Not enough messages in this conversation."
|
|
276
289
|
return :redo
|
|
277
290
|
end
|
|
278
|
-
|
|
291
|
+
disable_content_parsing
|
|
279
292
|
content
|
|
280
293
|
when %r(^/collection(?:\s+(clear|change))?$)
|
|
281
294
|
case $1 || 'change'
|
|
@@ -319,30 +332,30 @@ class OllamaChat::Chat
|
|
|
319
332
|
think_loud.toggle
|
|
320
333
|
:next
|
|
321
334
|
when %r(^/import\s+(.+))
|
|
322
|
-
|
|
335
|
+
disable_content_parsing
|
|
323
336
|
import($1) or :next
|
|
324
337
|
when %r(^/summarize\s+(?:(\d+)\s+)?(.+))
|
|
325
|
-
|
|
338
|
+
disable_content_parsing
|
|
326
339
|
summarize($2, words: $1) or :next
|
|
327
340
|
when %r(^/embedding$)
|
|
328
341
|
embedding_paused.toggle(show: false)
|
|
329
342
|
embedding.show
|
|
330
343
|
:next
|
|
331
344
|
when %r(^/embed\s+(.+))
|
|
332
|
-
|
|
345
|
+
disable_content_parsing
|
|
333
346
|
embed($1) or :next
|
|
334
347
|
when %r(^/web\s+(?:(\d+)\s+)?(.+))
|
|
335
|
-
|
|
348
|
+
disable_content_parsing
|
|
336
349
|
web($1, $2)
|
|
337
350
|
when %r(^/input(?:\s+(.+))?$)
|
|
338
351
|
arg = $1
|
|
339
352
|
arg and patterns = arg.scan(/(\S+)/).flatten
|
|
340
|
-
|
|
353
|
+
disable_content_parsing
|
|
341
354
|
input(patterns) or :next
|
|
342
355
|
when %r(^/context(?:\s+(.+))?$)
|
|
343
356
|
arg = $1
|
|
344
357
|
arg and patterns = arg.scan(/(\S+)/).flatten
|
|
345
|
-
|
|
358
|
+
disable_content_parsing
|
|
346
359
|
context_spook(patterns) or :next
|
|
347
360
|
when %r(^/compose$)
|
|
348
361
|
compose or :next
|
|
@@ -396,7 +409,7 @@ class OllamaChat::Chat
|
|
|
396
409
|
end
|
|
397
410
|
:next
|
|
398
411
|
when %r(^/persona(?:\s+(add|delete|edit|file|info|list|load|play))?$)
|
|
399
|
-
|
|
412
|
+
disable_content_parsing
|
|
400
413
|
case $1
|
|
401
414
|
when 'add'
|
|
402
415
|
if result = add_persona
|
|
@@ -453,7 +466,7 @@ class OllamaChat::Chat
|
|
|
453
466
|
STDOUT.puts "Goodbye."
|
|
454
467
|
:return
|
|
455
468
|
when %r(^/help me$)
|
|
456
|
-
|
|
469
|
+
disable_content_parsing
|
|
457
470
|
config.prompts.help % { commands: display_chat_help_message }
|
|
458
471
|
when %r(^/)
|
|
459
472
|
display_chat_help
|
|
@@ -580,9 +593,11 @@ class OllamaChat::Chat
|
|
|
580
593
|
# @param what [ String, nil ] the type of data to clear, defaults to
|
|
581
594
|
# 'messages' if nil
|
|
582
595
|
def clean(what)
|
|
596
|
+
persona_profile = nil
|
|
583
597
|
case what
|
|
584
598
|
when 'messages', nil
|
|
585
599
|
messages.clear
|
|
600
|
+
persona_profile = reload_default_persona
|
|
586
601
|
STDOUT.puts "Cleared messages."
|
|
587
602
|
when 'links'
|
|
588
603
|
links.clear
|
|
@@ -599,11 +614,13 @@ class OllamaChat::Chat
|
|
|
599
614
|
@documents.clear
|
|
600
615
|
links.clear
|
|
601
616
|
clear_history
|
|
617
|
+
persona_profile = reload_default_persona
|
|
602
618
|
STDOUT.puts "Cleared messages and collection #{bold{@documents.collection}}."
|
|
603
619
|
else
|
|
604
620
|
STDOUT.puts 'Cancelled.'
|
|
605
621
|
end
|
|
606
622
|
end
|
|
623
|
+
persona_profile
|
|
607
624
|
end
|
|
608
625
|
|
|
609
626
|
# The interact_with_user method manages the interactive loop for user input
|
|
@@ -621,7 +638,7 @@ class OllamaChat::Chat
|
|
|
621
638
|
def interact_with_user
|
|
622
639
|
loop do
|
|
623
640
|
if persona_result = setup_persona_from_opts
|
|
624
|
-
|
|
641
|
+
disable_content_parsing
|
|
625
642
|
content = persona_result
|
|
626
643
|
else
|
|
627
644
|
@parse_content = true
|
|
@@ -629,7 +646,7 @@ class OllamaChat::Chat
|
|
|
629
646
|
input_prompt = bold { color(172) { message_type(@images) + " user" } } + bold { "> " }
|
|
630
647
|
begin
|
|
631
648
|
if content = handle_tool_call_results?
|
|
632
|
-
|
|
649
|
+
disable_content_parsing
|
|
633
650
|
else
|
|
634
651
|
content = enable_command_completion do
|
|
635
652
|
if prefill_prompt = @prefill_prompt.full?
|
|
@@ -691,9 +708,11 @@ class OllamaChat::Chat
|
|
|
691
708
|
end
|
|
692
709
|
|
|
693
710
|
if runtime_info.on? && content
|
|
694
|
-
|
|
711
|
+
runtime_info_values = {
|
|
695
712
|
languages: config.languages * ', ',
|
|
696
713
|
location: location.on? ? location_description.inspect : 'n/a',
|
|
714
|
+
client: ,
|
|
715
|
+
current_directory: Pathname.pwd.expand_path.to_path.inspect,
|
|
697
716
|
terminal_rows: Tins::Terminal.rows,
|
|
698
717
|
terminal_cols: Tins::Terminal.cols,
|
|
699
718
|
time: Time.now.iso8601,
|
|
@@ -701,7 +720,7 @@ class OllamaChat::Chat
|
|
|
701
720
|
markdown: markdown.on? ? 'enabled' : 'disabled',
|
|
702
721
|
tool_paths_allowed: JSON(tool_paths_allowed),
|
|
703
722
|
}
|
|
704
|
-
content << config.prompts.runtime_info %
|
|
723
|
+
content << config.prompts.runtime_info % runtime_info_values
|
|
705
724
|
end
|
|
706
725
|
|
|
707
726
|
messages << Ollama::Message.new(role: 'user', content:, images: @images.dup)
|
|
@@ -55,6 +55,15 @@ module OllamaChat::Information
|
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
# The client method returns the application name and its current version as a
|
|
59
|
+
# single string
|
|
60
|
+
#
|
|
61
|
+
# @return [ String ] the progname followed by the OllamaChat version
|
|
62
|
+
# separated by a space
|
|
63
|
+
def client
|
|
64
|
+
[ progname, OllamaChat::VERSION ] * ' '
|
|
65
|
+
end
|
|
66
|
+
|
|
58
67
|
# The collection_stats method displays statistics about the current document
|
|
59
68
|
# collection.
|
|
60
69
|
#
|
|
@@ -24,6 +24,14 @@ module OllamaChat::LocationHandling
|
|
|
24
24
|
config.prompts.location % location_data
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
# The location_description? method returns the location description string if
|
|
28
|
+
# the location setting is enabled; otherwise it returns nil.
|
|
29
|
+
#
|
|
30
|
+
# @return [String, nil]
|
|
31
|
+
def location_description?
|
|
32
|
+
location_description if location.on?
|
|
33
|
+
end
|
|
34
|
+
|
|
27
35
|
# Generates a hash containing current location data.
|
|
28
36
|
#
|
|
29
37
|
# This method collects and returns structured location information including
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
# A collection class for managing chat messages with support for system
|
|
2
2
|
# prompts, paged output, and conversation history.
|
|
3
|
-
|
|
3
|
+
#
|
|
4
4
|
# This class provides functionality for storing, retrieving, and displaying
|
|
5
5
|
# chat messages in a structured manner. It handles system prompts separately
|
|
6
6
|
# from regular user and assistant messages, supports pagination for displaying
|
|
7
7
|
# conversations, and offers methods for manipulating message history including
|
|
8
8
|
# clearing, loading, saving, and dropping exchanges. The class integrates with
|
|
9
|
-
# Kramdown::ANSI for formatted output
|
|
10
|
-
#
|
|
11
|
-
|
|
9
|
+
# Kramdown::ANSI for formatted output.
|
|
10
|
+
#
|
|
12
11
|
# @example Creating a new message list
|
|
13
12
|
# chat = OllamaChat::Chat.new
|
|
14
13
|
# messages = OllamaChat::MessageList.new(chat)
|
|
@@ -285,39 +284,12 @@ class OllamaChat::MessageList
|
|
|
285
284
|
end
|
|
286
285
|
|
|
287
286
|
# The to_ary method converts the message list into an array of
|
|
288
|
-
# Ollama::Message objects.
|
|
289
|
-
# list contains a system message, the system messages is decorated with the
|
|
290
|
-
# curent location, time, and unit preferences.
|
|
287
|
+
# Ollama::Message objects.
|
|
291
288
|
#
|
|
292
289
|
# @return [Array] An array of Ollama::Message objects representing the
|
|
293
290
|
# messages in the list.
|
|
294
291
|
def to_ary
|
|
295
|
-
|
|
296
|
-
add_system = !!location
|
|
297
|
-
result = @messages.map do |message|
|
|
298
|
-
if message.role == 'system' && location
|
|
299
|
-
add_system = false
|
|
300
|
-
content = message.content + "\n\n#{location}"
|
|
301
|
-
Ollama::Message.new(role: message.role, content:)
|
|
302
|
-
else
|
|
303
|
-
message
|
|
304
|
-
end
|
|
305
|
-
end
|
|
306
|
-
if add_system
|
|
307
|
-
prompt = @chat.config.system_prompts.assistant?
|
|
308
|
-
content = [ prompt, location ].compact * "\n\n"
|
|
309
|
-
message = Ollama::Message.new(role: 'system', content:)
|
|
310
|
-
result.unshift message
|
|
311
|
-
end
|
|
312
|
-
result
|
|
313
|
-
end
|
|
314
|
-
|
|
315
|
-
# The at_location method returns the location/time/units information as a
|
|
316
|
-
# string if location is enabled.
|
|
317
|
-
#
|
|
318
|
-
# @return [ String ] the location information
|
|
319
|
-
def at_location
|
|
320
|
-
@chat.location_description if @chat.location.on?
|
|
292
|
+
@messages.dup
|
|
321
293
|
end
|
|
322
294
|
|
|
323
295
|
private
|
|
@@ -46,6 +46,8 @@ prompts:
|
|
|
46
46
|
|
|
47
47
|
- Languages the user prefers: %{languages}.
|
|
48
48
|
- Location is %{location}.
|
|
49
|
+
- Current directory is %{current_directory}.
|
|
50
|
+
- Client is %{client}.
|
|
49
51
|
- Terminal has %{terminal_rows} rows.
|
|
50
52
|
- Terminal width is %{terminal_cols} columns. **Always** aim to stay within
|
|
51
53
|
80%% of this width in your output of responses, especially when using
|
|
@@ -39,8 +39,7 @@ module OllamaChat::PersonaeManagement
|
|
|
39
39
|
# for a provided persona option, determining the appropriate file path, and
|
|
40
40
|
# playing the persona file if it exists.
|
|
41
41
|
def setup_persona_from_opts
|
|
42
|
-
@
|
|
43
|
-
@persona_setup = true
|
|
42
|
+
@default_persona and return
|
|
44
43
|
if persona = @opts[?p].full? { Pathname.new(_1) }
|
|
45
44
|
if persona.extname == '.md'
|
|
46
45
|
pathname = persona
|
|
@@ -48,15 +47,28 @@ module OllamaChat::PersonaeManagement
|
|
|
48
47
|
pathname = personae_directory + (persona.to_s + '.md')
|
|
49
48
|
end
|
|
50
49
|
if pathname.exist?
|
|
50
|
+
@default_persona = pathname
|
|
51
51
|
play_persona_file pathname
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
|
+
ensure
|
|
55
|
+
@default_persona ||= :none
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Reloads the default persona file if one is set and not :none, prompting the
|
|
59
|
+
# user for confirmation before playing the persona file.
|
|
60
|
+
def reload_default_persona
|
|
61
|
+
!@default_persona || @default_persona == :none and return
|
|
62
|
+
prompt = "Reload default persona #{@default_persona.basename.sub_ext('')}? (y/n) "
|
|
63
|
+
if ask?(prompt:) =~ /\Ay/i
|
|
64
|
+
play_persona_file @default_persona
|
|
65
|
+
end
|
|
54
66
|
end
|
|
55
67
|
|
|
56
68
|
# Returns a sorted list of available persona file names.
|
|
57
69
|
#
|
|
58
|
-
# This method scans the personae directory for Markdown files and
|
|
59
|
-
#
|
|
70
|
+
# This method scans the personae directory for Markdown files and returns
|
|
71
|
+
# their basenames sorted alphabetically.
|
|
60
72
|
#
|
|
61
73
|
# @return [Array<String>] Sorted array of persona filenames without extension
|
|
62
74
|
def available_personae
|
|
@@ -75,24 +75,24 @@ class OllamaChat::Tools::GemPathLookup
|
|
|
75
75
|
|
|
76
76
|
if gem_spec
|
|
77
77
|
{
|
|
78
|
-
gem_name
|
|
79
|
-
path:
|
|
78
|
+
gem_name:,
|
|
79
|
+
path: gem_spec.gem_dir,
|
|
80
80
|
version: gem_spec.version,
|
|
81
|
-
found:
|
|
82
|
-
message: "Found gem '#{gem_name}' at #{gem_spec.gem_dir.inspect}"
|
|
81
|
+
found: true,
|
|
82
|
+
message: "Found gem '#{gem_name}' at #{gem_spec.gem_dir.inspect}",
|
|
83
83
|
}.to_json
|
|
84
84
|
else
|
|
85
85
|
{
|
|
86
|
-
gem_name
|
|
87
|
-
path:
|
|
88
|
-
found:
|
|
89
|
-
message: "Gem '#{gem_name}' not found in bundle"
|
|
86
|
+
gem_name:,
|
|
87
|
+
path: nil,
|
|
88
|
+
found: false,
|
|
89
|
+
message: "Gem '#{gem_name}' not found in bundle",
|
|
90
90
|
}.to_json
|
|
91
91
|
end
|
|
92
92
|
rescue => e
|
|
93
93
|
{
|
|
94
|
-
error:
|
|
95
|
-
message: e.message
|
|
94
|
+
error: e.class,
|
|
95
|
+
message: e.message,
|
|
96
96
|
}.to_json
|
|
97
97
|
end
|
|
98
98
|
|
|
@@ -63,14 +63,14 @@ class OllamaChat::Tools::GetEndoflife
|
|
|
63
63
|
'Accept' => 'application/json',
|
|
64
64
|
'User-Agent' => OllamaChat::Chat.user_agent
|
|
65
65
|
},
|
|
66
|
-
debug:
|
|
66
|
+
debug: OC::OLLAMA::CHAT::DEBUG,
|
|
67
67
|
reraise: true,
|
|
68
68
|
&valid_json?
|
|
69
69
|
)
|
|
70
70
|
rescue => e
|
|
71
71
|
{
|
|
72
72
|
product:,
|
|
73
|
-
error:
|
|
73
|
+
error: e.class,
|
|
74
74
|
message: e.message,
|
|
75
75
|
}.to_json
|
|
76
76
|
end
|
|
@@ -79,16 +79,16 @@ class OllamaChat::Tools::OpenFileInEditor
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
{
|
|
82
|
-
success:
|
|
83
|
-
message:
|
|
84
|
-
path:
|
|
82
|
+
success: true,
|
|
83
|
+
message: result_msg,
|
|
84
|
+
path: file_path,
|
|
85
85
|
start_line: start_line,
|
|
86
|
-
end_line:
|
|
86
|
+
end_line: end_line,
|
|
87
87
|
}.to_json
|
|
88
88
|
rescue => e
|
|
89
89
|
{
|
|
90
|
-
error:
|
|
91
|
-
message: e.message
|
|
90
|
+
error: e.class,
|
|
91
|
+
message: e.message,
|
|
92
92
|
}.to_json
|
|
93
93
|
end
|
|
94
94
|
|
data/lib/ollama_chat/version.rb
CHANGED
|
@@ -23,7 +23,7 @@ module OllamaChat::WebSearching
|
|
|
23
23
|
# @return [ Array<String>, nil ] an array of URLs from the search results or
|
|
24
24
|
# nil if the search engine is not implemented
|
|
25
25
|
def search_web(query, n = nil)
|
|
26
|
-
l =
|
|
26
|
+
l = location_description? and query += " #{l}"
|
|
27
27
|
n = n.to_i.clamp(1..)
|
|
28
28
|
query = URI.encode_uri_component(query)
|
|
29
29
|
search_command = :"search_web_with_#{search_engine}"
|
data/ollama_chat.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: ollama_chat 0.0.
|
|
2
|
+
# stub: ollama_chat 0.0.76 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "ollama_chat".freeze
|
|
6
|
-
s.version = "0.0.
|
|
6
|
+
s.version = "0.0.76".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]
|
|
@@ -277,14 +277,7 @@ describe OllamaChat::MessageList do
|
|
|
277
277
|
expect(list.size).to eq 1
|
|
278
278
|
end
|
|
279
279
|
|
|
280
|
-
it 'can determine location for system prompt' do
|
|
281
|
-
expect(chat).to receive(:location).and_return(double(on?: true))
|
|
282
|
-
expect(list.send(:at_location)).to match(
|
|
283
|
-
%r(You are at Berlin \(52.514127, 13.475211\), ))
|
|
284
|
-
end
|
|
285
|
-
|
|
286
280
|
it 'can be converted int an Ollama::Message array' do
|
|
287
|
-
expect(chat).to receive(:location).and_return(double(on?: false))
|
|
288
281
|
list << Ollama::Message.new(role: 'user', content: 'world')
|
|
289
282
|
expect(list.to_ary.map(&:as_json)).to eq [
|
|
290
283
|
Ollama::Message.new(role: 'system', content: 'hello', thinking: 'a while').as_json,
|
|
@@ -292,28 +285,6 @@ describe OllamaChat::MessageList do
|
|
|
292
285
|
]
|
|
293
286
|
end
|
|
294
287
|
|
|
295
|
-
it 'can be converted int an Ollama::Message array with location' do
|
|
296
|
-
expect(chat).to receive(:location).and_return(double(on?: true))
|
|
297
|
-
list << Ollama::Message.new(role: 'user', content: 'world')
|
|
298
|
-
first = list.to_ary.first
|
|
299
|
-
expect(first.role).to eq 'system'
|
|
300
|
-
expect(first.content).to match(
|
|
301
|
-
%r(You are at Berlin \(52.514127, 13.475211\), ))
|
|
302
|
-
end
|
|
303
|
-
|
|
304
|
-
it 'can be converted int an Ollama::Message array with location without a system prompt' do
|
|
305
|
-
expect(chat).to receive(:location).and_return(double(on?: true))
|
|
306
|
-
list = described_class.new(chat).tap do |list|
|
|
307
|
-
list << Ollama::Message.new(role: 'user', content: 'hello')
|
|
308
|
-
list << Ollama::Message.new(role: 'assistant', content: 'world')
|
|
309
|
-
end
|
|
310
|
-
first = list.to_ary.first
|
|
311
|
-
expect(first.role).to eq 'system'
|
|
312
|
-
expect(first.content).to match(
|
|
313
|
-
%r(You are a helpful assistant.\n\nYou are at Berlin \(52.514127, 13.475211\), ))
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
|
|
317
288
|
it 'can display messages with images' do
|
|
318
289
|
expect(list.message_type([])).to eq ?📨
|
|
319
290
|
end
|