ollama-ruby 0.6.0 → 0.8.0

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: bb7858cf04c638fa3369fe7d96d96eed12e5553fd17abe9ed48c1eaf25113ffb
4
- data.tar.gz: ccb56d4b85a6e74256feb52ac5642d50850f7b980f9060dbb9fdf933985be746
3
+ metadata.gz: 7a6a94882e3f76e84fbceadd80ec844f9a93febd18ed294b01f7874867c53e68
4
+ data.tar.gz: 47cda3eef10438ff1cd136ffcc4469d2275bc2e26cdab985c7a001e2d0178b7f
5
5
  SHA512:
6
- metadata.gz: f36aacde399c0be934425f12669fa6cc55cdfad938ea8157c5195db8c2367243cc6470dff24ec5bf83800079732bfa271450a4779246335c45c2bedbb0e3a6cf
7
- data.tar.gz: 56e465f056934210a6cc45677d52518d8adb76e8702561248b6db4cd1e4b129cfd22eedbdcc0c935f69bf85eeb9bc324aef6876f39969942af4529978a277756
6
+ metadata.gz: 5c42f47be513e41465693c47dee68447ac42a967f7ecaaf88ea51df6ea30eb9beb61b25595fc145909a0c9b8838d22756f47e71bc6acdd33bb47e4876545ccdc
7
+ data.tar.gz: b4ac6bf59882a23774fbfb3503607c1a22d200037b31613a8f9d565ebf174b99d66259cc62d99f0635e7ac99fd07cc51aec735dd7dbb31259dc767e403eaa5d7
data/CHANGES.md CHANGED
@@ -1,15 +1,124 @@
1
1
  # Changes
2
2
 
3
+ ## 2024-10-07 v0.8.0
4
+
5
+ * **Refactor source handling in Ollama chat**:
6
+ + Update regular expression to match dot-dot, dot or tilde prefix for local files
7
+ + Add error handling for non-existent files in `Utils::Fetcher.read`
8
+ + Stop matching the "hostname" part in file:// URLs
9
+ * **Update voice list command to suppress errors**:
10
+ + Changed `say` command in OllamaChatConfig to `-v ? 2>/dev/null`
11
+ * **Add 'List:' and list of collections to the collection stats output**
12
+ * **Update collection stats display**:
13
+ + Added new stat: `#Tags` to `collection_stats` method in `ollama_chat.rb`
14
+ + Displaying number of tags for the current document collection
15
+ * **Refactor embed_source function to include document count**:
16
+ + Added `count` parameter to `embed_source` method
17
+ + Updated `puts` statements in `embed_source` and main loop to display document counts
18
+ + Incremented `count` variable in main loop to track total documents embedded
19
+ + Passed `count:` keyword argument to `embed_source` method
20
+ * **Add config option for batch_size and update document adding logic**:
21
+ + Added `batch_size` option to `OllamaChatConfig`
22
+ + Updated `embed_source` method in `bin/ollama_chat` to use `batch_size` from `config`
23
+ + Updated `add` method in `lib/ollama/documents.rb` to accept `batch_size` and default to 10
24
+ * **Update Redis image to valkey/valkey:7.2.7-alpine**:
25
+ + Updated `image` in `docker-compose.yml` to `valkey/valkey:7.2.7-alpine`
26
+ * **Reformat CHANGES.md**
27
+
28
+ ## 2024-10-03 v0.7.0
29
+
30
+ * **Refactor command line interface**
31
+ + Moved case order
32
+ + Renamed `/collection clear [tag]|change` to `/collection (clear|change)`
33
+ + Improved help message, added /info
34
+ * **Update README.md**
35
+ + Update README.md to reflect changed/added commands
36
+ * **Add support for reading PostScript**
37
+ + Extracted `pdf_read` method to read PDF files using `PDF::Reader`
38
+ + Added `ps_read` method to read PostScript files by converting them to PDF with Ghostscript and using `pdf_read`.
39
+ + Updated `parse_source` method to handle PostScript files
40
+ * **Update read buffer size for tempfile writes**
41
+ + Updated `tmp.write` to use a larger buffer size (**16KB**) in IO.popen block.
42
+ * **Refactor Collection Chooser and usages**
43
+ + Added confirmation prompt before clearing collection
44
+ + Improved collection chooser with `[EXIT]` and `[ALL]` options
45
+ + Added `ask?` method for user input
46
+ * **Add prompt to choose method**
47
+ + Added `prompt` parameter to `choose` method in `Ollama::Utils::Chooser`
48
+ + Modified output formatting for selected entry in `choose` method
49
+ + Updated `choose` method to handle cases better where no entry was chosen
50
+ * **Fix Redis cache expiration logic**
51
+ + Update `set` method to delete key expiration time is less than 1 second.
52
+ * **Update dependencies and add source tracking**
53
+ - Remove `sorted_set` dependency from Rakefile
54
+ - Modify `Ollama::Documents` class to track source of tags
55
+ - Update `Ollama::Utils::Tags` class to include source in tag output and add methods for tracking source
56
+ - Update tests for `Ollama::Utils::Tags` class
57
+ * **Refactor width calculation and add tests for wrap and truncate methods.**
58
+ + Extend `Term::ANSIColor` in `Ollama::Utils::Width`
59
+ + Update `width` method to use ellipsis length when truncating text
60
+ + Add tests for `wrap` and `truncate` methods with percentage and length arguments
61
+ * **Add attr_reader for data and update equality check**
62
+ + Added `attr_reader :data` to Ollama::Image class
63
+ + Updated `==` method in Ollama::Image class to use `other.data`
64
+ + Added test case in `image_spec.rb` to verify equality of images
65
+
66
+ ## 2024-09-30 v0.6.0
67
+
68
+ ### Significant Changes
69
+
70
+ * **Added voice toggle and change functionality**:
71
+ + Removed `-v` command line switch
72
+ + Added new Switch class for voice output
73
+ + Added new method `change_voice` to toggle or change voice output
74
+ + Updated `info` method to display current voice output if enabled
75
+ + Updated `display_chat_help` method to include /voice command
76
+ * **Added expiring cache support**:
77
+ + Added `Ollama::Utils::CacheFetcher` class for caching HTTP responses
78
+ + Modified `Ollama::Utils::Fetcher` to use the new cache class
79
+ + Updated `ollama_chat` script to use the cache when fetching sources
80
+ + Added specs for the new cache fetcher class
81
+ * **Added change system prompt feature**:
82
+ + Added `/system` command to change system prompt
83
+ + Implemented `set_system_prompt` and `change_system_prompt` methods in `bin/ollama_chat`
84
+ + Updated help messages in `README.md`
85
+
86
+ ### Other Changes
87
+
88
+ * **Updated dependencies**:
89
+ + Updated version of `xdg` gem to **7.0**
90
+ + Added `xdg` dependency to Rakefile
91
+ * **Refactored error handling**:
92
+ + Warn message updated to include more context about the error
93
+ + `warn` statement now mentions "while pulling model"
94
+ * **Updated chat commands and added clipboard functionality**:
95
+ + Added `/copy` command to copy last response to clipboard
96
+ + Implemented `copy_to_clipboard` method in `ollama_chat`
97
+ + Updated chat help display to include new `/copy` command
98
+ * **Refactored Ollama::Utils::Fetcher**:
99
+ + Made instance methods private and only exposed class methods
100
+ + Added `expose` method to `Ollama::Utils::FetcherSpec` for testing
101
+ * **Added version command to ollama chat binary**:
102
+ + Added `version` method to print Ollama version and exit
103
+ + Updated `$opts` string in `ollama` script to include `-V` option for version command
104
+ + Added call to `version` method when `-V` option is used
105
+ * **Updated system prompt display**:
106
+ + Changed `Ollama::Utils::Width.wrap` to `Ollama::Utils::ANSIMarkdown.parse` in `show_system_prompt` method
107
+ * **Added system prompt configuration via search_ui for ? argument value**:
108
+ + Added `show_system_prompt` method to print configured system prompt
109
+ + Modified `info` method to include system prompt in output
110
+ + Implemented option `-s ?` to choose or specify system prompt
111
+
3
112
  ## 2024-09-26 v0.5.0
4
113
 
5
114
  ### New Features
6
115
 
7
116
  * Add stdin substitution and variable expansion to `ollama_cli`:
8
- + Added support for `%{stdin}` in prompts, substituting with actual input
9
- + Added `-P` option to set prompt variables from command line arguments
10
- + Added handling of multiple placeholders in prompts
117
+ + Added support for `%{stdin}` in prompts, substituting with actual input
118
+ + Added `-P` option to set prompt variables from command line arguments
119
+ + Added handling of multiple placeholders in prompts
11
120
  * Add proxy support to Ollama chat client:
12
- + Add `tins/xt/hash_union` gem to dependencies
121
+ + Add `tins/xt/hash_union` gem to dependencies
13
122
  + Update `OllamaChatConfig` with new `proxy` option
14
123
  + Modify `http_options` method to include proxy and SSL verify peer options
15
124
  based on config settings
@@ -41,7 +150,7 @@
41
150
  + Added support for displaying a specific number of messages with `/list
42
151
  [n]`
43
152
  * Update chat commands' quit functionality:
44
- + Moved `/quit` command to exit the program
153
+ + Moved `/quit` command to exit the program
45
154
  * Refactor OllamaChatConfig web prompt:
46
155
  + Add `web` prompt to `OllamaChatConfig` class
47
156
  + Replace hardcoded content with variable `content`
@@ -71,10 +180,10 @@
71
180
  ### Refactoring
72
181
 
73
182
  * Refactor `file_argument.rb` for better readability:
74
- + Update conditionals in Ollama::Utils::FileArgument module
75
- + Simplify logic with improved variable usage
76
- + Remove unnecessary elsif statement
77
- + Use consistent indentation and spacing throughout the code
183
+ + Update conditionals in Ollama::Utils::FileArgument module
184
+ + Simplify logic with improved variable usage
185
+ + Remove unnecessary elsif statement
186
+ + Use consistent indentation and spacing throughout the code
78
187
  * Refactor Redis-backed memory cache:
79
188
  + Removed `pre` and `unpre` methods from `Ollama::Documents` use mixin
80
189
  instead.
@@ -82,12 +191,12 @@
82
191
  ### Documentation
83
192
 
84
193
  * Update README.md to reflect changes in `ollama_chat` functionality.
85
- + Modified commands:
86
- - `/import source` to import the source's content
87
- - `/embed source` to embed the source's content
194
+ + Modified commands:
195
+ - `/import source` to import the source's content
196
+ - `/embed source` to embed the source's content
88
197
  - `/summarize [n] source` to summarize the source's content in n words
89
198
  - `/embedding` to toggle embedding paused or not
90
- - `/embed source` to embed the source's content
199
+ - `/embed source` to embed the source's content
91
200
 
92
201
  ### Dependencies and Date Updates
93
202
 
@@ -95,13 +204,13 @@
95
204
  + Added `logger` (~> **1.0**) and `json` (~> **2.0**) as runtime
96
205
  dependencies to Rakefile and ollama-ruby.gemspec.
97
206
  + Updated date in ollama-ruby.gemspec from "2024-09-21" to "2024-09-22".
98
- + Added `require 'logger'` to lib/ollama.rb.
207
+ + Added `require 'logger'` to lib/ollama.rb.
99
208
 
100
209
  ### Other Changes
101
210
 
102
211
  * Add SSL no verify option to OllamaChatConfig and Utils::Fetcher:
103
- + Added `ssl_no_verify` option to OllamaChatConfig
104
- + Updated Utils::Fetcher to take an
212
+ + Added `ssl_no_verify` option to OllamaChatConfig
213
+ + Updated Utils::Fetcher to take an
105
214
 
106
215
  ## 2024-09-21 v0.4.0
107
216
 
@@ -134,20 +243,20 @@
134
243
  ## 2024-09-15 v0.3.2
135
244
 
136
245
  * Add color support to chooser module:
137
- + Include `Term::ANSIColor` in `Ollama::Utils::Chooser` module
246
+ + Include `Term::ANSIColor` in `Ollama::Utils::Chooser` module
138
247
  + Use `blue`, `on_blue` ANSI color for selected item in query method
139
248
  * Refactor summarize method to also import sources:
140
- + Added `content` variable to store result of `parse_source`
141
- + Replaced `or return` with explicit assignment and return
142
- + Added calls to `source_io.rewind` and `import_document`
249
+ + Added `content` variable to store result of `parse_source`
250
+ + Replaced `or return` with explicit assignment and return
251
+ + Added calls to `source_io.rewind` and `import_document`
143
252
  * Add new test for `file_argument_spec.rb`
144
253
  * Refactor tag list initialization and merging:
145
- + Use array literals for initializing tags lists
146
- + Use array literals for passing to merge method
254
+ + Use array literals for initializing tags lists
255
+ + Use array literals for passing to merge method
147
256
  * Update dependencies and dates in Rakefile and gemspec:
148
- + Removed '.utilsrc' from ignored files in Rakefile
149
- + Updated date in `ollama-ruby.gemspec` to "2024-09-13"
150
- + Removed 'utils' development dependency from `ollama-ruby.gemspec`
257
+ + Removed '.utilsrc' from ignored files in Rakefile
258
+ + Updated date in `ollama-ruby.gemspec` to "2024-09-13"
259
+ + Removed 'utils' development dependency from `ollama-ruby.gemspec`
151
260
  * Refactor `search_web` method to allow n parameter to be optional and default
152
261
  to 1.
153
262
 
@@ -222,31 +331,31 @@
222
331
  ### Changes
223
332
 
224
333
  * **Added Web Search Functionality to `ollama_chat`**
225
- + Added `/web` command to fetch search results from DuckDuckGo
226
- + Updated `/summarize` command to handle cases where summarization fails
227
- + Fix bug in parsing content type of source document
334
+ + Added `/web` command to fetch search results from DuckDuckGo
335
+ + Updated `/summarize` command to handle cases where summarization fails
336
+ + Fix bug in parsing content type of source document
228
337
  * **Refactored Options Class and Usage**
229
- + Renamed `options` variable to use `Options[]` method in ollama_chat script
230
- + Added `[](value)` method to Ollama::Options class for casting hashes
231
- + Updated options_spec.rb with tests for casting hashes and error handling
338
+ + Renamed `options` variable to use `Options[]` method in ollama_chat script
339
+ + Added `[](value)` method to Ollama::Options class for casting hashes
340
+ + Updated options_spec.rb with tests for casting hashes and error handling
232
341
  * **Refactored Web Search Command**
233
- + Added support for specifying a page number in `/web` command
234
- + Updated regular expression to match new format
235
- + Passed page number as an argument to `search_web` method
236
- + Updated content string to reference the query and sources correctly
342
+ + Added support for specifying a page number in `/web` command
343
+ + Updated regular expression to match new format
344
+ + Passed page number as an argument to `search_web` method
345
+ + Updated content string to reference the query and sources correctly
237
346
  * **DTO Class Changes**
238
- + Renamed `json_create` method to `from_hash` in Ollama::DTO class
239
- + Updated `as_json` method to remove now unnecessary hash creation
347
+ + Renamed `json_create` method to `from_hash` in Ollama::DTO class
348
+ + Updated `as_json` method to remove now unnecessary hash creation
240
349
  * **Message and Tool Spec Changes**
241
- + Removed `json_class` from JSON serialization in message_spec
242
- + Removed `json_class` from JSON serialization in tool_spec
350
+ + Removed `json_class` from JSON serialization in message_spec
351
+ + Removed `json_class` from JSON serialization in tool_spec
243
352
  * **Command Spec Changes**
244
- + Removed `json_class` from JSON serialization in various command specs (e.g. generate_spec, pull_spec, etc.)
353
+ + Removed `json_class` from JSON serialization in various command specs (e.g. generate_spec, pull_spec, etc.)
245
354
  * **Miscellaneous Changes**
246
- + Improved width calculation for text truncation
247
- + Updated FollowChat class to display evaluation statistics
248
- + Update OllamaChatConfig to use EOT instead of end for heredoc syntax
249
- + Add .keep file to tmp directory
355
+ + Improved width calculation for text truncation
356
+ + Updated FollowChat class to display evaluation statistics
357
+ + Update OllamaChatConfig to use EOT instead of end for heredoc syntax
358
+ + Add .keep file to tmp directory
250
359
 
251
360
  ## 2024-08-30 v0.1.0
252
361
 
@@ -255,18 +364,18 @@
255
364
  #### Significant Changes
256
365
 
257
366
  * **Document Splitting and Embedding Functionality**: Added `Ollama::Documents` class with methods for adding documents, checking existence, deleting documents, and finding similar documents.
258
- + Introduced two types of caches: `MemoryCache` and `RedisCache`
259
- + Implemented `SemanticSplitter` class to split text into sentences based on semantic similarity
367
+ + Introduced two types of caches: `MemoryCache` and `RedisCache`
368
+ + Implemented `SemanticSplitter` class to split text into sentences based on semantic similarity
260
369
  * **Improved Ollama Chat Client**: Added support for document embeddings and web/file RAG
261
- + Allowed configuration per yaml file
262
- + Parse user input for URLs or files to send images to multimodal models
370
+ + Allowed configuration per yaml file
371
+ + Parse user input for URLs or files to send images to multimodal models
263
372
  * **Redis Docker Service**: Set `REDIS_URL` environment variable to `redis://localhost:9736`
264
- + Added Redis service to `docker-compose.yml`
373
+ + Added Redis service to `docker-compose.yml`
265
374
  * **Status Display and Progress Updates**: Added infobar.label = response.status when available
266
- + Updated infobar with progress message on each call if total and completed are set
267
- + Display error message from response.error if present
375
+ + Updated infobar with progress message on each call if total and completed are set
376
+ + Display error message from response.error if present
268
377
  * **Refactored Chat Commands**: Simplified regular expression patterns for `/pop`, `/save`, `/load`, and `/image` commands
269
- + Added whitespace to some command patterns for better readability
378
+ + Added whitespace to some command patterns for better readability
270
379
 
271
380
  #### Other Changes
272
381
 
@@ -282,13 +391,13 @@
282
391
  ## 2024-08-16 v0.0.1
283
392
 
284
393
  * **New Features**
285
- + Added missing options parameter to Embed command
286
- + Documented new `/api/embed` endpoint
394
+ + Added missing options parameter to Embed command
395
+ + Documented new `/api/embed` endpoint
287
396
  * **Improvements**
288
- + Improved example in README.md
397
+ + Improved example in README.md
289
398
  * **Code Refactoring**
290
- + Renamed `client` to `ollama` in client and command specs
291
- + Updated expectations to use `ollama` instead of `client`
399
+ + Renamed `client` to `ollama` in client and command specs
400
+ + Updated expectations to use `ollama` instead of `client`
292
401
 
293
402
  ## 2024-08-12 v0.0.0
294
403
 
data/README.md CHANGED
@@ -34,7 +34,7 @@ This a chat client, that can be used to connect to an ollama server and enter a
34
34
  chat converstation with a LLM. It can be called with the following arguments:
35
35
 
36
36
  ```
37
- ollama_chat [OPTIONS]
37
+ Usage: ollama_chat [OPTIONS]
38
38
 
39
39
  -f CONFIG config file to read
40
40
  -u URL the ollama base url, OLLAMA_URL
@@ -42,9 +42,10 @@ ollama_chat [OPTIONS]
42
42
  -s SYSTEM the system prompt to use as a file, OLLAMA_CHAT_SYSTEM
43
43
  -c CHAT a saved chat conversation to load
44
44
  -C COLLECTION name of the collection used in this conversation
45
- -D DOCUMENT load document and add to collection (multiple)
45
+ -D DOCUMENT load document and add to embeddings collection (multiple)
46
46
  -M use (empty) MemoryCache for this chat session
47
47
  -E disable embeddings for this chat session
48
+ -V display the current version number and quit
48
49
  -h this help
49
50
  ```
50
51
 
@@ -157,6 +158,7 @@ The following commands can be given inside the chat, if prefixed by a `/`:
157
158
  /paste to paste content
158
159
  /markdown toggle markdown output
159
160
  /stream toggle stream output
161
+ /location toggle location submission
160
162
  /voice( change) toggle voice output or change the voice
161
163
  /list [n] list the last n / all conversation exchanges
162
164
  /clear clear the whole conversation
@@ -165,7 +167,8 @@ The following commands can be given inside the chat, if prefixed by a `/`:
165
167
  /model change the model
166
168
  /system change system prompt (clears conversation)
167
169
  /regenerate the last answer message
168
- /collection clear [tag]|change clear or show stats of current collection
170
+ /collection( clear|change) change (default) collection or clear
171
+ /info show information for current session
169
172
  /import source import the source's content
170
173
  /summarize [n] source summarize the source's content in n words
171
174
  /embedding toggle embedding paused or not
data/Rakefile CHANGED
@@ -32,7 +32,6 @@ GemHadar do
32
32
  dependency 'redis', '~> 5.0'
33
33
  dependency 'numo-narray', '~> 0.9'
34
34
  dependency 'more_math', '~> 1.1'
35
- dependency 'sorted_set', '~> 1.0'
36
35
  dependency 'mime-types', '~> 3.0'
37
36
  dependency 'reverse_markdown', '~> 2.0'
38
37
  dependency 'complex_config', '~> 0.22'
@@ -42,6 +41,7 @@ GemHadar do
42
41
  dependency 'logger', '~> 1.0'
43
42
  dependency 'json', '~> 2.0'
44
43
  dependency 'xdg', '~> 7.0'
44
+ dependency 'tins', '~> 1.34'
45
45
  development_dependency 'all_images', '~> 0.4'
46
46
  development_dependency 'rspec', '~> 3.2'
47
47
  development_dependency 'webmock'