ollama_chat 0.0.7 → 0.0.8
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 +11 -0
- data/README.md +21 -0
- data/VERSION +1 -1
- data/lib/ollama_chat/chat.rb +20 -0
- data/lib/ollama_chat/ollama_chat_config.rb +12 -3
- data/lib/ollama_chat/server_socket.rb +5 -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: 36395404aa00934bda9f2229306a374143c30046bf7439188d369b9fe167f649
|
4
|
+
data.tar.gz: 2dc4c482a17e31a86c347d557475af52eccbe6638f2487abc564c11b5ef379b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ece58d0452a5695dc3fec1a1032a9e45a6e9400085e48f512c13b9473acd53596a55d69a7f9264689fdb0a3b3335b8223547efbc504c9a3052a85e5ef9a0cc89
|
7
|
+
data.tar.gz: 11a052d21eed75504722adde01ff43c10213ba371887b7f376fdbe4b962cf3dd3bd550325341af16c2215101776ca14753cf353eec221f3f5e98fff386053f51
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 2025-05-23 v0.0.8
|
4
|
+
|
5
|
+
* Introduce `fix_config` method to rescue `ComplexConfig` exceptions and prompt
|
6
|
+
user for correction.
|
7
|
+
* Added section to README.md on using `ollama_chat_send` to send input to a
|
8
|
+
running `ollama_chat` process.
|
9
|
+
* Fix path existence check and cleanup on server socket initialization.
|
10
|
+
* Added check for existing path at
|
11
|
+
`OllamaChat::ServerSocket.server_socket_path` to prevent overwrite.
|
12
|
+
* Clean up server socket file if it exists when leaving thread.
|
13
|
+
|
3
14
|
## 2025-05-22 v0.0.7
|
4
15
|
|
5
16
|
* Added `ollama_chat_send` executable in `/bin`, required 'ollama_chat' gem,
|
data/README.md
CHANGED
@@ -144,6 +144,27 @@ The following commands can be given inside the chat, if prefixed by a `/`:
|
|
144
144
|
/help to view this help
|
145
145
|
```
|
146
146
|
|
147
|
+
### Using `ollama_chat_send` to send input to a running `ollama_chat`
|
148
|
+
|
149
|
+
You can do this from the shell by pasting into the `ollama_chat_send`
|
150
|
+
executable.
|
151
|
+
|
152
|
+
```
|
153
|
+
$ echo "Why is the sky blue?" | ollama_chat_send
|
154
|
+
```
|
155
|
+
|
156
|
+
To send a text from inside a `vim` buffer, you can use a function/leader like
|
157
|
+
this:
|
158
|
+
|
159
|
+
```
|
160
|
+
map <leader>o :<C-U>call OllamaChatSend(@*)<CR>
|
161
|
+
|
162
|
+
function! OllamaChatSend(input)
|
163
|
+
let input = "Take note of the following code snippet (" . &filetype . ") **AND** await further instructions:\n\n```\n" . a:input . "\n```\n"
|
164
|
+
call system('ollama_chat_send', input)
|
165
|
+
endfunction
|
166
|
+
```
|
167
|
+
|
147
168
|
## Download
|
148
169
|
|
149
170
|
The homepage of this app is located at
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/lib/ollama_chat/chat.rb
CHANGED
@@ -13,6 +13,7 @@ require 'pdf/reader'
|
|
13
13
|
require 'csv'
|
14
14
|
require 'xdg'
|
15
15
|
require 'socket'
|
16
|
+
require 'shellwords'
|
16
17
|
|
17
18
|
class OllamaChat::Chat
|
18
19
|
include Tins::GO
|
@@ -67,6 +68,8 @@ class OllamaChat::Chat
|
|
67
68
|
@images = []
|
68
69
|
init_chat_history
|
69
70
|
init_server_socket
|
71
|
+
rescue ComplexConfig::AttributeMissing, ComplexConfig::ConfigurationSyntaxError => e
|
72
|
+
fix_config(e)
|
70
73
|
end
|
71
74
|
|
72
75
|
attr_reader :ollama
|
@@ -376,6 +379,8 @@ class OllamaChat::Chat
|
|
376
379
|
STDOUT.puts "Type /quit to quit."
|
377
380
|
end
|
378
381
|
0
|
382
|
+
rescue ComplexConfig::AttributeMissing, ComplexConfig::ConfigurationSyntaxError => e
|
383
|
+
fix_config(e)
|
379
384
|
ensure
|
380
385
|
save_history
|
381
386
|
end
|
@@ -445,4 +450,19 @@ class OllamaChat::Chat
|
|
445
450
|
)
|
446
451
|
end
|
447
452
|
end
|
453
|
+
|
454
|
+
def fix_config(exception)
|
455
|
+
STDOUT.puts "When reading the config file, a #{exception.class} "\
|
456
|
+
"exception was caught: #{exception.message.inspect}"
|
457
|
+
if ask?(prompt: 'Do you want to fix the config? (y/n) ') =~ /\Ay/i
|
458
|
+
system Shellwords.join([
|
459
|
+
@ollama_chat_config.diff_tool,
|
460
|
+
@ollama_chat_config.filename,
|
461
|
+
@ollama_chat_config.default_config_path,
|
462
|
+
])
|
463
|
+
exit 0
|
464
|
+
else
|
465
|
+
exit 1
|
466
|
+
end
|
467
|
+
end
|
448
468
|
end
|
@@ -4,9 +4,10 @@ class OllamaChat::OllamaChatConfig
|
|
4
4
|
include ComplexConfig
|
5
5
|
include FileUtils
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
DEFAULT_CONFIG_PATH = Pathname.new(__FILE__).dirname.
|
8
|
+
join('ollama_chat_config/default_config.yml')
|
9
|
+
|
10
|
+
DEFAULT_CONFIG = File.read(DEFAULT_CONFIG_PATH)
|
10
11
|
|
11
12
|
def initialize(filename = nil)
|
12
13
|
@filename = filename || default_path
|
@@ -30,6 +31,10 @@ class OllamaChat::OllamaChatConfig
|
|
30
31
|
|
31
32
|
attr_reader :config
|
32
33
|
|
34
|
+
def default_config_path
|
35
|
+
DEFAULT_CONFIG_PATH
|
36
|
+
end
|
37
|
+
|
33
38
|
def default_path
|
34
39
|
config_dir_path + 'config.yml'
|
35
40
|
end
|
@@ -45,4 +50,8 @@ class OllamaChat::OllamaChatConfig
|
|
45
50
|
def database_path
|
46
51
|
cache_dir_path + 'documents.db'
|
47
52
|
end
|
53
|
+
|
54
|
+
def diff_tool
|
55
|
+
ENV.fetch('DIFF_TOOL', 'vimdiff')
|
56
|
+
end
|
48
57
|
end
|
@@ -21,6 +21,9 @@ module OllamaChat::ServerSocket
|
|
21
21
|
|
22
22
|
def init_server_socket
|
23
23
|
FileUtils.mkdir_p OllamaChat::ServerSocket.runtime_dir
|
24
|
+
if File.exist?(OllamaChat::ServerSocket.server_socket_path)
|
25
|
+
raise Errno::EEXIST, "Path already exists #{OllamaChat::ServerSocket.server_socket_path.inspect}"
|
26
|
+
end
|
24
27
|
Thread.new do
|
25
28
|
Socket.unix_server_loop(OllamaChat::ServerSocket.server_socket_path) do |sock, client_addrinfo|
|
26
29
|
begin
|
@@ -33,6 +36,8 @@ module OllamaChat::ServerSocket
|
|
33
36
|
end
|
34
37
|
end
|
35
38
|
rescue Errno::ENOENT
|
39
|
+
ensure
|
40
|
+
FileUtils.rm_f OllamaChat::ServerSocket.server_socket_path
|
36
41
|
end
|
37
42
|
end
|
38
43
|
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.8 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.8".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]
|