Spaces:
Runtime error
Runtime error
Download app/main.py from justperquant/docker-quant-llm: direct link, hf CLI and curl.
- Browser
- Download file 736 Bytes
-
https://huggingface.co/spaces/justperquant/docker-quant-llm/resolve/main/app/main.py
- Command line
-
hf download hf://spaces/justperquant/docker-quant-llm/app/main.py
-
curl -L -o main.py https://huggingface.co/spaces/justperquant/docker-quant-llm/resolve/main/app/main.py
736 Bytes
| 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." | |