agentdb 1.0.0
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.
- package/LICENSE +38 -0
- package/LICENSE-APACHE +190 -0
- package/LICENSE-MIT +21 -0
- package/README.md +953 -0
- package/bin/agentdb.js +485 -0
- package/bin/plugin-cli-wrapper.mjs +21 -0
- package/dist/cache/query-cache.d.ts +105 -0
- package/dist/cache/query-cache.d.ts.map +1 -0
- package/dist/cache/query-cache.js +224 -0
- package/dist/cache/query-cache.js.map +1 -0
- package/dist/cache/query-cache.mjs +219 -0
- package/dist/cli/cache/query-cache.d.ts +104 -0
- package/dist/cli/cache/query-cache.js +244 -0
- package/dist/cli/cli/db-commands.d.ts +48 -0
- package/dist/cli/cli/db-commands.js +613 -0
- package/dist/cli/commands.d.ts +7 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +113 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/commands.mjs +104 -0
- package/dist/cli/core/backend-interface.d.ts +70 -0
- package/dist/cli/core/backend-interface.js +15 -0
- package/dist/cli/core/native-backend.d.ts +140 -0
- package/dist/cli/core/native-backend.js +432 -0
- package/dist/cli/core/vector-db.d.ts +126 -0
- package/dist/cli/core/vector-db.js +338 -0
- package/dist/cli/core/wasm-backend.d.ts +95 -0
- package/dist/cli/core/wasm-backend.js +418 -0
- package/dist/cli/db-commands.d.ts +49 -0
- package/dist/cli/db-commands.d.ts.map +1 -0
- package/dist/cli/db-commands.js +533 -0
- package/dist/cli/db-commands.js.map +1 -0
- package/dist/cli/db-commands.mjs +522 -0
- package/dist/cli/generator.d.ts +11 -0
- package/dist/cli/generator.d.ts.map +1 -0
- package/dist/cli/generator.js +567 -0
- package/dist/cli/generator.js.map +1 -0
- package/dist/cli/generator.mjs +527 -0
- package/dist/cli/help.d.ts +18 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +676 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/help.mjs +667 -0
- package/dist/cli/index/hnsw.d.ts +164 -0
- package/dist/cli/index/hnsw.js +558 -0
- package/dist/cli/plugin-cli.d.ts +7 -0
- package/dist/cli/plugin-cli.d.ts.map +1 -0
- package/dist/cli/plugin-cli.js +295 -0
- package/dist/cli/plugin-cli.js.map +1 -0
- package/dist/cli/plugin-cli.mjs +289 -0
- package/dist/cli/quantization/product-quantization.d.ts +108 -0
- package/dist/cli/quantization/product-quantization.js +350 -0
- package/dist/cli/query/query-builder.d.ts +322 -0
- package/dist/cli/query/query-builder.js +600 -0
- package/dist/cli/templates.d.ts +14 -0
- package/dist/cli/templates.d.ts.map +1 -0
- package/dist/cli/templates.js +182 -0
- package/dist/cli/templates.js.map +1 -0
- package/dist/cli/templates.mjs +176 -0
- package/dist/cli/types/index.d.ts +116 -0
- package/dist/cli/types/index.js +5 -0
- package/dist/cli/types.d.ts +91 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +6 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/types.mjs +4 -0
- package/dist/cli/wizard/index.d.ts +6 -0
- package/dist/cli/wizard/index.d.ts.map +1 -0
- package/dist/cli/wizard/index.js +138 -0
- package/dist/cli/wizard/index.js.map +1 -0
- package/dist/cli/wizard/index.mjs +131 -0
- package/dist/cli/wizard/prompts.d.ts +11 -0
- package/dist/cli/wizard/prompts.d.ts.map +1 -0
- package/dist/cli/wizard/prompts.js +482 -0
- package/dist/cli/wizard/prompts.js.map +1 -0
- package/dist/cli/wizard/prompts.mjs +470 -0
- package/dist/cli/wizard/validator.d.ts +13 -0
- package/dist/cli/wizard/validator.d.ts.map +1 -0
- package/dist/cli/wizard/validator.js +234 -0
- package/dist/cli/wizard/validator.js.map +1 -0
- package/dist/cli/wizard/validator.mjs +224 -0
- package/dist/core/backend-interface.d.ts +71 -0
- package/dist/core/backend-interface.d.ts.map +1 -0
- package/dist/core/backend-interface.js +16 -0
- package/dist/core/backend-interface.js.map +1 -0
- package/dist/core/backend-interface.mjs +12 -0
- package/dist/core/native-backend.d.ts +141 -0
- package/dist/core/native-backend.d.ts.map +1 -0
- package/dist/core/native-backend.js +457 -0
- package/dist/core/native-backend.js.map +1 -0
- package/dist/core/native-backend.mjs +449 -0
- package/dist/core/vector-db.d.ts +127 -0
- package/dist/core/vector-db.d.ts.map +1 -0
- package/dist/core/vector-db.js +266 -0
- package/dist/core/vector-db.js.map +1 -0
- package/dist/core/vector-db.mjs +261 -0
- package/dist/core/wasm-backend.d.ts +96 -0
- package/dist/core/wasm-backend.d.ts.map +1 -0
- package/dist/core/wasm-backend.js +393 -0
- package/dist/core/wasm-backend.js.map +1 -0
- package/dist/core/wasm-backend.mjs +385 -0
- package/dist/index/hnsw-optimized.d.ts +75 -0
- package/dist/index/hnsw-optimized.d.ts.map +1 -0
- package/dist/index/hnsw-optimized.js +412 -0
- package/dist/index/hnsw-optimized.js.map +1 -0
- package/dist/index/hnsw-optimized.mjs +407 -0
- package/dist/index/hnsw.d.ts +165 -0
- package/dist/index/hnsw.d.ts.map +1 -0
- package/dist/index/hnsw.js +521 -0
- package/dist/index/hnsw.js.map +1 -0
- package/dist/index/hnsw.mjs +516 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +63 -0
- package/dist/mcp-server.d.ts +27 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +789 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/mcp-server.mjs +784 -0
- package/dist/plugins/base-plugin.d.ts +114 -0
- package/dist/plugins/base-plugin.d.ts.map +1 -0
- package/dist/plugins/base-plugin.js +313 -0
- package/dist/plugins/base-plugin.js.map +1 -0
- package/dist/plugins/base-plugin.mjs +275 -0
- package/dist/plugins/implementations/active-learning.d.ts +135 -0
- package/dist/plugins/implementations/active-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/active-learning.js +372 -0
- package/dist/plugins/implementations/active-learning.js.map +1 -0
- package/dist/plugins/implementations/active-learning.mjs +367 -0
- package/dist/plugins/implementations/actor-critic.d.ts +64 -0
- package/dist/plugins/implementations/actor-critic.d.ts.map +1 -0
- package/dist/plugins/implementations/actor-critic.js +363 -0
- package/dist/plugins/implementations/actor-critic.js.map +1 -0
- package/dist/plugins/implementations/actor-critic.mjs +358 -0
- package/dist/plugins/implementations/adversarial-training.d.ts +133 -0
- package/dist/plugins/implementations/adversarial-training.d.ts.map +1 -0
- package/dist/plugins/implementations/adversarial-training.js +409 -0
- package/dist/plugins/implementations/adversarial-training.js.map +1 -0
- package/dist/plugins/implementations/adversarial-training.mjs +404 -0
- package/dist/plugins/implementations/curriculum-learning.d.ts +132 -0
- package/dist/plugins/implementations/curriculum-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/curriculum-learning.js +354 -0
- package/dist/plugins/implementations/curriculum-learning.js.map +1 -0
- package/dist/plugins/implementations/curriculum-learning.mjs +349 -0
- package/dist/plugins/implementations/decision-transformer.d.ts +77 -0
- package/dist/plugins/implementations/decision-transformer.d.ts.map +1 -0
- package/dist/plugins/implementations/decision-transformer.js +422 -0
- package/dist/plugins/implementations/decision-transformer.js.map +1 -0
- package/dist/plugins/implementations/decision-transformer.mjs +417 -0
- package/dist/plugins/implementations/federated-learning.d.ts +126 -0
- package/dist/plugins/implementations/federated-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/federated-learning.js +436 -0
- package/dist/plugins/implementations/federated-learning.js.map +1 -0
- package/dist/plugins/implementations/federated-learning.mjs +431 -0
- package/dist/plugins/implementations/index.d.ts +30 -0
- package/dist/plugins/implementations/index.d.ts.map +1 -0
- package/dist/plugins/implementations/index.js +45 -0
- package/dist/plugins/implementations/index.js.map +1 -0
- package/dist/plugins/implementations/index.mjs +31 -0
- package/dist/plugins/implementations/multi-task-learning.d.ts +115 -0
- package/dist/plugins/implementations/multi-task-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/multi-task-learning.js +369 -0
- package/dist/plugins/implementations/multi-task-learning.js.map +1 -0
- package/dist/plugins/implementations/multi-task-learning.mjs +364 -0
- package/dist/plugins/implementations/neural-architecture-search.d.ts +148 -0
- package/dist/plugins/implementations/neural-architecture-search.d.ts.map +1 -0
- package/dist/plugins/implementations/neural-architecture-search.js +379 -0
- package/dist/plugins/implementations/neural-architecture-search.js.map +1 -0
- package/dist/plugins/implementations/neural-architecture-search.mjs +374 -0
- package/dist/plugins/implementations/q-learning.d.ts +98 -0
- package/dist/plugins/implementations/q-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/q-learning.js +435 -0
- package/dist/plugins/implementations/q-learning.js.map +1 -0
- package/dist/plugins/implementations/q-learning.mjs +430 -0
- package/dist/plugins/implementations/sarsa.d.ts +103 -0
- package/dist/plugins/implementations/sarsa.d.ts.map +1 -0
- package/dist/plugins/implementations/sarsa.js +347 -0
- package/dist/plugins/implementations/sarsa.js.map +1 -0
- package/dist/plugins/implementations/sarsa.mjs +342 -0
- package/dist/plugins/index.d.ts +107 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +179 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/index.mjs +168 -0
- package/dist/plugins/interface.d.ts +439 -0
- package/dist/plugins/interface.d.ts.map +1 -0
- package/dist/plugins/interface.js +12 -0
- package/dist/plugins/interface.js.map +1 -0
- package/dist/plugins/interface.mjs +10 -0
- package/dist/plugins/learning-plugin.interface.d.ts +257 -0
- package/dist/plugins/learning-plugin.interface.d.ts.map +1 -0
- package/dist/plugins/learning-plugin.interface.js +7 -0
- package/dist/plugins/learning-plugin.interface.js.map +1 -0
- package/dist/plugins/learning-plugin.interface.mjs +5 -0
- package/dist/plugins/plugin-exports.d.ts +71 -0
- package/dist/plugins/plugin-exports.d.ts.map +1 -0
- package/dist/plugins/plugin-exports.js +78 -0
- package/dist/plugins/plugin-exports.js.map +1 -0
- package/dist/plugins/plugin-exports.mjs +69 -0
- package/dist/plugins/registry.d.ts +206 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +365 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/registry.mjs +356 -0
- package/dist/plugins/validator.d.ts +63 -0
- package/dist/plugins/validator.d.ts.map +1 -0
- package/dist/plugins/validator.js +464 -0
- package/dist/plugins/validator.js.map +1 -0
- package/dist/plugins/validator.mjs +458 -0
- package/dist/quantization/binary-quantization.d.ts +104 -0
- package/dist/quantization/binary-quantization.d.ts.map +1 -0
- package/dist/quantization/binary-quantization.js +246 -0
- package/dist/quantization/binary-quantization.js.map +1 -0
- package/dist/quantization/binary-quantization.mjs +240 -0
- package/dist/quantization/optimized-pq.d.ts +138 -0
- package/dist/quantization/optimized-pq.d.ts.map +1 -0
- package/dist/quantization/optimized-pq.js +320 -0
- package/dist/quantization/optimized-pq.js.map +1 -0
- package/dist/quantization/optimized-pq.mjs +313 -0
- package/dist/quantization/product-quantization.d.ts +109 -0
- package/dist/quantization/product-quantization.d.ts.map +1 -0
- package/dist/quantization/product-quantization.js +287 -0
- package/dist/quantization/product-quantization.js.map +1 -0
- package/dist/quantization/product-quantization.mjs +282 -0
- package/dist/quantization/scalar-quantization.d.ts +100 -0
- package/dist/quantization/scalar-quantization.d.ts.map +1 -0
- package/dist/quantization/scalar-quantization.js +324 -0
- package/dist/quantization/scalar-quantization.js.map +1 -0
- package/dist/quantization/scalar-quantization.mjs +319 -0
- package/dist/query/index.d.ts +6 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +9 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/index.mjs +4 -0
- package/dist/query/query-builder.d.ts +323 -0
- package/dist/query/query-builder.d.ts.map +1 -0
- package/dist/query/query-builder.js +524 -0
- package/dist/query/query-builder.js.map +1 -0
- package/dist/query/query-builder.mjs +519 -0
- package/dist/reasoning/context-synthesizer.d.ts +57 -0
- package/dist/reasoning/context-synthesizer.d.ts.map +1 -0
- package/dist/reasoning/context-synthesizer.js +224 -0
- package/dist/reasoning/context-synthesizer.js.map +1 -0
- package/dist/reasoning/context-synthesizer.mjs +219 -0
- package/dist/reasoning/experience-curator.d.ts +66 -0
- package/dist/reasoning/experience-curator.d.ts.map +1 -0
- package/dist/reasoning/experience-curator.js +288 -0
- package/dist/reasoning/experience-curator.js.map +1 -0
- package/dist/reasoning/experience-curator.mjs +283 -0
- package/dist/reasoning/memory-optimizer.d.ts +69 -0
- package/dist/reasoning/memory-optimizer.d.ts.map +1 -0
- package/dist/reasoning/memory-optimizer.js +331 -0
- package/dist/reasoning/memory-optimizer.js.map +1 -0
- package/dist/reasoning/memory-optimizer.mjs +326 -0
- package/dist/reasoning/pattern-matcher.d.ts +59 -0
- package/dist/reasoning/pattern-matcher.d.ts.map +1 -0
- package/dist/reasoning/pattern-matcher.js +229 -0
- package/dist/reasoning/pattern-matcher.js.map +1 -0
- package/dist/reasoning/pattern-matcher.mjs +224 -0
- package/dist/reasoningbank/adapter/agentdb-adapter.d.ts +118 -0
- package/dist/reasoningbank/adapter/agentdb-adapter.d.ts.map +1 -0
- package/dist/reasoningbank/adapter/agentdb-adapter.js +477 -0
- package/dist/reasoningbank/adapter/agentdb-adapter.js.map +1 -0
- package/dist/reasoningbank/adapter/types.d.ts +113 -0
- package/dist/reasoningbank/adapter/types.d.ts.map +1 -0
- package/dist/reasoningbank/adapter/types.js +9 -0
- package/dist/reasoningbank/adapter/types.js.map +1 -0
- package/dist/reasoningbank/cli/commands.d.ts +16 -0
- package/dist/reasoningbank/cli/commands.d.ts.map +1 -0
- package/dist/reasoningbank/cli/commands.js +272 -0
- package/dist/reasoningbank/cli/commands.js.map +1 -0
- package/dist/reasoningbank/mcp/agentdb-tools.d.ts +319 -0
- package/dist/reasoningbank/mcp/agentdb-tools.d.ts.map +1 -0
- package/dist/reasoningbank/mcp/agentdb-tools.js +301 -0
- package/dist/reasoningbank/mcp/agentdb-tools.js.map +1 -0
- package/dist/reasoningbank/migration/migrate.d.ts +25 -0
- package/dist/reasoningbank/migration/migrate.d.ts.map +1 -0
- package/dist/reasoningbank/migration/migrate.js +178 -0
- package/dist/reasoningbank/migration/migrate.js.map +1 -0
- package/dist/reasoningbank/reasoning/context-synthesizer.d.ts +37 -0
- package/dist/reasoningbank/reasoning/context-synthesizer.d.ts.map +1 -0
- package/dist/reasoningbank/reasoning/context-synthesizer.js +114 -0
- package/dist/reasoningbank/reasoning/context-synthesizer.js.map +1 -0
- package/dist/reasoningbank/reasoning/experience-curator.d.ts +39 -0
- package/dist/reasoningbank/reasoning/experience-curator.d.ts.map +1 -0
- package/dist/reasoningbank/reasoning/experience-curator.js +98 -0
- package/dist/reasoningbank/reasoning/experience-curator.js.map +1 -0
- package/dist/reasoningbank/reasoning/memory-optimizer.d.ts +44 -0
- package/dist/reasoningbank/reasoning/memory-optimizer.d.ts.map +1 -0
- package/dist/reasoningbank/reasoning/memory-optimizer.js +184 -0
- package/dist/reasoningbank/reasoning/memory-optimizer.js.map +1 -0
- package/dist/reasoningbank/reasoning/pattern-matcher.d.ts +40 -0
- package/dist/reasoningbank/reasoning/pattern-matcher.d.ts.map +1 -0
- package/dist/reasoningbank/reasoning/pattern-matcher.js +87 -0
- package/dist/reasoningbank/reasoning/pattern-matcher.js.map +1 -0
- package/dist/reasoningbank/sync/quic-sync.d.ts +77 -0
- package/dist/reasoningbank/sync/quic-sync.d.ts.map +1 -0
- package/dist/reasoningbank/sync/quic-sync.js +165 -0
- package/dist/reasoningbank/sync/quic-sync.js.map +1 -0
- package/dist/sync/conflict.d.ts +78 -0
- package/dist/sync/conflict.d.ts.map +1 -0
- package/dist/sync/conflict.js +202 -0
- package/dist/sync/conflict.js.map +1 -0
- package/dist/sync/conflict.mjs +196 -0
- package/dist/sync/coordinator.d.ts +111 -0
- package/dist/sync/coordinator.d.ts.map +1 -0
- package/dist/sync/coordinator.js +256 -0
- package/dist/sync/coordinator.js.map +1 -0
- package/dist/sync/coordinator.mjs +250 -0
- package/dist/sync/delta.d.ts +81 -0
- package/dist/sync/delta.d.ts.map +1 -0
- package/dist/sync/delta.js +245 -0
- package/dist/sync/delta.js.map +1 -0
- package/dist/sync/delta.mjs +238 -0
- package/dist/sync/index.d.ts +11 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +22 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/index.mjs +9 -0
- package/dist/sync/quic-sync.d.ts +81 -0
- package/dist/sync/quic-sync.d.ts.map +1 -0
- package/dist/sync/quic-sync.js +329 -0
- package/dist/sync/quic-sync.js.map +1 -0
- package/dist/sync/quic-sync.mjs +323 -0
- package/dist/sync/types.d.ts +168 -0
- package/dist/sync/types.d.ts.map +1 -0
- package/dist/sync/types.js +8 -0
- package/dist/sync/types.js.map +1 -0
- package/dist/sync/types.mjs +6 -0
- package/dist/types/index.d.ts +117 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +4 -0
- package/dist/wasm-loader.d.ts +32 -0
- package/dist/wasm-loader.d.ts.map +1 -0
- package/dist/wasm-loader.js +75 -0
- package/dist/wasm-loader.js.map +1 -0
- package/dist/wasm-loader.mjs +64 -0
- package/examples/adaptive-learning.ts +284 -0
- package/examples/browser/README.md +732 -0
- package/examples/browser/adaptive-recommendations/index.html +427 -0
- package/examples/browser/collaborative-filtering/index.html +310 -0
- package/examples/browser/continual-learning/index.html +736 -0
- package/examples/browser/experience-replay/index.html +616 -0
- package/examples/browser/index.html +369 -0
- package/examples/browser/meta-learning/index.html +789 -0
- package/examples/browser/neuro-symbolic/index.html +692 -0
- package/examples/browser/pattern-learning/index.html +620 -0
- package/examples/browser/quantum-inspired/index.html +728 -0
- package/examples/browser/rag/index.html +624 -0
- package/examples/browser/swarm-intelligence/index.html +811 -0
- package/examples/browser-basic.html +170 -0
- package/examples/hnsw-example.ts +148 -0
- package/examples/node-basic.js +70 -0
- package/examples/quic-sync-example.ts +310 -0
- package/examples/quick-start.js +68 -0
- package/examples/wasm-example.ts +222 -0
- package/package.json +118 -0
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Adaptive Recommendations - AgentDB</title>
|
|
7
|
+
<style>
|
|
8
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
9
|
+
body {
|
|
10
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
11
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
12
|
+
min-height: 100vh;
|
|
13
|
+
padding: 2rem;
|
|
14
|
+
}
|
|
15
|
+
.container { max-width: 1200px; margin: 0 auto; }
|
|
16
|
+
header {
|
|
17
|
+
background: white;
|
|
18
|
+
border-radius: 12px;
|
|
19
|
+
padding: 2rem;
|
|
20
|
+
margin-bottom: 2rem;
|
|
21
|
+
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
22
|
+
}
|
|
23
|
+
h1 { color: #333; margin-bottom: 0.5rem; }
|
|
24
|
+
.subtitle { color: #666; }
|
|
25
|
+
.grid { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; }
|
|
26
|
+
.card {
|
|
27
|
+
background: white;
|
|
28
|
+
border-radius: 12px;
|
|
29
|
+
padding: 2rem;
|
|
30
|
+
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
31
|
+
}
|
|
32
|
+
.card h2 { color: #333; margin-bottom: 1rem; }
|
|
33
|
+
.content-card {
|
|
34
|
+
background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
|
|
35
|
+
border: 2px solid #e0e0e0;
|
|
36
|
+
border-radius: 8px;
|
|
37
|
+
padding: 1.5rem;
|
|
38
|
+
margin-bottom: 1rem;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
transition: all 0.2s ease;
|
|
41
|
+
}
|
|
42
|
+
.content-card:hover {
|
|
43
|
+
border-color: #667eea;
|
|
44
|
+
transform: translateY(-2px);
|
|
45
|
+
}
|
|
46
|
+
.content-card.shown { border-color: #28a745; background: #d4edda22; }
|
|
47
|
+
.content-header {
|
|
48
|
+
display: flex;
|
|
49
|
+
justify-content: space-between;
|
|
50
|
+
align-items: start;
|
|
51
|
+
margin-bottom: 0.75rem;
|
|
52
|
+
}
|
|
53
|
+
.content-title {
|
|
54
|
+
font-weight: 600;
|
|
55
|
+
color: #333;
|
|
56
|
+
font-size: 1.1rem;
|
|
57
|
+
}
|
|
58
|
+
.content-score {
|
|
59
|
+
background: #667eea;
|
|
60
|
+
color: white;
|
|
61
|
+
padding: 0.25rem 0.75rem;
|
|
62
|
+
border-radius: 12px;
|
|
63
|
+
font-size: 0.85rem;
|
|
64
|
+
font-weight: 600;
|
|
65
|
+
}
|
|
66
|
+
.content-description {
|
|
67
|
+
color: #666;
|
|
68
|
+
line-height: 1.6;
|
|
69
|
+
margin-bottom: 0.75rem;
|
|
70
|
+
}
|
|
71
|
+
.content-tags {
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-wrap: wrap;
|
|
74
|
+
gap: 0.5rem;
|
|
75
|
+
}
|
|
76
|
+
.tag {
|
|
77
|
+
background: #f0f0f0;
|
|
78
|
+
padding: 0.25rem 0.75rem;
|
|
79
|
+
border-radius: 12px;
|
|
80
|
+
font-size: 0.85rem;
|
|
81
|
+
color: #666;
|
|
82
|
+
}
|
|
83
|
+
.feedback-buttons {
|
|
84
|
+
display: flex;
|
|
85
|
+
gap: 0.5rem;
|
|
86
|
+
margin-top: 1rem;
|
|
87
|
+
}
|
|
88
|
+
.feedback-btn {
|
|
89
|
+
flex: 1;
|
|
90
|
+
padding: 0.5rem;
|
|
91
|
+
border: none;
|
|
92
|
+
border-radius: 6px;
|
|
93
|
+
font-weight: 600;
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
transition: all 0.2s ease;
|
|
96
|
+
}
|
|
97
|
+
.feedback-btn.like {
|
|
98
|
+
background: #28a745;
|
|
99
|
+
color: white;
|
|
100
|
+
}
|
|
101
|
+
.feedback-btn.dislike {
|
|
102
|
+
background: #dc3545;
|
|
103
|
+
color: white;
|
|
104
|
+
}
|
|
105
|
+
.feedback-btn:hover { opacity: 0.8; }
|
|
106
|
+
.stat-card {
|
|
107
|
+
background: #f8f9fa;
|
|
108
|
+
border-radius: 6px;
|
|
109
|
+
padding: 1rem;
|
|
110
|
+
margin-bottom: 0.5rem;
|
|
111
|
+
}
|
|
112
|
+
.stat-label { color: #666; font-size: 0.9rem; }
|
|
113
|
+
.stat-value {
|
|
114
|
+
color: #333;
|
|
115
|
+
font-size: 1.5rem;
|
|
116
|
+
font-weight: bold;
|
|
117
|
+
margin-top: 0.25rem;
|
|
118
|
+
}
|
|
119
|
+
.algorithm-info {
|
|
120
|
+
background: #e3f2fd;
|
|
121
|
+
border-left: 4px solid #2196f3;
|
|
122
|
+
padding: 1rem;
|
|
123
|
+
border-radius: 4px;
|
|
124
|
+
margin-top: 1rem;
|
|
125
|
+
}
|
|
126
|
+
.algorithm-info h3 {
|
|
127
|
+
color: #2196f3;
|
|
128
|
+
margin-bottom: 0.5rem;
|
|
129
|
+
font-size: 1rem;
|
|
130
|
+
}
|
|
131
|
+
.algorithm-info p {
|
|
132
|
+
color: #666;
|
|
133
|
+
font-size: 0.9rem;
|
|
134
|
+
line-height: 1.5;
|
|
135
|
+
}
|
|
136
|
+
.progress-indicator {
|
|
137
|
+
margin-top: 1rem;
|
|
138
|
+
}
|
|
139
|
+
.progress-label {
|
|
140
|
+
display: flex;
|
|
141
|
+
justify-content: space-between;
|
|
142
|
+
margin-bottom: 0.5rem;
|
|
143
|
+
font-size: 0.9rem;
|
|
144
|
+
color: #666;
|
|
145
|
+
}
|
|
146
|
+
.progress-bar {
|
|
147
|
+
width: 100%;
|
|
148
|
+
height: 8px;
|
|
149
|
+
background: #e0e0e0;
|
|
150
|
+
border-radius: 4px;
|
|
151
|
+
overflow: hidden;
|
|
152
|
+
}
|
|
153
|
+
.progress-fill {
|
|
154
|
+
height: 100%;
|
|
155
|
+
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
|
|
156
|
+
transition: width 0.3s ease;
|
|
157
|
+
}
|
|
158
|
+
</style>
|
|
159
|
+
</head>
|
|
160
|
+
<body>
|
|
161
|
+
<div class="container">
|
|
162
|
+
<header>
|
|
163
|
+
<h1>🎨 Adaptive Recommendation System</h1>
|
|
164
|
+
<p class="subtitle">Multi-Armed Bandit with Thompson Sampling - Real-time Learning</p>
|
|
165
|
+
</header>
|
|
166
|
+
|
|
167
|
+
<div class="grid">
|
|
168
|
+
<div class="card">
|
|
169
|
+
<h2>Content Feed</h2>
|
|
170
|
+
<p style="color: #666; margin-bottom: 1rem;">
|
|
171
|
+
Click on content to view. Like or dislike to help the system learn your preferences!
|
|
172
|
+
</p>
|
|
173
|
+
<div id="contentFeed"></div>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<div>
|
|
177
|
+
<div class="card" style="margin-bottom: 1rem;">
|
|
178
|
+
<h2>Learning Stats</h2>
|
|
179
|
+
|
|
180
|
+
<div class="stat-card">
|
|
181
|
+
<div class="stat-label">Content Viewed</div>
|
|
182
|
+
<div class="stat-value" id="viewedCount">0</div>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<div class="stat-card">
|
|
186
|
+
<div class="stat-label">Positive Feedback</div>
|
|
187
|
+
<div class="stat-value" id="likeCount">0</div>
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
<div class="stat-card">
|
|
191
|
+
<div class="stat-label">Learning Rate</div>
|
|
192
|
+
<div class="stat-value" id="learningRate">0%</div>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<div class="stat-card">
|
|
196
|
+
<div class="stat-label">Exploration Rate</div>
|
|
197
|
+
<div class="stat-value" id="exploreRate">50%</div>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<div class="card">
|
|
202
|
+
<h2>Category Preferences</h2>
|
|
203
|
+
<div id="categoryStats"></div>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
|
|
208
|
+
<div class="card" style="margin-top: 2rem;">
|
|
209
|
+
<h2>How It Works</h2>
|
|
210
|
+
<div class="algorithm-info">
|
|
211
|
+
<h3>🎰 Multi-Armed Bandit (Thompson Sampling)</h3>
|
|
212
|
+
<p>
|
|
213
|
+
This system uses Thompson Sampling to balance exploration (trying new content categories)
|
|
214
|
+
and exploitation (showing categories you've liked before). It maintains a Beta distribution
|
|
215
|
+
for each category and samples from it to decide what to recommend next. Your feedback
|
|
216
|
+
updates the distributions in real-time, making recommendations increasingly personalized.
|
|
217
|
+
</p>
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
|
|
222
|
+
<script type="module">
|
|
223
|
+
const CONTENT_POOL = [
|
|
224
|
+
{ id: 1, category: 'tech', title: 'Latest AI Breakthroughs', description: 'Discover cutting-edge developments in artificial intelligence', tags: ['AI', 'Research', 'Innovation'] },
|
|
225
|
+
{ id: 2, category: 'tech', title: 'Cloud Computing Guide', description: 'Complete guide to modern cloud architecture', tags: ['Cloud', 'DevOps', 'Architecture'] },
|
|
226
|
+
{ id: 3, category: 'tech', title: 'Quantum Computing 101', description: 'Introduction to quantum computing principles', tags: ['Quantum', 'Physics', 'Computing'] },
|
|
227
|
+
{ id: 4, category: 'business', title: 'Startup Success Stories', description: 'Learn from founders who built billion-dollar companies', tags: ['Startup', 'Entrepreneurship'] },
|
|
228
|
+
{ id: 5, category: 'business', title: 'Marketing Strategies 2024', description: 'Latest trends in digital marketing', tags: ['Marketing', 'Strategy', 'Growth'] },
|
|
229
|
+
{ id: 6, category: 'business', title: 'Leadership Best Practices', description: 'How to build and lead high-performing teams', tags: ['Leadership', 'Management'] },
|
|
230
|
+
{ id: 7, category: 'science', title: 'Space Exploration Update', description: 'Recent discoveries from Mars missions', tags: ['Space', 'Mars', 'Exploration'] },
|
|
231
|
+
{ id: 8, category: 'science', title: 'Climate Change Research', description: 'Latest findings on climate science', tags: ['Climate', 'Environment', 'Research'] },
|
|
232
|
+
{ id: 9, category: 'science', title: 'Neuroscience Insights', description: 'How the brain processes information', tags: ['Neuroscience', 'Brain', 'Psychology'] },
|
|
233
|
+
{ id: 10, category: 'lifestyle', title: 'Healthy Living Tips', description: 'Science-backed health and wellness advice', tags: ['Health', 'Wellness', 'Fitness'] },
|
|
234
|
+
{ id: 11, category: 'lifestyle', title: 'Travel Destinations 2024', description: 'Must-visit places around the world', tags: ['Travel', 'Adventure', 'Culture'] },
|
|
235
|
+
{ id: 12, category: 'lifestyle', title: 'Mindfulness Practices', description: 'Meditation and stress reduction techniques', tags: ['Mindfulness', 'Mental Health'] },
|
|
236
|
+
];
|
|
237
|
+
|
|
238
|
+
let viewedContent = new Set();
|
|
239
|
+
let categoryBandits = {
|
|
240
|
+
tech: { alpha: 1, beta: 1 },
|
|
241
|
+
business: { alpha: 1, beta: 1 },
|
|
242
|
+
science: { alpha: 1, beta: 1 },
|
|
243
|
+
lifestyle: { alpha: 1, beta: 1 }
|
|
244
|
+
};
|
|
245
|
+
let feedbackHistory = [];
|
|
246
|
+
|
|
247
|
+
function betaSample(alpha, beta) {
|
|
248
|
+
// Approximate Beta distribution sampling using gamma distributions
|
|
249
|
+
const x = gammaSample(alpha, 1);
|
|
250
|
+
const y = gammaSample(beta, 1);
|
|
251
|
+
return x / (x + y);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function gammaSample(shape, scale) {
|
|
255
|
+
// Marsaglia and Tsang method for gamma sampling
|
|
256
|
+
if (shape < 1) {
|
|
257
|
+
return gammaSample(shape + 1, scale) * Math.pow(Math.random(), 1 / shape);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const d = shape - 1/3;
|
|
261
|
+
const c = 1 / Math.sqrt(9 * d);
|
|
262
|
+
|
|
263
|
+
while (true) {
|
|
264
|
+
let x, v;
|
|
265
|
+
do {
|
|
266
|
+
x = normalSample(0, 1);
|
|
267
|
+
v = 1 + c * x;
|
|
268
|
+
} while (v <= 0);
|
|
269
|
+
|
|
270
|
+
v = v * v * v;
|
|
271
|
+
x = x * x;
|
|
272
|
+
const u = Math.random();
|
|
273
|
+
|
|
274
|
+
if (u < 1 - 0.0331 * x * x) {
|
|
275
|
+
return scale * d * v;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (Math.log(u) < 0.5 * x + d * (1 - v + Math.log(v))) {
|
|
279
|
+
return scale * d * v;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function normalSample(mean, variance) {
|
|
285
|
+
// Box-Muller transform
|
|
286
|
+
const u1 = Math.random();
|
|
287
|
+
const u2 = Math.random();
|
|
288
|
+
const z = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
|
|
289
|
+
return mean + Math.sqrt(variance) * z;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function selectCategory() {
|
|
293
|
+
const samples = {};
|
|
294
|
+
|
|
295
|
+
Object.entries(categoryBandits).forEach(([category, { alpha, beta }]) => {
|
|
296
|
+
samples[category] = betaSample(alpha, beta);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
return Object.entries(samples).reduce((a, b) => a[1] > b[1] ? a : b)[0];
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function getRandomContent(category) {
|
|
303
|
+
const available = CONTENT_POOL.filter(c => c.category === category && !viewedContent.has(c.id));
|
|
304
|
+
|
|
305
|
+
if (available.length === 0) {
|
|
306
|
+
viewedContent.clear();
|
|
307
|
+
return getRandomContent(category);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return available[Math.floor(Math.random() * available.length)];
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function renderFeed() {
|
|
314
|
+
const feed = document.getElementById('contentFeed');
|
|
315
|
+
const category = selectCategory();
|
|
316
|
+
const content = getRandomContent(category);
|
|
317
|
+
|
|
318
|
+
const card = document.createElement('div');
|
|
319
|
+
card.className = 'content-card';
|
|
320
|
+
card.innerHTML = `
|
|
321
|
+
<div class="content-header">
|
|
322
|
+
<div class="content-title">${content.title}</div>
|
|
323
|
+
<div class="content-score">${category}</div>
|
|
324
|
+
</div>
|
|
325
|
+
<div class="content-description">${content.description}</div>
|
|
326
|
+
<div class="content-tags">
|
|
327
|
+
${content.tags.map(tag => `<span class="tag">${tag}</span>`).join('')}
|
|
328
|
+
</div>
|
|
329
|
+
<div class="feedback-buttons">
|
|
330
|
+
<button class="feedback-btn like">👍 Like</button>
|
|
331
|
+
<button class="feedback-btn dislike">👎 Not Interested</button>
|
|
332
|
+
</div>
|
|
333
|
+
`;
|
|
334
|
+
|
|
335
|
+
card.querySelector('.like').addEventListener('click', (e) => {
|
|
336
|
+
e.stopPropagation();
|
|
337
|
+
handleFeedback(content, true);
|
|
338
|
+
card.classList.add('shown');
|
|
339
|
+
setTimeout(renderFeed, 500);
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
card.querySelector('.dislike').addEventListener('click', (e) => {
|
|
343
|
+
e.stopPropagation();
|
|
344
|
+
handleFeedback(content, false);
|
|
345
|
+
card.classList.add('shown');
|
|
346
|
+
setTimeout(renderFeed, 500);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
feed.insertBefore(card, feed.firstChild);
|
|
350
|
+
|
|
351
|
+
while (feed.children.length > 5) {
|
|
352
|
+
feed.removeChild(feed.lastChild);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
viewedContent.add(content.id);
|
|
356
|
+
updateStats();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function handleFeedback(content, liked) {
|
|
360
|
+
feedbackHistory.push({
|
|
361
|
+
content: content,
|
|
362
|
+
liked: liked,
|
|
363
|
+
timestamp: Date.now()
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
// Update bandit
|
|
367
|
+
if (liked) {
|
|
368
|
+
categoryBandits[content.category].alpha += 1;
|
|
369
|
+
} else {
|
|
370
|
+
categoryBandits[content.category].beta += 1;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
updateStats();
|
|
374
|
+
renderCategoryStats();
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function updateStats() {
|
|
378
|
+
document.getElementById('viewedCount').textContent = feedbackHistory.length;
|
|
379
|
+
|
|
380
|
+
const likes = feedbackHistory.filter(f => f.liked).length;
|
|
381
|
+
document.getElementById('likeCount').textContent = likes;
|
|
382
|
+
|
|
383
|
+
if (feedbackHistory.length > 0) {
|
|
384
|
+
const rate = (likes / feedbackHistory.length * 100).toFixed(0);
|
|
385
|
+
document.getElementById('learningRate').textContent = `${rate}%`;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Calculate exploration rate (entropy of category distribution)
|
|
389
|
+
const totalFeedback = Object.values(categoryBandits).reduce((sum, b) => sum + b.alpha + b.beta, 0);
|
|
390
|
+
const entropy = Object.values(categoryBandits).reduce((sum, b) => {
|
|
391
|
+
const prob = (b.alpha + b.beta) / totalFeedback;
|
|
392
|
+
return sum - (prob > 0 ? prob * Math.log2(prob) : 0);
|
|
393
|
+
}, 0);
|
|
394
|
+
const maxEntropy = Math.log2(Object.keys(categoryBandits).length);
|
|
395
|
+
const exploreRate = ((entropy / maxEntropy) * 100).toFixed(0);
|
|
396
|
+
document.getElementById('exploreRate').textContent = `${exploreRate}%`;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function renderCategoryStats() {
|
|
400
|
+
const container = document.getElementById('categoryStats');
|
|
401
|
+
|
|
402
|
+
container.innerHTML = Object.entries(categoryBandits)
|
|
403
|
+
.map(([category, { alpha, beta }]) => {
|
|
404
|
+
const total = alpha + beta;
|
|
405
|
+
const mean = alpha / total;
|
|
406
|
+
const percentage = (mean * 100).toFixed(0);
|
|
407
|
+
|
|
408
|
+
return `
|
|
409
|
+
<div class="progress-indicator">
|
|
410
|
+
<div class="progress-label">
|
|
411
|
+
<span>${category.charAt(0).toUpperCase() + category.slice(1)}</span>
|
|
412
|
+
<span>${percentage}%</span>
|
|
413
|
+
</div>
|
|
414
|
+
<div class="progress-bar">
|
|
415
|
+
<div class="progress-fill" style="width: ${percentage}%"></div>
|
|
416
|
+
</div>
|
|
417
|
+
</div>
|
|
418
|
+
`;
|
|
419
|
+
}).join('');
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// Initialize
|
|
423
|
+
renderFeed();
|
|
424
|
+
renderCategoryStats();
|
|
425
|
+
</script>
|
|
426
|
+
</body>
|
|
427
|
+
</html>
|