ollama_chat 0.0.117 → 0.0.118
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 +39 -0
- data/README.md +33 -0
- data/lib/ollama_chat/compaction.rb +1 -1
- data/lib/ollama_chat/database/models/app_state.rb +5 -4
- data/lib/ollama_chat/ollama_chat_config/default_config.yml +42 -6
- data/lib/ollama_chat/personae_management.rb +12 -6
- data/lib/ollama_chat/prompt_management.rb +8 -2
- data/lib/ollama_chat/session_management.rb +20 -6
- data/lib/ollama_chat/source_fetching.rb +1 -1
- data/lib/ollama_chat/tools/get_url.rb +15 -1
- data/lib/ollama_chat/version.rb +1 -1
- data/ollama_chat.gemspec +2 -2
- data/spec/ollama_chat/compaction_spec.rb +1 -21
- data/spec/ollama_chat/session_management_spec.rb +2 -0
- data/spec/ollama_chat/tools/get_url_spec.rb +29 -14
- 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: f5db2a60d43d3a57a30e3c33a16b9ba26e60807afd9ff6b74c0781af25fe2516
|
|
4
|
+
data.tar.gz: e670d0cfcbbcfa815e4b9a7f6e0ccb6093dc4986b736035aea3dc38b4bc646ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f7cb31ed0e38db5baca42a29076b3a01e3bae64d5a80d55584bd0ecdaaa41fd15eb814fc8b34ac55d2e73e4d767c52f305167cd8d2a7b32af4e9668f7d43706
|
|
7
|
+
data.tar.gz: a54ebe900c8b8a2c9e31ce3a4aded809f1b6e179679b2f2b4e3174f9e4ba5f6c976c8e7f1aaf3ae7efb8b8c8417f605b8c2522676eb0952f6d4b38165ac087af
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-09-05 v0.0.118
|
|
4
|
+
|
|
5
|
+
* Documented the upgrade workflow in the README, adding an "Upgrading"
|
|
6
|
+
section that covers the post-`gem update` flow: `/config diff` with
|
|
7
|
+
`:diffget`, reload, and `/prompt sync` for per-prompt drift resolution.
|
|
8
|
+
* Clarified that the local `config.yml` is a partial override requiring no
|
|
9
|
+
migration script.
|
|
10
|
+
* Improved the prompt drift nagging message in `app_state.rb#seed` by
|
|
11
|
+
replacing the previous prompt with a two-part message featuring a bold
|
|
12
|
+
`Tip:` line suggesting `/prompt sync` and a "Seen these changes?"
|
|
13
|
+
confirmation.
|
|
14
|
+
* Replaced literal `⚠️` emoji with `\u26A0\uFE0F` escapes for consistent
|
|
15
|
+
rendering and introduced `Term::ANSIColor` locally for the bold tip prefix.
|
|
16
|
+
* Added a `session.standup` template to `default_config.yml` defining a
|
|
17
|
+
six-section end-of-day document.
|
|
18
|
+
* Moved the compaction system prompt from `prompts.compaction.system` to
|
|
19
|
+
`prompts.system.compaction` and updated `compaction.rb` to call
|
|
20
|
+
`prompt(:compaction, context: 'system')`.
|
|
21
|
+
* Added `prompts.system.report`, a genre-neutral writer system prompt, and
|
|
22
|
+
updated `session_management.rb#report_session` to pass `system:` and
|
|
23
|
+
`think: true` to `generate` for report generation.
|
|
24
|
+
* Simplified `compaction_spec.rb` to resolve templates from
|
|
25
|
+
`chat.config.prompts.system.compaction` and added a `prompt(:report,
|
|
26
|
+
context: 'system')` expectation to `session_management_spec.rb`.
|
|
27
|
+
* Fixed the `get_url` summarizing policy by wrapping it in `Infobar.busy` and
|
|
28
|
+
`chat.generate` to ensure the LLM produces the summary.
|
|
29
|
+
* Added a `words` (integer) parameter to the `get_url` tool schema, forwarded
|
|
30
|
+
to `summarize_source` to control summary length.
|
|
31
|
+
* Changed `STDOUT.puts` to `infobar.puts` in `summarize_source` to prevent
|
|
32
|
+
garbling spinner output.
|
|
33
|
+
* Updated `get_url_spec.rb` to include `words: nil` in argument doubles,
|
|
34
|
+
reworked the summarizing test to expect `chat.generate`, and added a
|
|
35
|
+
`words: 50` forwarding test.
|
|
36
|
+
* Added `Infobar.busy` spinners with descriptive labels to LLM `generate`
|
|
37
|
+
calls in `personae_management.rb`, `prompt_management.rb`, and
|
|
38
|
+
`session_management.rb`.
|
|
39
|
+
* Modified `prompt_management.rb` to only call `edit_text(suggestions)` if
|
|
40
|
+
`suggestions.present?`.
|
|
41
|
+
|
|
3
42
|
## 2026-09-03 v0.0.117
|
|
4
43
|
|
|
5
44
|
* Fixed `/favourite` subcommand completion rendering by replacing separate
|
data/README.md
CHANGED
|
@@ -19,6 +19,39 @@ gem install ollama_chat
|
|
|
19
19
|
|
|
20
20
|
in your terminal.
|
|
21
21
|
|
|
22
|
+
## Upgrading
|
|
23
|
+
|
|
24
|
+
After `gem update ollama_chat`, the next launch will either
|
|
25
|
+
start cleanly or prompt you to fix the config:
|
|
26
|
+
|
|
27
|
+
1. **Open the config diff.** Run `/config diff`, or wait for
|
|
28
|
+
the automatic `fix_config` prompt if the new version
|
|
29
|
+
introduced required keys. Either way, your `$DIFF_TOOL`
|
|
30
|
+
(default: `vimdiff`) opens with your local `config.yml`
|
|
31
|
+
on one side and the shipped `default_config.yml` on the
|
|
32
|
+
other.
|
|
33
|
+
2. **Pull in the changes.** In vimdiff, use `:diffget` to
|
|
34
|
+
copy new or updated keys from the default into your local
|
|
35
|
+
file. Ignore keys you've intentionally overridden.
|
|
36
|
+
3. **Reload.** Close the diff tool and answer `y` to the
|
|
37
|
+
"restart?" prompt.
|
|
38
|
+
4. **Prompt drift.** If the new version changed any shipped
|
|
39
|
+
prompts, a fingerprint notice lists modified, added, and
|
|
40
|
+
removed prompts. To reconcile your stored prompts with
|
|
41
|
+
the new defaults, run `/prompt sync`. It diffs each
|
|
42
|
+
prompt against the shipped version and lets you decide
|
|
43
|
+
per prompt: adopt the new default, keep your local edit,
|
|
44
|
+
or review the change. After syncing, the fingerprint is
|
|
45
|
+
updated and the nagging stops.
|
|
46
|
+
|
|
47
|
+
If you simply want to dismiss the notice without
|
|
48
|
+
syncing, answer `y` to the boot prompt. The fingerprint
|
|
49
|
+
is stored and you won't be asked again.
|
|
50
|
+
|
|
51
|
+
Your local config is a partial override. Keys you don't
|
|
52
|
+
have fall through to the shipped defaults. No migration
|
|
53
|
+
script needed.
|
|
54
|
+
|
|
22
55
|
## Configuration
|
|
23
56
|
|
|
24
57
|
### Environment Variables
|
|
@@ -191,7 +191,7 @@ module OllamaChat::Compaction
|
|
|
191
191
|
prompt = prompt(:summarize, context: 'compaction').to_s % {
|
|
192
192
|
previous:, groups:
|
|
193
193
|
}
|
|
194
|
-
system = prompt(:
|
|
194
|
+
system = prompt(:compaction, context: 'system').to_s
|
|
195
195
|
|
|
196
196
|
es = OllamaChat::TokenEstimator.estimate(prompt)
|
|
197
197
|
log(:info, "Compaction: sending prompt " \
|
|
@@ -73,19 +73,20 @@ class OllamaChat::Database::Models::AppState < Sequel::Model(OllamaChat::DB)
|
|
|
73
73
|
removed = old.keys - hashes.keys
|
|
74
74
|
changed = hashes.select { |k, v| old[k] && old[k] != v }.keys
|
|
75
75
|
|
|
76
|
-
STDERR.puts "
|
|
76
|
+
STDERR.puts "\u26A0\uFE0F Shipped prompts changed since last boot:"
|
|
77
77
|
changed.each { |k| STDERR.puts " ~ #{k} (modified)" }
|
|
78
78
|
added.each { |k| STDERR.puts " + #{k} (new)" }
|
|
79
79
|
removed.each { |k| STDERR.puts " - #{k} (removed)" }
|
|
80
80
|
elsif !OllamaChat.test_mode?
|
|
81
|
-
STDERR.puts
|
|
81
|
+
STDERR.puts "\u26A0\uFE0F First run — storing prompt fingerprints."
|
|
82
82
|
store_fingerprint(fingerprint, hashes)
|
|
83
83
|
return true
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
+
c = Term::ANSIColor
|
|
86
87
|
prompt = <<~EOT.chomp << ' '
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
#{c.bold{'Tip'}}: /prompt sync adopts shipped defaults into local config.
|
|
89
|
+
Seen these changes? (y = stop nagging, n = ask again next boot) %s
|
|
89
90
|
EOT
|
|
90
91
|
if OllamaChat.test_mode? || chat.confirm?(prompt:, yes: /\Ay/i, timeout: 5)
|
|
91
92
|
store_fingerprint(fingerprint, hashes)
|
|
@@ -190,12 +190,40 @@ prompts:
|
|
|
190
190
|
|
|
191
191
|
Write a narrative retelling of the roleplay session
|
|
192
192
|
above. Your story MUST:
|
|
193
|
+
|
|
193
194
|
- Capture the emotional arc and key plot beats.
|
|
194
195
|
- Stay in the established setting and character voices.
|
|
195
196
|
- Use vivid, evocative prose; show, don't tell.
|
|
196
197
|
- Highlight turning points, revelations, and character
|
|
197
198
|
growth.
|
|
198
199
|
- Read it like a short story chapter, not a log.
|
|
200
|
+
standup: |
|
|
201
|
+
%{content}
|
|
202
|
+
|
|
203
|
+
Write a document for an end-of-session snapshot. It captures what was
|
|
204
|
+
accomplished, which decisions were made and why, and what happens next —
|
|
205
|
+
the same alignment a Scrum standup provides, but written down so no
|
|
206
|
+
context is lost between sessions.
|
|
207
|
+
|
|
208
|
+
Your document MUST contain these exact sections:
|
|
209
|
+
|
|
210
|
+
1. ## Progress Log — bulleted list of completed tasks with relative file
|
|
211
|
+
paths. 2. ## External References — all URLs, API docs, or GitHub links
|
|
212
|
+
discussed during the session. 3. ## Current Mental Model — current focus,
|
|
213
|
+
existing blockers, and the immediate next step. 4. ## Technical Decision
|
|
214
|
+
Log — rationale for chosen implementations vs. rejected alternatives
|
|
215
|
+
(table). 5. ## Pending Roadmap — Critical → Important → Future Polish. 6.
|
|
216
|
+
## Quick-Start Pointers — 2–3 files or links the next session must read
|
|
217
|
+
#first.
|
|
218
|
+
|
|
219
|
+
Constraints:
|
|
220
|
+
- Use relative Markdown paths for file references.
|
|
221
|
+
- Document *why* decisions were made, not just *what*.
|
|
222
|
+
- Do not restate what the conversation records verbatim.
|
|
223
|
+
- Professional, precise, technical tone.
|
|
224
|
+
|
|
225
|
+
Output only the standup document. No preamble, no
|
|
226
|
+
postamble, no meta-commentary.
|
|
199
227
|
suggest:
|
|
200
228
|
coding: |
|
|
201
229
|
## Context
|
|
@@ -366,12 +394,6 @@ prompts:
|
|
|
366
394
|
Output only the 9 suggestions as plain text, each separated by one empty line.
|
|
367
395
|
No other text.
|
|
368
396
|
compaction:
|
|
369
|
-
system: |
|
|
370
|
-
You are a context summarizer for a chat application.
|
|
371
|
-
Your sole task is to produce a concise, factual narrative
|
|
372
|
-
summary of the conversation provided. Be precise, omit
|
|
373
|
-
speculation, and follow the formatting instructions in the
|
|
374
|
-
user prompt exactly. Output only the summary text.
|
|
375
397
|
summarize: |
|
|
376
398
|
previous_summary:
|
|
377
399
|
%{previous}
|
|
@@ -408,6 +430,20 @@ prompts:
|
|
|
408
430
|
|
|
409
431
|
%{runtime_info}
|
|
410
432
|
assistant: You are a helpful assistant.
|
|
433
|
+
compaction: |
|
|
434
|
+
You are a context summarizer for a chat application.
|
|
435
|
+
Your sole task is to produce a concise, factual narrative
|
|
436
|
+
summary of the conversation provided. Be precise, omit
|
|
437
|
+
speculation, and follow the formatting instructions in the
|
|
438
|
+
user prompt exactly. Output only the summary text.
|
|
439
|
+
report: |
|
|
440
|
+
You are a writer. The user prompt below
|
|
441
|
+
specifies the document to produce: its
|
|
442
|
+
structure, tone, and constraints. Follow
|
|
443
|
+
it exactly. Output only the final document
|
|
444
|
+
— no preamble, no postamble, no commentary,
|
|
445
|
+
no reference to yourself or the act of
|
|
446
|
+
writing.
|
|
411
447
|
voice:
|
|
412
448
|
handler: OllamaChat::Say
|
|
413
449
|
enabled: false
|
|
@@ -597,12 +597,18 @@ module OllamaChat::PersonaeManagement
|
|
|
597
597
|
# @param persona_name [String] the name of the character to replace {{char}} with
|
|
598
598
|
# @return [String] the resulting structured Markdown persona profile
|
|
599
599
|
def convert_json_character_to_markdown(character, persona_name)
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
600
|
+
Infobar.busy(
|
|
601
|
+
label: 'Converting character…',
|
|
602
|
+
frames: :braille7,
|
|
603
|
+
output: STDOUT,
|
|
604
|
+
) do
|
|
605
|
+
generate(
|
|
606
|
+
prompt: prompt(:persona_architect).to_s % {
|
|
607
|
+
character:,
|
|
608
|
+
persona_template: prompt(:persona).to_s
|
|
609
|
+
}
|
|
610
|
+
).gsub(/{{user}}/i, '%{user}').gsub(/{{char}}/i, persona_name)
|
|
611
|
+
end
|
|
606
612
|
end
|
|
607
613
|
|
|
608
614
|
# Interactively exports a persona profile to a specified file.
|
|
@@ -346,10 +346,16 @@ module OllamaChat::PromptManagement
|
|
|
346
346
|
full_prompt = template % { history:, instruction: }
|
|
347
347
|
|
|
348
348
|
# Execute a silent chat oneshot call (doesn't add to history)
|
|
349
|
-
suggestions =
|
|
349
|
+
suggestions = Infobar.busy(
|
|
350
|
+
label: 'Creating suggestions…',
|
|
351
|
+
frames: :braille7,
|
|
352
|
+
output: STDOUT,
|
|
353
|
+
) do
|
|
354
|
+
generate(prompt: full_prompt)
|
|
355
|
+
end
|
|
350
356
|
|
|
351
357
|
# Pass the AI's suggestions through the editor for final refinement
|
|
352
|
-
edit_text(suggestions)
|
|
358
|
+
edit_text(suggestions) if suggestions.present?
|
|
353
359
|
end
|
|
354
360
|
|
|
355
361
|
# Lists all prompt templates in the database, indicating which are defaults
|
|
@@ -444,7 +444,15 @@ module OllamaChat::SessionManagement
|
|
|
444
444
|
end
|
|
445
445
|
template or return
|
|
446
446
|
|
|
447
|
-
|
|
447
|
+
system = prompt(:report, context: 'system').to_s
|
|
448
|
+
|
|
449
|
+
Infobar.busy(
|
|
450
|
+
label: 'Generating session report…',
|
|
451
|
+
frames: :braille7,
|
|
452
|
+
output: STDOUT,
|
|
453
|
+
) do
|
|
454
|
+
generate(system:, prompt: template.to_s % { content: }, think: true)
|
|
455
|
+
end
|
|
448
456
|
end
|
|
449
457
|
|
|
450
458
|
# Generates a report and displays or saves the result.
|
|
@@ -485,11 +493,17 @@ module OllamaChat::SessionManagement
|
|
|
485
493
|
c << "%s: %s\n\n" % [ sender_name, message.content ]
|
|
486
494
|
end
|
|
487
495
|
prompt = prompt(:session_title).to_s % { length:, content: }
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
496
|
+
Infobar.busy(
|
|
497
|
+
label: 'Naming session…',
|
|
498
|
+
frames: :braille7,
|
|
499
|
+
output: STDOUT,
|
|
500
|
+
) do
|
|
501
|
+
generate(prompt:).full? do |name|
|
|
502
|
+
name = name.
|
|
503
|
+
gsub(/(\A(\s|[^A-Za-z])+|(\s|[^A-Za-z])+\z)/m, '').
|
|
504
|
+
gsub(/\s+/, ' ')
|
|
505
|
+
Kramdown::ANSI::Width.truncate(name, length:)
|
|
506
|
+
end
|
|
493
507
|
end
|
|
494
508
|
end
|
|
495
509
|
|
|
@@ -144,7 +144,7 @@ module OllamaChat::SourceFetching
|
|
|
144
144
|
# @param words [Integer, nil] The target number of words for the summary (defaults to 100)
|
|
145
145
|
# @return [String, nil] The formatted summary message or nil if content is empty or cannot be processed
|
|
146
146
|
def summarize_source(source_io, source, words: nil)
|
|
147
|
-
|
|
147
|
+
infobar.puts "Summarizing #{italic { source_io&.content_type }} document #{source.to_s.inspect} now."
|
|
148
148
|
log(:info, "Source summarized", data: { source: source.to_s, content_type: source_io&.content_type, words: })
|
|
149
149
|
words = words.to_i
|
|
150
150
|
words < 1 and words = 100
|
|
@@ -52,6 +52,13 @@ class OllamaChat::Tools::GetURL
|
|
|
52
52
|
- 'summarizing': Returns a condensed summary of the content.
|
|
53
53
|
EOT
|
|
54
54
|
),
|
|
55
|
+
words: Tool::Function::Parameters::Property.new(
|
|
56
|
+
type: 'integer',
|
|
57
|
+
description: <<~EOT,
|
|
58
|
+
Target word count for the summary (only applies when
|
|
59
|
+
document_policy is 'summarizing'). Defaults to 100.
|
|
60
|
+
EOT
|
|
61
|
+
),
|
|
55
62
|
},
|
|
56
63
|
required: %w[url]
|
|
57
64
|
)
|
|
@@ -75,6 +82,7 @@ class OllamaChat::Tools::GetURL
|
|
|
75
82
|
args = tool_call.function.arguments
|
|
76
83
|
url = args.url.to_s
|
|
77
84
|
document_policy = args.document_policy.full? || 'ignoring'
|
|
85
|
+
words = args.words.to_i
|
|
78
86
|
|
|
79
87
|
allowed_schemes = Array(config.tools.functions.get_url.schemes?).map(&:to_s)
|
|
80
88
|
|
|
@@ -99,7 +107,13 @@ class OllamaChat::Tools::GetURL
|
|
|
99
107
|
when 'embedding'
|
|
100
108
|
content = chat.embed_source(source_io, source)
|
|
101
109
|
when 'summarizing'
|
|
102
|
-
content =
|
|
110
|
+
content = Infobar.busy(
|
|
111
|
+
label: 'Summarizing…',
|
|
112
|
+
frames: :braille7,
|
|
113
|
+
output: STDOUT,
|
|
114
|
+
) do
|
|
115
|
+
chat.generate(prompt: chat.summarize_source(source_io, source, words:))
|
|
116
|
+
end
|
|
103
117
|
else
|
|
104
118
|
message = "Invalid document policy #{document_policy.inspect} used."
|
|
105
119
|
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.118 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.118".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]
|
|
@@ -9,31 +9,11 @@ describe OllamaChat::Compaction do
|
|
|
9
9
|
|
|
10
10
|
connect_to_ollama_server
|
|
11
11
|
|
|
12
|
-
let :summarize_template do
|
|
13
|
-
chat.config.prompts.compaction.summarize
|
|
14
|
-
end
|
|
15
|
-
|
|
16
12
|
let :system_template do
|
|
17
|
-
chat.config.prompts.compaction
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
let :assemble_template do
|
|
21
|
-
chat.config.prompts.compaction.assemble
|
|
13
|
+
chat.config.prompts.system.compaction
|
|
22
14
|
end
|
|
23
15
|
|
|
24
16
|
before do
|
|
25
|
-
allow(chat).to receive(:prompt)
|
|
26
|
-
.with(:summarize, context: 'compaction')
|
|
27
|
-
.and_return(summarize_template)
|
|
28
|
-
|
|
29
|
-
allow(chat).to receive(:prompt)
|
|
30
|
-
.with(:system, context: 'compaction')
|
|
31
|
-
.and_return(system_template)
|
|
32
|
-
|
|
33
|
-
allow(chat).to receive(:prompt)
|
|
34
|
-
.with(:assemble, context: 'compaction')
|
|
35
|
-
.and_return(assemble_template)
|
|
36
|
-
|
|
37
17
|
allow(chat).to receive(:log)
|
|
38
18
|
end
|
|
39
19
|
|
|
@@ -366,6 +366,8 @@ describe OllamaChat::SessionManagement do
|
|
|
366
366
|
expect(chat).to receive(:sender_name_displayed).and_return('User')
|
|
367
367
|
expect(chat).to receive(:prompt).with('coding_brief', context: 'session')
|
|
368
368
|
.and_return(double(to_s: '%{content}'))
|
|
369
|
+
expect(chat).to receive(:prompt).with(:report, context: 'system')
|
|
370
|
+
.and_return(double(to_s: '%{content}'))
|
|
369
371
|
expect(chat).to receive(:generate).and_return('Brief')
|
|
370
372
|
expect(chat.report_session(name: 'coding_brief')).to eq('Brief')
|
|
371
373
|
end
|
|
@@ -26,7 +26,8 @@ describe OllamaChat::Tools::GetURL do
|
|
|
26
26
|
name: 'get_url',
|
|
27
27
|
arguments: double(
|
|
28
28
|
url: 'https://www.example.com/foo',
|
|
29
|
-
document_policy: nil
|
|
29
|
+
document_policy: nil,
|
|
30
|
+
words: nil
|
|
30
31
|
)
|
|
31
32
|
)
|
|
32
33
|
)
|
|
@@ -55,7 +56,8 @@ describe OllamaChat::Tools::GetURL do
|
|
|
55
56
|
name: 'get_url',
|
|
56
57
|
arguments: double(
|
|
57
58
|
url:,
|
|
58
|
-
document_policy: nil
|
|
59
|
+
document_policy: nil,
|
|
60
|
+
words: nil
|
|
59
61
|
)
|
|
60
62
|
)
|
|
61
63
|
)
|
|
@@ -81,10 +83,11 @@ describe OllamaChat::Tools::GetURL do
|
|
|
81
83
|
'ToolCall',
|
|
82
84
|
function: double(
|
|
83
85
|
name: 'get_url',
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
arguments: double(
|
|
87
|
+
url: 'https://www.example.com/foo',
|
|
88
|
+
document_policy: nil,
|
|
89
|
+
words: nil,
|
|
90
|
+
)
|
|
88
91
|
)
|
|
89
92
|
)
|
|
90
93
|
|
|
@@ -111,7 +114,7 @@ describe OllamaChat::Tools::GetURL do
|
|
|
111
114
|
end
|
|
112
115
|
|
|
113
116
|
it 'handles the "ignoring" policy' do
|
|
114
|
-
args = double(url:, document_policy: 'ignoring')
|
|
117
|
+
args = double(url:, document_policy: 'ignoring', words: nil)
|
|
115
118
|
tool_call = double(function: double(arguments: args))
|
|
116
119
|
|
|
117
120
|
result = described_class.new.execute(tool_call, chat:)
|
|
@@ -120,7 +123,7 @@ describe OllamaChat::Tools::GetURL do
|
|
|
120
123
|
end
|
|
121
124
|
|
|
122
125
|
it 'handles the "importing" policy' do
|
|
123
|
-
args = double(url:, document_policy: 'importing')
|
|
126
|
+
args = double(url:, document_policy: 'importing', words: nil)
|
|
124
127
|
tool_call = double(function: double(arguments: args))
|
|
125
128
|
expect(chat).to receive(:import_source).with(source_io, URI.parse(url)).and_return('imported content')
|
|
126
129
|
|
|
@@ -130,7 +133,7 @@ describe OllamaChat::Tools::GetURL do
|
|
|
130
133
|
end
|
|
131
134
|
|
|
132
135
|
it 'handles the "embedding" policy' do
|
|
133
|
-
args = double(url:, document_policy: 'embedding')
|
|
136
|
+
args = double(url:, document_policy: 'embedding', words: nil)
|
|
134
137
|
tool_call = double(function: double(arguments: args))
|
|
135
138
|
expect(chat).to receive(:embed_source).with(source_io, URI.parse(url)).and_return('embedded content')
|
|
136
139
|
|
|
@@ -140,17 +143,29 @@ describe OllamaChat::Tools::GetURL do
|
|
|
140
143
|
end
|
|
141
144
|
|
|
142
145
|
it 'handles the "summarizing" policy' do
|
|
143
|
-
args = double(url:, document_policy: 'summarizing')
|
|
146
|
+
args = double(url:, document_policy: 'summarizing', words: nil)
|
|
144
147
|
tool_call = double(function: double(arguments: args))
|
|
145
|
-
expect(chat).to receive(:summarize_source).with(source_io, URI.parse(url)).and_return('
|
|
148
|
+
expect(chat).to receive(:summarize_source).with(source_io, URI.parse(url), words: 0).and_return('summarize prompt')
|
|
149
|
+
expect(chat).to receive(:generate).with(prompt: 'summarize prompt').and_return('summarized content')
|
|
146
150
|
|
|
147
151
|
result = described_class.new.execute(tool_call, chat:)
|
|
148
152
|
json = json_object(result)
|
|
149
153
|
expect(json.content).to eq('summarized content')
|
|
150
154
|
end
|
|
151
155
|
|
|
156
|
+
it 'handles the "summarizing" policy with custom words' do
|
|
157
|
+
args = double(url:, document_policy: 'summarizing', words: 50)
|
|
158
|
+
tool_call = double(function: double(arguments: args))
|
|
159
|
+
expect(chat).to receive(:summarize_source).with(source_io, URI.parse(url), words: 50).and_return('summarize prompt 50')
|
|
160
|
+
expect(chat).to receive(:generate).with(prompt: 'summarize prompt 50').and_return('short summary')
|
|
161
|
+
|
|
162
|
+
result = described_class.new.execute(tool_call, chat:)
|
|
163
|
+
json = json_object(result)
|
|
164
|
+
expect(json.content).to eq('short summary')
|
|
165
|
+
end
|
|
166
|
+
|
|
152
167
|
it 'handles an invalid policy' do
|
|
153
|
-
args = double(url:, document_policy: 'chaos_mode')
|
|
168
|
+
args = double(url:, document_policy: 'chaos_mode', words: nil)
|
|
154
169
|
tool_call = double(function: double(arguments: args))
|
|
155
170
|
|
|
156
171
|
result = described_class.new.execute(tool_call, chat:)
|
|
@@ -167,7 +182,7 @@ describe OllamaChat::Tools::GetURL do
|
|
|
167
182
|
expect(chat).to receive(:fetch_source).and_yield(source_io)
|
|
168
183
|
expect(chat).to receive(:add_image).with(chat.images, source_io, URI.parse(url))
|
|
169
184
|
|
|
170
|
-
args = double(url:, document_policy: 'ignoring')
|
|
185
|
+
args = double(url:, document_policy: 'ignoring', words: nil)
|
|
171
186
|
tool_call = double(function: double(arguments: args))
|
|
172
187
|
|
|
173
188
|
result = described_class.new.execute(tool_call, chat:)
|
|
@@ -179,7 +194,7 @@ describe OllamaChat::Tools::GetURL do
|
|
|
179
194
|
source_io = double('SourceIO', content_type: double(media_type: 'video'))
|
|
180
195
|
expect(chat).to receive(:fetch_source).and_yield(source_io)
|
|
181
196
|
|
|
182
|
-
args = double(url:, document_policy: 'ignoring')
|
|
197
|
+
args = double(url:, document_policy: 'ignoring', words: nil)
|
|
183
198
|
tool_call = double(function: double(arguments: args))
|
|
184
199
|
|
|
185
200
|
result = described_class.new.execute(tool_call, chat:)
|