ollama_chat 0.0.37 → 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 +17 -0
- data/lib/ollama_chat/conversation.rb +3 -0
- 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 +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 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,22 @@
|
|
|
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
|
+
|
|
3
20
|
## 2025-10-31 v0.0.37
|
|
4
21
|
|
|
5
22
|
- Refactored system prompt selection logic to use `case`/`when` statement
|
|
@@ -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
|
|
@@ -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]
|