ollama_chat 0.0.69 → 0.0.70
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 +36 -0
- data/Rakefile +1 -1
- data/lib/ollama_chat/chat.rb +7 -4
- data/lib/ollama_chat/config_handling.rb +6 -5
- data/lib/ollama_chat/env_config.rb +125 -127
- data/lib/ollama_chat/history.rb +1 -1
- data/lib/ollama_chat/input_content.rb +2 -2
- data/lib/ollama_chat/kramdown_ansi.rb +1 -1
- data/lib/ollama_chat/message_editing.rb +2 -2
- data/lib/ollama_chat/message_list.rb +2 -2
- data/lib/ollama_chat/ollama_chat_config/default_config.yml +11 -6
- data/lib/ollama_chat/ollama_chat_config.rb +3 -3
- data/lib/ollama_chat/tools/browse.rb +1 -1
- data/lib/ollama_chat/tools/generate_password.rb +215 -0
- data/lib/ollama_chat/tools/get_cve.rb +1 -1
- data/lib/ollama_chat/tools/get_endoflife.rb +1 -1
- data/lib/ollama_chat/tools/get_jira_issue.rb +2 -2
- data/lib/ollama_chat/tools/get_rfc.rb +69 -0
- data/lib/ollama_chat/tools/get_time.rb +33 -16
- data/lib/ollama_chat/tools/read_file.rb +28 -0
- data/lib/ollama_chat/tools/run_tests.rb +1 -1
- data/lib/ollama_chat/tools.rb +2 -0
- data/lib/ollama_chat/version.rb +1 -1
- data/ollama_chat.gemspec +6 -6
- data/spec/ollama_chat/information_spec.rb +1 -1
- data/spec/ollama_chat/input_content_spec.rb +3 -3
- data/spec/ollama_chat/kramdown_ansi_spec.rb +2 -2
- data/spec/ollama_chat/message_editing_spec.rb +3 -3
- data/spec/ollama_chat/tools/browse_spec.rb +1 -1
- data/spec/ollama_chat/tools/generate_password_spec.rb +135 -0
- data/spec/ollama_chat/tools/get_jira_issue_spec.rb +3 -3
- data/spec/ollama_chat/tools/get_rfc_spec.rb +73 -0
- data/spec/ollama_chat/tools/run_tests_spec.rb +2 -2
- metadata +11 -5
- data/lib/ollama_chat/tools/endoflife.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 54c023c5c8eca7b676ab5a3803f657c941e7bf2416d77fda8a54ac3ec8e3a995
|
|
4
|
+
data.tar.gz: ee70e5b6cf6e279e919e3a06377c016a4c5fa83ea09b5fb68ade1839538514ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d38bf14e210c51df07476ea648ef2ae430f0ad9620267940ce7c5f7ecb0ad2451a700bb6ac0d1043c82331bc5c91f4b1a8cc5ad7030f1b0a07e06b6d9e14781e
|
|
7
|
+
data.tar.gz: 7df74bd1ce54a2ebc94243f83516cae117ff03ed6d9e721aaff2b0ee050d8c61e7128a7f519f2af3fe404b3a4dd49b8d5c7a9c0ad018fdd6f65454d46e6481e7
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-02-23 v0.0.70
|
|
4
|
+
|
|
5
|
+
- Added `generate_password` tool with secure password generation, supporting
|
|
6
|
+
multiple alphabet types.
|
|
7
|
+
- Updated `tins` gem dependency to **1.52**.
|
|
8
|
+
- Added comprehensive tests for `generate_password` with various parameters.
|
|
9
|
+
- Registered `generate_password` tool in the gemspec and configured it in
|
|
10
|
+
`default_config.yml`.
|
|
11
|
+
- Added `get_rfc` tool for fetching RFC documents, including URL template
|
|
12
|
+
configuration in `default_config.yml`.
|
|
13
|
+
- Implemented `OllamaChat::Tools::GetRFC` class and required it in `tools.rb`.
|
|
14
|
+
- Added comprehensive test suite for `get_rfc` in `get_rfc_spec.rb`.
|
|
15
|
+
- Implemented backup fallback for conversation loading: `chat.rb` now loads
|
|
16
|
+
from `OC::XDG_CACHE_HOME.join('backup.json')` when `-c` is not provided, and
|
|
17
|
+
deletes the backup after successful load.
|
|
18
|
+
- Updated `config_handling.rb` to save backups to
|
|
19
|
+
`OC::XDG_CACHE_HOME.join('backup.json')` instead of the current directory.
|
|
20
|
+
- Modified `message_list.rb` to print file‑existence errors using
|
|
21
|
+
`filename.to_s.inspect` and to safely remove the backup file with
|
|
22
|
+
`FileUtils.rm_f`.
|
|
23
|
+
- Renamed `OllamaChat::EnvConfig` to `OC` module alias, updating all references
|
|
24
|
+
accordingly.
|
|
25
|
+
- Added new constants: `OC::OLLAMA::SEARXNG_URL`, `OC::OLLAMA::REDIS_URL`,
|
|
26
|
+
`OC::OLLAMA::REDIS_EXPIRING_URL`.
|
|
27
|
+
- Updated nested module paths, e.g., `OC::OLLAMA::CHAT::TOOLS::JIRA` and
|
|
28
|
+
`OC::OLLAMA::CHAT::TOOLS::RUN_TESTS_TEST_RUNNER`.
|
|
29
|
+
- Refactored code to use nested class structure within the module and added
|
|
30
|
+
comprehensive YARD documentation with `@param`, `@return`, and `@example`
|
|
31
|
+
tags.
|
|
32
|
+
- Added module‑level documentation explaining tool purpose.
|
|
33
|
+
- Added YARD documentation to `read_file.rb`, including module docstring,
|
|
34
|
+
return type `[Ollama::Tool]`, and execute method parameter/return
|
|
35
|
+
documentation.
|
|
36
|
+
- Removed empty `lib/ollama_chat/tools/endoflife.rb`; the functionality is now
|
|
37
|
+
provided by the `get_endoflife` tool.
|
|
38
|
+
|
|
3
39
|
## 2026-02-23 v0.0.69
|
|
4
40
|
|
|
5
41
|
- Reorganized access modifiers in `module OllamaChat::Dialog`, moving `ask?` to
|
data/Rakefile
CHANGED
|
@@ -51,7 +51,7 @@ GemHadar do
|
|
|
51
51
|
dependency 'reverse_markdown', '~> 3.0'
|
|
52
52
|
dependency 'kramdown-ansi', '~> 0.3'
|
|
53
53
|
dependency 'complex_config', '~> 0.22', '>= 0.22.2'
|
|
54
|
-
dependency 'tins', '~> 1.
|
|
54
|
+
dependency 'tins', '~> 1.52'
|
|
55
55
|
dependency 'search_ui', '~> 0.0'
|
|
56
56
|
dependency 'amatch', '~> 0.4'
|
|
57
57
|
dependency 'pdf-reader', '~> 2.0'
|
data/lib/ollama_chat/chat.rb
CHANGED
|
@@ -97,8 +97,11 @@ class OllamaChat::Chat
|
|
|
97
97
|
@model = choose_model(@opts[?m], config.model.name)
|
|
98
98
|
@model_options = Ollama::Options[config.model.options]
|
|
99
99
|
@model_system = pull_model_unless_present(@model, @model_options)
|
|
100
|
-
if @opts[?c]
|
|
101
|
-
messages.load_conversation(
|
|
100
|
+
if conversation_file = @opts[?c]
|
|
101
|
+
messages.load_conversation(conversation_file)
|
|
102
|
+
elsif backup_file = OC::XDG_CACHE_HOME + 'backup.json' and backup_file.exist?
|
|
103
|
+
messages.load_conversation(backup_file)
|
|
104
|
+
FileUtils.rm_f backup_file
|
|
102
105
|
else
|
|
103
106
|
setup_system_prompt
|
|
104
107
|
end
|
|
@@ -188,7 +191,7 @@ class OllamaChat::Chat
|
|
|
188
191
|
#
|
|
189
192
|
# @return [TrueClass, FalseClass] the current debug mode status
|
|
190
193
|
def debug
|
|
191
|
-
|
|
194
|
+
OC::OLLAMA::CHAT::DEBUG
|
|
192
195
|
end
|
|
193
196
|
|
|
194
197
|
private
|
|
@@ -692,7 +695,7 @@ class OllamaChat::Chat
|
|
|
692
695
|
#
|
|
693
696
|
# @return [String] the base URL used for connecting to the Ollama API
|
|
694
697
|
def base_url
|
|
695
|
-
@opts[?u] ||
|
|
698
|
+
@opts[?u] || OC::OLLAMA::URL
|
|
696
699
|
end
|
|
697
700
|
|
|
698
701
|
# The connect_ollama method establishes a connection to the Ollama API server.
|
|
@@ -34,7 +34,7 @@ module OllamaChat::ConfigHandling
|
|
|
34
34
|
# variables and available system commands, then uses Kramdown::ANSI::Pager to
|
|
35
35
|
# show the formatted configuration output.
|
|
36
36
|
def display_config
|
|
37
|
-
command =
|
|
37
|
+
command = OC::PAGER?
|
|
38
38
|
rendered = config.to_s
|
|
39
39
|
Kramdown::ANSI::Pager.pager(
|
|
40
40
|
lines: rendered.count(?\n),
|
|
@@ -52,10 +52,10 @@ module OllamaChat::ConfigHandling
|
|
|
52
52
|
# @param exception [Exception] the exception that occurred while reading
|
|
53
53
|
# the config file
|
|
54
54
|
def fix_config(exception)
|
|
55
|
-
save_conversation('backup.json')
|
|
55
|
+
save_conversation(OC::XDG_CACHE_HOME + 'backup.json')
|
|
56
56
|
STDOUT.puts "When reading the config file, a #{exception.class} "\
|
|
57
57
|
"exception was caught: #{exception.message.inspect}"
|
|
58
|
-
unless diff_tool =
|
|
58
|
+
unless diff_tool = OC::DIFF_TOOL?
|
|
59
59
|
exit 1
|
|
60
60
|
end
|
|
61
61
|
if ask?(prompt: 'Do you want to fix the config? (y/n) ') =~ /\Ay/i
|
|
@@ -73,7 +73,7 @@ module OllamaChat::ConfigHandling
|
|
|
73
73
|
# Edit the current configuration file in the editor defined by the
|
|
74
74
|
# environment variable `EDITOR`.
|
|
75
75
|
#
|
|
76
|
-
# 1. Looks up the editor command via `
|
|
76
|
+
# 1. Looks up the editor command via `OC::EDITOR`.
|
|
77
77
|
# If the value is `nil` or empty, it prints an error message to
|
|
78
78
|
# STDERR and returns immediately.
|
|
79
79
|
# 2. Invokes the editor with the path to the active configuration
|
|
@@ -83,13 +83,14 @@ module OllamaChat::ConfigHandling
|
|
|
83
83
|
# 3. If editing was successful, prompts the user to restart
|
|
84
84
|
# `ollama_chat` if desired.
|
|
85
85
|
def edit_config
|
|
86
|
-
unless editor =
|
|
86
|
+
unless editor = OC::EDITOR?
|
|
87
87
|
STDERR.puts "Need the environment variable var EDITOR defined to use an editor"
|
|
88
88
|
return
|
|
89
89
|
end
|
|
90
90
|
result = system Shellwords.join([ editor, @ollama_chat_config.filename ])
|
|
91
91
|
if result
|
|
92
92
|
if ask?(prompt: "Do you want to restart #{progname}? (y/n) ") =~ /\Ay/i
|
|
93
|
+
save_conversation(OC::XDG_CACHE_HOME + 'backup.json')
|
|
93
94
|
exec($0, *ARGV)
|
|
94
95
|
end
|
|
95
96
|
else
|
|
@@ -1,171 +1,169 @@
|
|
|
1
1
|
require 'const_conf'
|
|
2
2
|
require 'pathname'
|
|
3
3
|
|
|
4
|
-
module OllamaChat
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
end
|
|
4
|
+
# Environment configuration module for OllamaChat
|
|
5
|
+
#
|
|
6
|
+
# This module provides a structured way to manage environment variables and
|
|
7
|
+
# configuration settings for the OllamaChat application. It uses the
|
|
8
|
+
# ConstConf library to define and manage configuration parameters with
|
|
9
|
+
# default values, descriptions, and decoding logic.
|
|
10
|
+
#
|
|
11
|
+
# The module organizes configuration into logical sections including general
|
|
12
|
+
# settings, Ollama-specific configurations, and chat-specific options.
|
|
13
|
+
module OC
|
|
14
|
+
include ConstConf
|
|
15
|
+
|
|
16
|
+
description 'Environment config for OllamaChat'
|
|
17
|
+
prefix ''
|
|
18
|
+
|
|
19
|
+
XDG_CONFIG_HOME = set do
|
|
20
|
+
description 'XDG Configuration directory path'
|
|
21
|
+
default { '~/.config' }
|
|
22
|
+
decode { Pathname.new(_1).join('ollama_chat').expand_path }
|
|
23
|
+
end
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
XDG_CACHE_HOME = set do
|
|
26
|
+
description 'XDG Cache directory path'
|
|
27
|
+
default { '~/.cache' }
|
|
28
|
+
decode { Pathname.new(_1).join('ollama_chat').expand_path }
|
|
29
|
+
end
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
PAGER = set do
|
|
32
|
+
description 'Pager command to use in case terminal lines are exceeded by output'
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
end
|
|
34
|
+
default do
|
|
35
|
+
if fallback_pager = `which less`.full?(:chomp) || `which more`.full?(:chomp)
|
|
36
|
+
fallback_pager << ' -r'
|
|
39
37
|
end
|
|
40
38
|
end
|
|
39
|
+
end
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
EDITOR = set do
|
|
42
|
+
description 'Editor to use'
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
end
|
|
44
|
+
default do
|
|
45
|
+
if editor = %w[ vim vi ].find { `which #{_1}`.full?(:chomp) }
|
|
46
|
+
editor
|
|
47
|
+
else
|
|
48
|
+
warn 'Need an editor command configured via env var "EDITOR"'
|
|
51
49
|
end
|
|
52
50
|
end
|
|
51
|
+
end
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
BROWSER = set do
|
|
54
|
+
description 'Browser to use'
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
end
|
|
56
|
+
default do
|
|
57
|
+
%w[ open xdg-open ].find { `which #{_1}` }.full?(:chomp)
|
|
60
58
|
end
|
|
59
|
+
end
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
DIFF_TOOL = set do
|
|
62
|
+
description 'Diff tool to apply changes with'
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
end
|
|
64
|
+
default do
|
|
65
|
+
if diff = `which vimdiff`.full?(:chomp)
|
|
66
|
+
diff
|
|
67
|
+
else
|
|
68
|
+
warn 'Need a diff tool configured via env var "DIFF_TOOL"'
|
|
71
69
|
end
|
|
72
70
|
end
|
|
71
|
+
end
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
KRAMDOWN_ANSI_OLLAMA_CHAT_STYLES = set do
|
|
74
|
+
description 'Styles to use for kramdown-ansi markdown'
|
|
76
75
|
|
|
77
|
-
|
|
76
|
+
default ENV['KRAMDOWN_ANSI_STYLES'].full?
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
module OLLAMA
|
|
80
|
+
description 'Ollama Configuration'
|
|
81
|
+
prefix 'OLLAMA'
|
|
82
|
+
|
|
83
|
+
HOST = set do
|
|
84
|
+
description 'Ollama "host" to connect to'
|
|
85
|
+
default 'localhost:11434'
|
|
78
86
|
end
|
|
79
87
|
|
|
80
|
-
|
|
81
|
-
description 'Ollama
|
|
82
|
-
|
|
88
|
+
URL = set do
|
|
89
|
+
description 'Ollama base URL to connect to'
|
|
90
|
+
default { 'http://%s' % OC::OLLAMA::HOST }
|
|
91
|
+
sensitive true
|
|
92
|
+
end
|
|
83
93
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
94
|
+
SEARXNG_URL = set do
|
|
95
|
+
description 'URL for the SearXNG service for searches'
|
|
96
|
+
default 'http://localhost:8088/search?q=%{query}&language=en&format=json'
|
|
97
|
+
sensitive true
|
|
98
|
+
end
|
|
88
99
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
REDIS_URL = set do
|
|
101
|
+
description 'Redis URL for documents'
|
|
102
|
+
default { ENV['REDIS_URL'].full? }
|
|
103
|
+
sensitive true
|
|
104
|
+
end
|
|
94
105
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
REDIS_EXPIRING_URL = set do
|
|
107
|
+
description 'Redis URL for caching'
|
|
108
|
+
default { OC::OLLAMA::REDIS_URL? || ENV['REDIS_URL'].full? }
|
|
109
|
+
sensitive true
|
|
110
|
+
end
|
|
100
111
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
module CHAT
|
|
113
|
+
description 'OllamaChat Configuration'
|
|
114
|
+
|
|
115
|
+
DEBUG = set do
|
|
116
|
+
description 'Enable debugging for chat client'
|
|
117
|
+
decode { _1.to_i == 1 }
|
|
118
|
+
default 0
|
|
105
119
|
end
|
|
106
120
|
|
|
107
|
-
|
|
108
|
-
description '
|
|
109
|
-
default
|
|
110
|
-
sensitive true
|
|
121
|
+
MODEL = set do
|
|
122
|
+
description 'Default model to use for the chat'
|
|
123
|
+
default 'llama3.1'
|
|
111
124
|
end
|
|
112
125
|
|
|
113
|
-
|
|
114
|
-
description '
|
|
126
|
+
SYSTEM = set do
|
|
127
|
+
description 'Default system prompt'
|
|
128
|
+
end
|
|
115
129
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
default 0
|
|
120
|
-
end
|
|
130
|
+
COLLECTION = set do
|
|
131
|
+
description 'Default collection for embeddings'
|
|
132
|
+
end
|
|
121
133
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
134
|
+
HISTORY = set do
|
|
135
|
+
description 'File to save the chat history in'
|
|
136
|
+
default XDG_CACHE_HOME + 'history.json'
|
|
137
|
+
end
|
|
126
138
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
end
|
|
139
|
+
module TOOLS
|
|
140
|
+
description 'Tool specific configuration settings'
|
|
130
141
|
|
|
131
|
-
|
|
132
|
-
|
|
142
|
+
# Run Tests tool configuration
|
|
143
|
+
RUN_TESTS_TEST_RUNNER = set do
|
|
144
|
+
description 'Configured test runner for run_tests tool function'
|
|
145
|
+
default 'rspec'
|
|
146
|
+
required true
|
|
133
147
|
end
|
|
134
148
|
|
|
135
|
-
|
|
136
|
-
description '
|
|
137
|
-
default XDG_CACHE_HOME + 'history.json'
|
|
138
|
-
end
|
|
149
|
+
module JIRA
|
|
150
|
+
description 'Jira tool configuration'
|
|
139
151
|
|
|
140
|
-
|
|
141
|
-
|
|
152
|
+
URL = set do
|
|
153
|
+
description 'Base URL for Jira instance'
|
|
154
|
+
sensitive true
|
|
155
|
+
end
|
|
142
156
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
required true
|
|
157
|
+
USER = set do
|
|
158
|
+
description 'Username for Jira authentication'
|
|
159
|
+
sensitive true
|
|
160
|
+
required { OC::OLLAMA::CHAT::TOOLS::JIRA::URL? }
|
|
148
161
|
end
|
|
149
162
|
|
|
150
|
-
|
|
151
|
-
description 'Jira
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
description 'Base URL for Jira instance'
|
|
155
|
-
sensitive true
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
USER = set do
|
|
159
|
-
description 'Username for Jira authentication'
|
|
160
|
-
sensitive true
|
|
161
|
-
required { OllamaChat::EnvConfig::OLLAMA::CHAT::TOOLS::JIRA::URL? }
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
API_TOKEN = set do
|
|
165
|
-
description 'API token for Jira authentication'
|
|
166
|
-
sensitive true
|
|
167
|
-
required { OllamaChat::EnvConfig::OLLAMA::CHAT::TOOLS::JIRA::URL? }
|
|
168
|
-
end
|
|
163
|
+
API_TOKEN = set do
|
|
164
|
+
description 'API token for Jira authentication'
|
|
165
|
+
sensitive true
|
|
166
|
+
required { OC::OLLAMA::CHAT::TOOLS::JIRA::URL? }
|
|
169
167
|
end
|
|
170
168
|
end
|
|
171
169
|
end
|
data/lib/ollama_chat/history.rb
CHANGED
|
@@ -28,7 +28,7 @@ module OllamaChat::History
|
|
|
28
28
|
# @return [String] the absolute file path to the chat history file as
|
|
29
29
|
# specified in the configuration
|
|
30
30
|
def chat_history_filename
|
|
31
|
-
File.expand_path(
|
|
31
|
+
File.expand_path(OC::OLLAMA::CHAT::HISTORY)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
# The init_chat_history method initializes the chat session by loading
|
|
@@ -110,9 +110,9 @@ module OllamaChat::InputContent
|
|
|
110
110
|
#
|
|
111
111
|
# @return [ String, nil ] the composed content if successful, nil otherwise
|
|
112
112
|
def compose
|
|
113
|
-
unless editor =
|
|
113
|
+
unless editor = OC::EDITOR?
|
|
114
114
|
STDERR.puts "Editor required for compose, set env var "\
|
|
115
|
-
"#{
|
|
115
|
+
"#{OC::EDITOR!.env_var.inspect}."
|
|
116
116
|
return
|
|
117
117
|
end
|
|
118
118
|
Tempfile.open do |tmp|
|
|
@@ -18,7 +18,7 @@ module OllamaChat::KramdownANSI
|
|
|
18
18
|
# @return [ Hash ] a hash of ANSI styles configured either from environment
|
|
19
19
|
# variables or using default settings
|
|
20
20
|
def configure_kramdown_ansi_styles
|
|
21
|
-
if json =
|
|
21
|
+
if json = OC::KRAMDOWN_ANSI_OLLAMA_CHAT_STYLES?
|
|
22
22
|
Kramdown::ANSI::Styles.from_json(json).ansi_styles
|
|
23
23
|
else
|
|
24
24
|
Kramdown::ANSI::Styles.new.ansi_styles
|
|
@@ -18,9 +18,9 @@ module OllamaChat::MessageEditing
|
|
|
18
18
|
# @return [String, nil] the edited content if successful, nil otherwise
|
|
19
19
|
def revise_last
|
|
20
20
|
if message = @messages.last
|
|
21
|
-
unless editor =
|
|
21
|
+
unless editor = OC::EDITOR?
|
|
22
22
|
STDERR.puts "Editor required for revise, set env var " \
|
|
23
|
-
"#{
|
|
23
|
+
"#{OC::EDITOR!.env_var.inspect}."
|
|
24
24
|
return
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -108,7 +108,7 @@ class OllamaChat::MessageList
|
|
|
108
108
|
# @return [ OllamaChat::MessageList ] self
|
|
109
109
|
def load_conversation(filename)
|
|
110
110
|
unless File.exist?(filename)
|
|
111
|
-
STDERR.puts "File #{filename.inspect} doesn't exist. Choose another filename."
|
|
111
|
+
STDERR.puts "File #{filename.to_s.inspect} doesn't exist. Choose another filename."
|
|
112
112
|
return
|
|
113
113
|
end
|
|
114
114
|
@messages =
|
|
@@ -320,7 +320,7 @@ class OllamaChat::MessageList
|
|
|
320
320
|
# '-r' flag for proper handling of raw control characters when a fallback
|
|
321
321
|
# pager is used.
|
|
322
322
|
def determine_pager_command
|
|
323
|
-
|
|
323
|
+
OC::PAGER?
|
|
324
324
|
end
|
|
325
325
|
|
|
326
326
|
# The message_text_for method generates formatted text representation of a
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
proxy: null # http://localhost:8080
|
|
3
3
|
model:
|
|
4
|
-
name: <%=
|
|
4
|
+
name: <%= OC::OLLAMA::CHAT::MODEL %>
|
|
5
5
|
options:
|
|
6
6
|
num_ctx: 8192
|
|
7
7
|
timeouts:
|
|
@@ -32,7 +32,7 @@ prompts:
|
|
|
32
32
|
%{results}
|
|
33
33
|
location: You are at %{location_name}, %{location_decimal_degrees}, preferring %{units}
|
|
34
34
|
system_prompts:
|
|
35
|
-
default: <%=
|
|
35
|
+
default: <%= OC::OLLAMA::CHAT::SYSTEM || 'null' %>
|
|
36
36
|
assistant: You are a helpful assistant.
|
|
37
37
|
voice:
|
|
38
38
|
enabled: false
|
|
@@ -57,7 +57,7 @@ embedding:
|
|
|
57
57
|
prompt: 'Represent this sentence for searching relevant passages: %s'
|
|
58
58
|
batch_size: 10
|
|
59
59
|
database_filename: null # ':memory:'
|
|
60
|
-
collection: <%=
|
|
60
|
+
collection: <%= OC::OLLAMA::CHAT::COLLECTION %>
|
|
61
61
|
found_texts_size: 4096
|
|
62
62
|
found_texts_count: 10
|
|
63
63
|
splitter:
|
|
@@ -66,9 +66,9 @@ embedding:
|
|
|
66
66
|
cache: Documentrix::Documents::SQLiteCache
|
|
67
67
|
redis:
|
|
68
68
|
documents:
|
|
69
|
-
url: <%=
|
|
69
|
+
url: <%= OC::OLLAMA::REDIS_URL %>
|
|
70
70
|
expiring:
|
|
71
|
-
url: <%=
|
|
71
|
+
url: <%= OC::OLLAMA::REDIS_EXPIRING_URL %>
|
|
72
72
|
ex: 86400
|
|
73
73
|
working_dir_dependent_socket: true
|
|
74
74
|
request_headers:
|
|
@@ -81,7 +81,7 @@ web_search:
|
|
|
81
81
|
duckduckgo:
|
|
82
82
|
url: 'https://www.duckduckgo.com/html/?q=%{query}'
|
|
83
83
|
searxng:
|
|
84
|
-
url: <%=
|
|
84
|
+
url: <%= OC::OLLAMA::SEARXNG_URL %>
|
|
85
85
|
vim:
|
|
86
86
|
clientserver: socket
|
|
87
87
|
tools:
|
|
@@ -147,3 +147,8 @@ tools:
|
|
|
147
147
|
default: true
|
|
148
148
|
get_jira_issue:
|
|
149
149
|
default: false
|
|
150
|
+
get_rfc:
|
|
151
|
+
url: "https://www.rfc-editor.org/rfc/rfc%{rfc_id}.txt"
|
|
152
|
+
default: true
|
|
153
|
+
generate_password:
|
|
154
|
+
default: true
|
|
@@ -87,7 +87,7 @@ class OllamaChat::OllamaChatConfig
|
|
|
87
87
|
# @return [ Pathname ] the pathname object representing the configuration
|
|
88
88
|
# directory
|
|
89
89
|
def config_dir_path
|
|
90
|
-
|
|
90
|
+
OC::XDG_CONFIG_HOME
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
# The cache_dir_path method returns the path to the ollama_chat cache
|
|
@@ -95,7 +95,7 @@ class OllamaChat::OllamaChatConfig
|
|
|
95
95
|
#
|
|
96
96
|
# @return [ Pathname ] the pathname object representing the cache directory path
|
|
97
97
|
def cache_dir_path
|
|
98
|
-
|
|
98
|
+
OC::XDG_CACHE_HOME
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
# The database_path method constructs the full path to the documents database
|
|
@@ -112,6 +112,6 @@ class OllamaChat::OllamaChatConfig
|
|
|
112
112
|
#
|
|
113
113
|
# @return [ String ] the command name of the diff tool to be used
|
|
114
114
|
def diff_tool
|
|
115
|
-
|
|
115
|
+
OC::DIFF_TOOL?
|
|
116
116
|
end
|
|
117
117
|
end
|
|
@@ -77,7 +77,7 @@ class OllamaChat::Tools::Browse
|
|
|
77
77
|
# @param url [String] the URL or file path to open
|
|
78
78
|
# @return [Process::Status] the process status of the system call
|
|
79
79
|
def browse_url(url)
|
|
80
|
-
browser =
|
|
80
|
+
browser = OC::BROWSER? || "open"
|
|
81
81
|
system %{#{browser} #{Shellwords.escape(url)}}
|
|
82
82
|
$?
|
|
83
83
|
end
|