From f21e9b433ef92fd29962ead31e9db923495fdd27 Mon Sep 17 00:00:00 2001 From: Dani Date: Fri, 25 Apr 2025 23:26:49 -0400 Subject: [PATCH] Added new growth and dreams trackers --- dashboard/dashboard.py | 38 +++++++++++++++++---- dashboard/templates/brainmap.html | 2 ++ dashboard/templates/concepts.html | 2 ++ dashboard/templates/dreams.html | 55 +++++++++++++++++++++++++++++++ dashboard/templates/growth.html | 50 ++++++++++++++++++++++++++++ dashboard/templates/index.html | 15 ++++++--- dashboard/templates/journal.html | 2 ++ model/brain.py | 1 + model/trainer.py | 1 + 9 files changed, 155 insertions(+), 11 deletions(-) create mode 100644 dashboard/templates/dreams.html create mode 100644 dashboard/templates/growth.html diff --git a/dashboard/dashboard.py b/dashboard/dashboard.py index c233b87..8884fe0 100644 --- a/dashboard/dashboard.py +++ b/dashboard/dashboard.py @@ -4,6 +4,7 @@ from model.journal import read_journal_entries from model.memory import load_dreams from model.tokenizer import Tokenizer from model.abstraction import cluster_vocab +from model.memory import load_dreams from context.context import load_context import json import os @@ -45,21 +46,39 @@ def index(): next_cycle=remaining) +@app.route("/growth") +def growth(): + vocab_size = len(tokenizer.vocab) + brainmap_size = len(get_brainmap()) + memory_size = len(load_context()) + return render_template("growth.html", + vocab_size=vocab_size, + brainmap_size=brainmap_size, + memory_size=memory_size) + + @app.route("/brainmap") def brainmap(): map_data = get_brainmap() nodes = [] links = [] + MIN_LINK_WEIGHT = 2 # only show links seen at least 2 times + seen_words = set() for word, connections in map_data.items(): - nodes.append({"id": word}) for linked_word, weight in connections.items(): - links.append({ - "source": word, - "target": linked_word, - "value": weight - }) + if weight >= MIN_LINK_WEIGHT: + links.append({ + "source": word, + "target": linked_word, + "value": weight + }) + seen_words.add(word) + seen_words.add(linked_word) + + for word in seen_words: + nodes.append({"id": word}) return render_template("brainmap.html", nodes=json.dumps(nodes), links=json.dumps(links)) @@ -76,5 +95,12 @@ def concepts(): return render_template("concepts.html", clusters=clusters) +@app.route("/dreams") +def dreams(): + dreams = load_dreams() + recent = dreams[-20:][::-1] # Last 20 dreams, newest first + return render_template("dreams.html", dreams=recent) + + def run_dashboard(): app.run(host="0.0.0.0", port=5000, debug=False, use_reloader=False) diff --git a/dashboard/templates/brainmap.html b/dashboard/templates/brainmap.html index 0e201e1..5c6fba7 100644 --- a/dashboard/templates/brainmap.html +++ b/dashboard/templates/brainmap.html @@ -38,6 +38,8 @@ πŸ““ Journal 🧠 Concepts πŸ•ΈοΈ Brain Map + πŸ“ˆ Growth + πŸŒƒ Dreams
diff --git a/dashboard/templates/concepts.html b/dashboard/templates/concepts.html index 419a9a4..0698de5 100644 --- a/dashboard/templates/concepts.html +++ b/dashboard/templates/concepts.html @@ -46,6 +46,8 @@ πŸ““ Journal 🧠 Concepts πŸ•ΈοΈ Brain Map + πŸ“ˆ Growth + πŸŒƒ Dreams

🧠 Ruby's Concept Clusters

diff --git a/dashboard/templates/dreams.html b/dashboard/templates/dreams.html new file mode 100644 index 0000000..bb8e9c7 --- /dev/null +++ b/dashboard/templates/dreams.html @@ -0,0 +1,55 @@ + + + + + Ruby's Dream Stream + + + + + + + +

πŸ’¬ Ruby's Dream Stream

+ +{% for dream in dreams %} +
+ Score: {{ dream.score }}
+ {{ dream.sentence }} +
+{% endfor %} + + + diff --git a/dashboard/templates/growth.html b/dashboard/templates/growth.html new file mode 100644 index 0000000..c644dcf --- /dev/null +++ b/dashboard/templates/growth.html @@ -0,0 +1,50 @@ + + + + + Ruby's Brain Growth + + + + + + +

πŸ“ˆ Ruby's Brain Growth

+ +
Vocabulary Size: {{ vocab_size }}
+
Brain Map Size: {{ brainmap_size }}
+
Memory Entries: {{ memory_size }}
+ + + diff --git a/dashboard/templates/index.html b/dashboard/templates/index.html index f35a875..36f2a93 100644 --- a/dashboard/templates/index.html +++ b/dashboard/templates/index.html @@ -30,12 +30,17 @@ -
- 🏠 Home - πŸ““ Journal - 🧠 Concepts - πŸ•ΈοΈ Brain Map + + + +

Ruby is Running 🧠

diff --git a/dashboard/templates/journal.html b/dashboard/templates/journal.html index edf9e53..a2e6720 100644 --- a/dashboard/templates/journal.html +++ b/dashboard/templates/journal.html @@ -38,6 +38,8 @@ πŸ““ Journal 🧠 Concepts πŸ•ΈοΈ Brain Map + πŸ“ˆ Growth + πŸŒƒ Dreams

πŸ““ Ruby's Journal

diff --git a/model/brain.py b/model/brain.py index 936d4ac..0d8ecf6 100644 --- a/model/brain.py +++ b/model/brain.py @@ -16,6 +16,7 @@ def generate_response(): seed_tokens = tokenizer.tokenize(start) if seed_tokens: seed = torch.tensor([seed_tokens[-1]], device=DEVICE).unsqueeze(0) + seed = seed[:, -128:] else: seed = torch.tensor([random.randint(0, tokenizer.next_id - 1)], device=DEVICE).unsqueeze(0) else: diff --git a/model/trainer.py b/model/trainer.py index 91f51b6..22e6623 100644 --- a/model/trainer.py +++ b/model/trainer.py @@ -23,6 +23,7 @@ def train_on_message(text: str): if len(tokens) < 2: return + tokens = tokens[:128] words = tokenizer.detokenize(tokens).split() update_brainmap(words) input_tensor = torch.tensor(tokens[:-1], dtype=torch.long, device=DEVICE).unsqueeze(0)