Spaces:
Runtime error
Runtime error
| from flask import Flask, request, jsonify | |
| import subprocess | |
| import json | |
| import os | |
| app = Flask(__name__) | |
| 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 | |
| def index(): | |
| return "Quant Signal LLM API is running." | |