ollama_chat 0.0.55 → 0.0.57
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 +60 -0
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/lib/ollama_chat/chat.rb +45 -22
- data/lib/ollama_chat/dialog.rb +2 -41
- data/lib/ollama_chat/env_config.rb +9 -0
- data/lib/ollama_chat/information.rb +5 -6
- data/lib/ollama_chat/input_content.rb +27 -21
- data/lib/ollama_chat/ollama_chat_config/default_config.yml +5 -2
- data/lib/ollama_chat/parsing.rb +1 -3
- data/lib/ollama_chat/state_selectors.rb +146 -0
- data/lib/ollama_chat/switches.rb +1 -1
- data/lib/ollama_chat/think_control.rb +11 -39
- data/lib/ollama_chat/version.rb +1 -1
- data/lib/ollama_chat.rb +1 -0
- data/ollama_chat.gemspec +8 -8
- data/spec/ollama_chat/chat_spec.rb +10 -9
- data/spec/ollama_chat/clipboard_spec.rb +1 -1
- data/spec/ollama_chat/information_spec.rb +1 -1
- data/spec/ollama_chat/input_content_spec.rb +15 -6
- data/spec/ollama_chat/message_editing_spec.rb +1 -1
- data/spec/ollama_chat/message_output_spec.rb +1 -1
- data/spec/ollama_chat/model_handling_spec.rb +1 -1
- data/spec/ollama_chat/parsing_spec.rb +7 -24
- data/spec/ollama_chat/source_fetching_spec.rb +1 -3
- data/spec/ollama_chat/state_selectors_spec.rb +193 -0
- data/spec/ollama_chat/think_control_spec.rb +41 -101
- data/spec/ollama_chat/web_searching_spec.rb +1 -1
- data/spec/spec_helper.rb +4 -0
- metadata +10 -6
|
@@ -5,52 +5,24 @@
|
|
|
5
5
|
# thinking modes, checking the current state, and displaying the current
|
|
6
6
|
# think mode status.
|
|
7
7
|
module OllamaChat::ThinkControl
|
|
8
|
-
# The think method returns the current
|
|
8
|
+
# The think method returns the current think mode selection.
|
|
9
9
|
#
|
|
10
|
-
# @return [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
think_modes = %w[ off on low medium high [EXIT] ]
|
|
19
|
-
case chosen = OllamaChat::Utils::Chooser.choose(think_modes)
|
|
20
|
-
when '[EXIT]', nil
|
|
21
|
-
STDOUT.puts "Exiting chooser."
|
|
22
|
-
when 'off'
|
|
23
|
-
@think = false
|
|
24
|
-
when 'on'
|
|
25
|
-
@think = true
|
|
26
|
-
when 'low', 'medium', 'high'
|
|
27
|
-
@think = chosen
|
|
10
|
+
# @return [ String ] the selected think mode value
|
|
11
|
+
def think
|
|
12
|
+
if think_mode.off?
|
|
13
|
+
false
|
|
14
|
+
elsif think_mode.selected == 'enabled'
|
|
15
|
+
true
|
|
16
|
+
else
|
|
17
|
+
think_mode.selected
|
|
28
18
|
end
|
|
29
19
|
end
|
|
30
20
|
|
|
31
21
|
# The think? method checks if the think mode is enabled.
|
|
32
22
|
#
|
|
33
|
-
# @return [
|
|
34
|
-
# otherwise
|
|
23
|
+
# @return [TrueClass, FalseClass] true if think mode is enabled, false otherwise
|
|
35
24
|
def think?
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# The think_mode method returns the current think mode status as a string.
|
|
40
|
-
#
|
|
41
|
-
# @return [ String ] returns 'enabled' if think mode is true, the think mode
|
|
42
|
-
# value if it's a string, or 'disabled' if think mode is false or nil
|
|
43
|
-
def think_mode
|
|
44
|
-
think == true ? 'enabled' : think || 'disabled'
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# The think_show method displays the current think mode status.
|
|
48
|
-
#
|
|
49
|
-
# This method checks the current think mode setting and outputs a message
|
|
50
|
-
# indicating whether think mode is enabled, disabled, or set to a specific
|
|
51
|
-
# mode level (low, medium, high).
|
|
52
|
-
def think_show
|
|
53
|
-
STDOUT.puts "Think mode is #{bold(think_mode)}."
|
|
25
|
+
think_mode.on?
|
|
54
26
|
end
|
|
55
27
|
|
|
56
28
|
# The think_loud? method checks if both think mode and think loud mode are
|
data/lib/ollama_chat/version.rb
CHANGED
data/lib/ollama_chat.rb
CHANGED
|
@@ -20,6 +20,7 @@ require 'ollama_chat/message_format'
|
|
|
20
20
|
require 'ollama_chat/ollama_chat_config'
|
|
21
21
|
require 'ollama_chat/follow_chat'
|
|
22
22
|
require 'ollama_chat/switches'
|
|
23
|
+
require 'ollama_chat/state_selectors'
|
|
23
24
|
require 'ollama_chat/message_list'
|
|
24
25
|
require 'ollama_chat/model_handling'
|
|
25
26
|
require 'ollama_chat/parsing'
|
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.57 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.57".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]
|
|
@@ -12,19 +12,19 @@ Gem::Specification.new do |s|
|
|
|
12
12
|
s.description = "The app provides a command-line interface (CLI) to an Ollama AI model,\nallowing users to engage in text-based conversations and generate\nhuman-like responses. Users can import data from local files or web pages,\nwhich are then processed through three different modes: fully importing the\ncontent into the conversation context, summarizing the information for\nconcise reference, or storing it in an embedding vector database for later\nretrieval based on the conversation.\n".freeze
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
|
14
14
|
s.executables = ["ollama_chat".freeze, "ollama_chat_send".freeze]
|
|
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/conversation.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/env_config.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/input_content.rb".freeze, "lib/ollama_chat/kramdown_ansi.rb".freeze, "lib/ollama_chat/message_editing.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/redis_cache.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/think_control.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 = [".utilsrc".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".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/conversation.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/env_config.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/input_content.rb".freeze, "lib/ollama_chat/kramdown_ansi.rb".freeze, "lib/ollama_chat/message_editing.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/redis_cache.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/think_control.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/example_with_quote.html".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/input_content_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_editing_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/redis_cache_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/think_control_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/vim_spec.rb".freeze, "spec/ollama_chat/web_searching_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tmp/.keep".freeze]
|
|
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/conversation.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/env_config.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/input_content.rb".freeze, "lib/ollama_chat/kramdown_ansi.rb".freeze, "lib/ollama_chat/message_editing.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/redis_cache.rb".freeze, "lib/ollama_chat/server_socket.rb".freeze, "lib/ollama_chat/source_fetching.rb".freeze, "lib/ollama_chat/state_selectors.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/think_control.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 = [".utilsrc".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".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/conversation.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/env_config.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/input_content.rb".freeze, "lib/ollama_chat/kramdown_ansi.rb".freeze, "lib/ollama_chat/message_editing.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/redis_cache.rb".freeze, "lib/ollama_chat/server_socket.rb".freeze, "lib/ollama_chat/source_fetching.rb".freeze, "lib/ollama_chat/state_selectors.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/think_control.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/example_with_quote.html".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/input_content_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_editing_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/redis_cache_spec.rb".freeze, "spec/ollama_chat/server_socket_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/state_selectors_spec.rb".freeze, "spec/ollama_chat/switches_spec.rb".freeze, "spec/ollama_chat/think_control_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/vim_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.2".freeze)
|
|
21
|
-
s.rubygems_version = "4.0.
|
|
21
|
+
s.rubygems_version = "4.0.3".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/input_content_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_editing_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/redis_cache_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/think_control_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/vim_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/input_content_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_editing_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/redis_cache_spec.rb".freeze, "spec/ollama_chat/server_socket_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/state_selectors_spec.rb".freeze, "spec/ollama_chat/switches_spec.rb".freeze, "spec/ollama_chat/think_control_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/vim_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, [">= 2.
|
|
27
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, [">= 2.17.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])
|
|
@@ -50,5 +50,5 @@ Gem::Specification.new do |s|
|
|
|
50
50
|
s.add_runtime_dependency(%q<bigdecimal>.freeze, ["~> 3.1".freeze])
|
|
51
51
|
s.add_runtime_dependency(%q<csv>.freeze, ["~> 3.0".freeze])
|
|
52
52
|
s.add_runtime_dependency(%q<const_conf>.freeze, ["~> 0.3".freeze])
|
|
53
|
-
s.add_runtime_dependency(%q<context_spook>.freeze, ["~> 1.
|
|
53
|
+
s.add_runtime_dependency(%q<context_spook>.freeze, ["~> 1.5".freeze])
|
|
54
54
|
end
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe OllamaChat::Chat, protect_env: true do
|
|
4
|
-
use_default_config = -> a {
|
|
5
|
-
a << '-f' << 'lib/ollama_chat/ollama_chat_config/default_config.yml'
|
|
6
|
-
}
|
|
7
|
-
|
|
8
4
|
let :argv do
|
|
9
|
-
|
|
5
|
+
chat_default_config(%w[ -C test ])
|
|
10
6
|
end
|
|
11
7
|
|
|
12
8
|
before do
|
|
@@ -28,6 +24,11 @@ describe OllamaChat::Chat, protect_env: true do
|
|
|
28
24
|
describe 'handle_input' do
|
|
29
25
|
connect_to_ollama_server
|
|
30
26
|
|
|
27
|
+
it 'returns :next when input is "/reconnect"' do
|
|
28
|
+
expect(chat).to receive(:connect_ollama).and_return double('ollama')
|
|
29
|
+
expect(chat.handle_input("/reconnect")).to eq :next
|
|
30
|
+
end
|
|
31
|
+
|
|
31
32
|
it 'returns :next when input is "/copy"' do
|
|
32
33
|
expect(chat).to receive(:copy_to_clipboard)
|
|
33
34
|
expect(chat.handle_input("/copy")).to eq :next
|
|
@@ -129,7 +130,7 @@ describe OllamaChat::Chat, protect_env: true do
|
|
|
129
130
|
end
|
|
130
131
|
|
|
131
132
|
it 'returns :next when input is "/document_policy"' do
|
|
132
|
-
|
|
133
|
+
expect_any_instance_of(OllamaChat::StateSelectors::StateSelector).to receive(:choose)
|
|
133
134
|
expect(chat.handle_input("/document_policy")).to eq :next
|
|
134
135
|
end
|
|
135
136
|
|
|
@@ -230,7 +231,7 @@ describe OllamaChat::Chat, protect_env: true do
|
|
|
230
231
|
connect_to_ollama_server(instantiate: false)
|
|
231
232
|
|
|
232
233
|
let :argv do
|
|
233
|
-
|
|
234
|
+
chat_default_config(%w[ -C test -c ] << asset('conversation.json'))
|
|
234
235
|
end
|
|
235
236
|
|
|
236
237
|
it 'dispays the last exchange of the converstation' do
|
|
@@ -247,7 +248,7 @@ describe OllamaChat::Chat, protect_env: true do
|
|
|
247
248
|
context 'with MemoryCache' do
|
|
248
249
|
|
|
249
250
|
let :argv do
|
|
250
|
-
|
|
251
|
+
chat_default_config(%w[ -M ])
|
|
251
252
|
end
|
|
252
253
|
|
|
253
254
|
it 'can use MemoryCache' do
|
|
@@ -269,7 +270,7 @@ describe OllamaChat::Chat, protect_env: true do
|
|
|
269
270
|
connect_to_ollama_server(instantiate: false)
|
|
270
271
|
|
|
271
272
|
let :argv do
|
|
272
|
-
|
|
273
|
+
chat_default_config(%w[ -C test -D ] << asset('example.html'))
|
|
273
274
|
end
|
|
274
275
|
|
|
275
276
|
it 'Adds documents passed to app via -D option' do
|
|
@@ -2,16 +2,19 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe OllamaChat::InputContent do
|
|
4
4
|
let :chat do
|
|
5
|
-
OllamaChat::Chat.new
|
|
5
|
+
OllamaChat::Chat.new argv: chat_default_config
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
connect_to_ollama_server
|
|
9
9
|
|
|
10
10
|
describe '#input' do
|
|
11
11
|
it 'can read content from a selected file' do
|
|
12
|
+
selected_filename = 'spec/assets/example.rb'
|
|
12
13
|
# Mock the file selection process
|
|
13
|
-
expect(chat).to receive(:choose_filename).with('**/*').
|
|
14
|
-
and_return(
|
|
14
|
+
expect(chat).to receive(:choose_filename).with('**/*', chosen: Set[]).
|
|
15
|
+
and_return(selected_filename)
|
|
16
|
+
expect(chat).to receive(:choose_filename).with('**/*', chosen: Set[selected_filename]).
|
|
17
|
+
and_return nil
|
|
15
18
|
|
|
16
19
|
# Test that it returns the file content
|
|
17
20
|
result = chat.input(nil)
|
|
@@ -19,13 +22,19 @@ describe OllamaChat::InputContent do
|
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
it 'returns nil when no file is selected' do
|
|
22
|
-
expect(chat).to receive(:choose_filename).with('**/*').
|
|
25
|
+
expect(chat).to receive(:choose_filename).with('**/*', chosen: Set[]).
|
|
26
|
+
and_return(nil)
|
|
23
27
|
expect(chat.input(nil)).to be_nil
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
it 'can read content with specific pattern' do
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
selected_filename = 'spec/assets/example.rb'
|
|
32
|
+
expect(chat).to receive(:choose_filename).
|
|
33
|
+
with('spec/assets/*', chosen: Set[]).
|
|
34
|
+
and_return(selected_filename)
|
|
35
|
+
expect(chat).to receive(:choose_filename).
|
|
36
|
+
with('spec/assets/*', chosen: Set[selected_filename]).
|
|
37
|
+
and_return nil
|
|
29
38
|
result = chat.input('spec/assets/*')
|
|
30
39
|
expect(result).to include('puts "Hello World!"')
|
|
31
40
|
end
|
|
@@ -3,8 +3,8 @@ require 'pathname'
|
|
|
3
3
|
|
|
4
4
|
describe OllamaChat::Parsing do
|
|
5
5
|
let :chat do
|
|
6
|
-
OllamaChat::Chat.new.tap do |chat|
|
|
7
|
-
chat.document_policy = 'importing'
|
|
6
|
+
OllamaChat::Chat.new(argv: chat_default_config).tap do |chat|
|
|
7
|
+
chat.document_policy.selected = 'importing'
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -49,24 +49,7 @@ describe OllamaChat::Parsing do
|
|
|
49
49
|
def io.content_type
|
|
50
50
|
'text/csv'
|
|
51
51
|
end
|
|
52
|
-
expect(chat.parse_source(io)).to eq(
|
|
53
|
-
name: John Doe
|
|
54
|
-
age: 32
|
|
55
|
-
occupation: Software Engineer
|
|
56
|
-
|
|
57
|
-
name: Jane Smith
|
|
58
|
-
age: 28
|
|
59
|
-
occupation: Marketing Manager
|
|
60
|
-
|
|
61
|
-
name: Bob Johnson
|
|
62
|
-
age: 45
|
|
63
|
-
occupation: Retired
|
|
64
|
-
|
|
65
|
-
name: Alice Brown
|
|
66
|
-
age: 25
|
|
67
|
-
occupation: Student
|
|
68
|
-
|
|
69
|
-
EOT
|
|
52
|
+
expect(chat.parse_source(io)).to eq(asset_content('example.csv'))
|
|
70
53
|
end
|
|
71
54
|
end
|
|
72
55
|
|
|
@@ -250,14 +233,14 @@ EOT
|
|
|
250
233
|
|
|
251
234
|
context 'document_policy' do
|
|
252
235
|
it 'can be ignoring' do
|
|
253
|
-
chat.document_policy = 'ignoring'
|
|
236
|
+
chat.document_policy.selected = 'ignoring'
|
|
254
237
|
c = "see #{Dir.pwd}/spec/assets/example.html"
|
|
255
238
|
content, = chat.parse_content(c, [])
|
|
256
239
|
expect(content).to eq(c)
|
|
257
240
|
end
|
|
258
241
|
|
|
259
242
|
it 'can be importing' do
|
|
260
|
-
chat.document_policy = 'importing'
|
|
243
|
+
chat.document_policy.selected = 'importing'
|
|
261
244
|
c = "see #{Dir.pwd}/spec/assets/example.html"
|
|
262
245
|
content, = chat.parse_content(c, [])
|
|
263
246
|
expect(content).to include(<<~EOT)
|
|
@@ -270,7 +253,7 @@ EOT
|
|
|
270
253
|
end
|
|
271
254
|
|
|
272
255
|
it 'can be embedding' do
|
|
273
|
-
chat.document_policy = 'embedding'
|
|
256
|
+
chat.document_policy.selected = 'embedding'
|
|
274
257
|
c = "see #{Dir.pwd}/spec/assets/example.html"
|
|
275
258
|
expect(chat).to receive(:embed_source).with(
|
|
276
259
|
kind_of(IO),
|
|
@@ -281,7 +264,7 @@ EOT
|
|
|
281
264
|
end
|
|
282
265
|
|
|
283
266
|
it 'can be summarizing' do
|
|
284
|
-
chat.document_policy = 'summarizing'
|
|
267
|
+
chat.document_policy.selected = 'summarizing'
|
|
285
268
|
c = "see #{Dir.pwd}/spec/assets/example.html"
|
|
286
269
|
content, = chat.parse_content(c, [])
|
|
287
270
|
expect(content).to start_with(<<~EOT)
|
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe OllamaChat::SourceFetching do
|
|
4
4
|
let :chat do
|
|
5
|
-
OllamaChat::Chat.new(
|
|
6
|
-
argv: %w[ -f lib/ollama_chat/ollama_chat_config/default_config.yml ]
|
|
7
|
-
)
|
|
5
|
+
OllamaChat::Chat.new(argv: chat_default_config)
|
|
8
6
|
end
|
|
9
7
|
|
|
10
8
|
connect_to_ollama_server
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe OllamaChat::StateSelectors::StateSelector do
|
|
4
|
+
let(:name) { 'Test Selector' }
|
|
5
|
+
let(:states) { %w[ enabled disabled low high ] }
|
|
6
|
+
let(:default) { 'enabled' }
|
|
7
|
+
let(:off) { %w[ disabled ] }
|
|
8
|
+
|
|
9
|
+
let(:selector) do
|
|
10
|
+
described_class.new(
|
|
11
|
+
name: name,
|
|
12
|
+
states: states,
|
|
13
|
+
default: default,
|
|
14
|
+
off: off
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe '#initialize' do
|
|
19
|
+
it 'creates a new StateSelector with provided parameters' do
|
|
20
|
+
expect(selector).to be_a described_class
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'sets the name correctly' do
|
|
24
|
+
expect(selector.instance_variable_get(:@name)).to eq name
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'sets the states correctly' do
|
|
28
|
+
expect(selector.instance_variable_get(:@states)).to eq Set.new(states)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'sets the default state' do
|
|
32
|
+
expect(selector.instance_variable_get(:@default)).to eq default
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'sets the off states correctly' do
|
|
36
|
+
expect(selector.instance_variable_get(:@off)).to eq off
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'sets the selected state to default' do
|
|
40
|
+
expect(selector.selected).to eq default
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context 'with empty states' do
|
|
44
|
+
it 'raises ArgumentError when states are empty' do
|
|
45
|
+
expect {
|
|
46
|
+
described_class.new(name: 'Test', states: [])
|
|
47
|
+
}.to raise_error(ArgumentError, 'states cannot be empty')
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context 'with invalid default' do
|
|
52
|
+
it 'raises ArgumentError when default is not in states' do
|
|
53
|
+
expect {
|
|
54
|
+
described_class.new(name: 'Test', states: %w[ a b ], default: 'c')
|
|
55
|
+
}.to raise_error(ArgumentError, 'default has to be one of a, b.')
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '#selected' do
|
|
61
|
+
it 'returns the currently selected state' do
|
|
62
|
+
expect(selector.selected).to eq default
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe '#selected=' do
|
|
67
|
+
it 'sets the selected state to a valid value' do
|
|
68
|
+
selector.selected = 'low'
|
|
69
|
+
expect(selector.selected).to eq 'low'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'raises ArgumentError when setting invalid state' do
|
|
73
|
+
expect {
|
|
74
|
+
selector.selected = 'invalid'
|
|
75
|
+
}.to raise_error(ArgumentError, 'value has to be one of enabled, disabled, low, high.')
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe '#allow_empty?' do
|
|
80
|
+
it 'returns false by default' do
|
|
81
|
+
expect(selector.allow_empty?).to be false
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
context 'when allow_empty is true' do
|
|
85
|
+
let(:selector) do
|
|
86
|
+
described_class.new(
|
|
87
|
+
name: name,
|
|
88
|
+
states: states,
|
|
89
|
+
default: nil,
|
|
90
|
+
allow_empty: true
|
|
91
|
+
)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'returns true when allow_empty is set' do
|
|
95
|
+
expect(selector.allow_empty?).to be true
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
describe '#off?' do
|
|
101
|
+
it 'returns true when selected state is in off set' do
|
|
102
|
+
selector.selected = 'disabled'
|
|
103
|
+
expect(selector.off?).to be true
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it 'returns false when selected state is not in off set' do
|
|
107
|
+
selector.selected = 'enabled'
|
|
108
|
+
expect(selector.off?).to be false
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
describe '#on?' do
|
|
113
|
+
it 'returns true when selected state is not in off set' do
|
|
114
|
+
selector.selected = 'enabled'
|
|
115
|
+
expect(selector.on?).to be true
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it 'returns false when selected state is in off set' do
|
|
119
|
+
selector.selected = 'disabled'
|
|
120
|
+
expect(selector.on?).to be false
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
describe '#choose' do
|
|
125
|
+
it 'allows user to select a state from available options' do
|
|
126
|
+
# Mock the chooser to return a specific choice
|
|
127
|
+
expect(OllamaChat::Utils::Chooser).to receive(:choose).with(
|
|
128
|
+
%w[ enabled disabled low high [EXIT] ]
|
|
129
|
+
).and_return('low')
|
|
130
|
+
|
|
131
|
+
selector.choose
|
|
132
|
+
expect(selector.selected).to eq 'low'
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it 'exits when user selects [EXIT]' do
|
|
136
|
+
expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('[EXIT]')
|
|
137
|
+
|
|
138
|
+
selector.choose
|
|
139
|
+
expect(selector.selected).to eq default
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it 'exits when user cancels selection' do
|
|
143
|
+
expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return(nil)
|
|
144
|
+
|
|
145
|
+
selector.choose
|
|
146
|
+
expect(selector.selected).to eq default
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe '#show' do
|
|
151
|
+
it 'outputs the current state to stdout' do
|
|
152
|
+
expect(STDOUT).to receive(:puts).with(/Test Selector is .*?enabled.*?\./)
|
|
153
|
+
selector.show
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
describe '#to_s' do
|
|
158
|
+
it 'returns the string representation of the selected state' do
|
|
159
|
+
expect(selector.to_s).to eq default
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
it 'returns the string representation after changing state' do
|
|
163
|
+
selector.selected = 'low'
|
|
164
|
+
expect(selector.to_s).to eq 'low'
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
describe 'with allow_empty true' do
|
|
169
|
+
let(:selector) do
|
|
170
|
+
described_class.new(
|
|
171
|
+
name: 'Empty Selector',
|
|
172
|
+
states: %w[ a b c ],
|
|
173
|
+
default: nil,
|
|
174
|
+
allow_empty: true
|
|
175
|
+
)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it 'allows setting nil as selected state' do
|
|
179
|
+
selector.selected = nil
|
|
180
|
+
expect(selector.selected).to eq ""
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
it 'allows empty state when allow_empty is true' do
|
|
184
|
+
expect(selector.allow_empty?).to be true
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
it 'raises no error when setting invalid state' do
|
|
188
|
+
expect {
|
|
189
|
+
selector.selected = 'invalid'
|
|
190
|
+
}.not_to raise_error
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|