Spaces:
Runtime error
Runtime error
File size: 736 Bytes
92c83f8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | from flask import Flask, request, jsonify
import subprocess
import json
import os
app = Flask(__name__)
@app.route("/analyze", methods=["POST"])
def analyze_signal():
data = request.get_json()
prompt = f"Analyze this trading signal:\n\n{json.dumps(data, indent=2)}"
try:
result = subprocess.run(
["ollama", "run", "llama3", prompt],
capture_output=True,
text=True,
timeout=60
)
return jsonify({
"success": True,
"response": result.stdout.strip()
})
except Exception as e:
return jsonify({"success": False, "error": str(e)}), 500
@app.route("/")
def index():
return "Quant Signal LLM API is running."
|