From 2ea2d17bca8eb1b5d0d89a9eec47388621bb3b28 Mon Sep 17 00:00:00 2001 From: Solaria Lumis Havens Date: Fri, 20 Feb 2026 05:37:16 +0000 Subject: [PATCH] feat: Flask-based API --- app.py | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 app.py diff --git a/app.py b/app.py new file mode 100644 index 0000000..88d9eab --- /dev/null +++ b/app.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 +"""BECOMINGONE Flask API.""" + +from flask import Flask, request, jsonify, render_template_string +from becomingone.llm_integrator import EmissaryLLM +import asyncio + +app = Flask(__name__) + +# Initialize models +MASTER = EmissaryLLM(model='llama3.1:8b') +EMISSARY = EmissaryLLM(model='deepseek-coder-v2:lite') + +HTML = ''' + + + BECOMINGONE + + + + +

🔗 BECOMINGONE

+

Master + Emissary = Unified

+ + +
+ + +''' + +@app.route('/') +def index(): + return render_template_string(HTML) + +@app.route('/health') +def health(): + return jsonify({'status': 'ok'}) + +@app.route('/api/chat', methods=['POST']) +def chat(): + data = request.json + prompt = data.get('prompt', 'Hello') + + # Run async in sync context + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + try: + m, e = loop.run_until_complete(asyncio.gather( + MASTER.respond(prompt), + EMISSARY.respond(prompt) + )) + return jsonify({ + 'master': {'response': m.get('response', '')[:500]}, + 'emissary': {'response': e.get('response', '')[:500]} + }) + except Exception as ex: + return jsonify({'error': str(ex)}) + finally: + loop.close() + +if __name__ == '__main__': + print("Starting BECOMINGONE on http://192.168.1.6:8001") + app.run(host='0.0.0.0', port=8001, debug=False, threaded=True)