yangtb24 commited on
Commit
a3632ca
·
verified ·
1 Parent(s): aa31fc8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -23
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
- # os.environ['TZ'] = 'Asia/Shanghai'
19
- # time.tzset()
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
- markdown_image_link = f"![]({image_url})"
960
- chunk_size = 2048
961
- for i in range(0, len(markdown_image_link), chunk_size):
962
- chunk = markdown_image_link[i:i + chunk_size]
963
- chunk_data = {
964
- "id": f"chatcmpl-{uuid.uuid4()}",
965
- "object": "chat.completion.chunk",
966
- "created": int(time.time()),
967
- "model": model_name,
968
- "choices": [
969
- {
970
- "index": 0,
971
- "delta": {
972
- "role": "assistant",
973
- "content": chunk
974
- },
975
- "finish_reason": None
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()}",