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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2f4b23386064513dc339fa0b3479e70c8e15b091b146bfcf700602fd1497b87
4
- data.tar.gz: ce9857a08de2bec94a1e19b5e28a13535657ebdab3ca977fe2b5582a86708bb7
3
+ metadata.gz: 36395404aa00934bda9f2229306a374143c30046bf7439188d369b9fe167f649
4
+ data.tar.gz: 2dc4c482a17e31a86c347d557475af52eccbe6638f2487abc564c11b5ef379b7
5
5
  SHA512:
6
- metadata.gz: c7bcfbc3966c7189cc3d93b6ac3e09a49d79b1dd3bbfd5ed729a7ae5484ef7fcdadd194705363c574f18dd43f11c6c8d204577292516c3f9b286ba4380417e41
7
- data.tar.gz: 855accf3d5d72aa6c8a6cdd9fc8e534db40d97a4533bee03fc6a240cc5a12b8da46f304d02cf1c71378f592347866b84a95e9b18f9046975f630902996dd409a
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.7
1
+ 0.0.8
@@ -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
- DEFAULT_CONFIG = File.read(
8
- Pathname.new(__FILE__).dirname.join('ollama_chat_config/default_config.yml')
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
@@ -1,6 +1,6 @@
1
1
  module OllamaChat
2
2
  # OllamaChat version
3
- VERSION = '0.0.7'
3
+ VERSION = '0.0.8'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/ollama_chat.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: ollama_chat 0.0.7 ruby lib
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.7".freeze
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]
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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank