ADD WELCOME MESSAGE
Browse files
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
|
|
| 1 |
from flask import Flask, request, Response, json
|
| 2 |
import requests
|
| 3 |
from uuid import uuid4
|
| 4 |
import time
|
| 5 |
-
|
| 6 |
app = Flask(__name__)
|
| 7 |
|
| 8 |
MODEL_MAPPING = {
|
|
@@ -132,6 +133,34 @@ def normal_response(question, session_id, messages, request_model, actual_model)
|
|
| 132 |
}
|
| 133 |
return response
|
| 134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
@app.route("/v1/chat/completions", methods=["POST"])
|
| 136 |
def chat_completions():
|
| 137 |
data = request.json
|
|
|
|
| 1 |
+
import datetime
|
| 2 |
from flask import Flask, request, Response, json
|
| 3 |
import requests
|
| 4 |
from uuid import uuid4
|
| 5 |
import time
|
| 6 |
+
import socket
|
| 7 |
app = Flask(__name__)
|
| 8 |
|
| 9 |
MODEL_MAPPING = {
|
|
|
|
| 133 |
}
|
| 134 |
return response
|
| 135 |
|
| 136 |
+
@app.get("/")
|
| 137 |
+
async def health_check():
|
| 138 |
+
return {
|
| 139 |
+
"health": "ok",
|
| 140 |
+
"timestamp": datetime.datetime.now().isoformat(),
|
| 141 |
+
"service": "AI API Forwarding Service",
|
| 142 |
+
"version": "1.0"
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
@app.get("/ip")
|
| 146 |
+
async def get_ip():
|
| 147 |
+
# Get internal IP
|
| 148 |
+
hostname = socket.gethostname()
|
| 149 |
+
internal_ip = socket.gethostbyname(hostname)
|
| 150 |
+
|
| 151 |
+
# Get external IP
|
| 152 |
+
try:
|
| 153 |
+
external_ip = requests.get('https://api.ipify.org').text
|
| 154 |
+
except:
|
| 155 |
+
external_ip = "Unable to fetch external IP"
|
| 156 |
+
|
| 157 |
+
return {
|
| 158 |
+
"hostname": hostname,
|
| 159 |
+
"internal_ip": internal_ip,
|
| 160 |
+
"external_ip": external_ip,
|
| 161 |
+
"timestamp": datetime.datetime.now().isoformat()
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
@app.route("/v1/chat/completions", methods=["POST"])
|
| 165 |
def chat_completions():
|
| 166 |
data = request.json
|