Fix: Restore missing
Browse files- freeapis-proxy/requirements.txt +3 -0
- freeapis-proxy/server.py +33 -0
freeapis-proxy/requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flask
|
| 2 |
+
requests
|
| 3 |
+
g4f
|
freeapis-proxy/server.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify
|
| 2 |
+
import os
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
app = Flask(__name__)
|
| 6 |
+
logging.basicConfig(level=logging.DEBUG)
|
| 7 |
+
|
| 8 |
+
@app.route('/health', methods=['GET'])
|
| 9 |
+
def health():
|
| 10 |
+
return jsonify({"status": "ok", "service": "freeapis-proxy"})
|
| 11 |
+
|
| 12 |
+
@app.route('/v1/chat/completions', methods=['POST'])
|
| 13 |
+
def chat_completions():
|
| 14 |
+
# Placeholder for actual g4f/freeapis integration
|
| 15 |
+
return jsonify({
|
| 16 |
+
"id": "chatcmpl-freeapis",
|
| 17 |
+
"object": "chat.completion",
|
| 18 |
+
"created": 1234567890,
|
| 19 |
+
"model": "gpt-3.5-turbo",
|
| 20 |
+
"choices": [{
|
| 21 |
+
"index": 0,
|
| 22 |
+
"message": {
|
| 23 |
+
"role": "assistant",
|
| 24 |
+
"content": "This is a response from the Free APIs Proxy (Placeholder)."
|
| 25 |
+
},
|
| 26 |
+
"finish_reason": "stop"
|
| 27 |
+
}]
|
| 28 |
+
})
|
| 29 |
+
|
| 30 |
+
if __name__ == '__main__':
|
| 31 |
+
# Ignore 'PORT' env var to avoid conflict with HF Space default (7860)
|
| 32 |
+
port = int(os.environ.get("FREEAPIS_PORT", 5001))
|
| 33 |
+
app.run(host='0.0.0.0', port=port)
|