Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -841,12 +841,17 @@ def handle_stream_response(response, model):
|
|
| 841 |
result = process_model_response(response_data, model)
|
| 842 |
|
| 843 |
if result["token"]:
|
| 844 |
-
|
|
|
|
|
|
|
|
|
|
| 845 |
|
| 846 |
if result["imageUrl"]:
|
| 847 |
CONFIG["IS_IMG_GEN2"] = True
|
| 848 |
image_data = handle_image_response(result["imageUrl"])
|
| 849 |
-
|
|
|
|
|
|
|
| 850 |
|
| 851 |
except json.JSONDecodeError:
|
| 852 |
continue
|
|
@@ -857,6 +862,7 @@ def handle_stream_response(response, model):
|
|
| 857 |
yield "data: [DONE]\n\n"
|
| 858 |
return generate()
|
| 859 |
|
|
|
|
| 860 |
def initialization():
|
| 861 |
sso_array = os.environ.get("SSO", "").split(',')
|
| 862 |
logger.info("开始加载令牌", "Server")
|
|
|
|
| 841 |
result = process_model_response(response_data, model)
|
| 842 |
|
| 843 |
if result["token"]:
|
| 844 |
+
# 修复的代码 - 使用临时变量
|
| 845 |
+
token_content = result["token"]
|
| 846 |
+
response_json = json.dumps(MessageProcessor.create_chat_response(token_content, model, True))
|
| 847 |
+
yield f"data: {response_json}\n\n"
|
| 848 |
|
| 849 |
if result["imageUrl"]:
|
| 850 |
CONFIG["IS_IMG_GEN2"] = True
|
| 851 |
image_data = handle_image_response(result["imageUrl"])
|
| 852 |
+
# 同样修复这里
|
| 853 |
+
response_json = json.dumps(MessageProcessor.create_chat_response(image_data, model, True))
|
| 854 |
+
yield f"data: {response_json}\n\n"
|
| 855 |
|
| 856 |
except json.JSONDecodeError:
|
| 857 |
continue
|
|
|
|
| 862 |
yield "data: [DONE]\n\n"
|
| 863 |
return generate()
|
| 864 |
|
| 865 |
+
|
| 866 |
def initialization():
|
| 867 |
sso_array = os.environ.get("SSO", "").split(',')
|
| 868 |
logger.info("开始加载令牌", "Server")
|