ollama_chat 0.0.21 → 0.0.22
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 +16 -0
- data/README.md +8 -0
- data/VERSION +1 -1
- data/bin/ollama_chat_send +3 -2
- data/lib/ollama_chat/chat.rb +4 -3
- data/lib/ollama_chat/server_socket.rb +36 -15
- data/lib/ollama_chat/version.rb +1 -1
- data/ollama_chat.gemspec +5 -5
- data/spec/ollama_chat/chat_spec.rb +1 -1
- data/spec/ollama_chat/server_socket_spec.rb +133 -0
- data/spec/spec_helper.rb +2 -6
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bffe3cc2184b33a1dec71799752eeb90f9f89f1120644195c138d4b0f2c61f67
|
4
|
+
data.tar.gz: 0024f487568be42097d48d44bc75284bd3bf756035e1aff01492c6ee509d7754
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14128bc440a4698b8ddda93d46f94ad43b756a028f4a11680703000d6b21410ff346d989112bbee3cb62af487382b398ab68e4c07a463b347d35d4faefaf22dd
|
7
|
+
data.tar.gz: 1a6b94ea5e570c50f3549f36f44a3cc3a8698837c7d1e66bc211d8139361d98d845807775e90162213453fe53d2bd20209383f2306cbf408a8c58b1a2ed02a93
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 2025-08-11 v0.0.21
|
4
|
+
|
5
|
+
* **Vim Integration**: The `/vim` command allows users to insert the last chat
|
6
|
+
message into a Vim server, improving workflow integration. It uses
|
7
|
+
`--servername` and `--remote-send` to insert text at the cursor position and
|
8
|
+
automatically indents based on the current column.
|
9
|
+
* **Improved Documentation**: Comprehensive documentation has been added to
|
10
|
+
various modules and classes, making it easier for developers to understand
|
11
|
+
and use the gem's features.
|
12
|
+
* **Model Selection Logic**: When only a single model is available, the code
|
13
|
+
now automatically selects that model instead of showing a prompt, improving
|
14
|
+
usability.
|
15
|
+
* **Configuration Handling**: Configuration file error handling has been
|
16
|
+
updated to use `STDERR` for output, ensuring errors are displayed
|
17
|
+
appropriately.
|
18
|
+
|
3
19
|
## 2025-08-11 v0.0.20
|
4
20
|
|
5
21
|
### Documentation
|
data/README.md
CHANGED
@@ -191,6 +191,14 @@ The `ollama_chat_send` command now supports additional parameters to enhance fun
|
|
191
191
|
$ echo "$response"
|
192
192
|
```
|
193
193
|
|
194
|
+
- **Source Parsing (`-p`)**: Enables automatic parsing of URLs, file paths, and
|
195
|
+
similar tokens in input content. When enabled, the system will attempt to
|
196
|
+
resolve and include external resources.
|
197
|
+
|
198
|
+
```bash
|
199
|
+
$ echo "Visit https://example.com for more info" | ollama_chat_send -p
|
200
|
+
```
|
201
|
+
|
194
202
|
- **Help (`-h` or `--help`)**: Displays usage information and available options.
|
195
203
|
|
196
204
|
```bash
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.22
|
data/bin/ollama_chat_send
CHANGED
@@ -5,7 +5,7 @@ require 'tins/go'
|
|
5
5
|
include Tins::GO
|
6
6
|
|
7
7
|
|
8
|
-
opts = go 'f:
|
8
|
+
opts = go 'f:rtph', ARGV
|
9
9
|
|
10
10
|
def usage(rc = 0)
|
11
11
|
puts <<~EOT
|
@@ -14,6 +14,7 @@ def usage(rc = 0)
|
|
14
14
|
Options:
|
15
15
|
-r Wait for the response from Ollama Chat and output it
|
16
16
|
-t Send input as terminal input including commands, e. g. /import
|
17
|
+
-p Send input with source parsing enabled (defaults to disabled)
|
17
18
|
-f CONFIG file to read
|
18
19
|
-h Show this help message
|
19
20
|
|
@@ -30,7 +31,7 @@ begin
|
|
30
31
|
else
|
31
32
|
opts[?r] ? :socket_input_with_response : :socket_input
|
32
33
|
end
|
33
|
-
response = OllamaChat::ServerSocket.send_to_server_socket(STDIN.read, type:, config:)
|
34
|
+
response = OllamaChat::ServerSocket.send_to_server_socket(STDIN.read, type:, config:, parse: !!opts[?p])
|
34
35
|
type == :socket_input_with_response and puts response.content
|
35
36
|
rescue => e
|
36
37
|
warn "Caught #{e.class}: #{e}"
|
data/lib/ollama_chat/chat.rb
CHANGED
@@ -217,7 +217,7 @@ class OllamaChat::Chat
|
|
217
217
|
:next
|
218
218
|
when %r(^/drop(?:\s+(\d*))?$)
|
219
219
|
messages.drop($1)
|
220
|
-
messages.
|
220
|
+
messages.show_last
|
221
221
|
:next
|
222
222
|
when %r(^/model$)
|
223
223
|
@model = choose_model('', @model)
|
@@ -495,8 +495,9 @@ class OllamaChat::Chat
|
|
495
495
|
end
|
496
496
|
rescue Interrupt
|
497
497
|
if message = server_socket_message
|
498
|
-
type
|
499
|
-
content
|
498
|
+
type = message.type.full?(:to_sym) || :socket_input
|
499
|
+
content = message.content
|
500
|
+
@parse_content = message.parse
|
500
501
|
STDOUT.puts color(112) { "Received a server socket message. Processing now…" }
|
501
502
|
else
|
502
503
|
raise
|
@@ -1,24 +1,48 @@
|
|
1
1
|
module OllamaChat::ServerSocket
|
2
2
|
class << self
|
3
|
-
# The send_to_server_socket method
|
4
|
-
#
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
3
|
+
# The send_to_server_socket method transmits a message to a Unix domain
|
4
|
+
# socket server for processing by the Ollama Chat client.
|
5
|
+
#
|
6
|
+
# This method creates a socket server instance using the provided
|
7
|
+
# configuration, prepares a message with the given content, type, and parse
|
8
|
+
# flag, then sends it either as a simple transmission or with a response
|
9
|
+
# expectation depending on the message type. It is used to enable
|
10
|
+
# communication between external processes and the chat session via a named
|
11
|
+
# Unix socket.
|
8
12
|
#
|
9
|
-
# @
|
10
|
-
#
|
11
|
-
|
13
|
+
# @param content [ String ] the message content to be sent
|
14
|
+
# @param config [ ComplexConfig::Settings ] the configuration object containing server settings
|
15
|
+
# @param type [ Symbol ] the type of message transmission, defaults to :socket_input
|
16
|
+
# @param parse [ TrueClass, FalseClass ] whether to parse the response, defaults to false
|
17
|
+
#
|
18
|
+
# @return [ UnixSocks::Message, nil ] the response from transmit_with_response if type
|
19
|
+
# is :socket_input_with_response, otherwise nil
|
20
|
+
def send_to_server_socket(content, config:, type: :socket_input, parse: false)
|
12
21
|
server = create_socket_server(config:)
|
13
|
-
message = { content:, type: }
|
22
|
+
message = { content:, type:, parse: }
|
14
23
|
if type.to_sym == :socket_input_with_response
|
15
|
-
|
24
|
+
server.transmit_with_response(message)
|
16
25
|
else
|
17
|
-
|
18
|
-
|
26
|
+
server.transmit(message)
|
27
|
+
nil
|
19
28
|
end
|
20
29
|
end
|
21
30
|
|
31
|
+
# The create_socket_server method constructs and returns a Unix domain
|
32
|
+
# socket server instance for communication with the Ollama Chat client.
|
33
|
+
#
|
34
|
+
# This method initializes a UnixSocks::Server object configured to listen
|
35
|
+
# for incoming messages on a named socket file. It supports specifying a
|
36
|
+
# custom runtime directory for the socket, which is useful for isolating
|
37
|
+
# multiple instances or environments. If no runtime directory is provided
|
38
|
+
# in the configuration, it defaults to using the standard system location
|
39
|
+
# for Unix domain sockets.
|
40
|
+
#
|
41
|
+
# @param config [ComplexConfig::Settings] the configuration object
|
42
|
+
# containing server settings
|
43
|
+
#
|
44
|
+
# @return [UnixSocks::Server] a configured Unix domain socket server
|
45
|
+
# instance ready to receive messages
|
22
46
|
def create_socket_server(config:)
|
23
47
|
if runtime_dir = config.server_socket_runtime_dir
|
24
48
|
UnixSocks::Server.new(socket_name: 'ollama_chat.sock', runtime_dir:)
|
@@ -37,9 +61,6 @@ module OllamaChat::ServerSocket
|
|
37
61
|
# messages in the background. When a message is received, it updates the
|
38
62
|
# instance variable `server_socket_message` and sends an interrupt signal
|
39
63
|
# to the current process in order to handle the message.
|
40
|
-
#
|
41
|
-
# @return [ nil ] This method does not return any value, it only sets up the
|
42
|
-
# server socket and kills the process when a message is received.
|
43
64
|
def init_server_socket
|
44
65
|
server = OllamaChat::ServerSocket.create_socket_server(config:)
|
45
66
|
server.receive_in_background do |message|
|
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.22 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.22".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]
|
@@ -13,18 +13,18 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.executables = ["ollama_chat".freeze, "ollama_chat_send".freeze]
|
15
15
|
s.extra_rdoc_files = ["README.md".freeze, "lib/ollama_chat.rb".freeze, "lib/ollama_chat/chat.rb".freeze, "lib/ollama_chat/clipboard.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/message_format.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_output.rb".freeze, "lib/ollama_chat/model_handling.rb".freeze, "lib/ollama_chat/ollama_chat_config.rb".freeze, "lib/ollama_chat/parsing.rb".freeze, "lib/ollama_chat/server_socket.rb".freeze, "lib/ollama_chat/source_fetching.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/utils.rb".freeze, "lib/ollama_chat/utils/cache_fetcher.rb".freeze, "lib/ollama_chat/utils/chooser.rb".freeze, "lib/ollama_chat/utils/fetcher.rb".freeze, "lib/ollama_chat/utils/file_argument.rb".freeze, "lib/ollama_chat/version.rb".freeze, "lib/ollama_chat/vim.rb".freeze, "lib/ollama_chat/web_searching.rb".freeze]
|
16
|
-
s.files = [".all_images.yml".freeze, ".envrc".freeze, ".gitignore".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/ollama_chat".freeze, "bin/ollama_chat_send".freeze, "config/searxng/settings.yml".freeze, "docker-compose.yml".freeze, "lib/ollama_chat.rb".freeze, "lib/ollama_chat/chat.rb".freeze, "lib/ollama_chat/clipboard.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/message_format.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_output.rb".freeze, "lib/ollama_chat/model_handling.rb".freeze, "lib/ollama_chat/ollama_chat_config.rb".freeze, "lib/ollama_chat/ollama_chat_config/default_config.yml".freeze, "lib/ollama_chat/parsing.rb".freeze, "lib/ollama_chat/server_socket.rb".freeze, "lib/ollama_chat/source_fetching.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/utils.rb".freeze, "lib/ollama_chat/utils/cache_fetcher.rb".freeze, "lib/ollama_chat/utils/chooser.rb".freeze, "lib/ollama_chat/utils/fetcher.rb".freeze, "lib/ollama_chat/utils/file_argument.rb".freeze, "lib/ollama_chat/version.rb".freeze, "lib/ollama_chat/vim.rb".freeze, "lib/ollama_chat/web_searching.rb".freeze, "ollama_chat.gemspec".freeze, "redis/redis.conf".freeze, "spec/assets/api_show.json".freeze, "spec/assets/api_tags.json".freeze, "spec/assets/api_version.json".freeze, "spec/assets/conversation.json".freeze, "spec/assets/duckduckgo.html".freeze, "spec/assets/example.atom".freeze, "spec/assets/example.csv".freeze, "spec/assets/example.html".freeze, "spec/assets/example.pdf".freeze, "spec/assets/example.ps".freeze, "spec/assets/example.rb".freeze, "spec/assets/example.rss".freeze, "spec/assets/example.xml".freeze, "spec/assets/kitten.jpg".freeze, "spec/assets/prompt.txt".freeze, "spec/assets/searxng.json".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/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/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, "tmp/.keep".freeze]
|
16
|
+
s.files = [".all_images.yml".freeze, ".envrc".freeze, ".gitignore".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/ollama_chat".freeze, "bin/ollama_chat_send".freeze, "config/searxng/settings.yml".freeze, "docker-compose.yml".freeze, "lib/ollama_chat.rb".freeze, "lib/ollama_chat/chat.rb".freeze, "lib/ollama_chat/clipboard.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/message_format.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_output.rb".freeze, "lib/ollama_chat/model_handling.rb".freeze, "lib/ollama_chat/ollama_chat_config.rb".freeze, "lib/ollama_chat/ollama_chat_config/default_config.yml".freeze, "lib/ollama_chat/parsing.rb".freeze, "lib/ollama_chat/server_socket.rb".freeze, "lib/ollama_chat/source_fetching.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/utils.rb".freeze, "lib/ollama_chat/utils/cache_fetcher.rb".freeze, "lib/ollama_chat/utils/chooser.rb".freeze, "lib/ollama_chat/utils/fetcher.rb".freeze, "lib/ollama_chat/utils/file_argument.rb".freeze, "lib/ollama_chat/version.rb".freeze, "lib/ollama_chat/vim.rb".freeze, "lib/ollama_chat/web_searching.rb".freeze, "ollama_chat.gemspec".freeze, "redis/redis.conf".freeze, "spec/assets/api_show.json".freeze, "spec/assets/api_tags.json".freeze, "spec/assets/api_version.json".freeze, "spec/assets/conversation.json".freeze, "spec/assets/duckduckgo.html".freeze, "spec/assets/example.atom".freeze, "spec/assets/example.csv".freeze, "spec/assets/example.html".freeze, "spec/assets/example.pdf".freeze, "spec/assets/example.ps".freeze, "spec/assets/example.rb".freeze, "spec/assets/example.rss".freeze, "spec/assets/example.xml".freeze, "spec/assets/kitten.jpg".freeze, "spec/assets/prompt.txt".freeze, "spec/assets/searxng.json".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/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, "tmp/.keep".freeze]
|
17
17
|
s.homepage = "https://github.com/flori/ollama_chat".freeze
|
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.1".freeze)
|
21
21
|
s.rubygems_version = "3.6.9".freeze
|
22
22
|
s.summary = "A command-line interface (CLI) for interacting with an Ollama AI model.".freeze
|
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/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/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]
|
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/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
|
|
25
25
|
s.specification_version = 4
|
26
26
|
|
27
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, ["~>
|
27
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.0".freeze])
|
28
28
|
s.add_development_dependency(%q<all_images>.freeze, ["~> 0.6".freeze])
|
29
29
|
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.2".freeze])
|
30
30
|
s.add_development_dependency(%q<kramdown>.freeze, ["~> 2.0".freeze])
|
@@ -79,7 +79,7 @@ describe OllamaChat::Chat do
|
|
79
79
|
|
80
80
|
it 'returns :next when input is "/drop(?:\s+(\d*))?"' do
|
81
81
|
expect(chat.messages).to receive(:drop).with(?2)
|
82
|
-
expect(chat.messages).to receive(:
|
82
|
+
expect(chat.messages).to receive(:show_last)
|
83
83
|
expect(chat.handle_input("/drop 2")).to eq :next
|
84
84
|
end
|
85
85
|
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OllamaChat::ServerSocket do
|
4
|
+
let :instance do
|
5
|
+
Object.extend(described_class)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#send_to_server_socket' do
|
9
|
+
let(:config) { double('Config') }
|
10
|
+
let(:server) { double('Server') }
|
11
|
+
|
12
|
+
before do
|
13
|
+
expect(OllamaChat::ServerSocket).to receive(:create_socket_server).with(config: config).and_return(server)
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'with default parameters' do
|
17
|
+
it 'uses correct defaults' do
|
18
|
+
message = { content: 'test', type: :socket_input, parse: false }
|
19
|
+
|
20
|
+
expect(server).to receive(:transmit).with(message).and_return(nil)
|
21
|
+
|
22
|
+
result = OllamaChat::ServerSocket.send_to_server_socket('test', config: config)
|
23
|
+
|
24
|
+
expect(result).to be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'with :socket_input type and parse: true' do
|
29
|
+
it 'sends message with parse flag and returns nil' do
|
30
|
+
message = { content: 'test', type: :socket_input, parse: true }
|
31
|
+
|
32
|
+
expect(server).to receive(:transmit).with(message).and_return(nil)
|
33
|
+
|
34
|
+
result = OllamaChat::ServerSocket.send_to_server_socket(
|
35
|
+
'test',
|
36
|
+
config: config,
|
37
|
+
type: :socket_input,
|
38
|
+
parse: true
|
39
|
+
)
|
40
|
+
|
41
|
+
expect(result).to be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with :socket_input_with_response type and parse: false' do
|
46
|
+
it 'sends message and returns response with parse flag' do
|
47
|
+
message = { content: 'test', type: :socket_input_with_response, parse: false }
|
48
|
+
response = double('Response')
|
49
|
+
|
50
|
+
expect(server).to receive(:transmit_with_response).with(message).and_return(response)
|
51
|
+
|
52
|
+
result = OllamaChat::ServerSocket.send_to_server_socket(
|
53
|
+
'test',
|
54
|
+
config: config,
|
55
|
+
type: :socket_input_with_response,
|
56
|
+
parse: false
|
57
|
+
)
|
58
|
+
|
59
|
+
expect(result).to eq(response)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'with :socket_input_with_response type and parse: true' do
|
64
|
+
it 'sends message and returns response with parse flag' do
|
65
|
+
message = { content: 'test', type: :socket_input_with_response, parse: true }
|
66
|
+
response = double('Response')
|
67
|
+
|
68
|
+
expect(server).to receive(:transmit_with_response).with(message).and_return(response)
|
69
|
+
|
70
|
+
result = OllamaChat::ServerSocket.send_to_server_socket(
|
71
|
+
'test',
|
72
|
+
config: config,
|
73
|
+
type: :socket_input_with_response,
|
74
|
+
parse: true
|
75
|
+
)
|
76
|
+
|
77
|
+
expect(result).to eq(response)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#create_socket_server' do
|
84
|
+
context 'with configured runtime_dir' do
|
85
|
+
it 'can be created with configured runtime_dir' do
|
86
|
+
config = double('Config', server_socket_runtime_dir: '/custom/runtime')
|
87
|
+
expect(UnixSocks::Server).to receive(:new).with(
|
88
|
+
socket_name: 'ollama_chat.sock',
|
89
|
+
runtime_dir: '/custom/runtime'
|
90
|
+
).and_return :unix_socks_server
|
91
|
+
|
92
|
+
result = OllamaChat::ServerSocket.create_socket_server(config: config)
|
93
|
+
expect(result).to eq :unix_socks_server
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'with default runtime_dir' do
|
98
|
+
it 'can be created with default runtime_dir' do
|
99
|
+
config = double('Config', server_socket_runtime_dir: nil)
|
100
|
+
expect(UnixSocks::Server).to receive(:new).with(
|
101
|
+
socket_name: 'ollama_chat.sock'
|
102
|
+
).and_return :unix_socks_server
|
103
|
+
|
104
|
+
result = OllamaChat::ServerSocket.create_socket_server(config: config)
|
105
|
+
expect(result).to eq :unix_socks_server
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#server_socket_message' do
|
111
|
+
it 'can be set' do
|
112
|
+
message = double('message')
|
113
|
+
instance.server_socket_message = message
|
114
|
+
expect(instance.server_socket_message).to eq(message)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'can be read' do
|
118
|
+
message = double('message')
|
119
|
+
instance.server_socket_message = message
|
120
|
+
expect(instance.server_socket_message).to eq(message)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#init_server_socket' do
|
125
|
+
it 'can be initialized' do
|
126
|
+
config = double('Config')
|
127
|
+
expect(instance).to receive(:config).and_return config
|
128
|
+
server = double('Server', receive_in_background: :receive_in_background)
|
129
|
+
expect(described_class).to receive(:create_socket_server).and_return server
|
130
|
+
expect(instance.init_server_socket).to eq :receive_in_background
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
SimpleCov.start do
|
4
|
-
add_filter "#{File.basename(File.dirname(__FILE__))}/"
|
5
|
-
end
|
6
|
-
end
|
1
|
+
require 'gem_hadar/simplecov'
|
2
|
+
GemHadar::SimpleCov.start
|
7
3
|
require 'rspec'
|
8
4
|
require 'tins/xt/expose'
|
9
5
|
begin
|
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.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: '
|
18
|
+
version: '2.0'
|
19
19
|
type: :development
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: '
|
25
|
+
version: '2.0'
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: all_images
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -468,6 +468,7 @@ files:
|
|
468
468
|
- spec/ollama_chat/message_output_spec.rb
|
469
469
|
- spec/ollama_chat/model_handling_spec.rb
|
470
470
|
- spec/ollama_chat/parsing_spec.rb
|
471
|
+
- spec/ollama_chat/server_socket_spec.rb
|
471
472
|
- spec/ollama_chat/source_fetching_spec.rb
|
472
473
|
- spec/ollama_chat/switches_spec.rb
|
473
474
|
- spec/ollama_chat/utils/cache_fetcher_spec.rb
|
@@ -511,6 +512,7 @@ test_files:
|
|
511
512
|
- spec/ollama_chat/message_output_spec.rb
|
512
513
|
- spec/ollama_chat/model_handling_spec.rb
|
513
514
|
- spec/ollama_chat/parsing_spec.rb
|
515
|
+
- spec/ollama_chat/server_socket_spec.rb
|
514
516
|
- spec/ollama_chat/source_fetching_spec.rb
|
515
517
|
- spec/ollama_chat/switches_spec.rb
|
516
518
|
- spec/ollama_chat/utils/cache_fetcher_spec.rb
|