Spaces:
Runtime error
Runtime error
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,58 +1,39 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import json
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
try:
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
"
|
| 18 |
-
|
| 19 |
-
"
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
result["tia"] = f"TIA error: {e}"
|
| 28 |
-
|
| 29 |
-
if PrimeSchema:
|
| 30 |
-
try:
|
| 31 |
-
result["lineage"] = PrimeSchema().summarize()
|
| 32 |
-
except Exception as e:
|
| 33 |
-
result["lineage"] = f"Lineage error: {e}"
|
| 34 |
-
|
| 35 |
-
return json.dumps(result, indent=2)
|
| 36 |
-
|
| 37 |
-
with gr.Blocks(css="body { background: black; color: cyan; }") as app:
|
| 38 |
-
gr.Markdown("# **QGTNL Command Centre**")
|
| 39 |
-
gr.Markdown("### Citadel • TIA • AION • ORACLE • Holo3D")
|
| 40 |
-
|
| 41 |
-
with gr.Row():
|
| 42 |
-
cmd = gr.Textbox(label="Command Input")
|
| 43 |
-
out = gr.Code(label="System Output")
|
| 44 |
-
|
| 45 |
-
run = gr.Button("Execute")
|
| 46 |
-
run.click(qgtnl_process, cmd, out)
|
| 47 |
-
|
| 48 |
-
gr.Markdown("---")
|
| 49 |
-
gr.Markdown("### Holo3D UI (if available)")
|
| 50 |
-
|
| 51 |
-
if HoloCommandCentre:
|
| 52 |
-
try:
|
| 53 |
-
html = HoloCommandCentre().render()
|
| 54 |
-
gr.HTML(html)
|
| 55 |
-
except:
|
| 56 |
-
gr.Markdown("Holo3D failed to load.")
|
| 57 |
-
|
| 58 |
-
app.launch()
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
import os, json
|
| 3 |
+
from flask import Flask, request, jsonify
|
| 4 |
+
from huggingface_hub import HfApi
|
| 5 |
+
|
| 6 |
+
app = Flask(__name__)
|
| 7 |
+
# Securely pulling the token from the Space's settings
|
| 8 |
+
TOKEN = os.getenv("HF_TOKEN")
|
| 9 |
+
VAULT_ID = "DJ-Goanna-Coding/TIA-storage"
|
| 10 |
+
api = HfApi(token=TOKEN)
|
| 11 |
+
|
| 12 |
+
@app.route('/ignite_harvest', methods=['POST'])
|
| 13 |
+
@app.route('/ingest', methods=['POST'])
|
| 14 |
+
def catch_payload():
|
| 15 |
+
if not TOKEN:
|
| 16 |
+
return jsonify({"status": "ERROR", "message": "HF_TOKEN secret is missing in Space settings"}), 500
|
| 17 |
+
|
| 18 |
try:
|
| 19 |
+
payload = request.json
|
| 20 |
+
filename = payload.get("fileName", "unknown_shard.9293")
|
| 21 |
+
content = payload.get("content", "")
|
| 22 |
+
|
| 23 |
+
# Save the incoming lightweight text directly to the HF Dataset
|
| 24 |
+
api.upload_file(
|
| 25 |
+
path_or_fileobj=content.encode('utf-8'),
|
| 26 |
+
path_in_repo=f"ingested_core/{filename}",
|
| 27 |
+
repo_id=VAULT_ID,
|
| 28 |
+
repo_type="dataset"
|
| 29 |
+
)
|
| 30 |
+
return jsonify({"status": "CAUGHT_AND_STORED", "file": filename}), 200
|
| 31 |
+
except Exception as e:
|
| 32 |
+
return jsonify({"status": "ERROR", "message": str(e)}), 500
|
| 33 |
+
|
| 34 |
+
@app.route('/', methods=['GET'])
|
| 35 |
+
def health_check():
|
| 36 |
+
return jsonify({"status": "SOVEREIGN_NODE_ONLINE", "vault": "TIA-storage"})
|
| 37 |
+
|
| 38 |
+
if __name__ == "__main__":
|
| 39 |
+
app.run(host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|