ollama_chat 0.0.145 → 0.0.146
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/CHANGES.md +76 -0
- data/Gemfile +0 -2
- data/Rakefile +4 -4
- data/lib/ollama_chat/chat.rb +2 -2
- data/lib/ollama_chat/commands.rb +23 -22
- data/lib/ollama_chat/compaction.rb +2 -2
- data/lib/ollama_chat/conversation.rb +9 -28
- data/lib/ollama_chat/dialog.rb +16 -13
- data/lib/ollama_chat/favourites_management.rb +35 -51
- data/lib/ollama_chat/input_content.rb +2 -2
- data/lib/ollama_chat/message_list.rb +2 -0
- data/lib/ollama_chat/model_handling.rb +9 -11
- data/lib/ollama_chat/ollama_chat_config/default_config.yml +1 -0
- data/lib/ollama_chat/personae_management.rb +29 -17
- data/lib/ollama_chat/prompt_management.rb +1 -1
- data/lib/ollama_chat/rag_handling.rb +30 -54
- data/lib/ollama_chat/session_management.rb +1 -1
- data/lib/ollama_chat/source_fetching.rb +9 -2
- data/lib/ollama_chat/tool_calling.rb +36 -76
- data/lib/ollama_chat/tools/memorize.rb +1 -1
- data/lib/ollama_chat/tools/search_knowledge.rb +6 -4
- data/lib/ollama_chat/utils/chooser.rb +66 -1
- data/lib/ollama_chat/utils/fetcher.rb +4 -0
- data/lib/ollama_chat/utils/strip_ansi.rb +1 -1
- data/lib/ollama_chat/version.rb +1 -1
- data/lib/ollama_chat/web_searching.rb +16 -24
- data/ollama_chat.gemspec +7 -7
- data/spec/ollama_chat/commands_spec.rb +11 -20
- data/spec/ollama_chat/conversation_spec.rb +7 -17
- data/spec/ollama_chat/favourites_management_spec.rb +19 -60
- data/spec/ollama_chat/input_content_spec.rb +7 -18
- data/spec/ollama_chat/model_handling_spec.rb +3 -3
- data/spec/ollama_chat/prompt_management_spec.rb +3 -3
- data/spec/ollama_chat/rag_handling_spec.rb +14 -18
- data/spec/ollama_chat/system_prompt_management_spec.rb +3 -3
- data/spec/ollama_chat/tool_calling_spec.rb +25 -64
- metadata +11 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c04237cdba36634f4903266f0bf8c8815c098a7b40ad1e1bef15cc80dd2c9d33
|
|
4
|
+
data.tar.gz: 39032efcc4c3afe95271e2381491f82feceebe32e165e55c37eef0fadf426407
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f589d57bafef1236ab67bf478f5e074457e4824c038f7077b13aaf3b9067e8ce69c2db97a09f119728a056f2f0cc5f122bf5e6391d00bcacabeab2b29e30be5
|
|
7
|
+
data.tar.gz: 5e807de46b0a5333a57a22a35d33827e07dd2428cfc1fd85d33bf1140f68bb5a3e73f13dd769c9d80b30ef2d3ff9861237df3807b5a945ca6eda62d35e845206
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,81 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-11-18 v0.0.146
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- Added `/restart` command to reload configuration and continue the session.
|
|
8
|
+
- Added `compaction.think` configuration option to control thinking mode during
|
|
9
|
+
context compaction; defaults to `'auto'` (delegates to `ThinkControl#think`),
|
|
10
|
+
with `'never'` forcing `false`.
|
|
11
|
+
- Introduced `choose_multi` utility for interactive multi-selection with
|
|
12
|
+
`[ALL]`/`[NONE]` sentinels, replacing legacy sentinel-loop pickers across the
|
|
13
|
+
codebase.
|
|
14
|
+
- Added `text` field to the `memorize` tool result to echo stored content back
|
|
15
|
+
to the LLM.
|
|
16
|
+
|
|
17
|
+
### Fixes
|
|
18
|
+
|
|
19
|
+
- Fixed `NoMethodError` in `ollama-ruby` `Progress` when the server transmits
|
|
20
|
+
`success` before a progress bar exists (cached-model path) by bumping
|
|
21
|
+
dependency to **1.26.4**.
|
|
22
|
+
- Resolved ghost-bar clobbering in `ollama_update` pull output by bumping
|
|
23
|
+
`ollama-ruby` to **1.26.3** and `infobar` to **0.16.0**.
|
|
24
|
+
- Ensured `infobar.finish` is called on all exit paths in `fetcher.rb`
|
|
25
|
+
(`fetch_url` and `fetch_streaming`) to release saved cursor positions and
|
|
26
|
+
render final frames.
|
|
27
|
+
- Cleared `infobar` after message list and last output in `message_list.rb` to
|
|
28
|
+
prevent ghost-bar artifacts before subsequent `output.puts` calls.
|
|
29
|
+
- Handled invalid UTF-8 bytes in `strip_ansi` by encoding input with `invalid:
|
|
30
|
+
:replace` and `undef: :replace`.
|
|
31
|
+
- Prevented stale history entries from surfacing during collection incineration
|
|
32
|
+
confirmation by clearing `Reline::HISTORY` and removing prefill.
|
|
33
|
+
|
|
34
|
+
### Improvements
|
|
35
|
+
|
|
36
|
+
- Migrated all interactive multi-select pickers (tools, favourites, personae,
|
|
37
|
+
links, conversations, files, models, memory collections) to use
|
|
38
|
+
`choose_multi` for consistent UX and reduced code complexity.
|
|
39
|
+
- Replaced `⚪`/`⚫` circle icons with `☑`/`🔳` box glyphs in `load_personae`
|
|
40
|
+
to visually distinguish pick state from favourited markers.
|
|
41
|
+
- Updated favourite icons from `❤`/`🩶` to `⭐`/`⚫` for better visual
|
|
42
|
+
consistency.
|
|
43
|
+
- Silenced `infobar` during parallel embedding in `bulk_embed_sources` and
|
|
44
|
+
added user-visible feedback lines for sequential and parallel embed paths.
|
|
45
|
+
- Improved `/update all` feedback wording with bold collection names and
|
|
46
|
+
explicit type values.
|
|
47
|
+
- Delegated editorial thinking to `ThinkControl` in `compaction.rb`,
|
|
48
|
+
`session_management.rb`, `personae_management.rb`, and `prompt_management.rb`
|
|
49
|
+
to respect global `think_mode` settings.
|
|
50
|
+
- Added `think:` value to log data in `chat.rb` `generate` for better
|
|
51
|
+
observability at info level.
|
|
52
|
+
- Updated `SearchKnowledge` tool descriptions to guide the model toward using
|
|
53
|
+
natural language queries.
|
|
54
|
+
- Simplified `source_modified?` guard in `rag_handling.rb` by removing
|
|
55
|
+
redundant `infobar.puts`.
|
|
56
|
+
|
|
57
|
+
### Build & CI
|
|
58
|
+
|
|
59
|
+
- Bumped `ollama-ruby` dependency to **1.26.4**.
|
|
60
|
+
- Bumped `documentrix` dependency to **0.8.1** to pick up `ensure
|
|
61
|
+
infobar.finish` fix.
|
|
62
|
+
- Bumped `infobar` dependency to **0.16.0**.
|
|
63
|
+
- Bumped `search_ui` dependency to **0.4**.
|
|
64
|
+
- Bumped `gem_hadar` development dependency to **2.22.1**.
|
|
65
|
+
- Removed vim modeline configuration from `Gemfile`.
|
|
66
|
+
|
|
67
|
+
### Testing
|
|
68
|
+
|
|
69
|
+
- Updated specs to stub `docs.collection` in `update_collection` tests.
|
|
70
|
+
- Converted mock returns in specs from sentinel strings to arrays to match new
|
|
71
|
+
`choose_multi` API.
|
|
72
|
+
- Added spec for `/restart` command.
|
|
73
|
+
- Updated favourite icon assertions in specs to reflect new `⭐`/`⚫` glyphs.
|
|
74
|
+
|
|
75
|
+
### Documentation
|
|
76
|
+
|
|
77
|
+
- Updated YARD documentation context to omit `@return void` clauses.
|
|
78
|
+
|
|
3
79
|
## 2026-11-13 v0.0.145
|
|
4
80
|
|
|
5
81
|
### Fix
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
|
@@ -39,8 +39,8 @@ GemHadar do
|
|
|
39
39
|
)
|
|
40
40
|
|
|
41
41
|
dependency 'excon', '~> 1.0'
|
|
42
|
-
dependency 'ollama-ruby', '~> 1.26', '>= 1.26.
|
|
43
|
-
dependency 'documentrix', '>= 0.8.
|
|
42
|
+
dependency 'ollama-ruby', '~> 1.26', '>= 1.26.4'
|
|
43
|
+
dependency 'documentrix', '>= 0.8.1'
|
|
44
44
|
dependency 'unix_socks', '>= 0.4'
|
|
45
45
|
dependency 'rss', '~> 0.3'
|
|
46
46
|
dependency 'term-ansicolor', '~> 1.11'
|
|
@@ -50,14 +50,14 @@ GemHadar do
|
|
|
50
50
|
dependency 'kramdown-ansi', '~> 0.9'
|
|
51
51
|
dependency 'complex_config', '~> 0.22', '>= 0.22.2'
|
|
52
52
|
dependency 'tins', '~> 1.62'
|
|
53
|
-
dependency 'search_ui', '>= 0.
|
|
53
|
+
dependency 'search_ui', '>= 0.4'
|
|
54
54
|
dependency 'amatch', '~> 0.4'
|
|
55
55
|
dependency 'pdf-reader', '~> 2.0'
|
|
56
56
|
dependency 'bigdecimal', '~> 3.1'
|
|
57
57
|
dependency 'csv', '~> 3.0'
|
|
58
58
|
dependency 'const_conf', '~> 0.9'
|
|
59
59
|
dependency 'context_spook', '~> 1.7'
|
|
60
|
-
dependency 'infobar', '>= 0.
|
|
60
|
+
dependency 'infobar', '>= 0.16.0'
|
|
61
61
|
dependency 'rubyzip', '~> 3.0'
|
|
62
62
|
dependency 'sequel', '~> 5.0'
|
|
63
63
|
dependency 'file-tail', '~> 1.4'
|
data/lib/ollama_chat/chat.rb
CHANGED
|
@@ -296,9 +296,9 @@ class OllamaChat::Chat
|
|
|
296
296
|
)&.message&.content.to_s
|
|
297
297
|
|
|
298
298
|
if content.empty?
|
|
299
|
-
log(:warn, "LLM generation returned empty content", data: { prompt: })
|
|
299
|
+
log(:warn, "LLM generation returned empty content", data: { prompt:, think: })
|
|
300
300
|
else
|
|
301
|
-
log(:info, "LLM generation successful", data: { prompt:, content: })
|
|
301
|
+
log(:info, "LLM generation successful", data: { prompt:, content:, think: })
|
|
302
302
|
end
|
|
303
303
|
|
|
304
304
|
content
|
data/lib/ollama_chat/commands.rb
CHANGED
|
@@ -93,19 +93,14 @@ module OllamaChat::Commands
|
|
|
93
93
|
|
|
94
94
|
command(
|
|
95
95
|
name: :favourite,
|
|
96
|
-
regexp: %r(^/favourite
|
|
97
|
-
complete: [ 'favourite', %w[
|
|
96
|
+
regexp: %r(^/favourite\s+(model|prompt|system|persona|suggest)$),
|
|
97
|
+
complete: [ 'favourite', %w[ model prompt system persona suggest ] ],
|
|
98
98
|
help: <<~EOT
|
|
99
|
-
\u2B50 Manage favorites (
|
|
99
|
+
\u2B50 Manage favorites (toggle models,
|
|
100
100
|
prompts, personae)
|
|
101
101
|
EOT
|
|
102
|
-
) do |
|
|
103
|
-
|
|
104
|
-
when 'add'
|
|
105
|
-
add_favourite(type)
|
|
106
|
-
when 'delete'
|
|
107
|
-
delete_favourite(type)
|
|
108
|
-
end
|
|
102
|
+
) do |type|
|
|
103
|
+
choose_favourite(type)
|
|
109
104
|
:next
|
|
110
105
|
end
|
|
111
106
|
|
|
@@ -199,27 +194,22 @@ module OllamaChat::Commands
|
|
|
199
194
|
|
|
200
195
|
command(
|
|
201
196
|
name: :tools,
|
|
202
|
-
regexp: %r(^/tools(?:\s+(on|off
|
|
203
|
-
complete: [ 'tools', %w[ on off
|
|
197
|
+
regexp: %r(^/tools(?:\s+(on|off))?),
|
|
198
|
+
complete: [ 'tools', %w[ on off ] ],
|
|
204
199
|
optional: true,
|
|
205
200
|
help: <<~EOT
|
|
206
201
|
🛠 Manage tools:
|
|
207
|
-
|
|
202
|
+
- (no subcommand): Interactively choose tools
|
|
208
203
|
- on/off: Activate/Deactivate globally
|
|
209
|
-
- enable/disable: Interactively toggle specific
|
|
210
204
|
EOT
|
|
211
205
|
) do |subcommand|
|
|
212
206
|
case subcommand
|
|
213
|
-
when nil
|
|
214
|
-
list_tools
|
|
215
|
-
when 'enable'
|
|
216
|
-
enable_tool
|
|
217
|
-
when 'disable'
|
|
218
|
-
disable_tool
|
|
219
207
|
when 'on'
|
|
220
208
|
tools_support.set(true, show: true)
|
|
221
209
|
when 'off'
|
|
222
210
|
tools_support.set(false, show: true)
|
|
211
|
+
else
|
|
212
|
+
choose_tools
|
|
223
213
|
end
|
|
224
214
|
:next
|
|
225
215
|
end
|
|
@@ -655,9 +645,9 @@ module OllamaChat::Commands
|
|
|
655
645
|
when 'update all'
|
|
656
646
|
results = ''
|
|
657
647
|
all_collections.pluck(:name).each do |collection|
|
|
658
|
-
feedback("
|
|
648
|
+
feedback("Starting to update collection #{bold{collection}}", type: :info)
|
|
659
649
|
results << update_collection(collection) << ?\n
|
|
660
|
-
feedback("
|
|
650
|
+
feedback("Collection #{bold{collection}} was updated.", type: :success)
|
|
661
651
|
end
|
|
662
652
|
results.full? and next results
|
|
663
653
|
when 'update'
|
|
@@ -1064,6 +1054,17 @@ module OllamaChat::Commands
|
|
|
1064
1054
|
quit_app
|
|
1065
1055
|
end
|
|
1066
1056
|
|
|
1057
|
+
command(
|
|
1058
|
+
name: :restart,
|
|
1059
|
+
regexp: %r(^/restart$),
|
|
1060
|
+
help: <<~EOT
|
|
1061
|
+
🔄 Restart application
|
|
1062
|
+
EOT
|
|
1063
|
+
) do
|
|
1064
|
+
reload_config
|
|
1065
|
+
:next
|
|
1066
|
+
end
|
|
1067
|
+
|
|
1067
1068
|
category :Information
|
|
1068
1069
|
|
|
1069
1070
|
command(
|
|
@@ -230,13 +230,13 @@ module OllamaChat::Compaction
|
|
|
230
230
|
es = OllamaChat::TokenEstimator.estimate(prompt)
|
|
231
231
|
log(:info, "Compaction: sending prompt " \
|
|
232
232
|
"#{es.tokens_formatted} (#{es.bytes_formatted}) to #{@model}")
|
|
233
|
-
|
|
233
|
+
think = config.compaction.think == 'auto' ? self.think : false
|
|
234
234
|
response = Infobar.busy(
|
|
235
235
|
label: 'Compacting context…',
|
|
236
236
|
frames: :braille7,
|
|
237
237
|
output: STDOUT,
|
|
238
238
|
) do
|
|
239
|
-
generate(system:, prompt:, think:
|
|
239
|
+
generate(system:, prompt:, think:).strip
|
|
240
240
|
end
|
|
241
241
|
|
|
242
242
|
if response.empty?
|
|
@@ -66,42 +66,23 @@ module OllamaChat::Conversation
|
|
|
66
66
|
|
|
67
67
|
# Selectively cleans parts of the current conversation.
|
|
68
68
|
#
|
|
69
|
-
# Presents
|
|
69
|
+
# Presents a multi-select chooser of cleanable targets:
|
|
70
70
|
# tool content, images, thinking, messages, history, links.
|
|
71
|
-
# The user
|
|
71
|
+
# The user toggles one or more items and confirms; the
|
|
72
72
|
# selected items are cleared.
|
|
73
73
|
def conversation_clean
|
|
74
74
|
options = %w[ tools images thinking messages history links ]
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
case choice
|
|
83
|
-
when nil, '[DONE]'
|
|
84
|
-
break
|
|
85
|
-
when '[ALL]'
|
|
86
|
-
selected.merge(remaining)
|
|
87
|
-
break
|
|
88
|
-
else
|
|
89
|
-
selected << choice
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
75
|
+
selected = choose_multi(
|
|
76
|
+
%w[ [ALL] [NONE] ] + options,
|
|
77
|
+
all: '[ALL]',
|
|
78
|
+
none: '[NONE]',
|
|
79
|
+
prompt: 'What to clean from conversation? %s ' \
|
|
80
|
+
'[Tab=toggle, Enter=apply, C-c=abort]'
|
|
81
|
+
) or return feedback('Cancelled, nothing selected.', type: :cancel)
|
|
94
82
|
return feedback('Cancelled, nothing selected.', type: :cancel) if selected.empty?
|
|
95
83
|
|
|
96
84
|
what = selected.map { |s| bold{s} }.to_a
|
|
97
85
|
|
|
98
|
-
unless confirm?(
|
|
99
|
-
prompt: "🔔 Clean #{what * ', '} from conversation? (y/n) ",
|
|
100
|
-
yes: /\Ay/i
|
|
101
|
-
)
|
|
102
|
-
return feedback('Denied.', type: :denied)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
86
|
field_options = %w[ tools images thinking ].select { selected.include?(_1) }
|
|
106
87
|
messages.clear if selected.include?('messages')
|
|
107
88
|
messages.clean_messages!(what: field_options.map(&:to_sym)) unless field_options.empty?
|
data/lib/ollama_chat/dialog.rb
CHANGED
|
@@ -112,26 +112,29 @@ module OllamaChat::Dialog
|
|
|
112
112
|
|
|
113
113
|
private
|
|
114
114
|
|
|
115
|
-
# The
|
|
116
|
-
#
|
|
117
|
-
#
|
|
115
|
+
# The choose_multiple_filenames method presents a multi-select picker of
|
|
116
|
+
# all files matching the given glob patterns. The user toggles files with
|
|
117
|
+
# Tab and confirms with Enter.
|
|
118
118
|
#
|
|
119
119
|
# @param patterns [ Array<String> ] optional glob patterns to match; defaults
|
|
120
120
|
# to '**/*'.
|
|
121
121
|
#
|
|
122
122
|
# @return [ Set<Pathname> ] a set of expanded Pathname objects for each
|
|
123
|
-
# selected file.
|
|
123
|
+
# selected file (empty set on abort).
|
|
124
124
|
#
|
|
125
|
-
def
|
|
125
|
+
def choose_multiple_filenames(patterns)
|
|
126
126
|
patterns ||= '**/*'
|
|
127
|
-
patterns
|
|
128
|
-
files
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
127
|
+
patterns = Array(patterns).map { Pathname.new(_1).expand_path }
|
|
128
|
+
files = patterns.flat_map { Pathname.glob(_1) }
|
|
129
|
+
files = files.select { _1.file? }.uniq
|
|
130
|
+
result = choose_multi(
|
|
131
|
+
%w[ [ALL] [NONE] ] + files,
|
|
132
|
+
all: '[ALL]',
|
|
133
|
+
none: '[NONE]',
|
|
134
|
+
prompt: 'Select files to import: %s ' \
|
|
135
|
+
'[Tab=toggle, Enter=apply, C-c=abort]'
|
|
136
|
+
)
|
|
137
|
+
(result || []).to_set
|
|
135
138
|
end
|
|
136
139
|
|
|
137
140
|
# Displays an info-level feedback message indicating that a connection
|
|
@@ -11,7 +11,7 @@ module OllamaChat::FavouritesManagement
|
|
|
11
11
|
# @param favourited [Boolean] whether the item is a favourite
|
|
12
12
|
# @return [String] the decorated string
|
|
13
13
|
def prefix_favourite(string, favourited)
|
|
14
|
-
fav = favourited ?
|
|
14
|
+
fav = favourited ? '⭐' : '⚫'
|
|
15
15
|
"%s %s" % [ fav, string ]
|
|
16
16
|
end
|
|
17
17
|
|
|
@@ -29,61 +29,45 @@ module OllamaChat::FavouritesManagement
|
|
|
29
29
|
end.to_a
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
# The
|
|
33
|
-
#
|
|
34
|
-
#
|
|
32
|
+
# The choose_favourite method opens an interactive multi-select picker
|
|
33
|
+
# showing all available items of the given type with their current
|
|
34
|
+
# favourite state (⭐ / ⚫). The user toggles items with Tab and
|
|
35
|
+
# applies changes with Enter.
|
|
35
36
|
#
|
|
36
37
|
# @param type [ String ] the context type for the favourite
|
|
37
38
|
#
|
|
38
|
-
# @note This method uses a chooser to present options and
|
|
39
|
-
# for adding
|
|
40
|
-
def
|
|
41
|
-
all_things = favourite_all_things(type)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
39
|
+
# @note This method uses a multi-select chooser to present options and
|
|
40
|
+
# handles user input for adding/removing favourites in one pass.
|
|
41
|
+
def choose_favourite(type)
|
|
42
|
+
all_things = favourite_all_things(type).map(&:value)
|
|
43
|
+
current = all_favourited(type)
|
|
44
|
+
picked = all_things.select { current.include?(_1) }
|
|
45
|
+
|
|
46
|
+
result = choose_multi(
|
|
47
|
+
all_things,
|
|
48
|
+
prompt: "Choose favourites (#{type}): %s "\
|
|
49
|
+
"[Tab=toggle, Enter=apply, C-c=abort]",
|
|
50
|
+
picked: picked,
|
|
51
|
+
picked_icon: '⭐',
|
|
52
|
+
unpicked_icon: '⚫'
|
|
53
|
+
) or return feedback('Aborted.', type: :cancel)
|
|
54
|
+
|
|
55
|
+
to_add = result - current.keys
|
|
56
|
+
to_remove = current.keys - result
|
|
57
|
+
|
|
58
|
+
to_add.each do |name|
|
|
59
|
+
models::Favourite.create(context: type, name:)
|
|
60
|
+
log(:info, 'Favourite added', data: { context: type, name: })
|
|
61
|
+
end
|
|
62
|
+
to_remove.each do |name|
|
|
63
|
+
models::Favourite.where(context: type, name:).destroy
|
|
64
|
+
log(:info, 'Favourite removed', data: { context: type, name: })
|
|
60
65
|
end
|
|
61
|
-
end
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
# @param type [ String ] the context type of the favourite to delete
|
|
68
|
-
#
|
|
69
|
-
# @note This method uses a chooser to present options and handles user input
|
|
70
|
-
# for removing favourites from the database.
|
|
71
|
-
def delete_favourite(type)
|
|
72
|
-
all_things = favourite_all_things(type)
|
|
73
|
-
choose_with_state do
|
|
74
|
-
loop do
|
|
75
|
-
to_select = models::Favourite.where(context: type).map(&:name)
|
|
76
|
-
to_select = all_things.select { to_select.member?(_1.value) }
|
|
77
|
-
to_select = [ '[EXIT]' ] + to_select
|
|
78
|
-
case chosen = choose_entry(to_select, prompt: 'Select a favourite to remove: %s')
|
|
79
|
-
when '[EXIT]', nil
|
|
80
|
-
feedback("Cancelled.", type: :cancel)
|
|
81
|
-
return
|
|
82
|
-
when SearchUI::Wrapper
|
|
83
|
-
models::Favourite.where(context: type, name: chosen.value).destroy
|
|
84
|
-
log(:info, "Favourite removed", data: { context: type, name: chosen.value })
|
|
85
|
-
end
|
|
86
|
-
end
|
|
67
|
+
unless (to_add + to_remove).empty?
|
|
68
|
+
feedback(
|
|
69
|
+
"Added: %s | Removed: %s" % [ to_add.joined, to_remove.joined ]
|
|
70
|
+
)
|
|
87
71
|
end
|
|
88
72
|
end
|
|
89
73
|
|
|
@@ -18,7 +18,7 @@ module OllamaChat::InputContent
|
|
|
18
18
|
# @yield [file] yields each file to the supplied block
|
|
19
19
|
# @return [Array<File>] the array of files that were processed
|
|
20
20
|
def file_set_each(patterns, all: false, &block)
|
|
21
|
-
files = all ? all_file_set(patterns) :
|
|
21
|
+
files = all ? all_file_set(patterns) : choose_multiple_filenames(patterns)
|
|
22
22
|
block and files.each(&block)
|
|
23
23
|
files
|
|
24
24
|
end
|
|
@@ -35,7 +35,7 @@ module OllamaChat::InputContent
|
|
|
35
35
|
#
|
|
36
36
|
# @return [String] a concatenated string of file contents with filenames as headers
|
|
37
37
|
def input(patterns)
|
|
38
|
-
files =
|
|
38
|
+
files = choose_multiple_filenames(patterns)
|
|
39
39
|
files.each_with_object('') do |filename, result|
|
|
40
40
|
result << ("%s:\n\n%s\n\n" % [ filename, filename.read ])
|
|
41
41
|
end.full?
|
|
@@ -458,6 +458,7 @@ class OllamaChat::MessageList
|
|
|
458
458
|
output.puts message_text_for(message, think_loud:)
|
|
459
459
|
+infobar
|
|
460
460
|
end
|
|
461
|
+
infobar.clear
|
|
461
462
|
end
|
|
462
463
|
self
|
|
463
464
|
end
|
|
@@ -494,6 +495,7 @@ class OllamaChat::MessageList
|
|
|
494
495
|
output.puts message_text_for(message, think_loud:)
|
|
495
496
|
+infobar
|
|
496
497
|
end
|
|
498
|
+
infobar.clear
|
|
497
499
|
ensure
|
|
498
500
|
if last_message_user_message
|
|
499
501
|
message_content = Kramdown::ANSI::Width.truncate(
|
|
@@ -343,17 +343,15 @@ module OllamaChat::ModelHandling
|
|
|
343
343
|
|
|
344
344
|
# Let user pick models if more than one
|
|
345
345
|
if data.size > 1
|
|
346
|
-
|
|
347
|
-
chosen
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
selected = data.select { |d| d['model_name'] == chosen }
|
|
356
|
-
end
|
|
346
|
+
names = data.map { |d| d['model_name'] }
|
|
347
|
+
chosen = choose_multi(
|
|
348
|
+
%w[ [ALL] [NONE] ] + names,
|
|
349
|
+
all: '[ALL]',
|
|
350
|
+
none: '[NONE]',
|
|
351
|
+
prompt: 'Which model(s) to import? %s [Tab=toggle, Enter=apply, C-c=abort]'
|
|
352
|
+
) or return feedback('Cancelled.', type: :cancel)
|
|
353
|
+
return feedback('Cancelled.', type: :cancel) if chosen.empty?
|
|
354
|
+
selected = data.select { |d| chosen.include?(d['model_name']) }
|
|
357
355
|
else
|
|
358
356
|
selected = data
|
|
359
357
|
end
|
|
@@ -448,23 +448,37 @@ module OllamaChat::PersonaeManagement
|
|
|
448
448
|
|
|
449
449
|
# Interactive method to load multiple personae for use.
|
|
450
450
|
#
|
|
451
|
-
#
|
|
452
|
-
#
|
|
451
|
+
# Presents a multi-select picker with `[ALL]`/`[NONE]` sentinels.
|
|
452
|
+
# Returns a compiled
|
|
453
|
+
# description string for all picked personae.
|
|
454
|
+
#
|
|
455
|
+
# @return [String, nil] A string containing all descriptions, or nil if
|
|
456
|
+
# the selection was cancelled or no persona was chosen.
|
|
453
457
|
def load_personae
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
chosen << persona
|
|
459
|
-
end
|
|
458
|
+
personae = available_personae_names
|
|
459
|
+
if personae.empty?
|
|
460
|
+
feedback("No personae defined.", type: :warn)
|
|
461
|
+
return
|
|
460
462
|
end
|
|
461
463
|
|
|
462
|
-
|
|
464
|
+
entries = %w[ [ALL] [NONE] ] + personae
|
|
465
|
+
|
|
466
|
+
picked = choose_multi(
|
|
467
|
+
entries,
|
|
468
|
+
prompt: 'Who should join? %s [Tab=toggle, Enter=apply, C-c=abort]',
|
|
469
|
+
all: '[ALL]',
|
|
470
|
+
none: '[NONE]',
|
|
471
|
+
picked_icon: '☑ ',
|
|
472
|
+
unpicked_icon: '🔳'
|
|
473
|
+
) or return
|
|
474
|
+
names = picked.map(&:value)
|
|
475
|
+
|
|
476
|
+
if names.empty?
|
|
463
477
|
feedback("No persona loaded.", type: :info)
|
|
464
478
|
return
|
|
465
479
|
end
|
|
466
480
|
|
|
467
|
-
personae_result(
|
|
481
|
+
personae_result(names)
|
|
468
482
|
end
|
|
469
483
|
|
|
470
484
|
# Compiles the descriptions for one or more personae into a single string.
|
|
@@ -637,13 +651,11 @@ module OllamaChat::PersonaeManagement
|
|
|
637
651
|
frames: :braille7,
|
|
638
652
|
output: STDOUT,
|
|
639
653
|
) do
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
)
|
|
646
|
-
).gsub(/{{user}}/i, '%{user}').gsub(/{{char}}/i, persona_name)
|
|
654
|
+
prompt = prompt(:persona_architect).to_s.named_placeholders_interpolate(
|
|
655
|
+
{ character:, persona_template: prompt(:persona).to_s }
|
|
656
|
+
)
|
|
657
|
+
generate(prompt:, think:).
|
|
658
|
+
gsub(/{{user}}/i, '%{user}').gsub(/{{char}}/i, persona_name)
|
|
647
659
|
end
|
|
648
660
|
end
|
|
649
661
|
|