fix: 文生图、图生图发送本地文件错误

This commit is contained in:
hp0912 2026-05-06 21:07:19 +08:00
parent 0a14269187
commit 708e56666a
4 changed files with 19 additions and 6 deletions

15
.vscode/launch.json vendored
View File

@ -5,9 +5,22 @@
"name": "text-to-image", "name": "text-to-image",
"type": "debugpy", "type": "debugpy",
"request": "launch", "request": "launch",
"program": "skills/text-to-image/scripts/debug_openai_image_generation_test.py", "program": "skills/text-to-image/scripts/text_to_image.py",
"console": "integratedTerminal", "console": "integratedTerminal",
"justMyCode": true, "justMyCode": true,
"args": [
"--prompt=马云在直播间卖红薯",
"--model=gpt-image-2"
],
"env": {
"ROBOT_WECHAT_CLIENT_PORT": "9001",
"ROBOT_FROM_WX_ID": "57004904192@chatroom",
"ROBOT_CODE": "houhouipad",
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "houhou"
}
} }
] ]
} }

View File

@ -78,7 +78,7 @@
{ {
"to_wxid": "{{ROBOT_FROM_WX_ID}}", "to_wxid": "{{ROBOT_FROM_WX_ID}}",
"file_path": ["{{file_path}}"] "file_path": "{{file_path}}"
} }
``` ```

View File

@ -350,11 +350,11 @@ def _send_image_outputs(client_port: str, from_wx_id: str, image_outputs: list[s
response = _http_post_json(send_url, send_body, {"Content-Type": "application/json"}, timeout=300) response = _http_post_json(send_url, send_body, {"Content-Type": "application/json"}, timeout=300)
_debug_response("send image url response", response) _debug_response("send image url response", response)
if local_paths: for file_path in local_paths:
send_url = f"http://127.0.0.1:{client_port}/api/v1/robot/message/send/image/local" send_url = f"http://127.0.0.1:{client_port}/api/v1/robot/message/send/image/local"
send_body = { send_body = {
"to_wxid": from_wx_id, "to_wxid": from_wx_id,
"file_path": local_paths, "file_path": file_path,
} }
response = _http_post_json(send_url, send_body, {"Content-Type": "application/json"}, timeout=300) response = _http_post_json(send_url, send_body, {"Content-Type": "application/json"}, timeout=300)
_debug_response("send image local response", response) _debug_response("send image local response", response)

View File

@ -361,11 +361,11 @@ def _send_image_outputs(client_port: str, from_wx_id: str, image_outputs: list[s
response = _http_post_json(send_url, send_body, {"Content-Type": "application/json"}, timeout=300) response = _http_post_json(send_url, send_body, {"Content-Type": "application/json"}, timeout=300)
_debug_response("send image url response", response) _debug_response("send image url response", response)
if local_paths: for file_path in local_paths:
send_url = f"http://127.0.0.1:{client_port}/api/v1/robot/message/send/image/local" send_url = f"http://127.0.0.1:{client_port}/api/v1/robot/message/send/image/local"
send_body = { send_body = {
"to_wxid": from_wx_id, "to_wxid": from_wx_id,
"file_path": local_paths, "file_path": file_path,
} }
response = _http_post_json(send_url, send_body, {"Content-Type": "application/json"}, timeout=300) response = _http_post_json(send_url, send_body, {"Content-Type": "application/json"}, timeout=300)
_debug_response("send image local response", response) _debug_response("send image local response", response)