llmemory 0.2.1 → 0.2.2

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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +47 -1
  3. data/app/controllers/llmemory/dashboard/application_controller.rb +15 -1
  4. data/app/controllers/llmemory/dashboard/episodic_controller.rb +22 -0
  5. data/app/controllers/llmemory/dashboard/forget_log_controller.rb +12 -0
  6. data/app/controllers/llmemory/dashboard/maintenance_controller.rb +92 -0
  7. data/app/controllers/llmemory/dashboard/procedural_controller.rb +22 -0
  8. data/app/controllers/llmemory/dashboard/reflection_controller.rb +37 -0
  9. data/app/controllers/llmemory/dashboard/working_controller.rb +14 -0
  10. data/app/views/llmemory/dashboard/episodic/index.html.erb +37 -0
  11. data/app/views/llmemory/dashboard/forget_log/show.html.erb +23 -0
  12. data/app/views/llmemory/dashboard/maintenance/show.html.erb +65 -0
  13. data/app/views/llmemory/dashboard/procedural/index.html.erb +38 -0
  14. data/app/views/llmemory/dashboard/reflection/show.html.erb +29 -0
  15. data/app/views/llmemory/dashboard/users/show.html.erb +16 -0
  16. data/app/views/llmemory/dashboard/working/show.html.erb +20 -0
  17. data/config/routes.rb +14 -0
  18. data/lib/generators/llmemory/install/templates/create_llmemory_tables.rb +2 -0
  19. data/lib/llmemory/cli/commands/maintain.rb +62 -0
  20. data/lib/llmemory/cli/commands/mine_skills.rb +50 -0
  21. data/lib/llmemory/cli.rb +6 -0
  22. data/lib/llmemory/configuration.rb +7 -1
  23. data/lib/llmemory/instrumentation.rb +33 -0
  24. data/lib/llmemory/llm/anthropic.rb +19 -15
  25. data/lib/llmemory/llm/openai.rb +16 -12
  26. data/lib/llmemory/long_term/episodic/memory.rb +23 -10
  27. data/lib/llmemory/long_term/episodic/storages/active_record_storage.rb +14 -4
  28. data/lib/llmemory/long_term/episodic/storages/base.rb +15 -2
  29. data/lib/llmemory/long_term/episodic/storages/database_storage.rb +26 -5
  30. data/lib/llmemory/long_term/episodic/storages/file_storage.rb +27 -6
  31. data/lib/llmemory/long_term/episodic/storages/memory_storage.rb +35 -4
  32. data/lib/llmemory/long_term/file_based/memory.rb +12 -4
  33. data/lib/llmemory/long_term/file_based/storages/active_record_storage.rb +4 -2
  34. data/lib/llmemory/long_term/file_based/storages/base.rb +2 -2
  35. data/lib/llmemory/long_term/file_based/storages/database_storage.rb +4 -2
  36. data/lib/llmemory/long_term/file_based/storages/file_storage.rb +4 -2
  37. data/lib/llmemory/long_term/file_based/storages/memory_storage.rb +4 -2
  38. data/lib/llmemory/long_term/graph_based/memory.rb +12 -4
  39. data/lib/llmemory/long_term/graph_based/storages/active_record_storage.rb +4 -2
  40. data/lib/llmemory/long_term/graph_based/storages/base.rb +2 -2
  41. data/lib/llmemory/long_term/graph_based/storages/memory_storage.rb +4 -2
  42. data/lib/llmemory/long_term/procedural/memory.rb +26 -13
  43. data/lib/llmemory/long_term/procedural/skill.rb +6 -2
  44. data/lib/llmemory/long_term/procedural/storages/active_record_storage.rb +15 -5
  45. data/lib/llmemory/long_term/procedural/storages/base.rb +14 -1
  46. data/lib/llmemory/long_term/procedural/storages/database_storage.rb +27 -6
  47. data/lib/llmemory/long_term/procedural/storages/file_storage.rb +28 -7
  48. data/lib/llmemory/long_term/procedural/storages/memory_storage.rb +36 -5
  49. data/lib/llmemory/maintenance/cognitive_pass.rb +109 -0
  50. data/lib/llmemory/maintenance/ttl_expiry.rb +50 -0
  51. data/lib/llmemory/maintenance.rb +2 -0
  52. data/lib/llmemory/mcp/server.rb +5 -1
  53. data/lib/llmemory/mcp/tools/memory_maintain.rb +53 -0
  54. data/lib/llmemory/mcp/tools/memory_mine_skills.rb +53 -0
  55. data/lib/llmemory/memory.rb +20 -0
  56. data/lib/llmemory/memory_module.rb +13 -6
  57. data/lib/llmemory/reflection/reflector.rb +24 -20
  58. data/lib/llmemory/retrieval/engine.rb +25 -16
  59. data/lib/llmemory/skill_mining/miner.rb +163 -0
  60. data/lib/llmemory/skill_mining.rb +8 -0
  61. data/lib/llmemory/vector_store/openai_embeddings.rb +11 -7
  62. data/lib/llmemory/version.rb +1 -1
  63. data/lib/llmemory.rb +2 -0
  64. metadata +22 -1
@@ -54,14 +54,18 @@ module Llmemory
54
54
  end
55
55
 
56
56
  def fetch_embedding(text)
57
- response = connection.post("embeddings") do |req|
58
- req.headers["Authorization"] = "Bearer #{@api_key}"
59
- req.headers["Content-Type"] = "application/json"
60
- req.body = { input: text.to_s.strip, model: @model }.to_json
57
+ result = nil
58
+ Llmemory::Instrumentation.instrument(:llm_embed, provider: :openai, model: @model, text_chars: text.to_s.length) do
59
+ response = connection.post("embeddings") do |req|
60
+ req.headers["Authorization"] = "Bearer #{@api_key}"
61
+ req.headers["Content-Type"] = "application/json"
62
+ req.body = { input: text.to_s.strip, model: @model }.to_json
63
+ end
64
+ raise Llmemory::LLMError, "OpenAI Embeddings API error: #{response.body}" unless response.success?
65
+ body = response.body.is_a?(Hash) ? response.body : JSON.parse(response.body.to_s)
66
+ result = body.dig("data", 0, "embedding")&.map(&:to_f) || Array.new(DEFAULT_DIMS, 0.0)
61
67
  end
62
- raise Llmemory::LLMError, "OpenAI Embeddings API error: #{response.body}" unless response.success?
63
- body = response.body.is_a?(Hash) ? response.body : JSON.parse(response.body.to_s)
64
- body.dig("data", 0, "embedding")&.map(&:to_f) || Array.new(DEFAULT_DIMS, 0.0)
68
+ result
65
69
  end
66
70
 
67
71
  def connection
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Llmemory
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
data/lib/llmemory.rb CHANGED
@@ -4,6 +4,7 @@ require_relative "llmemory/version"
4
4
  require_relative "llmemory/configuration"
5
5
  require_relative "llmemory/provenance"
6
6
  require_relative "llmemory/tokenizer"
7
+ require_relative "llmemory/instrumentation"
7
8
  require_relative "llmemory/memory_module"
8
9
  require_relative "llmemory/forget_log"
9
10
  require_relative "llmemory/llm"
@@ -15,6 +16,7 @@ require_relative "llmemory/vector_store"
15
16
  require_relative "llmemory/maintenance"
16
17
  require_relative "llmemory/extractors"
17
18
  require_relative "llmemory/reflection"
19
+ require_relative "llmemory/skill_mining"
18
20
  require_relative "llmemory/actions"
19
21
  require_relative "llmemory/memory"
20
22
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llmemory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - llmemory
@@ -106,21 +106,33 @@ files:
106
106
  - LICENSE.txt
107
107
  - README.md
108
108
  - app/controllers/llmemory/dashboard/application_controller.rb
109
+ - app/controllers/llmemory/dashboard/episodic_controller.rb
110
+ - app/controllers/llmemory/dashboard/forget_log_controller.rb
109
111
  - app/controllers/llmemory/dashboard/graph_controller.rb
110
112
  - app/controllers/llmemory/dashboard/long_term_controller.rb
113
+ - app/controllers/llmemory/dashboard/maintenance_controller.rb
114
+ - app/controllers/llmemory/dashboard/procedural_controller.rb
115
+ - app/controllers/llmemory/dashboard/reflection_controller.rb
111
116
  - app/controllers/llmemory/dashboard/search_controller.rb
112
117
  - app/controllers/llmemory/dashboard/short_term_controller.rb
113
118
  - app/controllers/llmemory/dashboard/stats_controller.rb
114
119
  - app/controllers/llmemory/dashboard/users_controller.rb
120
+ - app/controllers/llmemory/dashboard/working_controller.rb
115
121
  - app/views/layouts/application.html.erb
122
+ - app/views/llmemory/dashboard/episodic/index.html.erb
123
+ - app/views/llmemory/dashboard/forget_log/show.html.erb
116
124
  - app/views/llmemory/dashboard/graph/index.html.erb
117
125
  - app/views/llmemory/dashboard/long_term/categories.html.erb
118
126
  - app/views/llmemory/dashboard/long_term/index.html.erb
127
+ - app/views/llmemory/dashboard/maintenance/show.html.erb
128
+ - app/views/llmemory/dashboard/procedural/index.html.erb
129
+ - app/views/llmemory/dashboard/reflection/show.html.erb
119
130
  - app/views/llmemory/dashboard/search/index.html.erb
120
131
  - app/views/llmemory/dashboard/short_term/show.html.erb
121
132
  - app/views/llmemory/dashboard/stats/index.html.erb
122
133
  - app/views/llmemory/dashboard/users/index.html.erb
123
134
  - app/views/llmemory/dashboard/users/show.html.erb
135
+ - app/views/llmemory/dashboard/working/show.html.erb
124
136
  - config/routes.rb
125
137
  - exe/llmemory
126
138
  - exe/llmemory-mcp
@@ -140,7 +152,9 @@ files:
140
152
  - lib/llmemory/cli/commands/long_term/graph.rb
141
153
  - lib/llmemory/cli/commands/long_term/nodes.rb
142
154
  - lib/llmemory/cli/commands/long_term/resources.rb
155
+ - lib/llmemory/cli/commands/maintain.rb
143
156
  - lib/llmemory/cli/commands/mcp.rb
157
+ - lib/llmemory/cli/commands/mine_skills.rb
144
158
  - lib/llmemory/cli/commands/procedural.rb
145
159
  - lib/llmemory/cli/commands/search.rb
146
160
  - lib/llmemory/cli/commands/short_term.rb
@@ -154,6 +168,7 @@ files:
154
168
  - lib/llmemory/extractors/entity_relation_extractor.rb
155
169
  - lib/llmemory/extractors/fact_extractor.rb
156
170
  - lib/llmemory/forget_log.rb
171
+ - lib/llmemory/instrumentation.rb
157
172
  - lib/llmemory/llm.rb
158
173
  - lib/llmemory/llm/anthropic.rb
159
174
  - lib/llmemory/llm/base.rb
@@ -204,10 +219,12 @@ files:
204
219
  - lib/llmemory/long_term/procedural/storages/file_storage.rb
205
220
  - lib/llmemory/long_term/procedural/storages/memory_storage.rb
206
221
  - lib/llmemory/maintenance.rb
222
+ - lib/llmemory/maintenance/cognitive_pass.rb
207
223
  - lib/llmemory/maintenance/consolidator.rb
208
224
  - lib/llmemory/maintenance/reindexer.rb
209
225
  - lib/llmemory/maintenance/runner.rb
210
226
  - lib/llmemory/maintenance/summarizer.rb
227
+ - lib/llmemory/maintenance/ttl_expiry.rb
211
228
  - lib/llmemory/mcp.rb
212
229
  - lib/llmemory/mcp/authentication.rb
213
230
  - lib/llmemory/mcp/server.rb
@@ -217,6 +234,8 @@ files:
217
234
  - lib/llmemory/mcp/tools/memory_episodes.rb
218
235
  - lib/llmemory/mcp/tools/memory_forget.rb
219
236
  - lib/llmemory/mcp/tools/memory_info.rb
237
+ - lib/llmemory/mcp/tools/memory_maintain.rb
238
+ - lib/llmemory/mcp/tools/memory_mine_skills.rb
220
239
  - lib/llmemory/mcp/tools/memory_retrieve.rb
221
240
  - lib/llmemory/mcp/tools/memory_save.rb
222
241
  - lib/llmemory/mcp/tools/memory_search.rb
@@ -251,6 +270,8 @@ files:
251
270
  - lib/llmemory/short_term/stores/memory_store.rb
252
271
  - lib/llmemory/short_term/stores/postgres_store.rb
253
272
  - lib/llmemory/short_term/stores/redis_store.rb
273
+ - lib/llmemory/skill_mining.rb
274
+ - lib/llmemory/skill_mining/miner.rb
254
275
  - lib/llmemory/tokenizer.rb
255
276
  - lib/llmemory/vector_store.rb
256
277
  - lib/llmemory/vector_store/active_record_embedding.rb