61 lines
1.6 KiB
Python
61 lines
1.6 KiB
Python
from flask import Flask, render_template_string
|
|
from datetime import datetime
|
|
import os
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
@app.route("/")
|
|
def home():
|
|
dreams = []
|
|
if os.path.exists("logs/dreams.log"):
|
|
with open("logs/dreams.log", encoding="utf-8") as f:
|
|
dreams = [line.strip() for line in f.readlines()[-10:]]
|
|
|
|
messages = []
|
|
if os.path.exists("logs/messages.log"):
|
|
with open("logs/messages.log", encoding="utf-8") as f:
|
|
messages = [line.strip() for line in f.readlines()[-10:]]
|
|
|
|
vocab_size = 0
|
|
if os.path.exists("tokenizer_vocab.txt"):
|
|
with open("tokenizer_vocab.txt", encoding="utf-8") as f:
|
|
vocab_size = sum(1 for _ in f)
|
|
|
|
return render_template_string("""
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Ruby Dashboard</title>
|
|
<meta http-equiv="refresh" content="5">
|
|
<style>
|
|
body { background: #121212; color: #eee; font-family: sans-serif; padding: 20px; }
|
|
h1, h3 { color: #e48bf8; }
|
|
li { margin-bottom: 4px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>🌸 Ruby's Dashboard</h1>
|
|
<p><b>Vocabulary Size:</b> {{ vocab_size }}</p>
|
|
|
|
<h3>🧠 Recent Daydreams</h3>
|
|
<ul>
|
|
{% for dream in dreams %}
|
|
<li>{{ dream }}</li>
|
|
{% endfor %}
|
|
</ul>
|
|
|
|
<h3>📨 Recent Messages</h3>
|
|
<ul>
|
|
{% for msg in messages %}
|
|
<li>{{ msg }}</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</body>
|
|
</html>
|
|
""", dreams=dreams[::-1], messages=messages[::-1], vocab_size=vocab_size)
|
|
|
|
|
|
def start_dashboard():
|
|
app.run(debug=False, host="0.0.0.0", port=5000)
|