ollama_chat 0.0.12 → 0.0.13
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 +10 -0
- data/VERSION +1 -1
- data/lib/ollama_chat/chat.rb +9 -3
- data/lib/ollama_chat/clipboard.rb +16 -0
- data/lib/ollama_chat/information.rb +1 -1
- data/lib/ollama_chat/ollama_chat_config/default_config.yml +4 -0
- data/lib/ollama_chat/server_socket.rb +22 -0
- 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: a6a03b8af7c470d83520d269829f51fe480f7a5813bc1b4df50c63d339e28953
|
4
|
+
data.tar.gz: cb86dd9896d6948fb736c889a672fb29e4f21c8174a3ddb62d6fcc93be59f020
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef19594894b1bb11217e710e1a302a2d30add6140da629c66e3e60d990e30f45a29196d310e06f7c06b36d8ddf33f84e7bd4278f87705b48e501b06d5f53d290
|
7
|
+
data.tar.gz: 332c66cdca39a187ecb3aff193e5a2522ad11deabaedb584c32a78a620d4c068be3cc062d181a5e6c1d0bf44fed371b3409010f2a4e404614ba142e37d5afbdc
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 2025-06-05 v0.0.13
|
4
|
+
|
5
|
+
* Improved chat command handling
|
6
|
+
- Added support for '/clear tags' to clear all tags.
|
7
|
+
- Updated cases for 'history', 'all' and added case for 'tags'.
|
8
|
+
- Added commands to clear documents collection and print a message in `information.rb`.
|
9
|
+
- `OllamaChat::Chat#clean` now accepts 'tags' as an option.
|
10
|
+
* Apply read and write timeouts from configuration (300 seconds) for ollama server.
|
11
|
+
* Added method comments
|
12
|
+
|
3
13
|
## 2025-06-01 v0.0.12
|
4
14
|
|
5
15
|
* **API Compatibility**: Enforces Ollama API version `0.9.0` or higher to
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.13
|
data/lib/ollama_chat/chat.rb
CHANGED
@@ -41,8 +41,11 @@ class OllamaChat::Chat
|
|
41
41
|
setup_switches(config)
|
42
42
|
base_url = @opts[?u] || config.url
|
43
43
|
@ollama = Ollama::Client.new(
|
44
|
-
|
45
|
-
|
44
|
+
connect_timeout: config.timeouts.connect_timeout?,
|
45
|
+
read_timeout: config.timeouts.read_timeout?,
|
46
|
+
write_timeout: config.timeouts.write_timeout?,
|
47
|
+
base_url: base_url,
|
48
|
+
debug: config.debug,
|
46
49
|
user_agent:
|
47
50
|
)
|
48
51
|
if server_version.version < '0.9.0'.version
|
@@ -136,7 +139,7 @@ class OllamaChat::Chat
|
|
136
139
|
last = 2 * $1.to_i if $1
|
137
140
|
messages.list_conversation(last)
|
138
141
|
:next
|
139
|
-
when %r(^/clear(?:\s+(messages|links|history|all))?$)
|
142
|
+
when %r(^/clear(?:\s+(messages|links|history|tags|all))?$)
|
140
143
|
clean($1)
|
141
144
|
:next
|
142
145
|
when %r(^/clobber$)
|
@@ -306,6 +309,9 @@ class OllamaChat::Chat
|
|
306
309
|
when 'history'
|
307
310
|
clear_history
|
308
311
|
STDOUT.puts "Cleared history."
|
312
|
+
when 'tags'
|
313
|
+
@documents.clear
|
314
|
+
STDOUT.puts "Cleared all tags."
|
309
315
|
when 'all'
|
310
316
|
if ask?(prompt: 'Are you sure to clear messages and collection? (y/n) ') =~ /\Ay/i
|
311
317
|
messages.clear
|
@@ -1,4 +1,13 @@
|
|
1
1
|
module OllamaChat::Clipboard
|
2
|
+
|
3
|
+
# Copy the last assistant's message to the system clipboard.
|
4
|
+
#
|
5
|
+
# This method checks if there is a last message from an assistant in the `@messages`
|
6
|
+
# array and copies its content to the clipboard using the specified command from `config.copy`.
|
7
|
+
# If no assistant response is available or the clipboard command is not found, appropriate
|
8
|
+
# error messages are displayed.
|
9
|
+
#
|
10
|
+
# @return [NilClass] Always returns nil.
|
2
11
|
def copy_to_clipboard
|
3
12
|
if message = @messages.last and message.role == 'assistant'
|
4
13
|
copy = `which #{config.copy}`.chomp
|
@@ -16,6 +25,13 @@ module OllamaChat::Clipboard
|
|
16
25
|
nil
|
17
26
|
end
|
18
27
|
|
28
|
+
# Paste content from the input.
|
29
|
+
#
|
30
|
+
# Prompts the user to paste their content and then press C-d (Ctrl+D) to terminate
|
31
|
+
# input. Reads all lines from standard input until Ctrl+D is pressed and returns
|
32
|
+
# the pasted content as a string.
|
33
|
+
#
|
34
|
+
# @return [String] The pasted content entered by the user.
|
19
35
|
def paste_from_input
|
20
36
|
STDOUT.puts bold { "Paste your content and then press C-d!" }
|
21
37
|
STDIN.read
|
@@ -66,7 +66,7 @@ module OllamaChat::Information
|
|
66
66
|
/location toggle location submission
|
67
67
|
/voice [change] toggle voice output or change the voice
|
68
68
|
/list [n] list the last n / all conversation exchanges
|
69
|
-
/clear [messages|links|history
|
69
|
+
/clear [what] clear what=messages|links|history|tags|all
|
70
70
|
/clobber clear the conversation, links, and collection
|
71
71
|
/drop [n] drop the last n exchanges, defaults to 1
|
72
72
|
/model change the model
|
@@ -1,13 +1,23 @@
|
|
1
1
|
module OllamaChat::ServerSocket
|
2
2
|
class << self
|
3
|
+
# Returns the path to the XDG runtime directory, or a default path if not set.
|
4
|
+
# @return [String] the expanded path to the XDG runtime directory
|
3
5
|
def runtime_dir
|
4
6
|
File.expand_path(ENV.fetch('XDG_RUNTIME_DIR', '~/.local/run'))
|
5
7
|
end
|
6
8
|
|
9
|
+
# Constructs the full path to the server socket file.
|
10
|
+
# @return [String] the full path to the Unix socket
|
7
11
|
def server_socket_path
|
8
12
|
File.join(runtime_dir, 'ollama_chat.sock')
|
9
13
|
end
|
10
14
|
|
15
|
+
# Sends a message to the server socket.
|
16
|
+
#
|
17
|
+
# @param content [String] the content to send
|
18
|
+
# @param type [Symbol] the type of message (default: :socket_input)
|
19
|
+
# @raise [Errno::ENOENT] if the socket file does not exist
|
20
|
+
# @raise [Errno::ECONNREFUSED] if the socket is not listening (server no running)
|
11
21
|
def send_to_server_socket(content, type: :socket_input)
|
12
22
|
FileUtils.mkdir_p runtime_dir
|
13
23
|
message = { content:, type: }
|
@@ -17,8 +27,20 @@ module OllamaChat::ServerSocket
|
|
17
27
|
end
|
18
28
|
end
|
19
29
|
|
30
|
+
# Accessor for the server socket message.
|
31
|
+
# Holds the last message received from the Unix socket.
|
32
|
+
# @return [String, nil] the message content, or nil if not set
|
33
|
+
# @see OllamaChat::ServerSocket#init_server_socket
|
34
|
+
# @see OllamaChat::ServerSocket#send_to_server_socket
|
20
35
|
attr_accessor :server_socket_message
|
21
36
|
|
37
|
+
# Initializes a Unix domain socket server for OllamaChat.
|
38
|
+
#
|
39
|
+
# Creates the necessary runtime directory, checks for existing socket file,
|
40
|
+
# and starts a server loop in a new thread. Listens for incoming connections,
|
41
|
+
# reads JSON data, and terminates the server upon receiving a message.
|
42
|
+
#
|
43
|
+
# Raises Errno::EEXIST if the socket path already exists.
|
22
44
|
def init_server_socket
|
23
45
|
FileUtils.mkdir_p OllamaChat::ServerSocket.runtime_dir
|
24
46
|
if File.exist?(OllamaChat::ServerSocket.server_socket_path)
|
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.13 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.13".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]
|