ollama_chat 0.0.36 → 0.0.38
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 +0 -1
- data/CHANGES.md +29 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/ollama_chat/conversation.rb +3 -0
- data/lib/ollama_chat/dialog.rb +4 -1
- data/lib/ollama_chat/env_config.rb +1 -1
- data/lib/ollama_chat/message_list.rb +0 -4
- data/lib/ollama_chat/message_output.rb +24 -19
- data/lib/ollama_chat/version.rb +1 -1
- data/ollama_chat.gemspec +4 -4
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1702d897811e762ef2ba3b5018efcec7e55e01e96e14bbb56f09eb3be8d7d0a3
|
|
4
|
+
data.tar.gz: 0f27aa44e2574249ac90b4979a87afae0fc1b9f525643db523c7b392c7fad95a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b686679959f9662811104f7e12951106cfaca0d7a9820878bd6885548c3b16090da2d5f6473cb95df5387b30ece2f06eb2225bf78a76c1124cd2bb84f2f0a8f1
|
|
7
|
+
data.tar.gz: 1b26360782e6018faf976c248aef147dc6e4938618eb95db287ca2cc4a2248c8ca7ca7ce45586d780e7e14cdc5d66a80ac2546f7d77843507e3b5194a60cd07b
|
data/.utilsrc
CHANGED
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2025-11-11 v0.0.38
|
|
4
|
+
|
|
5
|
+
- Added `ask?` method call to confirm overwriting existing files when saving
|
|
6
|
+
conversations
|
|
7
|
+
- Modified `save_conversation` in `OllamaChat::Conversation` to prompt before
|
|
8
|
+
overwriting
|
|
9
|
+
- Removed explicit file existence check from `MessageList#save_conversation`
|
|
10
|
+
- Both `/save` and `/output` commands now support overwrite confirmation
|
|
11
|
+
- Replace `write_file_unless_exist` method with `attempt_to_write_file`
|
|
12
|
+
- Add user confirmation prompt before overwriting existing files
|
|
13
|
+
- Update method documentation to reflect new overwrite behavior
|
|
14
|
+
- Modify file writing logic to use `attempt_to_write_file` instead of direct
|
|
15
|
+
write
|
|
16
|
+
- Update `output` method to check return value of `attempt_to_write_file`
|
|
17
|
+
before printing success message
|
|
18
|
+
- Removed `xdg` gem from the list of dependencies in `code_indexer` block
|
|
19
|
+
|
|
20
|
+
## 2025-10-31 v0.0.37
|
|
21
|
+
|
|
22
|
+
- Refactored system prompt selection logic to use `case`/`when` statement
|
|
23
|
+
instead of `if`/`elsif` for improved readability
|
|
24
|
+
- Maintained same functionality for regex pattern matching with `/\A\?(.+)\z/`
|
|
25
|
+
pattern
|
|
26
|
+
- Handled special case with `?` argument to match any character with `/./` regex
|
|
27
|
+
- Updated `amatch` dependency version constraint from `~> 0.4.1` to `~> 0.4` in
|
|
28
|
+
`Rakefile` and `ollama_chat.gemspec`
|
|
29
|
+
- Updated `rubygems` version requirement from **3.6.9** to **3.7.2** in
|
|
30
|
+
`ollama_chat.gemspec`
|
|
31
|
+
|
|
3
32
|
## 2025-10-11 v0.0.36
|
|
4
33
|
|
|
5
34
|
- Added `openssl-dev` package to apk packages in Dockerfile
|
data/README.md
CHANGED
|
@@ -35,7 +35,7 @@ The following environment variables can be used to configure behavior:
|
|
|
35
35
|
- `PAGER` - Default pager for output
|
|
36
36
|
- `REDIS_URL` - Redis connection URL for caching
|
|
37
37
|
- `REDIS_EXPIRING_URL` - Redis connection URL for expiring data
|
|
38
|
-
- `OLLAMA_CHAT_HISTORY` - Chat history filename (default:
|
|
38
|
+
- `OLLAMA_CHAT_HISTORY` - Chat history filename (default: `$XDG_CACHE_HOME/ollama_chat/history.json`)
|
|
39
39
|
- `OLLAMA_CHAT_DEBUG` - Debug mode toggle (1 = enabled)
|
|
40
40
|
- `DIFF_TOOL` - Tool for diff operations (default: `vimdiff`)
|
|
41
41
|
- `OLLAMA_SEARXNG_URL` - SearxNG search endpoint URL
|
data/Rakefile
CHANGED
|
@@ -49,7 +49,7 @@ GemHadar do
|
|
|
49
49
|
dependency 'complex_config', '~> 0.22', '>= 0.22.2'
|
|
50
50
|
dependency 'tins', '~> 1.41'
|
|
51
51
|
dependency 'search_ui', '~> 0.0'
|
|
52
|
-
dependency 'amatch', '~> 0.4
|
|
52
|
+
dependency 'amatch', '~> 0.4'
|
|
53
53
|
dependency 'pdf-reader', '~> 2.0'
|
|
54
54
|
dependency 'csv', '~> 3.0'
|
|
55
55
|
dependency 'const_conf', '~> 0.3'
|
|
@@ -24,6 +24,9 @@ module OllamaChat::Conversation
|
|
|
24
24
|
# @example Save conversation with explicit filename
|
|
25
25
|
# chat.save_conversation('conversations/2023-10-15_my_session.json')
|
|
26
26
|
def save_conversation(filename)
|
|
27
|
+
File.exist?(filename) &&
|
|
28
|
+
ask?(prompt: "File #{filename.inspect} already exists, overwrite? (y/n) ") !~ /\Ay/i and
|
|
29
|
+
return
|
|
27
30
|
if messages.save_conversation(filename)
|
|
28
31
|
STDOUT.puts "Saved conversation to #{filename.inspect}."
|
|
29
32
|
else
|
data/lib/ollama_chat/dialog.rb
CHANGED
|
@@ -149,8 +149,11 @@ module OllamaChat::Dialog
|
|
|
149
149
|
# @param system [ String ] the system prompt identifier or pattern to
|
|
150
150
|
# search for
|
|
151
151
|
def change_system_prompt(default, system: nil)
|
|
152
|
-
selector =
|
|
152
|
+
selector = case system
|
|
153
|
+
when /\A\?(.+)\z/
|
|
153
154
|
Regexp.new($1)
|
|
155
|
+
when ??
|
|
156
|
+
/./
|
|
154
157
|
else
|
|
155
158
|
Regexp.new(system.to_s)
|
|
156
159
|
end
|
|
@@ -124,10 +124,6 @@ class OllamaChat::MessageList
|
|
|
124
124
|
#
|
|
125
125
|
# @return [ OllamaChat::MessageList ] self
|
|
126
126
|
def save_conversation(filename)
|
|
127
|
-
if File.exist?(filename)
|
|
128
|
-
STDERR.puts "File #{filename.inspect} already exists. Choose another filename."
|
|
129
|
-
return
|
|
130
|
-
end
|
|
131
127
|
File.open(filename, ?w) do |output|
|
|
132
128
|
output.puts JSON(@messages)
|
|
133
129
|
end
|
|
@@ -43,18 +43,16 @@ module OllamaChat::MessageOutput
|
|
|
43
43
|
|
|
44
44
|
# The output method writes the last assistant message to a file.
|
|
45
45
|
#
|
|
46
|
-
# @param filename [ String ] the path to the file where the
|
|
46
|
+
# @param filename [ String ] the path to the file where the last assistant
|
|
47
|
+
# message should be written
|
|
47
48
|
#
|
|
48
|
-
# @return [ Chat ] returns self
|
|
49
|
-
#
|
|
50
|
-
# @see write_file_unless_exist
|
|
51
|
-
#
|
|
52
|
-
# @note If no assistant message is available, an error message is printed to stderr.
|
|
49
|
+
# @return [ OllamaChat::Chat ] returns self
|
|
53
50
|
def output(filename)
|
|
54
51
|
if message = @messages.last and message.role == 'assistant'
|
|
55
52
|
begin
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
if attempt_to_write_file(filename, message)
|
|
54
|
+
STDOUT.puts "Last response was written to #{filename.inspect}."
|
|
55
|
+
end
|
|
58
56
|
self
|
|
59
57
|
rescue => e
|
|
60
58
|
STDERR.puts "Writing to #{filename.inspect}, caused #{e.class}: #{e}."
|
|
@@ -66,22 +64,29 @@ module OllamaChat::MessageOutput
|
|
|
66
64
|
|
|
67
65
|
private
|
|
68
66
|
|
|
69
|
-
# The
|
|
70
|
-
#
|
|
67
|
+
# The attempt_to_write_file method handles writing content to a file with
|
|
68
|
+
# overwrite confirmation.
|
|
71
69
|
#
|
|
72
|
-
#
|
|
70
|
+
# This method checks if a file already exists and prompts the user for
|
|
71
|
+
# confirmation before overwriting it. If the user declines or if the file
|
|
72
|
+
# doesn't exist, the method returns early without writing. Otherwise, it
|
|
73
|
+
# opens the file in write mode and writes the message content to it.
|
|
74
|
+
#
|
|
75
|
+
# @param filename [ String ] the path to the file where the content should be written
|
|
73
76
|
# @param message [ Ollama::Message ] the message object containing the content to write
|
|
74
77
|
#
|
|
75
|
-
# @return [ TrueClass ] if the file was successfully
|
|
76
|
-
# @return [ nil ] if the
|
|
77
|
-
def
|
|
78
|
-
if File.exist?(filename)
|
|
79
|
-
|
|
78
|
+
# @return [ TrueClass ] returns true if the file was successfully written
|
|
79
|
+
# @return [ nil ] returns nil if the user chose not to overwrite or if an error occurred
|
|
80
|
+
def attempt_to_write_file(filename, message)
|
|
81
|
+
if !File.exist?(filename) ||
|
|
82
|
+
ask?(prompt: "File #{filename.inspect} already exists, overwrite? (y/n) ") =~ /\Ay/i
|
|
83
|
+
then
|
|
84
|
+
File.open(filename, ?w) do |output|
|
|
85
|
+
output.write(message.content)
|
|
86
|
+
end
|
|
87
|
+
else
|
|
80
88
|
return
|
|
81
89
|
end
|
|
82
|
-
File.open(filename, ?w) do |output|
|
|
83
|
-
output.write(message.content)
|
|
84
|
-
end
|
|
85
90
|
true
|
|
86
91
|
end
|
|
87
92
|
end
|
data/lib/ollama_chat/version.rb
CHANGED
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.38 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.38".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]
|
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
s.licenses = ["MIT".freeze]
|
|
19
19
|
s.rdoc_options = ["--title".freeze, "OllamaChat - A command-line interface (CLI) for interacting with an Ollama AI model.".freeze, "--main".freeze, "README.md".freeze]
|
|
20
20
|
s.required_ruby_version = Gem::Requirement.new("~> 3.2".freeze)
|
|
21
|
-
s.rubygems_version = "3.
|
|
21
|
+
s.rubygems_version = "3.7.2".freeze
|
|
22
22
|
s.summary = "A command-line interface (CLI) for interacting with an Ollama AI model.".freeze
|
|
23
23
|
s.test_files = ["spec/assets/example.rb".freeze, "spec/ollama_chat/chat_spec.rb".freeze, "spec/ollama_chat/clipboard_spec.rb".freeze, "spec/ollama_chat/follow_chat_spec.rb".freeze, "spec/ollama_chat/information_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_list_spec.rb".freeze, "spec/ollama_chat/message_output_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/server_socket_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/switches_spec.rb".freeze, "spec/ollama_chat/utils/cache_fetcher_spec.rb".freeze, "spec/ollama_chat/utils/fetcher_spec.rb".freeze, "spec/ollama_chat/utils/file_argument_spec.rb".freeze, "spec/ollama_chat/web_searching_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
|
24
24
|
|
|
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
|
|
|
45
45
|
s.add_runtime_dependency(%q<complex_config>.freeze, ["~> 0.22".freeze, ">= 0.22.2".freeze])
|
|
46
46
|
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.41".freeze])
|
|
47
47
|
s.add_runtime_dependency(%q<search_ui>.freeze, ["~> 0.0".freeze])
|
|
48
|
-
s.add_runtime_dependency(%q<amatch>.freeze, ["~> 0.4
|
|
48
|
+
s.add_runtime_dependency(%q<amatch>.freeze, ["~> 0.4".freeze])
|
|
49
49
|
s.add_runtime_dependency(%q<pdf-reader>.freeze, ["~> 2.0".freeze])
|
|
50
50
|
s.add_runtime_dependency(%q<csv>.freeze, ["~> 3.0".freeze])
|
|
51
51
|
s.add_runtime_dependency(%q<const_conf>.freeze, ["~> 0.3".freeze])
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ollama_chat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.38
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -321,14 +321,14 @@ dependencies:
|
|
|
321
321
|
requirements:
|
|
322
322
|
- - "~>"
|
|
323
323
|
- !ruby/object:Gem::Version
|
|
324
|
-
version: 0.4
|
|
324
|
+
version: '0.4'
|
|
325
325
|
type: :runtime
|
|
326
326
|
prerelease: false
|
|
327
327
|
version_requirements: !ruby/object:Gem::Requirement
|
|
328
328
|
requirements:
|
|
329
329
|
- - "~>"
|
|
330
330
|
- !ruby/object:Gem::Version
|
|
331
|
-
version: 0.4
|
|
331
|
+
version: '0.4'
|
|
332
332
|
- !ruby/object:Gem::Dependency
|
|
333
333
|
name: pdf-reader
|
|
334
334
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -512,7 +512,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
512
512
|
- !ruby/object:Gem::Version
|
|
513
513
|
version: '0'
|
|
514
514
|
requirements: []
|
|
515
|
-
rubygems_version: 3.
|
|
515
|
+
rubygems_version: 3.7.2
|
|
516
516
|
specification_version: 4
|
|
517
517
|
summary: A command-line interface (CLI) for interacting with an Ollama AI model.
|
|
518
518
|
test_files:
|