mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-28 00:14:21 +00:00
fix(pipeline): handle File messages with base64 data in preproc (#2149)
File messages from platforms like Telegram carry base64 data with an empty url. The unconditional from_file_url(me.url) call passed an empty string downstream, causing httpx to fail with "Request URL is missing an 'http://' or 'https://' protocol" when uploading to Dify. Mirror the existing Voice handling pattern: check base64 first, fall back to url. Applied in both the main message chain and the Quote path. Closes #2079 Co-authored-by: Junyan Qin <rockchinq@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -160,7 +160,10 @@ class PreProcessor(stage.PipelineStage):
|
|||||||
elif me.url:
|
elif me.url:
|
||||||
content_list.append(provider_message.ContentElement.from_file_url(me.url, 'voice'))
|
content_list.append(provider_message.ContentElement.from_file_url(me.url, 'voice'))
|
||||||
elif isinstance(me, platform_message.File):
|
elif isinstance(me, platform_message.File):
|
||||||
content_list.append(provider_message.ContentElement.from_file_url(me.url, me.name))
|
if me.base64:
|
||||||
|
content_list.append(provider_message.ContentElement.from_file_base64(me.base64, me.name))
|
||||||
|
elif me.url:
|
||||||
|
content_list.append(provider_message.ContentElement.from_file_url(me.url, me.name))
|
||||||
elif isinstance(me, platform_message.Quote) and quote_msg:
|
elif isinstance(me, platform_message.Quote) and quote_msg:
|
||||||
for msg in me.origin:
|
for msg in me.origin:
|
||||||
if isinstance(msg, platform_message.Plain):
|
if isinstance(msg, platform_message.Plain):
|
||||||
@@ -172,7 +175,10 @@ class PreProcessor(stage.PipelineStage):
|
|||||||
if msg.base64 is not None:
|
if msg.base64 is not None:
|
||||||
content_list.append(provider_message.ContentElement.from_image_base64(msg.base64))
|
content_list.append(provider_message.ContentElement.from_image_base64(msg.base64))
|
||||||
elif isinstance(msg, platform_message.File):
|
elif isinstance(msg, platform_message.File):
|
||||||
content_list.append(provider_message.ContentElement.from_file_url(msg.url, msg.name))
|
if msg.base64:
|
||||||
|
content_list.append(provider_message.ContentElement.from_file_base64(msg.base64, msg.name))
|
||||||
|
elif msg.url:
|
||||||
|
content_list.append(provider_message.ContentElement.from_file_url(msg.url, msg.name))
|
||||||
elif isinstance(msg, platform_message.Voice):
|
elif isinstance(msg, platform_message.Voice):
|
||||||
if msg.base64:
|
if msg.base64:
|
||||||
content_list.append(
|
content_list.append(
|
||||||
|
|||||||
Reference in New Issue
Block a user