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
|
@@ -15,7 +15,7 @@ require 'htm'
|
|
|
15
15
|
|
|
16
16
|
# Configure for CLI (synchronous execution)
|
|
17
17
|
HTM.configure do |config|
|
|
18
|
-
config.
|
|
18
|
+
config.job.backend = :inline # Jobs run immediately
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
htm = HTM.new(robot_name: "cli_assistant")
|
|
@@ -151,7 +151,7 @@ HTM.configuration.job_backend # => :thread
|
|
|
151
151
|
|
|
152
152
|
```ruby
|
|
153
153
|
HTM.configure do |config|
|
|
154
|
-
config.
|
|
154
|
+
config.job.backend = :inline # Force synchronous
|
|
155
155
|
end
|
|
156
156
|
```
|
|
157
157
|
|
|
@@ -177,7 +177,7 @@ export HTM_JOB_BACKEND=inline # Override auto-detection
|
|
|
177
177
|
```ruby
|
|
178
178
|
# Use inline backend
|
|
179
179
|
HTM.configure do |config|
|
|
180
|
-
config.
|
|
180
|
+
config.job.backend = :inline
|
|
181
181
|
|
|
182
182
|
# CLI-friendly logging
|
|
183
183
|
config.logger.formatter = proc do |severity, datetime, progname, msg|
|
|
@@ -253,8 +253,8 @@ gem 'htm'
|
|
|
253
253
|
|
|
254
254
|
# config/initializers/htm.rb (optional)
|
|
255
255
|
HTM.configure do |config|
|
|
256
|
-
config.
|
|
257
|
-
config.
|
|
256
|
+
config.embedding.model = 'nomic-embed-text'
|
|
257
|
+
config.tag.model = 'llama3'
|
|
258
258
|
end
|
|
259
259
|
```
|
|
260
260
|
|
|
@@ -397,8 +397,8 @@ bundle exec sidekiq
|
|
|
397
397
|
```ruby
|
|
398
398
|
# Use faster/smaller models
|
|
399
399
|
HTM.configure do |config|
|
|
400
|
-
config.
|
|
401
|
-
config.
|
|
400
|
+
config.embedding.model = 'all-minilm' # Smaller, faster
|
|
401
|
+
config.tag.model = 'gemma2:2b' # Smaller model
|
|
402
402
|
end
|
|
403
403
|
|
|
404
404
|
# Or disable features
|
|
@@ -438,7 +438,7 @@ end
|
|
|
438
438
|
|
|
439
439
|
# After (explicit inline):
|
|
440
440
|
HTM.configure do |config|
|
|
441
|
-
config.
|
|
441
|
+
config.job.backend = :inline
|
|
442
442
|
end
|
|
443
443
|
# Jobs run synchronously, guaranteed to complete
|
|
444
444
|
```
|
|
@@ -63,12 +63,12 @@ Update your `.envrc` file (already done):
|
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
65
|
# Database connection - Localhost PostgreSQL
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
70
|
-
export
|
|
71
|
-
export
|
|
66
|
+
export HTM_DATABASE__HOST=localhost
|
|
67
|
+
export HTM_DATABASE__PORT=5432
|
|
68
|
+
export HTM_DATABASE__NAME=htm_development
|
|
69
|
+
export HTM_DATABASE__USER=${USER}
|
|
70
|
+
export HTM_DATABASE__PASSWORD=
|
|
71
|
+
export HTM_DATABASE__URL="postgresql://${HTM_DATABASE__USER}@${HTM_DATABASE__HOST}:${HTM_DATABASE__PORT}/${HTM_DATABASE__NAME}?sslmode=prefer"
|
|
72
72
|
|
|
73
73
|
# Client-side embedding generation
|
|
74
74
|
export HTM_EMBEDDINGS_PROVIDER=ollama
|
|
@@ -209,7 +209,7 @@ ollama serve
|
|
|
209
209
|
**Solution:**
|
|
210
210
|
```bash
|
|
211
211
|
direnv allow
|
|
212
|
-
echo $
|
|
212
|
+
echo $HTM_DATABASE__URL # Verify it's set
|
|
213
213
|
```
|
|
214
214
|
|
|
215
215
|
## Switching Back to TimescaleDB Cloud
|
|
@@ -218,21 +218,21 @@ To switch back to TimescaleDB Cloud (production), edit `.envrc`:
|
|
|
218
218
|
|
|
219
219
|
```bash
|
|
220
220
|
# Comment out localhost config
|
|
221
|
-
# export
|
|
222
|
-
# export
|
|
223
|
-
# export
|
|
224
|
-
# export
|
|
225
|
-
# export
|
|
226
|
-
# export
|
|
221
|
+
# export HTM_DATABASE__HOST=localhost
|
|
222
|
+
# export HTM_DATABASE__PORT=5432
|
|
223
|
+
# export HTM_DATABASE__NAME=htm_development
|
|
224
|
+
# export HTM_DATABASE__USER=${USER}
|
|
225
|
+
# export HTM_DATABASE__PASSWORD=
|
|
226
|
+
# export HTM_DATABASE__URL="postgresql://${HTM_DATABASE__USER}@${HTM_DATABASE__HOST}:${HTM_DATABASE__PORT}/${HTM_DATABASE__NAME}?sslmode=prefer"
|
|
227
227
|
|
|
228
228
|
# Uncomment TimescaleDB Cloud config
|
|
229
229
|
export HTM_SERVICE_NAME=$TIGER_SERVICE_NAME
|
|
230
|
-
export
|
|
231
|
-
export
|
|
232
|
-
export
|
|
233
|
-
export
|
|
234
|
-
export
|
|
235
|
-
export
|
|
230
|
+
export HTM_DATABASE__URL=$TIGER_DBURL
|
|
231
|
+
export HTM_DATABASE__NAME=$TIGER_DBNAME
|
|
232
|
+
export HTM_DATABASE__USER=$TIGER_DBUSER
|
|
233
|
+
export HTM_DATABASE__PASSWORD=$TIGER_DBPASS
|
|
234
|
+
export HTM_DATABASE__HOST=$TIGER_DBHOST
|
|
235
|
+
export HTM_DATABASE__PORT=$TIGER_DBPORT
|
|
236
236
|
```
|
|
237
237
|
|
|
238
238
|
Then reload:
|
|
@@ -63,14 +63,14 @@ Create a `.envrc` file in your application's root:
|
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
65
|
# .envrc
|
|
66
|
-
export
|
|
66
|
+
export HTM_DATABASE__URL="postgresql://user:password@host:port/dbname?sslmode=require"
|
|
67
67
|
|
|
68
68
|
# Or use individual parameters
|
|
69
|
-
export
|
|
70
|
-
export
|
|
71
|
-
export
|
|
72
|
-
export
|
|
73
|
-
export
|
|
69
|
+
export HTM_DATABASE__HOST="your-host.tsdb.cloud.timescale.com"
|
|
70
|
+
export HTM_DATABASE__PORT="37807"
|
|
71
|
+
export HTM_DATABASE__NAME="tsdb"
|
|
72
|
+
export HTM_DATABASE__USER="tsdbadmin"
|
|
73
|
+
export HTM_DATABASE__PASSWORD="your_password"
|
|
74
74
|
|
|
75
75
|
# Embedding configuration
|
|
76
76
|
export HTM_EMBEDDINGS_PROVIDER=ollama
|
|
@@ -93,7 +93,7 @@ direnv allow
|
|
|
93
93
|
### Option 2: Export in Shell
|
|
94
94
|
|
|
95
95
|
```bash
|
|
96
|
-
export
|
|
96
|
+
export HTM_DATABASE__URL="postgresql://user:password@host:port/dbname?sslmode=require"
|
|
97
97
|
rake htm:db:info
|
|
98
98
|
```
|
|
99
99
|
|
|
@@ -103,7 +103,7 @@ rake htm:db:info
|
|
|
103
103
|
# Rakefile
|
|
104
104
|
|
|
105
105
|
# Set environment variables programmatically
|
|
106
|
-
ENV['
|
|
106
|
+
ENV['HTM_DATABASE__URL'] = "postgresql://user:password@host:port/dbname?sslmode=require"
|
|
107
107
|
|
|
108
108
|
# Then load tasks
|
|
109
109
|
require 'htm/tasks'
|
|
@@ -122,7 +122,7 @@ require 'htm/tasks'
|
|
|
122
122
|
|
|
123
123
|
```bash
|
|
124
124
|
# .env
|
|
125
|
-
|
|
125
|
+
HTM_DATABASE__URL=postgresql://user:password@host:port/dbname?sslmode=require
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
## Real-World Example
|
|
@@ -297,13 +297,13 @@ jobs:
|
|
|
297
297
|
|
|
298
298
|
- name: Setup database
|
|
299
299
|
env:
|
|
300
|
-
|
|
300
|
+
HTM_DATABASE__URL: postgresql://postgres:postgres@localhost:5432/test
|
|
301
301
|
run: |
|
|
302
302
|
bundle exec rake htm:db:setup
|
|
303
303
|
|
|
304
304
|
- name: Run tests
|
|
305
305
|
env:
|
|
306
|
-
|
|
306
|
+
HTM_DATABASE__URL: postgresql://postgres:postgres@localhost:5432/test
|
|
307
307
|
run: |
|
|
308
308
|
bundle exec rake test
|
|
309
309
|
```
|
|
@@ -317,7 +317,7 @@ services:
|
|
|
317
317
|
app:
|
|
318
318
|
build: .
|
|
319
319
|
environment:
|
|
320
|
-
-
|
|
320
|
+
- HTM_DATABASE__URL=postgresql://postgres:postgres@db:5432/myapp
|
|
321
321
|
depends_on:
|
|
322
322
|
- db
|
|
323
323
|
command: bash -c "rake htm:db:setup && rake app:start"
|
|
@@ -347,10 +347,10 @@ rake -T
|
|
|
347
347
|
Error: Database configuration not found
|
|
348
348
|
```
|
|
349
349
|
|
|
350
|
-
Solution: Set `
|
|
350
|
+
Solution: Set `HTM_DATABASE__URL` environment variable
|
|
351
351
|
|
|
352
352
|
```bash
|
|
353
|
-
export
|
|
353
|
+
export HTM_DATABASE__URL="postgresql://user:password@host:port/dbname"
|
|
354
354
|
rake htm:db:info
|
|
355
355
|
```
|
|
356
356
|
|
data/examples/README.md
CHANGED
|
@@ -8,12 +8,12 @@ All examples require:
|
|
|
8
8
|
|
|
9
9
|
1. **PostgreSQL Database** with pgvector extension:
|
|
10
10
|
```bash
|
|
11
|
-
export
|
|
11
|
+
export HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
> **Note**: Database selection now respects `RAILS_ENV`. If `RAILS_ENV` is set,
|
|
15
|
-
> HTM extracts the base name from `
|
|
16
|
-
> For example, with `
|
|
15
|
+
> HTM extracts the base name from `HTM_DATABASE__URL` and appends the environment suffix.
|
|
16
|
+
> For example, with `HTM_DATABASE__URL=...htm_development` and `HTM_ENV=test`, HTM
|
|
17
17
|
> connects to `htm_test`. When `RAILS_ENV` is unset (typical for examples),
|
|
18
18
|
> behavior is unchanged.
|
|
19
19
|
|
|
@@ -32,6 +32,43 @@ All examples require:
|
|
|
32
32
|
|
|
33
33
|
## Standalone Scripts
|
|
34
34
|
|
|
35
|
+
### config_file_example/
|
|
36
|
+
|
|
37
|
+
**Configuration management with source tracing.**
|
|
38
|
+
|
|
39
|
+
Demonstrates how HTM uses `anyway_config` for layered configuration from multiple sources, with source tracing to show where each value originated.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
cd examples/config_file_example
|
|
43
|
+
ruby show_config.rb
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Features:**
|
|
47
|
+
- Configuration priority order (defaults → XDG → project → local → env vars)
|
|
48
|
+
- Source tracing showing origin of each config value
|
|
49
|
+
- `HTM_CONF` environment variable for custom config file paths
|
|
50
|
+
- Environment-specific configuration (`HTM_ENV`)
|
|
51
|
+
- Generating config templates with `htm_mcp config`
|
|
52
|
+
|
|
53
|
+
**Usage examples:**
|
|
54
|
+
```bash
|
|
55
|
+
# Basic - loads ./config/htm.local.yml automatically
|
|
56
|
+
ruby show_config.rb
|
|
57
|
+
|
|
58
|
+
# Use custom config file
|
|
59
|
+
HTM_CONF=./custom_config.yml ruby show_config.rb
|
|
60
|
+
|
|
61
|
+
# Override with environment variables
|
|
62
|
+
HTM_EMBEDDING__MODEL=mxbai-embed-large ruby show_config.rb
|
|
63
|
+
|
|
64
|
+
# Different environment
|
|
65
|
+
HTM_ENV=production ruby show_config.rb
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
See [config_file_example/README.md](config_file_example/README.md) for detailed documentation.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
35
72
|
### basic_usage.rb
|
|
36
73
|
|
|
37
74
|
**Getting started with HTM fundamentals.**
|
|
@@ -184,7 +221,7 @@ ruby examples/mcp_server.rb
|
|
|
184
221
|
"command": "ruby",
|
|
185
222
|
"args": ["/path/to/htm/examples/mcp_server.rb"],
|
|
186
223
|
"env": {
|
|
187
|
-
"
|
|
224
|
+
"HTM_DATABASE__URL": "postgresql://user@localhost:5432/htm_development"
|
|
188
225
|
}
|
|
189
226
|
}
|
|
190
227
|
}
|
|
@@ -260,7 +297,7 @@ ollama pull gpt-oss # Or your preferred model
|
|
|
260
297
|
```
|
|
261
298
|
|
|
262
299
|
**Environment Variables:**
|
|
263
|
-
- `
|
|
300
|
+
- `HTM_DATABASE__URL` - PostgreSQL connection (required)
|
|
264
301
|
- `OLLAMA_URL` - Ollama server URL (default: http://localhost:11434)
|
|
265
302
|
- `OLLAMA_MODEL` - Model to use (default: gpt-oss:latest)
|
|
266
303
|
- `HTM_ROBOT_NAME` - Robot name (optional, prompts if not set)
|
|
@@ -313,7 +350,7 @@ bundle exec ruby app.rb
|
|
|
313
350
|
- Tag tree visualization
|
|
314
351
|
|
|
315
352
|
**Environment Variables:**
|
|
316
|
-
- `
|
|
353
|
+
- `HTM_DATABASE__URL` - PostgreSQL connection (required)
|
|
317
354
|
- `REDIS_URL` - Redis for Sidekiq (default: redis://localhost:6379/0)
|
|
318
355
|
- `SESSION_SECRET` - Session encryption key
|
|
319
356
|
|
|
@@ -405,6 +442,12 @@ examples/
|
|
|
405
442
|
├── custom_llm_configuration.rb # LLM integration patterns
|
|
406
443
|
├── file_loader_usage.rb # Document loading
|
|
407
444
|
├── timeframe_demo.rb # Time-based filtering
|
|
445
|
+
├── config_file_example/
|
|
446
|
+
│ ├── show_config.rb # Config source tracing demo
|
|
447
|
+
│ ├── custom_config.yml # Example for HTM_CONF
|
|
448
|
+
│ ├── README.md # Configuration documentation
|
|
449
|
+
│ └── config/
|
|
450
|
+
│ └── htm.local.yml # Auto-loaded local overrides
|
|
408
451
|
├── telemetry/
|
|
409
452
|
│ ├── demo.rb # Live Grafana metrics dashboard
|
|
410
453
|
│ ├── README.md
|
|
@@ -438,6 +481,7 @@ examples/
|
|
|
438
481
|
| Use Case | Example |
|
|
439
482
|
|----------|---------|
|
|
440
483
|
| Learning HTM basics | `basic_usage.rb` |
|
|
484
|
+
| Configuration management | `config_file_example/` |
|
|
441
485
|
| Custom LLM integration | `custom_llm_configuration.rb` |
|
|
442
486
|
| Loading documents/files | `file_loader_usage.rb` |
|
|
443
487
|
| Time-based queries | `timeframe_demo.rb` |
|
data/examples/basic_usage.rb
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
# Basic usage example for HTM
|
|
5
5
|
#
|
|
6
6
|
# Prerequisites:
|
|
7
|
-
# 1.
|
|
8
|
-
#
|
|
7
|
+
# 1. Configure database via environment or config file:
|
|
8
|
+
# - HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
|
|
9
|
+
# - Or individual vars: HTM_DATABASE__HOST, HTM_DATABASE__NAME, etc.
|
|
10
|
+
# 2. Initialize database schema: rake htm:db:setup
|
|
9
11
|
# 3. Install dependencies: bundle install
|
|
10
12
|
|
|
11
13
|
require_relative '../lib/htm'
|
|
@@ -13,26 +15,31 @@ require_relative '../lib/htm'
|
|
|
13
15
|
puts "HTM Basic Usage Example"
|
|
14
16
|
puts "=" * 60
|
|
15
17
|
|
|
16
|
-
# Check
|
|
17
|
-
unless
|
|
18
|
-
puts "ERROR:
|
|
19
|
-
puts " export
|
|
20
|
-
puts "
|
|
18
|
+
# Check database configuration using the config system
|
|
19
|
+
unless HTM.config.database_configured?
|
|
20
|
+
puts "ERROR: Database not configured. Set one of:"
|
|
21
|
+
puts " export HTM_DATABASE__URL=\"postgresql://user@localhost:5432/htm_development\""
|
|
22
|
+
puts " Or configure in ~/.config/htm/htm.yml"
|
|
23
|
+
puts "Run 'bin/htm_mcp help' for all configuration options."
|
|
21
24
|
exit 1
|
|
22
25
|
end
|
|
23
26
|
|
|
24
27
|
begin
|
|
25
|
-
# Configure HTM globally (uses Ollama by default)
|
|
28
|
+
# Configure HTM globally (uses Ollama by default from defaults.yml)
|
|
26
29
|
puts "\n1. Configuring HTM with Ollama provider..."
|
|
27
30
|
HTM.configure do |config|
|
|
28
|
-
config.
|
|
29
|
-
config.
|
|
30
|
-
config.
|
|
31
|
-
config.
|
|
32
|
-
config.
|
|
33
|
-
|
|
31
|
+
config.embedding.provider = :ollama
|
|
32
|
+
config.embedding.model = 'nomic-embed-text:latest'
|
|
33
|
+
config.embedding.dimensions = 768
|
|
34
|
+
config.tag.provider = :ollama
|
|
35
|
+
config.tag.model = 'gemma3:latest'
|
|
36
|
+
# Use inline job backend for synchronous execution in examples
|
|
37
|
+
# (In production, use :thread or :sidekiq for async processing)
|
|
38
|
+
config.job.backend = :inline
|
|
39
|
+
# Quiet the logs for cleaner output
|
|
40
|
+
config.log_level = :warn
|
|
34
41
|
end
|
|
35
|
-
puts "✓ HTM configured with Ollama provider"
|
|
42
|
+
puts "✓ HTM configured with Ollama provider (inline job backend)"
|
|
36
43
|
|
|
37
44
|
# Initialize HTM for 'Code Helper' robot
|
|
38
45
|
puts "\n2. Initializing HTM for 'Code Helper' robot..."
|
|
@@ -43,7 +50,7 @@ begin
|
|
|
43
50
|
puts "✓ HTM initialized"
|
|
44
51
|
puts " Robot ID: #{htm.robot_id}"
|
|
45
52
|
puts " Robot Name: #{htm.robot_name}"
|
|
46
|
-
puts " Embedding Service:
|
|
53
|
+
puts " Embedding Service: #{HTM.config.embedding.provider} (#{HTM.config.embedding.model})"
|
|
47
54
|
|
|
48
55
|
# Remember some information
|
|
49
56
|
puts "\n3. Remembering information..."
|
|
@@ -63,15 +70,18 @@ begin
|
|
|
63
70
|
)
|
|
64
71
|
puts "✓ Remembered fact about user preferences (node #{node_id_3})"
|
|
65
72
|
|
|
66
|
-
#
|
|
67
|
-
sleep
|
|
73
|
+
# With inline backend, embeddings and tags are generated synchronously
|
|
74
|
+
# No sleep needed - memories are immediately searchable
|
|
68
75
|
|
|
69
|
-
# Demonstrate recall
|
|
70
|
-
|
|
76
|
+
# Demonstrate recall using fulltext search (keyword matching)
|
|
77
|
+
# Note: hybrid search requires fulltext matches first, so search terms
|
|
78
|
+
# must appear in the stored content. Use fulltext for keyword matching.
|
|
79
|
+
puts "\n4. Recalling memories about 'PostgreSQL'..."
|
|
71
80
|
memories = htm.recall(
|
|
72
|
-
"
|
|
81
|
+
"PostgreSQL", # This word appears in the stored content
|
|
73
82
|
timeframe: (Time.now - 3600)..Time.now, # Last hour
|
|
74
83
|
limit: 5,
|
|
84
|
+
strategy: :fulltext, # Keyword matching (words must appear in content)
|
|
75
85
|
raw: true # Return full node data (id, content, etc.)
|
|
76
86
|
)
|
|
77
87
|
puts "✓ Found #{memories.length} memories"
|
data/examples/cli_app/README.md
CHANGED
|
@@ -15,7 +15,7 @@ This example demonstrates using HTM in a command-line application with synchrono
|
|
|
15
15
|
1. **PostgreSQL Database**
|
|
16
16
|
```bash
|
|
17
17
|
# Set database connection URL
|
|
18
|
-
export
|
|
18
|
+
export HTM_DATABASE__URL='postgresql://user:pass@host:port/dbname'
|
|
19
19
|
|
|
20
20
|
# Or use your existing config
|
|
21
21
|
source ~/.bashrc__tiger
|
|
@@ -86,7 +86,7 @@ Unlike web applications, CLI apps use `:inline` job backend:
|
|
|
86
86
|
|
|
87
87
|
```ruby
|
|
88
88
|
HTM.configure do |config|
|
|
89
|
-
config.
|
|
89
|
+
config.job.backend = :inline # Execute jobs synchronously
|
|
90
90
|
end
|
|
91
91
|
```
|
|
92
92
|
|
|
@@ -197,8 +197,8 @@ end
|
|
|
197
197
|
|
|
198
198
|
```ruby
|
|
199
199
|
HTM.configure do |config|
|
|
200
|
-
config.
|
|
201
|
-
config.
|
|
200
|
+
config.embedding.model = 'custom-embedding-model'
|
|
201
|
+
config.tag.model = 'custom-tag-model'
|
|
202
202
|
end
|
|
203
203
|
```
|
|
204
204
|
|
|
@@ -206,8 +206,8 @@ end
|
|
|
206
206
|
|
|
207
207
|
```ruby
|
|
208
208
|
HTM.configure do |config|
|
|
209
|
-
config.
|
|
210
|
-
config.
|
|
209
|
+
config.embedding.timeout = 60 # 1 minute
|
|
210
|
+
config.tag.timeout = 120 # 2 minutes
|
|
211
211
|
end
|
|
212
212
|
```
|
|
213
213
|
|
|
@@ -246,10 +246,10 @@ end
|
|
|
246
246
|
|
|
247
247
|
```bash
|
|
248
248
|
# Verify database URL
|
|
249
|
-
echo $
|
|
249
|
+
echo $HTM_DATABASE__URL
|
|
250
250
|
|
|
251
251
|
# Test connection
|
|
252
|
-
psql $
|
|
252
|
+
psql $HTM_DATABASE__URL -c "SELECT version();"
|
|
253
253
|
|
|
254
254
|
# Initialize schema if needed
|
|
255
255
|
cd ../.. && rake db_setup
|
data/examples/cli_app/htm_cli.rb
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# ruby htm_cli.rb
|
|
14
14
|
#
|
|
15
15
|
# Environment:
|
|
16
|
-
#
|
|
16
|
+
# HTM_DATABASE__URL - PostgreSQL connection URL (required)
|
|
17
17
|
# OLLAMA_URL - Ollama server URL (default: http://localhost:11434)
|
|
18
18
|
#
|
|
19
19
|
|
|
@@ -39,7 +39,7 @@ class HTMCli
|
|
|
39
39
|
# Configure HTM for CLI usage
|
|
40
40
|
HTM.configure do |config|
|
|
41
41
|
# Use inline mode for synchronous execution
|
|
42
|
-
config.
|
|
42
|
+
config.job.backend = :inline
|
|
43
43
|
|
|
44
44
|
# CLI-friendly logging
|
|
45
45
|
config.logger.level = Logger::INFO
|
|
@@ -376,12 +376,12 @@ class HTMCli
|
|
|
376
376
|
end
|
|
377
377
|
|
|
378
378
|
# Check database configuration
|
|
379
|
-
unless ENV['
|
|
379
|
+
unless ENV['HTM_DATABASE__URL']
|
|
380
380
|
puts
|
|
381
|
-
puts "[✗] Error:
|
|
381
|
+
puts "[✗] Error: HTM_DATABASE__URL environment variable not set"
|
|
382
382
|
puts
|
|
383
383
|
puts "Please set your database connection URL:"
|
|
384
|
-
puts " export
|
|
384
|
+
puts " export HTM_DATABASE__URL='postgresql://postgres@localhost:5432/htm_development'"
|
|
385
385
|
puts
|
|
386
386
|
puts "See SETUP.md for database setup instructions."
|
|
387
387
|
puts
|