diff --git a/app.py b/app.py
index 88d9eab..0e7c101 100644
--- a/app.py
+++ b/app.py
@@ -1,15 +1,14 @@
#!/usr/bin/env python3
-"""BECOMINGONE Flask API."""
+"""BECOMINGONE Flask API - Sync version."""
+import requests
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')
+# Ollama endpoints
+MASTER_URL = "http://localhost:11434/api/chat"
+EMISSARY_URL = "http://localhost:11434/api/chat"
HTML = '''
@@ -44,8 +43,8 @@ HTML = '''
body: JSON.stringify({prompt: p})
});
const d = await r.json();
- let h = '
🧠Master
' + d.master.response + '
';
- h += 'âš¡ Emissary
' + d.emissary.response + '
';
+ let h = '🧠Master (llama3.1)
' + d.master.response + '
';
+ h += 'âš¡ Emissary (deepseek-coder)
' + d.emissary.response + '
';
document.getElementById('response').innerHTML = h;
} catch(e) {
document.getElementById('response').innerHTML = 'Error: ' + e + '
';
@@ -65,25 +64,34 @@ def health():
@app.route('/api/chat', methods=['POST'])
def chat():
- data = request.json
+ data = request.get_json(silent=True) or {}
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)
- ))
+ # Master (llama3.1)
+ master_resp = requests.post(MASTER_URL, json={
+ "model": "llama3.1:8b",
+ "messages": [{"role": "user", "content": prompt}],
+ "stream": False
+ }, timeout=60)
+ master_data = master_resp.json()
+ master_text = master_data.get("message", {}).get("content", str(master_data))[:500]
+
+ # Emissary (deepseek-coder)
+ emissary_resp = requests.post(EMISSARY_URL, json={
+ "model": "deepseek-coder-v2:lite",
+ "messages": [{"role": "user", "content": prompt}],
+ "stream": False
+ }, timeout=60)
+ emissary_data = emissary_resp.json()
+ emissary_text = emissary_data.get("message", {}).get("content", str(emissary_data))[:500]
+
return jsonify({
- 'master': {'response': m.get('response', '')[:500]},
- 'emissary': {'response': e.get('response', '')[:500]}
+ 'master': {'response': master_text},
+ 'emissary': {'response': emissary_text}
})
- except Exception as ex:
- return jsonify({'error': str(ex)})
- finally:
- loop.close()
+ except Exception as e:
+ return jsonify({'error': str(e)})
if __name__ == '__main__':
print("Starting BECOMINGONE on http://192.168.1.6:8001")