fix: Fix the file URL processing logic to support complete URLs (#1950)

This commit is contained in:
fdc310
2026-01-31 20:30:46 +08:00
committed by GitHub
parent 023281ae56
commit 2f06321ebf
@@ -289,6 +289,10 @@ class DifyServiceAPIRunner(runner.RequestRunner):
yield msg yield msg
if chunk['event'] == 'message_file': if chunk['event'] == 'message_file':
if chunk['type'] == 'image' and chunk['belongs_to'] == 'assistant': if chunk['type'] == 'image' and chunk['belongs_to'] == 'assistant':
# 检查URL是否已经是完整的连接
if chunk['url'].startswith('http://') or chunk['url'].startswith('https://'):
image_url = chunk['url']
else:
base_url = self.dify_client.base_url base_url = self.dify_client.base_url
if base_url.endswith('/v1'): if base_url.endswith('/v1'):
@@ -559,6 +563,10 @@ class DifyServiceAPIRunner(runner.RequestRunner):
if chunk['event'] == 'message_file': if chunk['event'] == 'message_file':
message_idx += 1 message_idx += 1
if chunk['type'] == 'image' and chunk['belongs_to'] == 'assistant': if chunk['type'] == 'image' and chunk['belongs_to'] == 'assistant':
# 检查URL是否已经是完整的连接
if chunk['url'].startswith('http://') or chunk['url'].startswith('https://'):
image_url = chunk['url']
else:
base_url = self.dify_client.base_url base_url = self.dify_client.base_url
if base_url.endswith('/v1'): if base_url.endswith('/v1'):