Update app.py
Browse files
app.py
CHANGED
|
@@ -3,11 +3,27 @@
|
|
| 3 |
# gr.load("models/Qwen/QwQ-32B-Preview").launch()
|
| 4 |
|
| 5 |
|
| 6 |
-
import
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
# Pass the API key to authenticate
|
| 12 |
-
interface = gr.load("models/Qwen/QwQ-32B-Preview", api_key=api_key)
|
| 13 |
-
interface.launch()
|
|
|
|
| 3 |
# gr.load("models/Qwen/QwQ-32B-Preview").launch()
|
| 4 |
|
| 5 |
|
| 6 |
+
from flask import Flask, request, jsonify
|
| 7 |
+
import requests
|
| 8 |
+
import os
|
| 9 |
+
from dotenv import load_dotenv
|
| 10 |
|
| 11 |
+
# Load environment variables
|
| 12 |
+
load_dotenv()
|
| 13 |
+
|
| 14 |
+
app = Flask(__name__)
|
| 15 |
+
HUGGINGFACE_API_URL = "https://api-inference.huggingface.co/models/Qwen/QwQ-32B-Preview"
|
| 16 |
+
API_KEY = os.getenv("HUGGINGFACE_API_KEY")
|
| 17 |
+
|
| 18 |
+
@app.route('/predict', methods=['POST'])
|
| 19 |
+
def predict():
|
| 20 |
+
user_input = request.json.get('input')
|
| 21 |
+
headers = {"Authorization": f"Bearer {API_KEY}"}
|
| 22 |
+
payload = {"inputs": user_input}
|
| 23 |
+
|
| 24 |
+
response = requests.post(HUGGINGFACE_API_URL, headers=headers, json=payload)
|
| 25 |
+
return jsonify(response.json())
|
| 26 |
+
|
| 27 |
+
if __name__ == '__main__':
|
| 28 |
+
app.run(debug=True)
|
| 29 |
|
|
|
|
|
|
|
|
|