Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,8 +15,8 @@ from apscheduler.schedulers.background import BackgroundScheduler
|
|
15 |
from flask import Flask, request, jsonify, Response, stream_with_context
|
16 |
from werkzeug.middleware.proxy_fix import ProxyFix
|
17 |
|
18 |
-
|
19 |
-
|
20 |
|
21 |
logging.basicConfig(level=logging.INFO,
|
22 |
format='%(asctime)s - %(levelname)s - %(message)s')
|
@@ -956,27 +956,23 @@ def handsome_chat_completions():
|
|
956 |
|
957 |
markdown_image_link = create_base64_markdown_image(image_url)
|
958 |
if image_url:
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
}
|
977 |
-
]
|
978 |
-
}
|
979 |
-
yield f"data: {json.dumps(chunk_data)}\n\n".encode('utf-8')
|
980 |
else:
|
981 |
chunk_data = {
|
982 |
"id": f"chatcmpl-{uuid.uuid4()}",
|
|
|
15 |
from flask import Flask, request, jsonify, Response, stream_with_context
|
16 |
from werkzeug.middleware.proxy_fix import ProxyFix
|
17 |
|
18 |
+
os.environ['TZ'] = 'Asia/Shanghai'
|
19 |
+
time.tzset()
|
20 |
|
21 |
logging.basicConfig(level=logging.INFO,
|
22 |
format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
956 |
|
957 |
markdown_image_link = create_base64_markdown_image(image_url)
|
958 |
if image_url:
|
959 |
+
chunk_data = {
|
960 |
+
"id": f"chatcmpl-{uuid.uuid4()}",
|
961 |
+
"object": "chat.completion.chunk",
|
962 |
+
"created": int(time.time()),
|
963 |
+
"model": model_name,
|
964 |
+
"choices": [
|
965 |
+
{
|
966 |
+
"index": 0,
|
967 |
+
"delta": {
|
968 |
+
"role": "assistant",
|
969 |
+
"content": markdown_image_link
|
970 |
+
},
|
971 |
+
"finish_reason": None
|
972 |
+
}
|
973 |
+
]
|
974 |
+
}
|
975 |
+
yield f"data: {json.dumps(chunk_data)}\n\n".encode('utf-8')
|
|
|
|
|
|
|
|
|
976 |
else:
|
977 |
chunk_data = {
|
978 |
"id": f"chatcmpl-{uuid.uuid4()}",
|