htm 0.0.18 → 0.0.30

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.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +119 -1
  3. data/README.md +12 -0
  4. data/Rakefile +104 -18
  5. data/db/migrate/00001_enable_extensions.rb +9 -5
  6. data/db/migrate/00002_create_robots.rb +18 -6
  7. data/db/migrate/00003_create_file_sources.rb +30 -17
  8. data/db/migrate/00004_create_nodes.rb +60 -48
  9. data/db/migrate/00005_create_tags.rb +24 -12
  10. data/db/migrate/00006_create_node_tags.rb +28 -13
  11. data/db/migrate/00007_create_robot_nodes.rb +40 -26
  12. data/db/schema.sql +17 -1
  13. data/db/seeds.rb +34 -34
  14. data/docs/api/embedding-service.md +140 -110
  15. data/docs/api/yard/HTM/ActiveRecordConfig.md +6 -0
  16. data/docs/api/yard/HTM/Config.md +173 -0
  17. data/docs/api/yard/HTM/ConfigSection.md +28 -0
  18. data/docs/api/yard/HTM/Database.md +1 -1
  19. data/docs/api/yard/HTM/Railtie.md +2 -2
  20. data/docs/api/yard/HTM.md +0 -57
  21. data/docs/api/yard/index.csv +76 -61
  22. data/docs/api/yard-reference.md +2 -1
  23. data/docs/architecture/adrs/003-ollama-embeddings.md +45 -36
  24. data/docs/architecture/adrs/004-hive-mind.md +1 -1
  25. data/docs/architecture/adrs/008-robot-identification.md +1 -1
  26. data/docs/architecture/index.md +11 -9
  27. data/docs/architecture/overview.md +11 -7
  28. data/docs/assets/images/balanced-strategy-decay.svg +41 -0
  29. data/docs/assets/images/class-hierarchy.svg +1 -1
  30. data/docs/assets/images/eviction-priority.svg +43 -0
  31. data/docs/assets/images/exception-hierarchy.svg +2 -2
  32. data/docs/assets/images/hive-mind-shared-memory.svg +52 -0
  33. data/docs/assets/images/htm-architecture-overview.svg +3 -3
  34. data/docs/assets/images/htm-core-components.svg +4 -4
  35. data/docs/assets/images/htm-layered-architecture.svg +1 -1
  36. data/docs/assets/images/htm-memory-addition-flow.svg +2 -2
  37. data/docs/assets/images/htm-memory-recall-flow.svg +2 -2
  38. data/docs/assets/images/memory-topology.svg +53 -0
  39. data/docs/assets/images/two-tier-memory-architecture.svg +55 -0
  40. data/docs/database/naming-convention.md +244 -0
  41. data/docs/database_rake_tasks.md +31 -0
  42. data/docs/development/rake-tasks.md +80 -35
  43. data/docs/development/setup.md +76 -44
  44. data/docs/examples/basic-usage.md +133 -0
  45. data/docs/examples/config-files.md +170 -0
  46. data/docs/examples/file-loading.md +208 -0
  47. data/docs/examples/index.md +116 -0
  48. data/docs/examples/llm-configuration.md +168 -0
  49. data/docs/examples/mcp-client.md +172 -0
  50. data/docs/examples/rails-integration.md +173 -0
  51. data/docs/examples/robot-groups.md +210 -0
  52. data/docs/examples/sinatra-integration.md +218 -0
  53. data/docs/examples/standalone-app.md +216 -0
  54. data/docs/examples/telemetry.md +224 -0
  55. data/docs/examples/timeframes.md +143 -0
  56. data/docs/getting-started/installation.md +97 -40
  57. data/docs/getting-started/quick-start.md +28 -11
  58. data/docs/guides/configuration.md +515 -0
  59. data/docs/guides/file-loading.md +322 -0
  60. data/docs/guides/getting-started.md +40 -9
  61. data/docs/guides/index.md +3 -3
  62. data/docs/guides/mcp-server.md +100 -13
  63. data/docs/guides/propositions.md +264 -0
  64. data/docs/guides/recalling-memories.md +4 -4
  65. data/docs/guides/search-strategies.md +3 -3
  66. data/docs/guides/tags.md +318 -0
  67. data/docs/guides/telemetry.md +229 -0
  68. data/docs/index.md +8 -16
  69. data/docs/{architecture → robots}/hive-mind.md +8 -111
  70. data/docs/robots/index.md +73 -0
  71. data/docs/{guides → robots}/multi-robot.md +3 -3
  72. data/docs/{guides → robots}/robot-groups.md +8 -7
  73. data/docs/{architecture → robots}/two-tier-memory.md +13 -149
  74. data/docs/robots/why-robots.md +85 -0
  75. data/examples/.envrc +6 -0
  76. data/examples/.gitignore +2 -0
  77. data/examples/00_create_examples_db.rb +94 -0
  78. data/examples/{basic_usage.rb → 01_basic_usage.rb} +12 -16
  79. data/examples/{custom_llm_configuration.rb → 03_custom_llm_configuration.rb} +13 -3
  80. data/examples/{file_loader_usage.rb → 04_file_loader_usage.rb} +11 -14
  81. data/examples/{timeframe_demo.rb → 05_timeframe_demo.rb} +10 -3
  82. data/examples/{example_app → 06_example_app}/app.rb +15 -15
  83. data/examples/{cli_app → 07_cli_app}/htm_cli.rb +15 -22
  84. data/examples/08_sinatra_app/Gemfile.lock +241 -0
  85. data/examples/{sinatra_app → 08_sinatra_app}/app.rb +19 -18
  86. data/examples/{mcp_client.rb → 09_mcp_client.rb} +5 -8
  87. data/examples/{telemetry → 10_telemetry}/SETUP_README.md +1 -1
  88. data/examples/{telemetry → 10_telemetry}/demo.rb +14 -10
  89. data/examples/11_robot_groups/README.md +335 -0
  90. data/examples/{robot_groups → 11_robot_groups/lib}/robot_worker.rb +17 -3
  91. data/examples/{robot_groups → 11_robot_groups}/multi_process.rb +9 -9
  92. data/examples/{robot_groups → 11_robot_groups}/same_process.rb +9 -12
  93. data/examples/{rails_app → 12_rails_app}/Gemfile +3 -0
  94. data/examples/{rails_app → 12_rails_app}/Gemfile.lock +87 -58
  95. data/examples/{rails_app → 12_rails_app}/app/controllers/dashboard_controller.rb +10 -6
  96. data/examples/{rails_app → 12_rails_app}/app/controllers/files_controller.rb +5 -5
  97. data/examples/{rails_app → 12_rails_app}/app/controllers/memories_controller.rb +11 -7
  98. data/examples/{rails_app → 12_rails_app}/app/controllers/robots_controller.rb +8 -8
  99. data/examples/12_rails_app/app/controllers/tags_controller.rb +36 -0
  100. data/examples/{rails_app → 12_rails_app}/app/views/dashboard/index.html.erb +2 -2
  101. data/examples/{rails_app → 12_rails_app}/app/views/files/new.html.erb +5 -2
  102. data/examples/{rails_app → 12_rails_app}/app/views/memories/_memory_card.html.erb +3 -3
  103. data/examples/{rails_app → 12_rails_app}/app/views/memories/deleted.html.erb +3 -3
  104. data/examples/{rails_app → 12_rails_app}/app/views/memories/edit.html.erb +3 -3
  105. data/examples/{rails_app → 12_rails_app}/app/views/memories/show.html.erb +4 -4
  106. data/examples/{rails_app → 12_rails_app}/app/views/robots/index.html.erb +2 -2
  107. data/examples/{rails_app → 12_rails_app}/app/views/robots/show.html.erb +4 -4
  108. data/examples/{rails_app → 12_rails_app}/app/views/search/index.html.erb +1 -1
  109. data/examples/{rails_app → 12_rails_app}/app/views/tags/index.html.erb +2 -2
  110. data/examples/{rails_app → 12_rails_app}/app/views/tags/show.html.erb +1 -1
  111. data/examples/12_rails_app/config/initializers/htm.rb +7 -0
  112. data/examples/12_rails_app/config/initializers/rack.rb +5 -0
  113. data/examples/README.md +230 -211
  114. data/examples/examples_helper.rb +138 -0
  115. data/lib/htm/config/builder.rb +167 -0
  116. data/lib/htm/config/database.rb +317 -0
  117. data/lib/htm/config/defaults.yml +41 -13
  118. data/lib/htm/config/section.rb +74 -0
  119. data/lib/htm/config/validator.rb +83 -0
  120. data/lib/htm/config.rb +65 -361
  121. data/lib/htm/database.rb +85 -127
  122. data/lib/htm/errors.rb +14 -0
  123. data/lib/htm/integrations/sinatra.rb +13 -44
  124. data/lib/htm/job_adapter.rb +75 -1
  125. data/lib/htm/jobs/generate_embedding_job.rb +3 -4
  126. data/lib/htm/jobs/generate_propositions_job.rb +4 -5
  127. data/lib/htm/jobs/generate_tags_job.rb +16 -15
  128. data/lib/htm/loaders/defaults_loader.rb +23 -0
  129. data/lib/htm/loaders/markdown_loader.rb +17 -15
  130. data/lib/htm/loaders/xdg_config_loader.rb +9 -9
  131. data/lib/htm/long_term_memory/fulltext_search.rb +14 -14
  132. data/lib/htm/long_term_memory/hybrid_search.rb +396 -229
  133. data/lib/htm/long_term_memory/node_operations.rb +24 -23
  134. data/lib/htm/long_term_memory/relevance_scorer.rb +23 -20
  135. data/lib/htm/long_term_memory/robot_operations.rb +4 -4
  136. data/lib/htm/long_term_memory/tag_operations.rb +91 -77
  137. data/lib/htm/long_term_memory/vector_search.rb +4 -5
  138. data/lib/htm/long_term_memory.rb +13 -13
  139. data/lib/htm/mcp/cli.rb +115 -8
  140. data/lib/htm/mcp/resources.rb +4 -3
  141. data/lib/htm/mcp/server.rb +5 -4
  142. data/lib/htm/mcp/tools.rb +37 -28
  143. data/lib/htm/migration.rb +72 -0
  144. data/lib/htm/models/file_source.rb +52 -31
  145. data/lib/htm/models/node.rb +224 -108
  146. data/lib/htm/models/node_tag.rb +49 -28
  147. data/lib/htm/models/robot.rb +38 -27
  148. data/lib/htm/models/robot_node.rb +63 -35
  149. data/lib/htm/models/tag.rb +126 -123
  150. data/lib/htm/observability.rb +45 -41
  151. data/lib/htm/proposition_service.rb +76 -7
  152. data/lib/htm/railtie.rb +2 -2
  153. data/lib/htm/robot_group.rb +30 -18
  154. data/lib/htm/sequel_config.rb +215 -0
  155. data/lib/htm/sql_builder.rb +14 -16
  156. data/lib/htm/tag_service.rb +78 -0
  157. data/lib/htm/tasks.rb +3 -0
  158. data/lib/htm/version.rb +1 -1
  159. data/lib/htm/workflows/remember_workflow.rb +213 -0
  160. data/lib/htm.rb +27 -22
  161. data/lib/tasks/db.rake +0 -2
  162. data/lib/tasks/doc.rake +2 -2
  163. data/lib/tasks/files.rake +11 -18
  164. data/lib/tasks/htm.rake +190 -62
  165. data/lib/tasks/jobs.rake +179 -54
  166. data/lib/tasks/tags.rake +8 -13
  167. data/mkdocs.yml +33 -8
  168. data/scripts/backfill_parent_tags.rb +376 -0
  169. data/scripts/normalize_plural_tags.rb +335 -0
  170. metadata +168 -86
  171. data/docs/api/yard/HTM/Configuration.md +0 -240
  172. data/docs/telemetry.md +0 -391
  173. data/examples/rails_app/app/controllers/tags_controller.rb +0 -30
  174. data/examples/sinatra_app/Gemfile.lock +0 -166
  175. data/lib/htm/active_record_config.rb +0 -104
  176. /data/examples/{config_file_example → 02_config_file_example}/README.md +0 -0
  177. /data/examples/{config_file_example → 02_config_file_example}/config/htm.local.yml +0 -0
  178. /data/examples/{config_file_example → 02_config_file_example}/custom_config.yml +0 -0
  179. /data/examples/{config_file_example → 02_config_file_example}/show_config.rb +0 -0
  180. /data/examples/{example_app → 06_example_app}/Rakefile +0 -0
  181. /data/examples/{cli_app → 07_cli_app}/README.md +0 -0
  182. /data/examples/{sinatra_app → 08_sinatra_app}/Gemfile +0 -0
  183. /data/examples/{telemetry → 10_telemetry}/README.md +0 -0
  184. /data/examples/{telemetry → 10_telemetry}/grafana/dashboards/htm-metrics.json +0 -0
  185. /data/examples/{rails_app → 12_rails_app}/.gitignore +0 -0
  186. /data/examples/{rails_app → 12_rails_app}/Procfile.dev +0 -0
  187. /data/examples/{rails_app → 12_rails_app}/README.md +0 -0
  188. /data/examples/{rails_app → 12_rails_app}/Rakefile +0 -0
  189. /data/examples/{rails_app → 12_rails_app}/app/assets/stylesheets/application.css +0 -0
  190. /data/examples/{rails_app → 12_rails_app}/app/assets/stylesheets/inter-font.css +0 -0
  191. /data/examples/{rails_app → 12_rails_app}/app/controllers/application_controller.rb +0 -0
  192. /data/examples/{rails_app → 12_rails_app}/app/controllers/search_controller.rb +0 -0
  193. /data/examples/{rails_app → 12_rails_app}/app/javascript/application.js +0 -0
  194. /data/examples/{rails_app → 12_rails_app}/app/javascript/controllers/application.js +0 -0
  195. /data/examples/{rails_app → 12_rails_app}/app/javascript/controllers/index.js +0 -0
  196. /data/examples/{rails_app → 12_rails_app}/app/views/files/index.html.erb +0 -0
  197. /data/examples/{rails_app → 12_rails_app}/app/views/files/show.html.erb +0 -0
  198. /data/examples/{rails_app → 12_rails_app}/app/views/layouts/application.html.erb +0 -0
  199. /data/examples/{rails_app → 12_rails_app}/app/views/memories/index.html.erb +0 -0
  200. /data/examples/{rails_app → 12_rails_app}/app/views/memories/new.html.erb +0 -0
  201. /data/examples/{rails_app → 12_rails_app}/app/views/robots/new.html.erb +0 -0
  202. /data/examples/{rails_app → 12_rails_app}/app/views/shared/_navbar.html.erb +0 -0
  203. /data/examples/{rails_app → 12_rails_app}/app/views/shared/_stat_card.html.erb +0 -0
  204. /data/examples/{rails_app → 12_rails_app}/bin/dev +0 -0
  205. /data/examples/{rails_app → 12_rails_app}/bin/rails +0 -0
  206. /data/examples/{rails_app → 12_rails_app}/bin/rake +0 -0
  207. /data/examples/{rails_app → 12_rails_app}/config/application.rb +0 -0
  208. /data/examples/{rails_app → 12_rails_app}/config/boot.rb +0 -0
  209. /data/examples/{rails_app → 12_rails_app}/config/database.yml +0 -0
  210. /data/examples/{rails_app → 12_rails_app}/config/environment.rb +0 -0
  211. /data/examples/{rails_app → 12_rails_app}/config/importmap.rb +0 -0
  212. /data/examples/{rails_app → 12_rails_app}/config/routes.rb +0 -0
  213. /data/examples/{rails_app → 12_rails_app}/config/tailwind.config.js +0 -0
  214. /data/examples/{rails_app → 12_rails_app}/config.ru +0 -0
  215. /data/examples/{rails_app → 12_rails_app}/log/.keep +0 -0
  216. /data/examples/{rails_app → 12_rails_app}/tmp/local_secret.txt +0 -0
@@ -1,20 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class CreateNodeTags < ActiveRecord::Migration[7.1]
4
- def change
5
- create_table :node_tags, comment: 'Join table connecting nodes to tags (many-to-many)' do |t|
6
- t.bigint :node_id, null: false, comment: 'ID of the node being tagged'
7
- t.bigint :tag_id, null: false, comment: 'ID of the tag being applied'
8
- t.timestamptz :created_at, default: -> { 'CURRENT_TIMESTAMP' }, comment: 'When this association was created'
9
- t.timestamptz :deleted_at, comment: 'Soft delete timestamp'
3
+ require_relative '../../lib/htm/migration'
4
+
5
+ class CreateNodeTags < HTM::Migration
6
+ def up
7
+ create_table(:node_tags) do
8
+ primary_key :id
9
+ Bignum :node_id, null: false
10
+ Bignum :tag_id, null: false
11
+ DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
12
+ DateTime :deleted_at
10
13
  end
11
14
 
12
- add_index :node_tags, [:node_id, :tag_id], unique: true, name: 'idx_node_tags_unique'
13
- add_index :node_tags, :node_id, name: 'idx_node_tags_node_id'
14
- add_index :node_tags, :tag_id, name: 'idx_node_tags_tag_id'
15
- add_index :node_tags, :deleted_at, name: 'idx_node_tags_deleted_at'
15
+ add_index :node_tags, [:node_id, :tag_id], unique: true, name: :idx_node_tags_unique
16
+ add_index :node_tags, :node_id, name: :idx_node_tags_node_id
17
+ add_index :node_tags, :tag_id, name: :idx_node_tags_tag_id
18
+ add_index :node_tags, :deleted_at, name: :idx_node_tags_deleted_at
19
+
20
+ alter_table(:node_tags) do
21
+ add_foreign_key [:node_id], :nodes, on_delete: :cascade
22
+ add_foreign_key [:tag_id], :tags, on_delete: :cascade
23
+ end
24
+
25
+ run "COMMENT ON TABLE node_tags IS 'Join table connecting nodes to tags (many-to-many)'"
26
+ run "COMMENT ON COLUMN node_tags.node_id IS 'ID of the node being tagged'"
27
+ run "COMMENT ON COLUMN node_tags.tag_id IS 'ID of the tag being applied'"
28
+ run "COMMENT ON COLUMN node_tags.created_at IS 'When this association was created'"
29
+ run "COMMENT ON COLUMN node_tags.deleted_at IS 'Soft delete timestamp'"
30
+ end
16
31
 
17
- add_foreign_key :node_tags, :nodes, column: :node_id, on_delete: :cascade
18
- add_foreign_key :node_tags, :tags, column: :tag_id, on_delete: :cascade
32
+ def down
33
+ drop_table(:node_tags)
19
34
  end
20
35
  end
@@ -1,33 +1,47 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class CreateRobotNodes < ActiveRecord::Migration[7.1]
4
- def change
5
- create_table :robot_nodes, comment: 'Join table connecting robots to nodes (many-to-many)' do |t|
6
- t.bigint :robot_id, null: false, comment: 'ID of the robot that remembered this node'
7
- t.bigint :node_id, null: false, comment: 'ID of the node being remembered'
8
- t.timestamptz :first_remembered_at, default: -> { 'CURRENT_TIMESTAMP' },
9
- comment: 'When this robot first remembered this content'
10
- t.timestamptz :last_remembered_at, default: -> { 'CURRENT_TIMESTAMP' },
11
- comment: 'When this robot last tried to remember this content'
12
- t.integer :remember_count, default: 1, null: false,
13
- comment: 'Number of times this robot has tried to remember this content'
14
- t.boolean :working_memory, default: false, null: false,
15
- comment: 'True if this node is currently in the robot working memory'
16
- t.timestamptz :created_at, default: -> { 'CURRENT_TIMESTAMP' }
17
- t.timestamptz :updated_at, default: -> { 'CURRENT_TIMESTAMP' }
18
- t.timestamptz :deleted_at, comment: 'Soft delete timestamp'
3
+ require_relative '../../lib/htm/migration'
4
+
5
+ class CreateRobotNodes < HTM::Migration
6
+ def up
7
+ create_table(:robot_nodes) do
8
+ primary_key :id
9
+ Bignum :robot_id, null: false
10
+ Bignum :node_id, null: false
11
+ DateTime :first_remembered_at, default: Sequel::CURRENT_TIMESTAMP
12
+ DateTime :last_remembered_at, default: Sequel::CURRENT_TIMESTAMP
13
+ Integer :remember_count, default: 1, null: false
14
+ TrueClass :working_memory, default: false, null: false
15
+ DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
16
+ DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
17
+ DateTime :deleted_at
18
+ end
19
+
20
+ add_index :robot_nodes, [:robot_id, :node_id], unique: true, name: :idx_robot_nodes_unique
21
+ add_index :robot_nodes, :robot_id, name: :idx_robot_nodes_robot_id
22
+ add_index :robot_nodes, :node_id, name: :idx_robot_nodes_node_id
23
+ add_index :robot_nodes, :last_remembered_at, name: :idx_robot_nodes_last_remembered_at
24
+ add_index :robot_nodes, :deleted_at, name: :idx_robot_nodes_deleted_at
25
+
26
+ # Partial index for working memory queries
27
+ run "CREATE INDEX idx_robot_nodes_working_memory ON robot_nodes (robot_id, working_memory) WHERE working_memory = true"
28
+
29
+ alter_table(:robot_nodes) do
30
+ add_foreign_key [:robot_id], :robots, on_delete: :cascade
31
+ add_foreign_key [:node_id], :nodes, on_delete: :cascade
19
32
  end
20
33
 
21
- add_index :robot_nodes, [:robot_id, :node_id], unique: true, name: 'idx_robot_nodes_unique'
22
- add_index :robot_nodes, :robot_id, name: 'idx_robot_nodes_robot_id'
23
- add_index :robot_nodes, :node_id, name: 'idx_robot_nodes_node_id'
24
- add_index :robot_nodes, :last_remembered_at, name: 'idx_robot_nodes_last_remembered_at'
25
- add_index :robot_nodes, :deleted_at, name: 'idx_robot_nodes_deleted_at'
26
- add_index :robot_nodes, [:robot_id, :working_memory],
27
- where: 'working_memory = true',
28
- name: 'idx_robot_nodes_working_memory'
34
+ run "COMMENT ON TABLE robot_nodes IS 'Join table connecting robots to nodes (many-to-many)'"
35
+ run "COMMENT ON COLUMN robot_nodes.robot_id IS 'ID of the robot that remembered this node'"
36
+ run "COMMENT ON COLUMN robot_nodes.node_id IS 'ID of the node being remembered'"
37
+ run "COMMENT ON COLUMN robot_nodes.first_remembered_at IS 'When this robot first remembered this content'"
38
+ run "COMMENT ON COLUMN robot_nodes.last_remembered_at IS 'When this robot last tried to remember this content'"
39
+ run "COMMENT ON COLUMN robot_nodes.remember_count IS 'Number of times this robot has tried to remember this content'"
40
+ run "COMMENT ON COLUMN robot_nodes.working_memory IS 'True if this node is currently in the robot working memory'"
41
+ run "COMMENT ON COLUMN robot_nodes.deleted_at IS 'Soft delete timestamp'"
42
+ end
29
43
 
30
- add_foreign_key :robot_nodes, :robots, column: :robot_id, on_delete: :cascade
31
- add_foreign_key :robot_nodes, :nodes, column: :node_id, on_delete: :cascade
44
+ def down
45
+ drop_table(:robot_nodes)
32
46
  end
33
47
  end
data/db/schema.sql CHANGED
@@ -3,6 +3,22 @@
3
3
  -- DO NOT EDIT THIS FILE MANUALLY
4
4
  -- Run 'rake htm:db:schema:dump' to regenerate
5
5
 
6
+ --
7
+ -- Name: paradedb; Type: SCHEMA; Schema: -; Owner: -
8
+ --
9
+
10
+ CREATE SCHEMA paradedb;
11
+
12
+ --
13
+ -- Name: pg_search; Type: EXTENSION; Schema: -; Owner: -
14
+ --
15
+
16
+ CREATE EXTENSION IF NOT EXISTS pg_search WITH SCHEMA paradedb;
17
+
18
+ --
19
+ -- Name: EXTENSION pg_search; Type: COMMENT; Schema: -; Owner: -
20
+ --
21
+
6
22
  --
7
23
  -- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: -
8
24
  --
@@ -793,4 +809,4 @@ ALTER TABLE ONLY public.robot_nodes
793
809
  -- PostgreSQL database dump complete
794
810
  --
795
811
 
796
- \unrestrict 4WlUqnJzNHaNhcr67XLIIhAvRPidZODUPGkM34l27SvmC0zu6dIsQdJ8dtu589Z
812
+ \unrestrict 1ItB7RQU4jC5IvOL40FU9j9sS6bzk9jcKeDUYSOd78ym0sA7pq0FXYSOEoWsPh7
data/db/seeds.rb CHANGED
@@ -6,14 +6,14 @@
6
6
  # and creates memory nodes with embeddings and tags.
7
7
  #
8
8
  # Configuration is read from environment variables:
9
- # HTM_EMBEDDING_PROVIDER - Embedding provider (default: ollama)
10
- # HTM_EMBEDDING_MODEL - Embedding model (default: nomic-embed-text)
11
- # HTM_EMBEDDING_DIMENSIONS - Embedding dimensions (default: 768)
12
- # HTM_TAG_PROVIDER - Tag extraction provider (default: ollama)
13
- # HTM_TAG_MODEL - Tag extraction model (default: gemma3)
14
- # OLLAMA_URL - Ollama server URL (default: http://localhost:11434)
15
- # HTM_EMBEDDING_TIMEOUT - Embedding generation timeout in seconds (default: 120)
16
- # HTM_TAG_TIMEOUT - Tag generation timeout in seconds (default: 180)
9
+ # HTM_EMBEDDING__PROVIDER - Embedding provider (default: ollama)
10
+ # HTM_EMBEDDING__MODEL - Embedding model (default: nomic-embed-text)
11
+ # HTM_EMBEDDING__DIMENSIONS - Embedding dimensions (default: 768)
12
+ # HTM_TAG__PROVIDER - Tag extraction provider (default: ollama)
13
+ # HTM_TAG__MODEL - Tag extraction model (default: gemma3)
14
+ # HTM_PROVIDERS__OLLAMA__URL - Ollama server URL (default: http://localhost:11434)
15
+ # HTM_EMBEDDING__TIMEOUT - Embedding generation timeout in seconds (default: 120)
16
+ # HTM_TAG__TIMEOUT - Tag generation timeout in seconds (default: 180)
17
17
  # HTM_CONNECTION_TIMEOUT - LLM connection timeout in seconds (default: 30)
18
18
  # HTM_DATABASE__URL - Database connection URL
19
19
  #
@@ -30,14 +30,14 @@ puts "=" * 80
30
30
  puts
31
31
 
32
32
  # Configure HTM using environment variables or defaults
33
- embedding_provider = (ENV['HTM_EMBEDDING_PROVIDER'] || 'ollama').to_sym
34
- embedding_model = ENV['HTM_EMBEDDING_MODEL'] || 'nomic-embed-text'
35
- embedding_dimensions = (ENV['HTM_EMBEDDING_DIMENSIONS'] || '768').to_i
36
- tag_provider = (ENV['HTM_TAG_PROVIDER'] || 'ollama').to_sym
37
- tag_model = ENV['HTM_TAG_MODEL'] || 'gemma3'
38
- embedding_timeout = (ENV['HTM_EMBEDDING_TIMEOUT'] || '120').to_i
39
- tag_timeout = (ENV['HTM_TAG_TIMEOUT'] || '180').to_i
40
- connection_timeout = (ENV['HTM_CONNECTION_TIMEOUT'] || '30').to_i
33
+ embedding_provider = (ENV['HTM_EMBEDDING__PROVIDER'] || 'ollama').to_sym
34
+ embedding_model = ENV['HTM_EMBEDDING__MODEL'] || 'nomic-embed-text'
35
+ embedding_dimensions = (ENV['HTM_EMBEDDING__DIMENSIONS'] || '768').to_i
36
+ tag_provider = (ENV['HTM_TAG__PROVIDER'] || 'ollama').to_sym
37
+ tag_model = ENV['HTM_TAG__MODEL'] || 'gemma3'
38
+ embedding_timeout = (ENV['HTM_EMBEDDING__TIMEOUT'] || '120').to_i
39
+ tag_timeout = (ENV['HTM_TAG__TIMEOUT'] || '180').to_i
40
+ connection_timeout = (ENV['HTM_CONNECTION_TIMEOUT'] || '60').to_i
41
41
 
42
42
  puts "Configuration:"
43
43
  puts " Embedding Provider: #{embedding_provider}"
@@ -49,15 +49,15 @@ puts " Timeouts: embedding=#{embedding_timeout}s, tag=#{tag_timeout}s, connecti
49
49
  puts
50
50
 
51
51
  HTM.configure do |c|
52
- c.embedding_provider = embedding_provider
53
- c.embedding_model = embedding_model
54
- c.embedding_dimensions = embedding_dimensions
55
- c.tag_provider = tag_provider
56
- c.tag_model = tag_model
57
- c.embedding_timeout = embedding_timeout
58
- c.tag_timeout = tag_timeout
52
+ c.embedding.provider = embedding_provider
53
+ c.embedding.model = embedding_model
54
+ c.embedding.dimensions = embedding_dimensions
55
+ c.tag.provider = tag_provider
56
+ c.tag.model = tag_model
57
+ c.embedding.timeout = embedding_timeout
58
+ c.tag.timeout = tag_timeout
59
59
  c.connection_timeout = connection_timeout
60
- c.ollama_url = ENV['OLLAMA_URL'] if ENV['OLLAMA_URL']
60
+ c.providers.ollama.url = ENV['HTM_PROVIDERS__OLLAMA__URL'] if ENV['HTM_PROVIDERS__OLLAMA__URL']
61
61
  c.reset_to_defaults # Apply default implementations with configured settings
62
62
  end
63
63
 
@@ -72,32 +72,32 @@ puts "Creating sample conversation..."
72
72
 
73
73
  htm.remember(
74
74
  "What is TimescaleDB good for?",
75
- source: "user"
75
+ metadata: { source: "user" }
76
76
  )
77
77
 
78
78
  htm.remember(
79
79
  "PostgreSQL with TimescaleDB provides efficient time-series data storage and querying capabilities.",
80
- source: "assistant"
80
+ metadata: { source: "assistant" }
81
81
  )
82
82
 
83
83
  htm.remember(
84
84
  "How much training data do ML models need?",
85
- source: "user"
85
+ metadata: { source: "user" }
86
86
  )
87
87
 
88
88
  htm.remember(
89
89
  "Machine learning models require large amounts of training data to achieve good performance.",
90
- source: "assistant"
90
+ metadata: { source: "assistant" }
91
91
  )
92
92
 
93
93
  htm.remember(
94
94
  "Tell me about Ruby on Rails",
95
- source: "user"
95
+ metadata: { source: "user" }
96
96
  )
97
97
 
98
98
  htm.remember(
99
99
  "Ruby on Rails is a web framework for building database-backed applications.",
100
- source: "assistant"
100
+ metadata: { source: "assistant" }
101
101
  )
102
102
 
103
103
  puts "✓ Created 6 conversation messages (3 exchanges)"
@@ -135,7 +135,7 @@ if Dir.exist?(seed_data_dir)
135
135
  # Save previous section if we have one
136
136
  if current_section && current_paragraph.any?
137
137
  paragraph_text = current_paragraph.join(' ')
138
- htm.remember(paragraph_text, source: filename)
138
+ htm.remember(paragraph_text, metadata: { source: filename })
139
139
  count += 1
140
140
  print "." if count % 10 == 0
141
141
  end
@@ -152,7 +152,7 @@ if Dir.exist?(seed_data_dir)
152
152
  # Don't forget the last section
153
153
  if current_section && current_paragraph.any?
154
154
  paragraph_text = current_paragraph.join(' ')
155
- htm.remember(paragraph_text, source: filename)
155
+ htm.remember(paragraph_text, metadata: { source: filename })
156
156
  count += 1
157
157
  end
158
158
 
@@ -187,7 +187,7 @@ puts
187
187
  puts "Checking completion status..."
188
188
 
189
189
  # Check completion status
190
- nodes_with_embeddings = HTM::Models::Node.where.not(embedding: nil).count
190
+ nodes_with_embeddings = HTM::Models::Node.exclude(embedding: nil).count
191
191
  puts " - Nodes with embeddings: #{nodes_with_embeddings}/#{total_records}"
192
192
 
193
193
  total_tags = HTM::Models::NodeTag.count
@@ -203,6 +203,6 @@ if nodes_with_embeddings == total_records && total_tags > 0
203
203
  else
204
204
  puts "⚠ Some background jobs may still be running."
205
205
  puts " Run this query to check progress:"
206
- puts " HTM::Models::Node.where.not(embedding: nil).count"
206
+ puts " HTM::Models::Node.exclude(embedding: nil).count"
207
207
  puts "=" * 80
208
208
  end