FerrellSyntheticIntelligence commited on
Commit
2f46672
·
1 Parent(s): a35e5e0

feat: implement runtime hot-ingestion API endpoint to bypass engine downtime

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py CHANGED
@@ -5,6 +5,7 @@ from flask import Flask, request, jsonify, render_template_string
5
 
6
  sys.path.append(os.path.dirname(os.path.abspath(__file__)))
7
  from src.core.retrieval_engine import LocalRetrievalEngine
 
8
  from brain import get_ripple_payload
9
 
10
  app = Flask(__name__)
@@ -33,6 +34,36 @@ def ripple():
33
  except Exception as e:
34
  return jsonify({"error": f"Internal cognitive pipeline exception: {str(e)}"}), 500
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  @app.route('/api/query', methods=['POST'])
37
  def semantic_query():
38
  data = request.get_json() or {}
@@ -49,5 +80,6 @@ def semantic_query():
49
  return jsonify({"error": f"Retrieval execution failure: {str(e)}"}), 500
50
 
51
  if __name__ == '__main__':
 
52
  print("[*] Secure Sovereign UI Gateway staging on http://127.0.0.1:5000")
53
  app.run(host='127.0.0.1', port=5000, debug=False)
 
5
 
6
  sys.path.append(os.path.dirname(os.path.abspath(__file__)))
7
  from src.core.retrieval_engine import LocalRetrievalEngine
8
+ from src.core.memory_engine import MemoryEngine
9
  from brain import get_ripple_payload
10
 
11
  app = Flask(__name__)
 
34
  except Exception as e:
35
  return jsonify({"error": f"Internal cognitive pipeline exception: {str(e)}"}), 500
36
 
37
+ @app.route('/api/ingest', methods=['POST'])
38
+ def hot_ingest():
39
+ """Triggers an online recompilation of local files into vector storage without downtime."""
40
+ data = request.get_json(force=True) or {}
41
+ target_dir = data.get("directory", "storage/knowledge")
42
+
43
+ try:
44
+ print(f"[*] Hot Ingestion triggered via API for target: {target_dir}")
45
+ ingestor = MemoryEngine()
46
+ ingestor.ingest_knowledge(target_dir)
47
+
48
+ # Verify the file generation parameters
49
+ base_path = os.path.join(os.getcwd(), target_dir)
50
+ manifest_path = os.path.join(base_path, "chunks_manifest.json")
51
+
52
+ if os.path.exists(manifest_path):
53
+ with open(manifest_path, 'r') as f:
54
+ nodes_count = len(json.load(f))
55
+ else:
56
+ nodes_count = 0
57
+
58
+ return jsonify({
59
+ "status": "SUCCESS",
60
+ "msg": "Sovereign knowledge matrix re-compiled successfully.",
61
+ "active_nodes": nodes_count,
62
+ "timestamp": time.time()
63
+ })
64
+ except Exception as e:
65
+ return jsonify({"error": f"Dynamic hot-ingestion compilation failure: {str(e)}"}), 500
66
+
67
  @app.route('/api/query', methods=['POST'])
68
  def semantic_query():
69
  data = request.get_json() or {}
 
80
  return jsonify({"error": f"Retrieval execution failure: {str(e)}"}), 500
81
 
82
  if __name__ == '__main__':
83
+ import json # Localized import shield for verification tracking inside block
84
  print("[*] Secure Sovereign UI Gateway staging on http://127.0.0.1:5000")
85
  app.run(host='127.0.0.1', port=5000, debug=False)