[fix] 支持绘图失败的错误输出

This commit is contained in:
Wizerd
2024-01-06 11:21:11 +08:00
parent ad435d05f4
commit 67ada03bb8

15
main.py
View File

@@ -187,9 +187,9 @@ CORS(app, resources={r"/images/*": {"origins": "*"}})
PANDORA_UPLOAD_URL = 'files.pandoranext.com'
VERSION = '0.4.6'
VERSION = '0.4.7'
# VERSION = 'test'
UPDATE_INFO = '支持使用随机ua头下载gpt-4-vision接口传入的文件'
UPDATE_INFO = '支持绘图失败的错误输出'
# UPDATE_INFO = '【仅供临时测试使用】 '
with app.app_context():
@@ -1966,6 +1966,17 @@ def images_generations():
pass
# 构造响应的 JSON 结构
response_json = {}
# 检查 image_urls 是否为空
if not image_urls:
response_json = {
"error": {
"message": all_new_text, # 使用累积的文本作为错误信息
"type": "invalid_request_error",
"param": "",
"code": "content_policy_violation"
}
}
else:
if response_format == "url":
response_json = {
"created": int(time.time()), # 使用当前时间戳