Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,7 @@ API_ENDPOINT = "https://api-st.siliconflow.cn/v1/user/info"
|
|
25 |
TEST_MODEL_ENDPOINT = "https://api-st.siliconflow.cn/v1/chat/completions"
|
26 |
MODELS_ENDPOINT = "https://api-st.siliconflow.cn/v1/models"
|
27 |
EMBEDDINGS_ENDPOINT = "https://api-st.siliconflow.cn/v1/embeddings"
|
|
|
28 |
|
29 |
app = Flask(__name__)
|
30 |
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1)
|
@@ -534,6 +535,8 @@ def handsome_embeddings():
|
|
534 |
data = request.get_json()
|
535 |
if not data or 'model' not in data:
|
536 |
return jsonify({"error": "Invalid request data"}), 400
|
|
|
|
|
537 |
|
538 |
model_name = data['model']
|
539 |
request_type = determine_request_type(
|
@@ -613,6 +616,8 @@ def handsome_images_generations():
|
|
613 |
data = request.get_json()
|
614 |
if not data or 'model' not in data:
|
615 |
return jsonify({"error": "Invalid request data"}), 400
|
|
|
|
|
616 |
|
617 |
model_name = data.get('model')
|
618 |
|
@@ -701,7 +706,7 @@ def handsome_images_generations():
|
|
701 |
try:
|
702 |
start_time = time.time()
|
703 |
response = requests.post(
|
704 |
-
|
705 |
headers=headers,
|
706 |
json=siliconflow_data,
|
707 |
timeout=120
|
@@ -904,7 +909,7 @@ def handsome_chat_completions():
|
|
904 |
try:
|
905 |
start_time = time.time()
|
906 |
response = requests.post(
|
907 |
-
|
908 |
headers=headers,
|
909 |
json=siliconflow_data,
|
910 |
timeout=120,
|
|
|
25 |
TEST_MODEL_ENDPOINT = "https://api-st.siliconflow.cn/v1/chat/completions"
|
26 |
MODELS_ENDPOINT = "https://api-st.siliconflow.cn/v1/models"
|
27 |
EMBEDDINGS_ENDPOINT = "https://api-st.siliconflow.cn/v1/embeddings"
|
28 |
+
IMAGE_ENDPOINT = "https://api-st.siliconflow.cn/v1/images/generations"
|
29 |
|
30 |
app = Flask(__name__)
|
31 |
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1)
|
|
|
535 |
data = request.get_json()
|
536 |
if not data or 'model' not in data:
|
537 |
return jsonify({"error": "Invalid request data"}), 400
|
538 |
+
if data['model'] not in embedding_models:
|
539 |
+
return jsonify({"error": "Invalid model"}), 400
|
540 |
|
541 |
model_name = data['model']
|
542 |
request_type = determine_request_type(
|
|
|
616 |
data = request.get_json()
|
617 |
if not data or 'model' not in data:
|
618 |
return jsonify({"error": "Invalid request data"}), 400
|
619 |
+
if data['model'] not in image_models:
|
620 |
+
return jsonify({"error": "Invalid model"}), 400
|
621 |
|
622 |
model_name = data.get('model')
|
623 |
|
|
|
706 |
try:
|
707 |
start_time = time.time()
|
708 |
response = requests.post(
|
709 |
+
IMAGE_ENDPOINT,
|
710 |
headers=headers,
|
711 |
json=siliconflow_data,
|
712 |
timeout=120
|
|
|
909 |
try:
|
910 |
start_time = time.time()
|
911 |
response = requests.post(
|
912 |
+
IMAGE_ENDPOINT,
|
913 |
headers=headers,
|
914 |
json=siliconflow_data,
|
915 |
timeout=120,
|