ollama_chat 0.0.73 → 0.0.74
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 +168 -121
- data/lib/ollama_chat/chat.rb +10 -14
- data/lib/ollama_chat/information.rb +1 -1
- data/lib/ollama_chat/input_content.rb +14 -12
- data/lib/ollama_chat/model_handling.rb +25 -0
- data/lib/ollama_chat/oc.rb +4 -0
- data/lib/ollama_chat/ollama_chat_config/default_config.yml +3 -1
- data/lib/ollama_chat/tools/execute_ri.rb +47 -0
- data/lib/ollama_chat/tools/get_current_weather.rb +60 -60
- data/lib/ollama_chat/tools/write_file.rb +6 -3
- data/lib/ollama_chat/tools.rb +1 -0
- data/lib/ollama_chat/utils/fetcher.rb +2 -1
- data/lib/ollama_chat/version.rb +1 -1
- data/ollama_chat.gemspec +5 -5
- data/spec/assets/pirateweather.json +1 -0
- data/spec/ollama_chat/input_content_spec.rb +8 -8
- data/spec/ollama_chat/parsing_spec.rb +1 -1
- data/spec/ollama_chat/tools/directory_structure_spec.rb +1 -1
- data/spec/ollama_chat/tools/execute_ri_spec.rb +89 -0
- data/spec/ollama_chat/tools/get_current_weather_spec.rb +16 -40
- data/spec/ollama_chat/tools/write_file_spec.rb +22 -0
- metadata +6 -3
- data/lib/ollama_chat/tools/weather/dwd_sensor.rb +0 -203
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5cf8d81848dd2c573db23ac8182a092822bc273ba1d224307e756ab7e6741698
|
|
4
|
+
data.tar.gz: ce5219be13b5293b477a89a9d1b187ec78dd06322b0e96275d7316f006d4828b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a010b8f1cc2ce2eed10d873ec28b5c3c60af9f9f025af0d6db21c3103d7247cd433ea638b9ce78efb5659e5515ef8e15f7136e193c3470d5f87183f1939adc8e
|
|
7
|
+
data.tar.gz: e2e0d34db7b81234f97e10e6e20e0747640ad15ac087c36c430c6d47540489414241c965a2759f31b3cf9bd9c6477c1d363793cb67f14c2769c03156f3ab2411
|
data/CHANGES.md
CHANGED
|
@@ -1,42 +1,89 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-03-06 v0.0.74
|
|
4
|
+
|
|
5
|
+
- Added new tool `ExecuteRI` in `lib/ollama_chat/tools/execute_ri.rb` that
|
|
6
|
+
invokes Ruby's `ri`, returning JSON with command, result, or error details.
|
|
7
|
+
- Registered `ExecuteRI` via a require in `lib/ollama_chat/tools.rb` and
|
|
8
|
+
enabled it by default in `default_config.yml`.
|
|
9
|
+
- Extended `Fetcher.execute` to accept an array of strings, joining them into a
|
|
10
|
+
shell‑safe string when needed.
|
|
11
|
+
- Added comprehensive RSpec tests for name resolution, tool creation, hash
|
|
12
|
+
conversion, successful execution with valid topics, missing/invalid topic
|
|
13
|
+
handling, and fetcher exception reporting.
|
|
14
|
+
- Updated gemspec to include `execute_ri.rb`, its spec, and related files in
|
|
15
|
+
`extra_rdoc_files`, `files`, and `test_files`.
|
|
16
|
+
- Refactored `OllamaChat::Tools::GetCurrentWeather` to use the Pirate Weather
|
|
17
|
+
API, adding a new config key `PIRATEWEATHER_API_KEY` and updating the default
|
|
18
|
+
URL template in `default_config.yml`.
|
|
19
|
+
- Removed legacy DWD sensor dependency and deleted
|
|
20
|
+
`lib/ollama_chat/tools/weather/dwd_sensor.rb`.
|
|
21
|
+
- Stubbed `get_weather_data` in tests and added new asset
|
|
22
|
+
`spec/assets/pirateweather.json`.
|
|
23
|
+
- Adjusted test expectations to account for the new JSON asset and increased
|
|
24
|
+
directory‑structure count from 18 to 19 items.
|
|
25
|
+
- Made `write_file` nil‑safe by assigning `bytes_written =
|
|
26
|
+
args.content&.size.to_i` and replaced the two‑branch logic with a `case…when`
|
|
27
|
+
on `args.mode` handling `'append'`, `'overwrite'`, and raising
|
|
28
|
+
`ArgumentError` for invalid modes.
|
|
29
|
+
- Updated `spec/ollama_chat/tools/write_file_spec.rb` to confirm that invalid
|
|
30
|
+
modes return JSON with an `"error": "ArgumentError"` and an informative
|
|
31
|
+
message.
|
|
32
|
+
- Removed unnecessary `tins/secure_write` dependency.
|
|
33
|
+
- Added support for multiple glob patterns to the `/input` command: split
|
|
34
|
+
`/input` args into an array of `patterns`, changed `InputContent#input`
|
|
35
|
+
signature to accept `Array<String>`, normalized with `Array(patterns)`,
|
|
36
|
+
passed expanded paths to `choose_filename`, refactored `choose_filename` to
|
|
37
|
+
aggregate matches via `Pathname.glob`, filter chosen files, and return a
|
|
38
|
+
single `Pathname` object.
|
|
39
|
+
- Replaced legacy `File.read(filename)` with idiomatic `filename.read` for
|
|
40
|
+
reading file contents.
|
|
41
|
+
- Expanded `use_model` implementation in `model_handling.rb` to pull metadata,
|
|
42
|
+
check think tools support, update tool settings, and return updated metadata.
|
|
43
|
+
- Added system prompt flag and improved model handling: introduced
|
|
44
|
+
`@setup_system_prompt`, conditional call in `Chat#start`, block sets chosen
|
|
45
|
+
model via `use_model`, assigns options to `@model_options`, and enables think
|
|
46
|
+
mode if needed.
|
|
47
|
+
- Updated capabilities output in `information.rb` using safe navigation
|
|
48
|
+
(`Array(@model_metadata&.capabilities) * ', '`).
|
|
49
|
+
|
|
3
50
|
## 2026-03-05 v0.0.73
|
|
4
51
|
|
|
5
52
|
- Renamed the `"/regenerate"` command to `"/revise"` with an optional `edit`
|
|
6
|
-
subcommand in `chat.rb`.
|
|
53
|
+
subcommand in `chat.rb`.
|
|
7
54
|
- Replaced the `revise_last` method with `change_response` in
|
|
8
|
-
`message_editing.rb`.
|
|
55
|
+
`message_editing.rb`.
|
|
9
56
|
- Added a new `edit_text` method that uses temporary files for external editor
|
|
10
|
-
integration.
|
|
11
|
-
- Updated help text and documentation references throughout the codebase.
|
|
12
|
-
- Adjusted tests in `chat_spec.rb` and `message_editing_spec.rb` accordingly.
|
|
57
|
+
integration.
|
|
58
|
+
- Updated help text and documentation references throughout the codebase.
|
|
59
|
+
- Adjusted tests in `chat_spec.rb` and `message_editing_spec.rb` accordingly.
|
|
13
60
|
- Added a `ModelMetadata` struct to encapsulate model information, including
|
|
14
|
-
capabilities.
|
|
61
|
+
capabilities.
|
|
15
62
|
- Introduced `OllamaChat::UnknownModelError` for better error handling when
|
|
16
|
-
models are not found.
|
|
63
|
+
models are not found.
|
|
17
64
|
- Implemented a `can?` method on `ModelMetadata` for clean capability checks,
|
|
18
|
-
e.g., `@model_metadata.can?('thinking')`.
|
|
65
|
+
e.g., `@model_metadata.can?('thinking')`.
|
|
19
66
|
- Updated `pull_model_unless_present` to return a `ModelMetadata` instance
|
|
20
|
-
instead of a system prompt string.
|
|
67
|
+
instead of a system prompt string.
|
|
21
68
|
- Enhanced the `"/model"` command with proper error handling using the new
|
|
22
|
-
exception class.
|
|
69
|
+
exception class.
|
|
23
70
|
- Added a capabilities display in the information output: `STDOUT.puts
|
|
24
|
-
"Capabilities: #{Array(@model_metadata.capabilities) * ', '}"`.
|
|
25
|
-
- Refactored the `use_model` method for cleaner model selection flow.
|
|
71
|
+
"Capabilities: #{Array(@model_metadata.capabilities) * ', '}"`.
|
|
72
|
+
- Refactored the `use_model` method for cleaner model selection flow.
|
|
26
73
|
- Updated tests to validate capability parsing from API responses (e.g.,
|
|
27
|
-
`"completion","tools"` for **8.0B** models).
|
|
74
|
+
`"completion","tools"` for **8.0B** models).
|
|
28
75
|
- Modified `setup_system_prompt` to use the new metadata system
|
|
29
|
-
(`@model_metadata.system`) instead of the old approach.
|
|
76
|
+
(`@model_metadata.system`) instead of the old approach.
|
|
30
77
|
- Improved error handling in chat initialization and the `"/model"` command
|
|
31
|
-
with specific model‑not‑found errors.
|
|
78
|
+
with specific model‑not‑found errors.
|
|
32
79
|
- Removed an unused parameter from the `pull_model_unless_present` method
|
|
33
|
-
signature.
|
|
80
|
+
signature.
|
|
34
81
|
- Updated `OllamaChat::Chat` to handle both `think?` and `tools_support?`
|
|
35
|
-
conditions in error recovery logic.
|
|
82
|
+
conditions in error recovery logic.
|
|
36
83
|
- Modified the rescue block to check `(think? || tools_support.on?)` instead of
|
|
37
|
-
just `think?`.
|
|
84
|
+
just `think?`.
|
|
38
85
|
- Added a `tools_support.set false` call alongside disabling think mode when
|
|
39
|
-
errors occur.
|
|
86
|
+
errors occur.
|
|
40
87
|
- Improved the error message to reflect that both modes are disabled during
|
|
41
88
|
retry attempts.
|
|
42
89
|
|
|
@@ -44,50 +91,50 @@
|
|
|
44
91
|
|
|
45
92
|
- Introduced `OllamaChat::PersonaeManagement` module and `/persona` command
|
|
46
93
|
with subcommands `add`, `delete`, `edit`, `list`, `play`, `file`, `info`,
|
|
47
|
-
`load`.
|
|
94
|
+
`load`.
|
|
48
95
|
- Added `/config reload` subcommand to `OllamaChat::Chat`; handler
|
|
49
96
|
`reload_config` in `OllamaChat::ConfigHandling` prompts for confirmation,
|
|
50
|
-
calls `save_conversation`, then restarts with `exec($0,*ARGV)`.
|
|
51
|
-
- Added `-p` command‑line option (`-p PERSONA`) to load personas at startup.
|
|
52
|
-
- Created `OllamaChat::Pager` module for pager functionality.
|
|
97
|
+
calls `save_conversation`, then restarts with `exec($0,*ARGV)`.
|
|
98
|
+
- Added `-p` command‑line option (`-p PERSONA`) to load personas at startup.
|
|
99
|
+
- Created `OllamaChat::Pager` module for pager functionality.
|
|
53
100
|
- Created `OllamaChat::FileEditing` module; refactored `edit_config`,
|
|
54
101
|
`compose`, `revise_last` to use `edit_file`; added `vim(server_name = nil)`
|
|
55
|
-
returning `OllamaChat::Vim` and `perform_insert(text:, content:)`.
|
|
102
|
+
returning `OllamaChat::Vim` and `perform_insert(text:, content:)`.
|
|
56
103
|
- Added LLM‑driven tool `insert_into_editor`
|
|
57
104
|
(`lib/ollama_chat/tools/insert_into_editor.rb`) with RSpec tests; default
|
|
58
|
-
config (`default_config.yml`) now enables confirmation flag for this tool.
|
|
105
|
+
config (`default_config.yml`) now enables confirmation flag for this tool.
|
|
59
106
|
- Enhanced `copy_to_clipboard` tool: accepts optional `text` parameter,
|
|
60
107
|
includes helper `last_message_content`, returns `true` on success, updated
|
|
61
|
-
error messages, added test for custom text.
|
|
62
|
-
- Added `bytes_written` tracking to `write_file` tool; fixed return hash key.
|
|
63
|
-
- Added visual separator for tool output.
|
|
64
|
-
- Renamed `env_config.rb` to `oc.rb`; updated requires accordingly.
|
|
108
|
+
error messages, added test for custom text.
|
|
109
|
+
- Added `bytes_written` tracking to `write_file` tool; fixed return hash key.
|
|
110
|
+
- Added visual separator for tool output.
|
|
111
|
+
- Renamed `env_config.rb` to `oc.rb`; updated requires accordingly.
|
|
65
112
|
- Added `save_history` call after conversation backup to persist history before
|
|
66
|
-
restart.
|
|
67
|
-
- Updated documentation and help messages to reflect new commands and options.
|
|
113
|
+
restart.
|
|
114
|
+
- Updated documentation and help messages to reflect new commands and options.
|
|
68
115
|
- Standardised type hints across codebase, replacing generic Boolean comments
|
|
69
|
-
with explicit `[ true, false ]`.
|
|
116
|
+
with explicit `[ true, false ]`.
|
|
70
117
|
|
|
71
118
|
## 2026-02-26 v0.0.71
|
|
72
119
|
|
|
73
120
|
- Add new clipboard utilities: `tools/copy_to_clipboard.rb` and
|
|
74
|
-
`tools/paste_from_clipboard.rb`.
|
|
121
|
+
`tools/paste_from_clipboard.rb`.
|
|
75
122
|
- Update gemspec to include the new tools in `s.extra_rdoc_files`, `s.files`,
|
|
76
|
-
and `s.test_files`.
|
|
77
|
-
- Update stub comment in `ollama_chat.gemspec` to reflect the new version.
|
|
123
|
+
and `s.test_files`.
|
|
124
|
+
- Update stub comment in `ollama_chat.gemspec` to reflect the new version.
|
|
78
125
|
- Enable more tools by default
|
|
79
126
|
- Rename `think_loud?` to `think?` in `follow_chat.rb` for storage logic;
|
|
80
127
|
update `last_message_with_user` to conditionally include thinking content;
|
|
81
128
|
remove empty string from `output_eval_stats`; add test for saving
|
|
82
129
|
conversations with thinking content in `message_list_spec.rb`; update spec
|
|
83
|
-
expectations to use `think_loud?: false` for display behavior.
|
|
130
|
+
expectations to use `think_loud?: false` for display behavior.
|
|
84
131
|
- Replace `/paste` command to use `paste_from_clipboard`; add
|
|
85
132
|
`perform_paste_from_clipboard` method in `lib/ollama_chat/clipboard.rb`; add
|
|
86
133
|
`paste_from_clipboard` tool in
|
|
87
134
|
`lib/ollama_chat/tools/paste_from_clipboard.rb`; add `paste: pfc`
|
|
88
135
|
configuration option; update tool defaults in configuration; update existing
|
|
89
136
|
tests to use new method names; add new spec file for `paste_from_clipboard`
|
|
90
|
-
tool.
|
|
137
|
+
tool.
|
|
91
138
|
- Add `OllamaChat::Tools::CopyToClipboard` tool that integrates with chat tool
|
|
92
139
|
system; implement `MessageList#find_last` method with optional `content`
|
|
93
140
|
parameter to filter empty messages; enhance
|
|
@@ -97,12 +144,12 @@
|
|
|
97
144
|
message finding functionality; integrate clipboard functionality with
|
|
98
145
|
existing configuration system using `config.copy`; update success message
|
|
99
146
|
text from "copied to the system clipboard" to "successfully copied to the
|
|
100
|
-
system clipboard".
|
|
147
|
+
system clipboard".
|
|
101
148
|
- Add interactive help mode with `/help me` command handler in
|
|
102
149
|
`lib/ollama_chat/chat.rb`; add `help` prompt template to
|
|
103
150
|
`lib/ollama_chat/ollama_chat_config/default_config.yml`; update help text in
|
|
104
151
|
`README.md` and `lib/ollama_chat/information.rb`; add test coverage in
|
|
105
|
-
`spec/ollama_chat/chat_spec.rb`.
|
|
152
|
+
`spec/ollama_chat/chat_spec.rb`.
|
|
106
153
|
- Make `Pathname` output quoted for string interpolation: replace
|
|
107
154
|
`filename.inspect` with `filename.to_s.inspect` in `save_conversation` and
|
|
108
155
|
`load_conversation` methods; update three locations in
|
|
@@ -111,137 +158,137 @@
|
|
|
111
158
|
## 2026-02-23 v0.0.70
|
|
112
159
|
|
|
113
160
|
- Added `generate_password` tool with secure password generation, supporting
|
|
114
|
-
multiple alphabet types.
|
|
115
|
-
- Updated `tins` gem dependency to **1.52**.
|
|
116
|
-
- Added comprehensive tests for `generate_password` with various parameters.
|
|
161
|
+
multiple alphabet types.
|
|
162
|
+
- Updated `tins` gem dependency to **1.52**.
|
|
163
|
+
- Added comprehensive tests for `generate_password` with various parameters.
|
|
117
164
|
- Registered `generate_password` tool in the gemspec and configured it in
|
|
118
|
-
`default_config.yml`.
|
|
165
|
+
`default_config.yml`.
|
|
119
166
|
- Added `get_rfc` tool for fetching RFC documents, including URL template
|
|
120
|
-
configuration in `default_config.yml`.
|
|
121
|
-
- Implemented `OllamaChat::Tools::GetRFC` class and required it in `tools.rb`.
|
|
122
|
-
- Added comprehensive test suite for `get_rfc` in `get_rfc_spec.rb`.
|
|
167
|
+
configuration in `default_config.yml`.
|
|
168
|
+
- Implemented `OllamaChat::Tools::GetRFC` class and required it in `tools.rb`.
|
|
169
|
+
- Added comprehensive test suite for `get_rfc` in `get_rfc_spec.rb`.
|
|
123
170
|
- Implemented backup fallback for conversation loading: `chat.rb` now loads
|
|
124
171
|
from `OC::XDG_CACHE_HOME.join('backup.json')` when `-c` is not provided, and
|
|
125
|
-
deletes the backup after successful load.
|
|
172
|
+
deletes the backup after successful load.
|
|
126
173
|
- Updated `config_handling.rb` to save backups to
|
|
127
|
-
`OC::XDG_CACHE_HOME.join('backup.json')` instead of the current directory.
|
|
174
|
+
`OC::XDG_CACHE_HOME.join('backup.json')` instead of the current directory.
|
|
128
175
|
- Modified `message_list.rb` to print file‑existence errors using
|
|
129
176
|
`filename.to_s.inspect` and to safely remove the backup file with
|
|
130
|
-
`FileUtils.rm_f`.
|
|
177
|
+
`FileUtils.rm_f`.
|
|
131
178
|
- Renamed `OllamaChat::EnvConfig` to `OC` module alias, updating all references
|
|
132
|
-
accordingly.
|
|
179
|
+
accordingly.
|
|
133
180
|
- Added new constants: `OC::OLLAMA::SEARXNG_URL`, `OC::OLLAMA::REDIS_URL`,
|
|
134
|
-
`OC::OLLAMA::REDIS_EXPIRING_URL`.
|
|
181
|
+
`OC::OLLAMA::REDIS_EXPIRING_URL`.
|
|
135
182
|
- Updated nested module paths, e.g., `OC::OLLAMA::CHAT::TOOLS::JIRA` and
|
|
136
|
-
`OC::OLLAMA::CHAT::TOOLS::RUN_TESTS_TEST_RUNNER`.
|
|
183
|
+
`OC::OLLAMA::CHAT::TOOLS::RUN_TESTS_TEST_RUNNER`.
|
|
137
184
|
- Refactored code to use nested class structure within the module and added
|
|
138
185
|
comprehensive YARD documentation with `@param`, `@return`, and `@example`
|
|
139
|
-
tags.
|
|
140
|
-
- Added module‑level documentation explaining tool purpose.
|
|
186
|
+
tags.
|
|
187
|
+
- Added module‑level documentation explaining tool purpose.
|
|
141
188
|
- Added YARD documentation to `read_file.rb`, including module docstring,
|
|
142
189
|
return type `[Ollama::Tool]`, and execute method parameter/return
|
|
143
|
-
documentation.
|
|
190
|
+
documentation.
|
|
144
191
|
- Removed empty `lib/ollama_chat/tools/endoflife.rb`; the functionality is now
|
|
145
192
|
provided by the `get_endoflife` tool.
|
|
146
193
|
|
|
147
194
|
## 2026-02-23 v0.0.69
|
|
148
195
|
|
|
149
196
|
- Reorganized access modifiers in `module OllamaChat::Dialog`, moving `ask?` to
|
|
150
|
-
be public before the `private` keyword.
|
|
197
|
+
be public before the `private` keyword.
|
|
151
198
|
- Moved `links`, `debug`, `config=`, and `config` from public to private in
|
|
152
|
-
`lib/ollama_chat/chat.rb`.
|
|
199
|
+
`lib/ollama_chat/chat.rb`.
|
|
153
200
|
- Added a `class_methods` block in `lib/ollama_chat/config_handling.rb`
|
|
154
|
-
declaring a class‑level `config` accessor via `Tins::Concern`.
|
|
201
|
+
declaring a class‑level `config` accessor via `Tins::Concern`.
|
|
155
202
|
- Added a private `config=` method in `config_handling.rb` to write to the
|
|
156
|
-
class‑level `config`.
|
|
157
|
-
- Kept a public `config` method that returns `self.class.config`.
|
|
203
|
+
class‑level `config`.
|
|
204
|
+
- Kept a public `config` method that returns `self.class.config`.
|
|
158
205
|
- Added `private` to modules: `OllamaChat::Clipboard`,
|
|
159
206
|
`OllamaChat::Conversation`, `OllamaChat::Dialog`,
|
|
160
207
|
`OllamaChat::DocumentCache`, `OllamaChat::History`,
|
|
161
208
|
`OllamaChat::InputContent`, `OllamaChat::MessageEditing`,
|
|
162
209
|
`OllamaChat::ModelHandling`, `OllamaChat::ServerSocket` and removed the
|
|
163
|
-
`private` declaration from `OllamaChat::ToolCalling`.
|
|
210
|
+
`private` declaration from `OllamaChat::ToolCalling`.
|
|
164
211
|
- Updated spec files to call `expose` on `OllamaChat::Chat.new(argv:
|
|
165
212
|
chat_default_config)` and on `Object.extend(described_class)` so that private
|
|
166
|
-
helpers can be exercised during testing.
|
|
213
|
+
helpers can be exercised during testing.
|
|
167
214
|
- Ensured the command‑handling logic in `handle_input` continues to invoke the
|
|
168
|
-
newly private methods correctly.
|
|
215
|
+
newly private methods correctly.
|
|
169
216
|
- Added `tool_function(name)` helper to `OllamaChat::ToolCalling` for
|
|
170
|
-
centralised tool config lookup.
|
|
217
|
+
centralised tool config lookup.
|
|
171
218
|
- Updated `lib/ollama_chat/follow_chat.rb` to use `@chat.tool_function(name)`
|
|
172
|
-
instead of `config.tools.functions[name]`.
|
|
219
|
+
instead of `config.tools.functions[name]`.
|
|
173
220
|
- Modified `lib/ollama_chat/switches.rb` switch messages to lower‑case
|
|
174
|
-
“support” (`"Tools support enabled."` / `"Tools support disabled."`).
|
|
221
|
+
“support” (`"Tools support enabled."` / `"Tools support disabled."`).
|
|
175
222
|
- In `lib/ollama_chat/tool_calling.rb`, replaced `config.tools.functions[tool]`
|
|
176
223
|
with `tool_function(tool)` when printing tools and checking
|
|
177
|
-
`require_confirmation?`.
|
|
224
|
+
`require_confirmation?`.
|
|
178
225
|
- Added a `private` section header in `lib/ollama_chat/tool_calling.rb` for
|
|
179
|
-
clarity.
|
|
226
|
+
clarity.
|
|
180
227
|
- Adjusted spec regex in `spec/ollama_chat/chat_spec.rb` to match updated
|
|
181
|
-
message (`Tools support enabled`).
|
|
228
|
+
message (`Tools support enabled`).
|
|
182
229
|
- Added `OllamaChat::ConfigHandling` module in
|
|
183
230
|
`lib/ollama_chat/config_handling.rb` with `display_config`, `fix_config`,
|
|
184
|
-
`edit_config`.
|
|
185
|
-
- Required `ollama_chat/config_handling` in `lib/ollama_chat.rb`.
|
|
186
|
-
- Included `OllamaChat::ConfigHandling` in `OllamaChat::Chat`.
|
|
231
|
+
`edit_config`.
|
|
232
|
+
- Required `ollama_chat/config_handling` in `lib/ollama_chat.rb`.
|
|
233
|
+
- Included `OllamaChat::ConfigHandling` in `OllamaChat::Chat`.
|
|
187
234
|
- Updated `/config` command regex to `^/config(?:\\s+(edit))?$` and dispatched
|
|
188
|
-
to `edit_config` or `display_config`.
|
|
235
|
+
to `edit_config` or `display_config`.
|
|
189
236
|
- Removed old `display_config`, `fix_config`, `edit_config` methods from
|
|
190
|
-
`chat.rb`.
|
|
237
|
+
`chat.rb`.
|
|
191
238
|
- Added helper methods `tool_configured?`, `tool_registered?`, `tool_enabled?`
|
|
192
|
-
to `OllamaChat::ToolCalling` for cleaner tool state checks.
|
|
239
|
+
to `OllamaChat::ToolCalling` for cleaner tool state checks.
|
|
193
240
|
- Updated `FollowChat` to use the new helpers instead of direct config/registry
|
|
194
241
|
lookups (`@chat.config.tools.functions.attribute_set?(name)` →
|
|
195
242
|
`@chat.tool_configured?(name)`, `OllamaChat::Tools.registered?(name)` →
|
|
196
243
|
`@chat.tool_registered?(name)`, `@chat.enabled_tools.member?(name)` →
|
|
197
|
-
`@chat.tool_enabled?(name)`).
|
|
244
|
+
`@chat.tool_enabled?(name)`).
|
|
198
245
|
- Refactored `default_enabled_tools` in `OllamaChat::ToolCalling` to call
|
|
199
246
|
`tool_registered?` and adjusted `list_tools` to use `tool_enabled?` for
|
|
200
|
-
checkbox rendering.
|
|
247
|
+
checkbox rendering.
|
|
201
248
|
- Simplified `Fetcher#fetch` signature from `fetch(url, headers: {}, options:
|
|
202
249
|
{})` to `fetch(url, opts = {})`; updated documentation to reflect the new
|
|
203
|
-
`opts` hash and optional `:headers` key.
|
|
250
|
+
`opts` hash and optional `:headers` key.
|
|
204
251
|
- Added guard in `lib/ollama_chat/follow_chat.rb` to skip execution of disabled
|
|
205
|
-
tools and record an error in `@chat.tool_call_results`.
|
|
252
|
+
tools and record an error in `@chat.tool_call_results`.
|
|
206
253
|
- Added `attr_reader :enabled_tools` to `OllamaChat::ToolCalling` and replaced
|
|
207
|
-
all `@enabled_tools` references with the reader.
|
|
254
|
+
all `@enabled_tools` references with the reader.
|
|
208
255
|
- Updated `tools`, `list_tools`, `enable_tool`, and `disable_tool` to use
|
|
209
|
-
`enabled_tools` instead of the instance variable.
|
|
210
|
-
- Updated `/tools` command to accept `on`/`off` and handle them.
|
|
256
|
+
`enabled_tools` instead of the instance variable.
|
|
257
|
+
- Updated `/tools` command to accept `on`/`off` and handle them.
|
|
211
258
|
- Added `tools_support` switch in `switches.rb` reflecting
|
|
212
|
-
`config.tools.enabled`.
|
|
213
|
-
- Refactored config to use `enabled:` and `functions:` under `tools:`.
|
|
214
|
-
- Updated all tool references to `config.tools.functions`.
|
|
215
|
-
- Guard tool calls with `@tools_support.off?` in `tool_calling.rb`.
|
|
259
|
+
`config.tools.enabled`.
|
|
260
|
+
- Refactored config to use `enabled:` and `functions:` under `tools:`.
|
|
261
|
+
- Updated all tool references to `config.tools.functions`.
|
|
262
|
+
- Guard tool calls with `@tools_support.off?` in `tool_calling.rb`.
|
|
216
263
|
- Updated `default_enabled_tools` and `list_tools` to use
|
|
217
|
-
`config.tools.functions`.
|
|
218
|
-
- Added `tools_support.show` to `information.rb`.
|
|
264
|
+
`config.tools.functions`.
|
|
265
|
+
- Added `tools_support.show` to `information.rb`.
|
|
219
266
|
- Updated tool implementations (`directory_structure`, `execute_grep`,
|
|
220
267
|
`file_context`, `get_current_weather`, `get_cve`, `get_endoflife`,
|
|
221
268
|
`import_url`, `read_file`, `search_web`, `write_file`) to use
|
|
222
|
-
`config.tools.functions`.
|
|
269
|
+
`config.tools.functions`.
|
|
223
270
|
- Adjusted specs to reference `functions` and modify `gem_path_lookup` spec to
|
|
224
|
-
return a symbol.
|
|
271
|
+
return a symbol.
|
|
225
272
|
- Added `OLLAMA_CHAT_TOOLS_RUN_TESTS_TEST_RUNNER` to `.envrc` for the
|
|
226
|
-
`run_tests` tool.
|
|
227
|
-
- Removed gem system updates from Dockerfile.
|
|
273
|
+
`run_tests` tool.
|
|
274
|
+
- Removed gem system updates from Dockerfile.
|
|
228
275
|
- Removed `model_with_size` and `choose_model` from
|
|
229
|
-
`lib/ollama_chat/dialog.rb`.
|
|
276
|
+
`lib/ollama_chat/dialog.rb`.
|
|
230
277
|
- Added `model_with_size` and `choose_model` to
|
|
231
|
-
`lib/ollama_chat/model_handling.rb`.
|
|
278
|
+
`lib/ollama_chat/model_handling.rb`.
|
|
232
279
|
- In `lib/ollama_chat/env_config.rb`, changed `decode` lambda to use
|
|
233
|
-
`Pathname.new(_1).join('ollama_chat').expand_path` for absolute paths.
|
|
280
|
+
`Pathname.new(_1).join('ollama_chat').expand_path` for absolute paths.
|
|
234
281
|
- In `lib/ollama_chat/ollama_chat_config.rb`, replaced
|
|
235
|
-
`File.directory?(cache_dir_path)` with `cache_dir_path.directory?`.
|
|
282
|
+
`File.directory?(cache_dir_path)` with `cache_dir_path.directory?`.
|
|
236
283
|
- Updated `default_path`, `config_dir_path`, `cache_dir_path`, and
|
|
237
|
-
`database_path` to consistently return `Pathname` objects.
|
|
238
|
-
- Added `and_call_original` to source fetching test.
|
|
239
|
-
- Removed `bundle update --all` from `.all_images.yml`.
|
|
284
|
+
`database_path` to consistently return `Pathname` objects.
|
|
285
|
+
- Added `and_call_original` to source fetching test.
|
|
286
|
+
- Removed `bundle update --all` from `.all_images.yml`.
|
|
240
287
|
- Added `before:` block to `.all_images.yml` that echoes 'Preparing…' and
|
|
241
|
-
deletes `Gemfile.lock`.
|
|
288
|
+
deletes `Gemfile.lock`.
|
|
242
289
|
- Added `after:` block to `.all_images.yml` that checks `$RESULT` and prints
|
|
243
|
-
success/failure messages, then deletes `Gemfile.lock`.
|
|
244
|
-
- Updated dependency `all_images` to **~>0.12**.
|
|
290
|
+
success/failure messages, then deletes `Gemfile.lock`.
|
|
291
|
+
- Updated dependency `all_images` to **~>0.12**.
|
|
245
292
|
|
|
246
293
|
## 2026-02-19 v0.0.68
|
|
247
294
|
|
|
@@ -385,44 +432,44 @@
|
|
|
385
432
|
|
|
386
433
|
## 2026-02-07 v0.0.62
|
|
387
434
|
|
|
388
|
-
**Tool Execution**
|
|
389
|
-
- All tools now return structured JSON errors (`error` + `message`).
|
|
390
|
-
- Confirmation prompts (`confirm?`) added to `OllamaChat::FollowChat`.
|
|
391
|
-
- `infobar` displays a busy indicator and status messages during tool runs.
|
|
435
|
+
**Tool Execution**
|
|
436
|
+
- All tools now return structured JSON errors (`error` + `message`).
|
|
437
|
+
- Confirmation prompts (`confirm?`) added to `OllamaChat::FollowChat`.
|
|
438
|
+
- `infobar` displays a busy indicator and status messages during tool runs.
|
|
392
439
|
- Tool methods accept `config:` and `chat:` keyword arguments.
|
|
393
440
|
|
|
394
|
-
**Tool Registration**
|
|
441
|
+
**Tool Registration**
|
|
395
442
|
- Centralized logic via `OllamaChat::Tools::Concern` to prevent duplicate
|
|
396
443
|
registrations.
|
|
397
444
|
|
|
398
|
-
**File Context Tool (`file_context`)**
|
|
399
|
-
- Supports an exact `path:` argument in addition to `directory:` + `pattern:`.
|
|
400
|
-
- Uses `blank?` for argument validation.
|
|
445
|
+
**File Context Tool (`file_context`)**
|
|
446
|
+
- Supports an exact `path:` argument in addition to `directory:` + `pattern:`.
|
|
447
|
+
- Uses `blank?` for argument validation.
|
|
401
448
|
- YARD documentation added.
|
|
402
449
|
|
|
403
|
-
**Directory Structure Tool (`directory_structure`)**
|
|
404
|
-
- Delegates to `OllamaChat::Utils::AnalyzeDirectory.generate_structure`.
|
|
405
|
-
- Excludes hidden files, symlinks, and the `pkg` directory by default.
|
|
450
|
+
**Directory Structure Tool (`directory_structure`)**
|
|
451
|
+
- Delegates to `OllamaChat::Utils::AnalyzeDirectory.generate_structure`.
|
|
452
|
+
- Excludes hidden files, symlinks, and the `pkg` directory by default.
|
|
406
453
|
- `exclude` option configurable in `default_config.yml`.
|
|
407
454
|
|
|
408
|
-
**Utility Module**
|
|
455
|
+
**Utility Module**
|
|
409
456
|
- New `OllamaChat::Utils::AnalyzeDirectory` containing the `generate_structure`
|
|
410
457
|
method.
|
|
411
458
|
|
|
412
|
-
**Error Handling**
|
|
459
|
+
**Error Handling**
|
|
413
460
|
- `CVE`, `EndOfLife`, `Grep`, and `Weather` tools now catch all exceptions and return structured JSON errors.
|
|
414
461
|
|
|
415
|
-
**Testing**
|
|
462
|
+
**Testing**
|
|
416
463
|
- Added comprehensive specs for `AnalyzeDirectory` (traversal, exclusions,
|
|
417
|
-
error handling).
|
|
418
|
-
- Tests for exact `path` usage in `file_context` with conflict detection.
|
|
464
|
+
error handling).
|
|
465
|
+
- Tests for exact `path` usage in `file_context` with conflict detection.
|
|
419
466
|
- Updated `test_files` list in the gemspec.
|
|
420
467
|
|
|
421
|
-
**Configuration**
|
|
422
|
-
- `directory_structure` accepts an `exclude` option via `default_config.yml`.
|
|
468
|
+
**Configuration**
|
|
469
|
+
- `directory_structure` accepts an `exclude` option via `default_config.yml`.
|
|
423
470
|
- Tool signatures updated to accept `config:` and `chat:`.
|
|
424
471
|
|
|
425
|
-
**Gem Specification**
|
|
472
|
+
**Gem Specification**
|
|
426
473
|
- Updated `test_files`, `extra_rdoc_files`, and `files` arrays to include new
|
|
427
474
|
utilities, tests, and documentation.
|
|
428
475
|
|
data/lib/ollama_chat/chat.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'tins'
|
|
2
|
-
require 'tins/secure_write'
|
|
3
2
|
require 'tins/xt/string_version'
|
|
4
3
|
require 'tins/xt/full'
|
|
5
4
|
require 'json'
|
|
@@ -97,19 +96,13 @@ class OllamaChat::Chat
|
|
|
97
96
|
setup_switches(config)
|
|
98
97
|
setup_state_selectors(config)
|
|
99
98
|
connect_ollama
|
|
100
|
-
begin
|
|
101
|
-
use_model(@opts[?m].full? || config.model.name)
|
|
102
|
-
rescue OllamaChat::UnknownModelError => e
|
|
103
|
-
abort "Failed to use to model: #{e}"
|
|
104
|
-
end
|
|
105
|
-
@model_options = Ollama::Options[config.model.options]
|
|
106
99
|
if conversation_file = @opts[?c]
|
|
107
100
|
messages.load_conversation(conversation_file)
|
|
108
101
|
elsif backup_file = OC::XDG_CACHE_HOME + 'backup.json' and backup_file.exist?
|
|
109
102
|
messages.load_conversation(backup_file)
|
|
110
103
|
FileUtils.rm_f backup_file
|
|
111
104
|
else
|
|
112
|
-
setup_system_prompt
|
|
105
|
+
@setup_system_prompt = true
|
|
113
106
|
end
|
|
114
107
|
embedding_enabled.set(config.embedding.enabled && !@opts[?E])
|
|
115
108
|
@documents = setup_documents
|
|
@@ -165,13 +158,14 @@ class OllamaChat::Chat
|
|
|
165
158
|
# The start method initializes the chat session by displaying information,
|
|
166
159
|
# then prompts the user for input to begin interacting with the chat.
|
|
167
160
|
def start
|
|
168
|
-
|
|
169
|
-
|
|
161
|
+
begin
|
|
162
|
+
use_model(@opts[?m].full? || config.model.name)
|
|
163
|
+
rescue OllamaChat::UnknownModelError => e
|
|
164
|
+
abort "Failed to use to model: #{e}"
|
|
170
165
|
end
|
|
166
|
+
@model_options = Ollama::Options[config.model.options]
|
|
171
167
|
|
|
172
|
-
|
|
173
|
-
tools_support.set false
|
|
174
|
-
end
|
|
168
|
+
@setup_system_prompt and setup_system_prompt
|
|
175
169
|
|
|
176
170
|
info
|
|
177
171
|
STDOUT.puts "\nType /help to display the chat help."
|
|
@@ -338,8 +332,10 @@ class OllamaChat::Chat
|
|
|
338
332
|
@parse_content = false
|
|
339
333
|
web($1, $2)
|
|
340
334
|
when %r(^/input(?:\s+(.+))?$)
|
|
335
|
+
arg = $1
|
|
336
|
+
arg and patterns = arg.scan(/(\S+)/).flatten
|
|
341
337
|
@parse_content = false
|
|
342
|
-
input(
|
|
338
|
+
input(patterns) or :next
|
|
343
339
|
when %r(^/context(?:\s+(.+))?$)
|
|
344
340
|
arg = $1
|
|
345
341
|
arg and patterns = arg.scan(/(\S+)/).flatten
|
|
@@ -85,7 +85,7 @@ module OllamaChat::Information
|
|
|
85
85
|
STDOUT.puts "Running ollama_chat version: #{bold(OllamaChat::VERSION)}"
|
|
86
86
|
STDOUT.puts "Connected to ollama server version: #{bold(server_version)} on: #{bold(server_url)}"
|
|
87
87
|
STDOUT.puts "Current conversation model is #{bold{@model}}."
|
|
88
|
-
STDOUT.puts " Capabilities: #{Array(@model_metadata
|
|
88
|
+
STDOUT.puts " Capabilities: #{Array(@model_metadata&.capabilities) * ', '}"
|
|
89
89
|
if @model_options.present?
|
|
90
90
|
STDOUT.puts " Options: #{JSON.pretty_generate(@model_options).gsub(/(?<!\A)^/, ' ')}"
|
|
91
91
|
end
|
|
@@ -16,18 +16,19 @@ module OllamaChat::InputContent
|
|
|
16
16
|
# pattern, reads their content, and returns a concatenated string with each
|
|
17
17
|
# file's content preceded by its filename.
|
|
18
18
|
#
|
|
19
|
-
# @param
|
|
19
|
+
# @param patterns [Array<String>] the glob patterns to search for files (defaults to '**/*')
|
|
20
20
|
#
|
|
21
21
|
# @return [String] a concatenated string of file contents with filenames as headers
|
|
22
|
-
def input(
|
|
23
|
-
|
|
22
|
+
def input(patterns)
|
|
23
|
+
patterns ||= '**/*'
|
|
24
|
+
patterns = Array(patterns)
|
|
24
25
|
files = Set[]
|
|
25
|
-
while filename = choose_filename(
|
|
26
|
-
files << filename
|
|
26
|
+
while filename = choose_filename(patterns, chosen: files)
|
|
27
|
+
files << filename.expand_path
|
|
27
28
|
end
|
|
28
29
|
result = ''
|
|
29
30
|
files.each do |filename|
|
|
30
|
-
result << ("%s:\n\n%s\n\n" % [ filename,
|
|
31
|
+
result << ("%s:\n\n%s\n\n" % [ filename, filename.read ])
|
|
31
32
|
end
|
|
32
33
|
result.full?
|
|
33
34
|
end
|
|
@@ -36,21 +37,22 @@ module OllamaChat::InputContent
|
|
|
36
37
|
# searches for files matching the given pattern, excludes already chosen
|
|
37
38
|
# files, and presents them in an interactive chooser menu.
|
|
38
39
|
#
|
|
39
|
-
# @param pattern [ String ] the glob pattern to search for files
|
|
40
|
+
# @param pattern [ Array<String> ] the glob pattern to search for files
|
|
40
41
|
# @param chosen [ Set ] a set of already chosen filenames to exclude from
|
|
41
42
|
# selection
|
|
42
43
|
#
|
|
43
44
|
# @return [ Pathname, nil ] the selected filename or nil if no file was chosen or user exited
|
|
44
|
-
def choose_filename(
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
def choose_filename(patterns, chosen: nil)
|
|
46
|
+
patterns = Array(patterns)
|
|
47
|
+
files = patterns.flat_map { Pathname.glob(_1) }
|
|
48
|
+
files = files.reject { chosen&.member?(_1.expand_path) }.select { _1.file? }
|
|
47
49
|
files.unshift('[EXIT]')
|
|
48
|
-
case
|
|
50
|
+
case chosen_file = OllamaChat::Utils::Chooser.choose(files)
|
|
49
51
|
when '[EXIT]', nil
|
|
50
52
|
STDOUT.puts "Exiting chooser."
|
|
51
53
|
return
|
|
52
54
|
else
|
|
53
|
-
Pathname.new(
|
|
55
|
+
Pathname.new(chosen_file)
|
|
54
56
|
end
|
|
55
57
|
end
|
|
56
58
|
|
|
@@ -104,13 +104,38 @@ module OllamaChat::ModelHandling
|
|
|
104
104
|
result
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
+
# The use_model method selects and sets the model to be used for the chat
|
|
108
|
+
# session.
|
|
109
|
+
#
|
|
110
|
+
# It allows specifying a particular model or defaults to the current model.
|
|
111
|
+
# After selecting, it pulls the model metadata if necessary. If think? is
|
|
112
|
+
# true and the chosen model does not support thinking, the think mode
|
|
113
|
+
# selector is set to 'disabled'. If tools_support.on? is true and the chosen
|
|
114
|
+
# model does not support tools, tool support is disabled. Returns the
|
|
115
|
+
# metadata for the selected model.
|
|
116
|
+
#
|
|
117
|
+
# @param model [ String, nil ] the model name to use; if omitted, the current
|
|
118
|
+
# model is retained
|
|
119
|
+
#
|
|
120
|
+
# @return [ ModelMetadata ] the metadata for the selected model.
|
|
107
121
|
def use_model(model = nil)
|
|
108
122
|
if model.nil?
|
|
109
123
|
@model = choose_model('', @model)
|
|
110
124
|
else
|
|
111
125
|
@model = choose_model(model, config.model.name)
|
|
112
126
|
end
|
|
127
|
+
|
|
113
128
|
@model_metadata = pull_model_unless_present(@model)
|
|
129
|
+
|
|
130
|
+
if think? && !@model_metadata.can?('thinking')
|
|
131
|
+
think_mode.selected = 'disabled'
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
if tools_support.on? && !@model_metadata.can?('tools')
|
|
135
|
+
tools_support.set false
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
@model_metadata
|
|
114
139
|
end
|
|
115
140
|
|
|
116
141
|
# The choose_model method selects a model from the available list based on
|