htm 0.0.17 → 0.0.18
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/.architecture/decisions/adrs/001-use-postgresql-timescaledb-storage.md +1 -1
- data/.architecture/decisions/adrs/011-database-side-embedding-generation-with-pgai.md +4 -4
- data/.architecture/decisions/adrs/012-llm-driven-ontology-topic-extraction.md +1 -1
- data/.envrc +12 -25
- data/.irbrc +7 -7
- data/.tbls.yml +2 -2
- data/CHANGELOG.md +71 -0
- data/README.md +1 -1
- data/Rakefile +8 -3
- data/SETUP.md +12 -12
- data/bin/htm_mcp +0 -4
- data/db/seed_data/README.md +2 -2
- data/db/seeds.rb +2 -2
- data/docs/api/database.md +37 -37
- data/docs/api/htm.md +1 -1
- data/docs/api/yard/HTM/ActiveRecordConfig.md +2 -2
- data/docs/api/yard/HTM/Configuration.md +26 -15
- data/docs/api/yard/HTM/Database.md +7 -8
- data/docs/api/yard/HTM/JobAdapter.md +1 -1
- data/docs/api/yard/HTM/Railtie.md +2 -2
- data/docs/architecture/adrs/001-postgresql-timescaledb.md +1 -1
- data/docs/architecture/adrs/011-pgai-integration.md +4 -4
- data/docs/database_rake_tasks.md +5 -5
- data/docs/development/rake-tasks.md +11 -11
- data/docs/development/setup.md +21 -21
- data/docs/development/testing.md +1 -1
- data/docs/getting-started/installation.md +20 -20
- data/docs/getting-started/quick-start.md +12 -12
- data/docs/guides/getting-started.md +2 -2
- data/docs/guides/long-term-memory.md +1 -1
- data/docs/guides/mcp-server.md +17 -17
- data/docs/guides/robot-groups.md +8 -8
- data/docs/index.md +4 -4
- data/docs/multi_framework_support.md +8 -8
- data/docs/setup_local_database.md +19 -19
- data/docs/using_rake_tasks_in_your_app.md +14 -14
- data/examples/README.md +50 -6
- data/examples/basic_usage.rb +31 -21
- data/examples/cli_app/README.md +8 -8
- data/examples/cli_app/htm_cli.rb +5 -5
- data/examples/config_file_example/README.md +256 -0
- data/examples/config_file_example/config/htm.local.yml +34 -0
- data/examples/config_file_example/custom_config.yml +22 -0
- data/examples/config_file_example/show_config.rb +125 -0
- data/examples/custom_llm_configuration.rb +7 -7
- data/examples/example_app/Rakefile +2 -2
- data/examples/example_app/app.rb +8 -8
- data/examples/file_loader_usage.rb +9 -9
- data/examples/mcp_client.rb +5 -5
- data/examples/rails_app/Gemfile.lock +48 -56
- data/examples/rails_app/README.md +1 -1
- data/examples/robot_groups/multi_process.rb +5 -5
- data/examples/robot_groups/robot_worker.rb +5 -5
- data/examples/robot_groups/same_process.rb +9 -9
- data/examples/sinatra_app/app.rb +1 -1
- data/examples/timeframe_demo.rb +1 -1
- data/lib/htm/active_record_config.rb +12 -25
- data/lib/htm/circuit_breaker.rb +0 -2
- data/lib/htm/config/defaults.yml +246 -0
- data/lib/htm/config.rb +888 -0
- data/lib/htm/database.rb +23 -27
- data/lib/htm/embedding_service.rb +0 -4
- data/lib/htm/integrations/sinatra.rb +3 -7
- data/lib/htm/job_adapter.rb +1 -15
- data/lib/htm/jobs/generate_embedding_job.rb +1 -7
- data/lib/htm/jobs/generate_propositions_job.rb +2 -12
- data/lib/htm/jobs/generate_tags_job.rb +1 -8
- data/lib/htm/loaders/defaults_loader.rb +143 -0
- data/lib/htm/loaders/xdg_config_loader.rb +116 -0
- data/lib/htm/mcp/cli.rb +200 -58
- data/lib/htm/mcp/server.rb +3 -3
- data/lib/htm/proposition_service.rb +2 -12
- data/lib/htm/railtie.rb +3 -4
- data/lib/htm/tag_service.rb +1 -8
- data/lib/htm/version.rb +1 -1
- data/lib/htm.rb +124 -5
- metadata +24 -4
- data/config/database.yml +0 -77
- data/lib/htm/configuration.rb +0 -799
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# HTM Configuration Example
|
|
2
|
+
|
|
3
|
+
This example demonstrates how HTM uses the `anyway_config` gem for flexible, layered configuration management.
|
|
4
|
+
|
|
5
|
+
## Configuration Sources (Priority Order)
|
|
6
|
+
|
|
7
|
+
HTM loads configuration from multiple sources, merged in order from lowest to highest priority:
|
|
8
|
+
|
|
9
|
+
| Priority | Source | Location | Description |
|
|
10
|
+
|----------|--------|----------|-------------|
|
|
11
|
+
| 1 | Bundled Defaults | `lib/htm/config/defaults.yml` | Ships with the gem, defines schema |
|
|
12
|
+
| 2 | XDG User Config | `~/.config/htm/htm.yml` | User-wide settings |
|
|
13
|
+
| 3 | Project Config | `./config/htm.yml` | Project-specific settings |
|
|
14
|
+
| 4 | Local Overrides | `./config/htm.local.yml` | Local dev settings (gitignored) |
|
|
15
|
+
| 5 | HTM_CONF File | Path in `HTM_CONF` env var | Custom config file path |
|
|
16
|
+
| 6 | Environment Variables | `HTM_*` | Runtime overrides |
|
|
17
|
+
| 7 | Code Block | `HTM.configure { }` | Programmatic configuration |
|
|
18
|
+
|
|
19
|
+
Higher priority sources override values from lower priority sources.
|
|
20
|
+
|
|
21
|
+
## Generating a Config File
|
|
22
|
+
|
|
23
|
+
> **Tip:** Use the `htm_mcp config` command to output the complete default configuration to STDOUT. Redirect it to any location with any filename:
|
|
24
|
+
>
|
|
25
|
+
> ```bash
|
|
26
|
+
> # Create a project config file
|
|
27
|
+
> htm_mcp config > ./config/htm.yml
|
|
28
|
+
>
|
|
29
|
+
> # Create a local overrides file
|
|
30
|
+
> htm_mcp config > ./config/htm.local.yml
|
|
31
|
+
>
|
|
32
|
+
> # Create a user-wide XDG config
|
|
33
|
+
> mkdir -p ~/.config/htm
|
|
34
|
+
> htm_mcp config > ~/.config/htm/htm.yml
|
|
35
|
+
>
|
|
36
|
+
> # Create a custom config for HTM_CONF
|
|
37
|
+
> htm_mcp config > /path/to/my_custom_config.yml
|
|
38
|
+
> ```
|
|
39
|
+
>
|
|
40
|
+
> This gives you a complete, documented template with all available settings that you can customize for your needs.
|
|
41
|
+
|
|
42
|
+
## Standard Config File Locations
|
|
43
|
+
|
|
44
|
+
### 1. Bundled Defaults (`lib/htm/config/defaults.yml`)
|
|
45
|
+
|
|
46
|
+
The gem ships with a defaults file that defines the complete configuration schema and sensible defaults. This is always loaded first.
|
|
47
|
+
|
|
48
|
+
### 2. XDG User Config (`~/.config/htm/htm.yml`)
|
|
49
|
+
|
|
50
|
+
User-wide configuration following the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html). On macOS, also checks `~/Library/Application Support/htm/htm.yml`.
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
# ~/.config/htm/htm.yml
|
|
54
|
+
embedding:
|
|
55
|
+
provider: openai
|
|
56
|
+
model: text-embedding-3-small
|
|
57
|
+
|
|
58
|
+
providers:
|
|
59
|
+
openai:
|
|
60
|
+
api_key: sk-your-api-key
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 3. Project Config (`./config/htm.yml`)
|
|
64
|
+
|
|
65
|
+
Project-specific configuration. Supports environment-specific sections:
|
|
66
|
+
|
|
67
|
+
```yaml
|
|
68
|
+
# ./config/htm.yml
|
|
69
|
+
defaults:
|
|
70
|
+
database:
|
|
71
|
+
host: localhost
|
|
72
|
+
port: 5432
|
|
73
|
+
|
|
74
|
+
development:
|
|
75
|
+
database:
|
|
76
|
+
name: myapp_development
|
|
77
|
+
|
|
78
|
+
production:
|
|
79
|
+
database:
|
|
80
|
+
name: myapp_production
|
|
81
|
+
pool_size: 25
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 4. Local Overrides (`./config/htm.local.yml`)
|
|
85
|
+
|
|
86
|
+
Developer-specific overrides, typically added to `.gitignore`:
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
# ./config/htm.local.yml
|
|
90
|
+
database:
|
|
91
|
+
name: my_local_db
|
|
92
|
+
|
|
93
|
+
log_level: debug
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Using HTM_CONF for Custom Config Files
|
|
97
|
+
|
|
98
|
+
The `HTM_CONF` environment variable lets you specify any YAML file path:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Relative path
|
|
102
|
+
HTM_CONF=./custom_config.yml ruby show_config.rb
|
|
103
|
+
|
|
104
|
+
# Absolute path
|
|
105
|
+
HTM_CONF=/etc/htm/production.yml ruby show_config.rb
|
|
106
|
+
|
|
107
|
+
# Different config per environment
|
|
108
|
+
HTM_CONF=./config/staging.yml HTM_ENV=staging ruby show_config.rb
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
This is useful for:
|
|
112
|
+
- Testing different configurations
|
|
113
|
+
- CI/CD pipelines with config files in non-standard locations
|
|
114
|
+
- Docker deployments with mounted config files
|
|
115
|
+
|
|
116
|
+
## Environment Variables
|
|
117
|
+
|
|
118
|
+
Environment variables use double underscores (`__`) for nested values:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Database configuration
|
|
122
|
+
export HTM_DATABASE__URL="postgresql://user:pass@host:5432/dbname"
|
|
123
|
+
export HTM_DATABASE__POOL_SIZE=25
|
|
124
|
+
|
|
125
|
+
# Embedding configuration
|
|
126
|
+
export HTM_EMBEDDING__PROVIDER=openai
|
|
127
|
+
export HTM_EMBEDDING__MODEL=text-embedding-3-small
|
|
128
|
+
export HTM_EMBEDDING__DIMENSIONS=1536
|
|
129
|
+
|
|
130
|
+
# Provider credentials
|
|
131
|
+
export HTM_PROVIDERS__OPENAI__API_KEY=sk-your-key
|
|
132
|
+
export HTM_PROVIDERS__OLLAMA__URL=http://localhost:11434
|
|
133
|
+
|
|
134
|
+
# General settings
|
|
135
|
+
export HTM_LOG_LEVEL=debug
|
|
136
|
+
export HTM_TELEMETRY_ENABLED=true
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Code-Level Configuration
|
|
140
|
+
|
|
141
|
+
The highest priority configuration is done programmatically:
|
|
142
|
+
|
|
143
|
+
```ruby
|
|
144
|
+
require 'htm'
|
|
145
|
+
|
|
146
|
+
HTM.configure do |config|
|
|
147
|
+
# Database
|
|
148
|
+
config.database.host = 'localhost'
|
|
149
|
+
config.database.name = 'my_database'
|
|
150
|
+
|
|
151
|
+
# Embedding provider
|
|
152
|
+
config.embedding.provider = :openai
|
|
153
|
+
config.embedding.model = 'text-embedding-3-small'
|
|
154
|
+
config.embedding.dimensions = 1536
|
|
155
|
+
|
|
156
|
+
# Tag extraction
|
|
157
|
+
config.tag.provider = :anthropic
|
|
158
|
+
config.tag.model = 'claude-3-haiku-20240307'
|
|
159
|
+
|
|
160
|
+
# Provider credentials
|
|
161
|
+
config.providers.openai.api_key = ENV['OPENAI_API_KEY']
|
|
162
|
+
|
|
163
|
+
# General settings
|
|
164
|
+
config.log_level = :debug
|
|
165
|
+
config.telemetry_enabled = false
|
|
166
|
+
|
|
167
|
+
# Custom callables
|
|
168
|
+
config.logger = Logger.new($stdout)
|
|
169
|
+
end
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Environment Selection
|
|
173
|
+
|
|
174
|
+
HTM detects the environment using these variables (in order):
|
|
175
|
+
|
|
176
|
+
1. `HTM_ENV`
|
|
177
|
+
2. `RAILS_ENV`
|
|
178
|
+
3. `RACK_ENV`
|
|
179
|
+
4. Defaults to `development`
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
HTM_ENV=production ruby show_config.rb
|
|
183
|
+
HTM_ENV=test ruby show_config.rb
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Running the Example
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
cd examples/config_file_example
|
|
190
|
+
|
|
191
|
+
# Basic usage - loads ./config/htm.local.yml automatically
|
|
192
|
+
ruby show_config.rb
|
|
193
|
+
|
|
194
|
+
# Different environment
|
|
195
|
+
HTM_ENV=production ruby show_config.rb
|
|
196
|
+
|
|
197
|
+
# Override with environment variable
|
|
198
|
+
HTM_EMBEDDING__MODEL=mxbai-embed-large ruby show_config.rb
|
|
199
|
+
|
|
200
|
+
# Use custom config file
|
|
201
|
+
HTM_CONF=./custom_config.yml ruby show_config.rb
|
|
202
|
+
|
|
203
|
+
# Combine multiple overrides
|
|
204
|
+
HTM_CONF=./custom_config.yml HTM_ENV=test HTM_LOG_LEVEL=warn ruby show_config.rb
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Example Output
|
|
208
|
+
|
|
209
|
+
The `show_config.rb` script displays the loaded configuration with source tracing:
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
HTM Configuration Example
|
|
213
|
+
============================================================
|
|
214
|
+
|
|
215
|
+
Environment: development
|
|
216
|
+
|
|
217
|
+
Config sources checked:
|
|
218
|
+
- Bundled defaults: lib/htm/config/defaults.yml
|
|
219
|
+
- XDG config: ~/.config/htm/htm.yml
|
|
220
|
+
- Project config: ./config/htm.yml
|
|
221
|
+
- Local overrides: ./config/htm.local.yml
|
|
222
|
+
- HTM_CONF override: (not set)
|
|
223
|
+
- Environment variables: HTM_*
|
|
224
|
+
|
|
225
|
+
------------------------------------------------------------
|
|
226
|
+
Configuration with Sources:
|
|
227
|
+
------------------------------------------------------------
|
|
228
|
+
|
|
229
|
+
database:
|
|
230
|
+
host: "localhost" # from: htm.local.yml
|
|
231
|
+
port: 5432 # from: htm.local.yml
|
|
232
|
+
name: "htm_example" # from: htm.local.yml
|
|
233
|
+
pool_size: 10 # from: bundled_defaults
|
|
234
|
+
embedding:
|
|
235
|
+
provider: "ollama" # from: htm.local.yml
|
|
236
|
+
model: "nomic-embed-text:latest" # from: htm.local.yml
|
|
237
|
+
dimensions: 768 # from: bundled_defaults
|
|
238
|
+
...
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Files in This Example
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
config_file_example/
|
|
245
|
+
├── README.md # This file
|
|
246
|
+
├── show_config.rb # Demo script with source tracing
|
|
247
|
+
├── custom_config.yml # Example for HTM_CONF usage
|
|
248
|
+
└── config/
|
|
249
|
+
└── htm.local.yml # Auto-loaded local overrides
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## See Also
|
|
253
|
+
|
|
254
|
+
- [anyway_config documentation](https://github.com/palkan/anyway_config)
|
|
255
|
+
- [HTM Configuration Guide](../../docs/configuration.md)
|
|
256
|
+
- [HTM README](../../README.md)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# HTM Local Configuration Example
|
|
2
|
+
#
|
|
3
|
+
# This file demonstrates local configuration overrides.
|
|
4
|
+
# Place in ./config/htm.local.yml (typically gitignored)
|
|
5
|
+
#
|
|
6
|
+
# Bundled defaults are loaded automatically from:
|
|
7
|
+
# lib/htm/config/defaults.yml
|
|
8
|
+
#
|
|
9
|
+
# This file overrides specific values for local development.
|
|
10
|
+
|
|
11
|
+
# Override database settings for this example
|
|
12
|
+
database:
|
|
13
|
+
host: localhost
|
|
14
|
+
port: 5432
|
|
15
|
+
name: htm_example
|
|
16
|
+
|
|
17
|
+
# Use local Ollama for embeddings
|
|
18
|
+
embedding:
|
|
19
|
+
provider: ollama
|
|
20
|
+
model: nomic-embed-text:latest
|
|
21
|
+
|
|
22
|
+
# Use local Ollama for tag extraction
|
|
23
|
+
tag:
|
|
24
|
+
provider: ollama
|
|
25
|
+
model: gemma3:latest
|
|
26
|
+
|
|
27
|
+
# Local development settings
|
|
28
|
+
log_level: debug
|
|
29
|
+
telemetry_enabled: false
|
|
30
|
+
|
|
31
|
+
# Provider endpoints
|
|
32
|
+
providers:
|
|
33
|
+
ollama:
|
|
34
|
+
url: http://localhost:11434
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Custom HTM Configuration
|
|
2
|
+
#
|
|
3
|
+
# Use this file with: HTM_CONF=custom_config.yml ruby show_config.rb
|
|
4
|
+
#
|
|
5
|
+
# This demonstrates loading config from an arbitrary file path
|
|
6
|
+
# using the HTM_CONF environment variable.
|
|
7
|
+
|
|
8
|
+
database:
|
|
9
|
+
host: custom-db.example.com
|
|
10
|
+
port: 5433
|
|
11
|
+
name: htm_custom
|
|
12
|
+
|
|
13
|
+
embedding:
|
|
14
|
+
provider: openai
|
|
15
|
+
model: text-embedding-3-small
|
|
16
|
+
dimensions: 1536
|
|
17
|
+
|
|
18
|
+
tag:
|
|
19
|
+
provider: anthropic
|
|
20
|
+
model: claude-3-haiku-20240307
|
|
21
|
+
|
|
22
|
+
log_level: warn
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Show Config Example
|
|
5
|
+
#
|
|
6
|
+
# Demonstrates how anyway_config automatically loads configuration
|
|
7
|
+
# from standard locations and traces the source of each value.
|
|
8
|
+
#
|
|
9
|
+
# Config loading priority (lowest to highest):
|
|
10
|
+
# 1. Bundled defaults: lib/htm/config/defaults.yml (ships with gem)
|
|
11
|
+
# 2. XDG user config: ~/.config/htm/htm.yml
|
|
12
|
+
# 3. Project config: ./config/htm.yml
|
|
13
|
+
# 4. Local overrides: ./config/htm.local.yml <-- This example uses this
|
|
14
|
+
# 5. HTM_CONF file: path specified by HTM_CONF env var (overrides above)
|
|
15
|
+
# 6. Environment variables (HTM_*)
|
|
16
|
+
#
|
|
17
|
+
# Usage:
|
|
18
|
+
# ruby show_config.rb
|
|
19
|
+
# HTM_ENV=production ruby show_config.rb
|
|
20
|
+
# HTM_EMBEDDING__MODEL=mxbai-embed-large ruby show_config.rb
|
|
21
|
+
# HTM_CONF=/path/to/custom.yml ruby show_config.rb
|
|
22
|
+
|
|
23
|
+
require_relative '../../lib/htm'
|
|
24
|
+
require 'amazing_print'
|
|
25
|
+
|
|
26
|
+
puts <<~HEADER
|
|
27
|
+
|
|
28
|
+
HTM Configuration Example
|
|
29
|
+
#{'=' * 60}
|
|
30
|
+
|
|
31
|
+
Environment: #{HTM.config.environment}
|
|
32
|
+
|
|
33
|
+
Config sources checked:
|
|
34
|
+
- Bundled defaults: lib/htm/config/defaults.yml
|
|
35
|
+
- XDG config: #{HTM::Config.xdg_config_file}
|
|
36
|
+
- Project config: ./config/htm.yml
|
|
37
|
+
- Local overrides: ./config/htm.local.yml
|
|
38
|
+
- HTM_CONF override: #{ENV['HTM_CONF'] || '(not set)'}
|
|
39
|
+
- Environment variables: HTM_*
|
|
40
|
+
|
|
41
|
+
Active XDG config: #{HTM::Config.active_xdg_config_file || '(none found)'}
|
|
42
|
+
|
|
43
|
+
#{'-' * 60}
|
|
44
|
+
Configuration with Sources:
|
|
45
|
+
#{'-' * 60}
|
|
46
|
+
|
|
47
|
+
HEADER
|
|
48
|
+
|
|
49
|
+
# Get the source trace from anyway_config
|
|
50
|
+
trace = HTM.config.to_source_trace
|
|
51
|
+
|
|
52
|
+
# Helper to format source information
|
|
53
|
+
def format_source(source)
|
|
54
|
+
return "unknown" unless source
|
|
55
|
+
|
|
56
|
+
case source[:type]
|
|
57
|
+
when :defaults
|
|
58
|
+
"defaults"
|
|
59
|
+
when :yml
|
|
60
|
+
path = source[:path]
|
|
61
|
+
# Shorten the path for readability
|
|
62
|
+
if path.include?('defaults.yml')
|
|
63
|
+
"defaults.yml"
|
|
64
|
+
elsif path.include?('htm.local.yml')
|
|
65
|
+
"htm.local.yml"
|
|
66
|
+
elsif path.include?('htm.yml')
|
|
67
|
+
"htm.yml"
|
|
68
|
+
else
|
|
69
|
+
File.basename(path)
|
|
70
|
+
end
|
|
71
|
+
when :env
|
|
72
|
+
"ENV[#{source[:key]}]"
|
|
73
|
+
when :user
|
|
74
|
+
"code"
|
|
75
|
+
else
|
|
76
|
+
source[:type].to_s
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Recursively print config with sources
|
|
81
|
+
def print_config(trace, indent = 0)
|
|
82
|
+
trace.each do |key, data|
|
|
83
|
+
prefix = " " * indent
|
|
84
|
+
|
|
85
|
+
if data.is_a?(Hash) && data[:value].nil? && data[:source].nil?
|
|
86
|
+
# Nested section
|
|
87
|
+
puts "\n#{prefix}#{key}:"
|
|
88
|
+
print_config(data, indent + 1)
|
|
89
|
+
elsif data.is_a?(Hash) && data.key?(:value)
|
|
90
|
+
# Leaf value with source
|
|
91
|
+
value = data[:value]
|
|
92
|
+
source = format_source(data[:source])
|
|
93
|
+
|
|
94
|
+
# Format value for display
|
|
95
|
+
display_value = case value
|
|
96
|
+
when nil then "nil"
|
|
97
|
+
when String then value.empty? ? '""' : "\"#{value}\""
|
|
98
|
+
when Symbol then ":#{value}"
|
|
99
|
+
else value.inspect
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Truncate long values
|
|
103
|
+
display_value = display_value[0..50] + "..." if display_value.length > 50
|
|
104
|
+
|
|
105
|
+
puts "#{prefix}#{key}: #{display_value} # from: #{source}"
|
|
106
|
+
else
|
|
107
|
+
# Fallback for unexpected structure
|
|
108
|
+
puts "#{prefix}#{key}: #{data.inspect}"
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
print_config(trace)
|
|
114
|
+
|
|
115
|
+
puts <<~LEGEND
|
|
116
|
+
|
|
117
|
+
#{'-' * 60}
|
|
118
|
+
Legend:
|
|
119
|
+
defaults.yml = bundled gem defaults
|
|
120
|
+
htm.local.yml = ./config/htm.local.yml
|
|
121
|
+
htm.yml = ./config/htm.yml or ~/.config/htm/htm.yml
|
|
122
|
+
ENV[KEY] = environment variable
|
|
123
|
+
code = set programmatically
|
|
124
|
+
|
|
125
|
+
LEGEND
|
|
@@ -118,15 +118,15 @@ puts "\n5. Configuring Default Provider Settings"
|
|
|
118
118
|
puts "-" * 50
|
|
119
119
|
|
|
120
120
|
HTM.configure do |config|
|
|
121
|
-
# Customize the default RubyLLM configuration
|
|
122
|
-
config.
|
|
123
|
-
config.
|
|
124
|
-
config.
|
|
121
|
+
# Customize the default RubyLLM configuration using nested syntax
|
|
122
|
+
config.embedding.provider = :ollama
|
|
123
|
+
config.embedding.model = 'nomic-embed-text'
|
|
124
|
+
config.embedding.dimensions = 768
|
|
125
125
|
|
|
126
|
-
config.
|
|
127
|
-
config.
|
|
126
|
+
config.tag.provider = :ollama
|
|
127
|
+
config.tag.model = 'llama3'
|
|
128
128
|
|
|
129
|
-
config.
|
|
129
|
+
config.providers.ollama.url = ENV['OLLAMA_URL'] || 'http://localhost:11434'
|
|
130
130
|
|
|
131
131
|
# Reset to use these new settings with default implementations
|
|
132
132
|
config.reset_to_defaults
|
|
@@ -13,7 +13,7 @@ namespace :app do
|
|
|
13
13
|
desc "Start the example application"
|
|
14
14
|
task :start do
|
|
15
15
|
puts "\n=== Starting Example HTM Application ==="
|
|
16
|
-
puts "Database configured: #{ENV['
|
|
16
|
+
puts "Database configured: #{ENV['HTM_DATABASE__URL'] ? 'Yes' : 'No'}"
|
|
17
17
|
puts "\nRun 'rake -T' to see all available tasks"
|
|
18
18
|
puts "Run 'rake -T htm:db' to see HTM database tasks\n\n"
|
|
19
19
|
|
|
@@ -63,7 +63,7 @@ task :help do
|
|
|
63
63
|
rake htm:db:reset Drop and recreate database
|
|
64
64
|
|
|
65
65
|
Environment:
|
|
66
|
-
export
|
|
66
|
+
export HTM_DATABASE__URL="postgresql://user:pass@host:port/dbname"
|
|
67
67
|
|
|
68
68
|
See docs/using_rake_tasks_in_your_app.md for more information.
|
|
69
69
|
|
data/examples/example_app/app.rb
CHANGED
|
@@ -16,8 +16,8 @@ class ExampleApp
|
|
|
16
16
|
config = HTM::Database.default_config
|
|
17
17
|
unless config
|
|
18
18
|
puts "\n⚠ Database not configured!"
|
|
19
|
-
puts "Set
|
|
20
|
-
puts " export
|
|
19
|
+
puts "Set HTM_DATABASE__URL environment variable:"
|
|
20
|
+
puts " export HTM_DATABASE__URL='postgresql://user:pass@host:port/dbname'"
|
|
21
21
|
puts "\nOr run: rake app:bootstrap"
|
|
22
22
|
return
|
|
23
23
|
end
|
|
@@ -32,14 +32,14 @@ class ExampleApp
|
|
|
32
32
|
c.logger.level = Logger::INFO
|
|
33
33
|
|
|
34
34
|
# Configure embedding generation (using Ollama)
|
|
35
|
-
c.
|
|
36
|
-
c.
|
|
37
|
-
c.
|
|
38
|
-
c.
|
|
35
|
+
c.embedding.provider = :ollama
|
|
36
|
+
c.embedding.model = 'nomic-embed-text'
|
|
37
|
+
c.embedding.dimensions = 768
|
|
38
|
+
c.providers.ollama.url = ENV['OLLAMA_URL'] || 'http://localhost:11434'
|
|
39
39
|
|
|
40
40
|
# Configure tag extraction (using Ollama - using smaller/faster model)
|
|
41
|
-
c.
|
|
42
|
-
c.
|
|
41
|
+
c.tag.provider = :ollama
|
|
42
|
+
c.tag.model = 'gemma3' # Smaller model (3.3GB) for faster tag generation
|
|
43
43
|
|
|
44
44
|
# Apply default implementations
|
|
45
45
|
c.reset_to_defaults
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
# - Unloading files
|
|
11
11
|
#
|
|
12
12
|
# Prerequisites:
|
|
13
|
-
# 1. Set
|
|
13
|
+
# 1. Set HTM_DATABASE__URL environment variable (see SETUP.md)
|
|
14
14
|
# 2. Initialize database schema: rake db_setup
|
|
15
15
|
# 3. Install dependencies: bundle install
|
|
16
16
|
|
|
@@ -22,9 +22,9 @@ puts "HTM File Loader Example"
|
|
|
22
22
|
puts "=" * 60
|
|
23
23
|
|
|
24
24
|
# Check environment
|
|
25
|
-
unless ENV['
|
|
26
|
-
puts "ERROR:
|
|
27
|
-
puts " export
|
|
25
|
+
unless ENV['HTM_DATABASE__URL']
|
|
26
|
+
puts "ERROR: HTM_DATABASE__URL not set. Please set it:"
|
|
27
|
+
puts " export HTM_DATABASE__URL=\"postgresql://postgres@localhost:5432/htm_development\""
|
|
28
28
|
puts "See SETUP.md for details."
|
|
29
29
|
exit 1
|
|
30
30
|
end
|
|
@@ -33,11 +33,11 @@ begin
|
|
|
33
33
|
# Configure HTM globally (uses Ollama by default)
|
|
34
34
|
puts "\n1. Configuring HTM with Ollama provider..."
|
|
35
35
|
HTM.configure do |config|
|
|
36
|
-
config.
|
|
37
|
-
config.
|
|
38
|
-
config.
|
|
39
|
-
config.
|
|
40
|
-
config.
|
|
36
|
+
config.embedding.provider = :ollama
|
|
37
|
+
config.embedding.model = 'nomic-embed-text:latest'
|
|
38
|
+
config.embedding.dimensions = 768
|
|
39
|
+
config.tag.provider = :ollama
|
|
40
|
+
config.tag.model = 'gemma3:latest'
|
|
41
41
|
config.reset_to_defaults
|
|
42
42
|
end
|
|
43
43
|
puts " Configured with Ollama provider"
|
data/examples/mcp_client.rb
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
# Prerequisites:
|
|
11
11
|
# 1. Install gems: gem install ruby_llm-mcp
|
|
12
12
|
# 2. Have Ollama running with gpt-oss model: ollama pull gpt-oss
|
|
13
|
-
# 3. Set
|
|
13
|
+
# 3. Set HTM_DATABASE__URL environment variable
|
|
14
14
|
# 4. The htm_mcp executable must be available (this client will launch it)
|
|
15
15
|
#
|
|
16
16
|
# Usage:
|
|
@@ -57,9 +57,9 @@ class HTMMcpClient
|
|
|
57
57
|
private
|
|
58
58
|
|
|
59
59
|
def validate_environment
|
|
60
|
-
unless ENV['
|
|
61
|
-
warn 'Error:
|
|
62
|
-
warn ' export
|
|
60
|
+
unless ENV['HTM_DATABASE__URL']
|
|
61
|
+
warn 'Error: HTM_DATABASE__URL not set.'
|
|
62
|
+
warn ' export HTM_DATABASE__URL="postgresql://postgres@localhost:5432/htm_development"'
|
|
63
63
|
exit 1
|
|
64
64
|
end
|
|
65
65
|
|
|
@@ -103,7 +103,7 @@ class HTMMcpClient
|
|
|
103
103
|
command: RbConfig.ruby,
|
|
104
104
|
args: [MCP_SERVER_PATH],
|
|
105
105
|
env: {
|
|
106
|
-
'
|
|
106
|
+
'HTM_DATABASE__URL' => ENV['HTM_DATABASE__URL'],
|
|
107
107
|
'OLLAMA_URL' => OLLAMA_URL
|
|
108
108
|
}
|
|
109
109
|
}
|