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.
@@ -2,153 +2,93 @@ require 'spec_helper'
2
2
 
3
3
  describe OllamaChat::ThinkControl 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
11
9
 
12
10
  describe '#think' do
13
- it 'returns the current think mode state' do
11
+ it 'returns false when the think mode selector is off' do
12
+ chat.think_mode.selected = 'disabled'
14
13
  expect(chat.think).to be false
15
- chat.instance_variable_set(:@think, true)
14
+ end
15
+
16
+ it 'returns true when the think mode selector is enabled' do
17
+ chat.think_mode.selected = 'enabled'
16
18
  expect(chat.think).to be true
17
- chat.instance_variable_set(:@think, false)
18
- expect(chat.think).to be false
19
- chat.instance_variable_set(:@think, 'low')
19
+ end
20
+
21
+ it 'returns the selected value when it is not “enabled”' do
22
+ chat.think_mode.selected = 'low'
20
23
  expect(chat.think).to eq 'low'
21
24
  end
22
25
  end
23
26
 
24
27
  describe '#think?' do
25
- it 'returns true when think mode is enabled (boolean true)' do
26
- chat.instance_variable_set(:@think, true)
28
+ it 'returns true when the think mode selector is on' do
29
+ chat.think_mode.selected = 'enabled'
27
30
  expect(chat.think?).to be true
28
31
  end
29
32
 
30
- it 'returns true when think mode is enabled (string value)' do
31
- chat.instance_variable_set(:@think, 'high')
33
+ it 'returns true when the think mode selector is on but the value is a string' do
34
+ chat.think_mode.selected = 'high'
32
35
  expect(chat.think?).to be true
33
36
  end
34
37
 
35
- it 'returns false when think mode is disabled (boolean false)' do
36
- chat.instance_variable_set(:@think, false)
37
- expect(chat.think?).to be false
38
- end
39
-
40
- it 'returns false when think mode is nil' do
41
- chat.instance_variable_set(:@think, nil)
38
+ it 'returns false when the think mode selector is off' do
39
+ chat.think_mode.selected = 'disabled'
42
40
  expect(chat.think?).to be false
43
41
  end
44
42
  end
45
43
 
46
44
  describe '#think_mode' do
47
- it 'returns "enabled" when think is true' do
48
- chat.instance_variable_set(:@think, true)
49
- expect(chat.think_mode).to eq 'enabled'
45
+ it 'exposes a StateSelector instance' do
46
+ expect(chat.think_mode).to be_a OllamaChat::StateSelectors::StateSelector
50
47
  end
51
48
 
52
- it 'returns the think value when it is a string' do
53
- chat.instance_variable_set(:@think, 'medium')
54
- expect(chat.think_mode).to eq 'medium'
55
- end
56
-
57
- it 'returns "disabled" when think is false' do
58
- chat.instance_variable_set(:@think, false)
59
- expect(chat.think_mode).to eq 'disabled'
60
- end
61
-
62
- it 'returns "disabled" when think is nil' do
63
- chat.instance_variable_set(:@think, nil)
64
- expect(chat.think_mode).to eq 'disabled'
65
- end
66
- end
67
-
68
- describe '#think_show' do
69
- it 'displays the current think mode status' do
70
- chat.instance_variable_set(:@think, true)
71
- expect(STDOUT).to receive(:puts).with(/Think mode is \e\[1menabled\e\[0m\./)
72
- chat.think_show
73
- end
74
-
75
- it 'displays the think mode level when set to string' do
76
- chat.instance_variable_set(:@think, 'high')
77
- expect(STDOUT).to receive(:puts).with(/Think mode is \e\[1mhigh\e\[0m\./)
78
- chat.think_show
79
- end
80
-
81
- it 'displays "disabled" when think is false' do
82
- chat.instance_variable_set(:@think, false)
83
- expect(STDOUT).to receive(:puts).with(/Think mode is \e\[1mdisabled\e\[0m\./)
84
- chat.think_show
85
- end
86
-
87
- it 'displays "disabled" when think is nil' do
88
- chat.instance_variable_set(:@think, nil)
89
- expect(STDOUT).to receive(:puts).with(/Think mode is \e\[1mdisabled\e\[0m\./)
90
- chat.think_show
49
+ it 'has the correct default selection (disabled)' do
50
+ expect(chat.think_mode.selected).to eq 'disabled'
91
51
  end
92
52
  end
93
53
 
94
54
  describe '#think_loud?' do
95
- it 'returns false when think is disabled' do
96
- chat.instance_variable_set(:@think, false)
55
+ it 'returns false when the think mode selector is off' do
56
+ chat.think_mode.selected = 'disabled'
97
57
  expect(chat.think_loud?).to be false
98
58
  end
99
59
 
100
- it 'returns false when think_loud is off' do
101
- chat.instance_variable_set(:@think, true)
60
+ it 'returns false when the think_loud switch is off' do
61
+ chat.think_mode.selected = 'enabled'
102
62
  allow(chat).to receive(:think_loud).and_return(double(on?: false))
103
63
  expect(chat.think_loud?).to be false
104
64
  end
105
65
 
106
- it 'returns true when both think and think_loud are enabled' do
107
- chat.instance_variable_set(:@think, true)
66
+ it 'returns true when both the think mode selector and think_loud switch are on' do
67
+ chat.think_mode.selected = 'enabled'
108
68
  allow(chat).to receive(:think_loud).and_return(double(on?: true))
109
69
  expect(chat.think_loud?).to be true
110
70
  end
111
71
  end
112
72
 
113
- describe '#choose_think_mode' do
114
- it 'can select "off" mode' do
115
- expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('off')
116
- chat.choose_think_mode
117
- expect(chat.think).to be false
73
+ describe '#think_mode.show' do
74
+ it 'prints the current think mode in bold' do
75
+ chat.think_mode.selected = 'high'
76
+ expect(STDOUT).to receive(:puts).with(/Think mode is \e\[1mhigh\e\[0m/)
77
+ chat.think_mode.show
118
78
  end
119
79
 
120
- it 'can select "on" mode' do
121
- expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('on')
122
- chat.choose_think_mode
123
- expect(chat.think).to be true
80
+ it 'prints “disabled” when the selector is off' do
81
+ chat.think_mode.selected = 'disabled'
82
+ expect(STDOUT).to receive(:puts).with(/Think mode is \e\[1mdisabled\e\[0m/)
83
+ chat.think_mode.show
124
84
  end
85
+ end
125
86
 
126
- it 'can select "low" mode' do
87
+ describe '#think_mode.choose' do
88
+ it 'updates the selector based on the user choice' do
127
89
  expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('low')
128
- chat.choose_think_mode
129
- expect(chat.think).to eq 'low'
130
- end
131
-
132
- it 'can select "medium" mode' do
133
- expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('medium')
134
- chat.choose_think_mode
135
- expect(chat.think).to eq 'medium'
136
- end
137
-
138
- it 'can select "high" mode' do
139
- expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('high')
140
- chat.choose_think_mode
141
- expect(chat.think).to eq 'high'
142
- end
143
-
144
- it 'can exit selection' do
145
- expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('[EXIT]')
146
- expect { chat.choose_think_mode }.not_to change { chat.think }
147
- end
148
-
149
- it 'can handle nil selection' do
150
- expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return(nil)
151
- expect { chat.choose_think_mode }.not_to change { chat.think }
90
+ chat.think_mode.choose
91
+ expect(chat.think_mode.selected).to eq 'low'
152
92
  end
153
93
  end
154
94
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe OllamaChat::WebSearching 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
data/spec/spec_helper.rb CHANGED
@@ -86,6 +86,10 @@ module AssetHelpers
86
86
  end
87
87
  end
88
88
 
89
+ def chat_default_config(a = [])
90
+ a + %w[ -f lib/ollama_chat/ollama_chat_config/default_config.yml ]
91
+ end
92
+
89
93
  # A module that provides functionality for stubbing Ollama server responses.
90
94
  #
91
95
  # The StubOllamaServer module enables developers to simulate Ollama API
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.55
4
+ version: 0.0.57
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: 2.16.3
18
+ version: 2.17.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: 2.16.3
25
+ version: 2.17.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: all_images
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -385,14 +385,14 @@ dependencies:
385
385
  requirements:
386
386
  - - "~>"
387
387
  - !ruby/object:Gem::Version
388
- version: '1.1'
388
+ version: '1.5'
389
389
  type: :runtime
390
390
  prerelease: false
391
391
  version_requirements: !ruby/object:Gem::Requirement
392
392
  requirements:
393
393
  - - "~>"
394
394
  - !ruby/object:Gem::Version
395
- version: '1.1'
395
+ version: '1.5'
396
396
  description: |
397
397
  The app provides a command-line interface (CLI) to an Ollama AI model,
398
398
  allowing users to engage in text-based conversations and generate
@@ -430,6 +430,7 @@ extra_rdoc_files:
430
430
  - lib/ollama_chat/redis_cache.rb
431
431
  - lib/ollama_chat/server_socket.rb
432
432
  - lib/ollama_chat/source_fetching.rb
433
+ - lib/ollama_chat/state_selectors.rb
433
434
  - lib/ollama_chat/switches.rb
434
435
  - lib/ollama_chat/think_control.rb
435
436
  - lib/ollama_chat/utils.rb
@@ -473,6 +474,7 @@ files:
473
474
  - lib/ollama_chat/redis_cache.rb
474
475
  - lib/ollama_chat/server_socket.rb
475
476
  - lib/ollama_chat/source_fetching.rb
477
+ - lib/ollama_chat/state_selectors.rb
476
478
  - lib/ollama_chat/switches.rb
477
479
  - lib/ollama_chat/think_control.rb
478
480
  - lib/ollama_chat/utils.rb
@@ -516,6 +518,7 @@ files:
516
518
  - spec/ollama_chat/redis_cache_spec.rb
517
519
  - spec/ollama_chat/server_socket_spec.rb
518
520
  - spec/ollama_chat/source_fetching_spec.rb
521
+ - spec/ollama_chat/state_selectors_spec.rb
519
522
  - spec/ollama_chat/switches_spec.rb
520
523
  - spec/ollama_chat/think_control_spec.rb
521
524
  - spec/ollama_chat/utils/cache_fetcher_spec.rb
@@ -547,7 +550,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
547
550
  - !ruby/object:Gem::Version
548
551
  version: '0'
549
552
  requirements: []
550
- rubygems_version: 4.0.2
553
+ rubygems_version: 4.0.3
551
554
  specification_version: 4
552
555
  summary: A command-line interface (CLI) for interacting with an Ollama AI model.
553
556
  test_files:
@@ -566,6 +569,7 @@ test_files:
566
569
  - spec/ollama_chat/redis_cache_spec.rb
567
570
  - spec/ollama_chat/server_socket_spec.rb
568
571
  - spec/ollama_chat/source_fetching_spec.rb
572
+ - spec/ollama_chat/state_selectors_spec.rb
569
573
  - spec/ollama_chat/switches_spec.rb
570
574
  - spec/ollama_chat/think_control_spec.rb
571
575
  - spec/ollama_chat/utils/cache_fetcher_spec.rb