Spaces:
Running
Running
tmgdlof commited on
Commit ·
214a88e
1
Parent(s): 7f79979
Migrate storage and database architecture to Hugging Face datasets and SQLite
Browse filesReplace Puter.js and Replit database with Hugging Face datasets and a local SQLite database for improved performance and persistence.
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 11305e0b-1f7f-4c74-8f4e-3202abfc6ecc
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: bcb07661-b402-4e57-b081-c86f15ec0c12
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6bad4f2d-41a1-4455-a72d-85e59438c6af/11305e0b-1f7f-4c74-8f4e-3202abfc6ecc/Nb3xGTK
Replit-Helium-Checkpoint-Created: true
- app.py +1 -7
- assistant.html +1 -1
- dev-assistant.html +1 -1
- hf_storage.py +1 -6
- index.html +1 -1
- recorder.html +1 -1
- static/lunos-storage.js +0 -17
- sudoku.html +1 -1
app.py
CHANGED
|
@@ -16,13 +16,7 @@ app = Flask(__name__, static_folder='.', static_url_path='')
|
|
| 16 |
app.secret_key = os.environ.get("SESSION_SECRET", "huggingface_default_session_secret_98765")
|
| 17 |
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
|
| 18 |
|
| 19 |
-
app.config["SQLALCHEMY_DATABASE_URI"] =
|
| 20 |
-
# Only fix protocol if it's not a local hostname like 'helium'
|
| 21 |
-
if app.config["SQLALCHEMY_DATABASE_URI"].startswith("postgres://") and "helium" not in app.config["SQLALCHEMY_DATABASE_URI"]:
|
| 22 |
-
app.config["SQLALCHEMY_DATABASE_URI"] = app.config["SQLALCHEMY_DATABASE_URI"].replace("postgres://", "postgresql://", 1)
|
| 23 |
-
# If it is a local replit hostname (helium) and we are not on Replit, fallback to sqlite
|
| 24 |
-
elif "helium" in app.config["SQLALCHEMY_DATABASE_URI"] and os.environ.get("REPL_ID") is None:
|
| 25 |
-
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///lunos.db"
|
| 26 |
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
| 27 |
|
| 28 |
app.config["SESSION_COOKIE_SAMESITE"] = "None"
|
|
|
|
| 16 |
app.secret_key = os.environ.get("SESSION_SECRET", "huggingface_default_session_secret_98765")
|
| 17 |
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
|
| 18 |
|
| 19 |
+
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///lunos.db"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
| 21 |
|
| 22 |
app.config["SESSION_COOKIE_SAMESITE"] = "None"
|
assistant.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>FynNX Assistant - Your AI Helper</title>
|
| 7 |
-
|
| 8 |
<style>
|
| 9 |
* {
|
| 10 |
margin: 0;
|
|
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>FynNX Assistant - Your AI Helper</title>
|
| 7 |
+
|
| 8 |
<style>
|
| 9 |
* {
|
| 10 |
margin: 0;
|
dev-assistant.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>LunAI Developer Console</title>
|
| 7 |
-
|
| 8 |
<script src="/static/lunid-auth.js"></script>
|
| 9 |
<style>
|
| 10 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>LunAI Developer Console</title>
|
| 7 |
+
|
| 8 |
<script src="/static/lunid-auth.js"></script>
|
| 9 |
<style>
|
| 10 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
hf_storage.py
CHANGED
|
@@ -13,12 +13,7 @@ logger = logging.getLogger(__name__)
|
|
| 13 |
class HFDatasetStorage:
|
| 14 |
def __init__(self):
|
| 15 |
self.token = os.environ.get("HF_TOKEN")
|
| 16 |
-
dataset_id =
|
| 17 |
-
|
| 18 |
-
# Clean the dataset ID if a full URL was pasted by mistake
|
| 19 |
-
if dataset_id and "huggingface.co/datasets/" in dataset_id:
|
| 20 |
-
dataset_id = dataset_id.split("huggingface.co/datasets/")[-1].split("?")[0].strip("/")
|
| 21 |
-
|
| 22 |
self.repo_id = dataset_id
|
| 23 |
self.api = HfApi()
|
| 24 |
|
|
|
|
| 13 |
class HFDatasetStorage:
|
| 14 |
def __init__(self):
|
| 15 |
self.token = os.environ.get("HF_TOKEN")
|
| 16 |
+
dataset_id = "Sachin5112/cachegah67hs627bhih6262772"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
self.repo_id = dataset_id
|
| 18 |
self.api = HfApi()
|
| 19 |
|
index.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
| 12 |
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
| 13 |
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
| 14 |
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
| 15 |
-
|
| 16 |
<script src="/static/lunid-auth.js"></script>
|
| 17 |
<script src="/static/lunos-storage.js"></script>
|
| 18 |
<script>
|
|
|
|
| 12 |
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
| 13 |
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
| 14 |
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
| 15 |
+
|
| 16 |
<script src="/static/lunid-auth.js"></script>
|
| 17 |
<script src="/static/lunos-storage.js"></script>
|
| 18 |
<script>
|
recorder.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 6 |
<title>Recorder - LunOS</title>
|
| 7 |
-
|
| 8 |
<style>
|
| 9 |
* {
|
| 10 |
margin: 0;
|
|
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 6 |
<title>Recorder - LunOS</title>
|
| 7 |
+
|
| 8 |
<style>
|
| 9 |
* {
|
| 10 |
margin: 0;
|
static/lunos-storage.js
CHANGED
|
@@ -28,12 +28,6 @@ class LunOSStorage {
|
|
| 28 |
}
|
| 29 |
|
| 30 |
async detectProviders() {
|
| 31 |
-
this.puterAvailable = await this.checkPuter();
|
| 32 |
-
if (this.puterAvailable) {
|
| 33 |
-
this.storageProvider = 'puter';
|
| 34 |
-
return;
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
this.supabaseAvailable = await this.checkSupabase();
|
| 38 |
if (this.supabaseAvailable) {
|
| 39 |
this.storageProvider = 'supabase';
|
|
@@ -44,17 +38,6 @@ class LunOSStorage {
|
|
| 44 |
}
|
| 45 |
|
| 46 |
async checkPuter() {
|
| 47 |
-
try {
|
| 48 |
-
if (typeof puter !== 'undefined' && puter.kv) {
|
| 49 |
-
const testKey = '__lunos_puter_test__';
|
| 50 |
-
await puter.kv.set(testKey, 'test');
|
| 51 |
-
await puter.kv.del(testKey);
|
| 52 |
-
console.log('[LunOS Storage] Puter.js KV available');
|
| 53 |
-
return true;
|
| 54 |
-
}
|
| 55 |
-
} catch (e) {
|
| 56 |
-
console.log('[LunOS Storage] Puter.js not available:', e.message);
|
| 57 |
-
}
|
| 58 |
return false;
|
| 59 |
}
|
| 60 |
|
|
|
|
| 28 |
}
|
| 29 |
|
| 30 |
async detectProviders() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
this.supabaseAvailable = await this.checkSupabase();
|
| 32 |
if (this.supabaseAvailable) {
|
| 33 |
this.storageProvider = 'supabase';
|
|
|
|
| 38 |
}
|
| 39 |
|
| 40 |
async checkPuter() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
return false;
|
| 42 |
}
|
| 43 |
|
sudoku.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
<meta charset="utf-8">
|
| 6 |
<meta name="viewport" content="width=device-width,initial-scale=1">
|
| 7 |
<title>Pro Sudoku</title>
|
| 8 |
-
|
| 9 |
<script src="/static/lunid-auth.js"></script>
|
| 10 |
<script src="/static/lunos-storage.js"></script>
|
| 11 |
<style>
|
|
|
|
| 5 |
<meta charset="utf-8">
|
| 6 |
<meta name="viewport" content="width=device-width,initial-scale=1">
|
| 7 |
<title>Pro Sudoku</title>
|
| 8 |
+
|
| 9 |
<script src="/static/lunid-auth.js"></script>
|
| 10 |
<script src="/static/lunos-storage.js"></script>
|
| 11 |
<style>
|