mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-26 20:27:13 +00:00
fix: 在设置model为非视觉模型时,非local-agent的runner无法获得图片消息 (#948)
This commit is contained in:
@@ -105,10 +105,6 @@ class AsyncDifyServiceClient:
|
|||||||
timeout: float = 30.0,
|
timeout: float = 30.0,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""上传文件"""
|
"""上传文件"""
|
||||||
# curl -X POST 'http://dify.rockchin.top/v1/files/upload' \
|
|
||||||
# --header 'Authorization: Bearer {api_key}' \
|
|
||||||
# --form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif] \
|
|
||||||
# --form 'user=abc-123'
|
|
||||||
async with httpx.AsyncClient(
|
async with httpx.AsyncClient(
|
||||||
base_url=self.base_url,
|
base_url=self.base_url,
|
||||||
trust_env=True,
|
trust_env=True,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class PreProcessor(stage.PipelineStage):
|
|||||||
|
|
||||||
|
|
||||||
# 检查vision是否启用,没启用就删除所有图片
|
# 检查vision是否启用,没启用就删除所有图片
|
||||||
if not self.ap.provider_cfg.data['enable-vision'] or not query.use_model.vision_supported:
|
if not self.ap.provider_cfg.data['enable-vision'] or (self.ap.provider_cfg.data['runner'] == 'local-agent' and not query.use_model.vision_supported):
|
||||||
for msg in query.messages:
|
for msg in query.messages:
|
||||||
if isinstance(msg.content, list):
|
if isinstance(msg.content, list):
|
||||||
for me in msg.content:
|
for me in msg.content:
|
||||||
@@ -60,13 +60,13 @@ class PreProcessor(stage.PipelineStage):
|
|||||||
llm_entities.ContentElement.from_text(me.text)
|
llm_entities.ContentElement.from_text(me.text)
|
||||||
)
|
)
|
||||||
elif isinstance(me, platform_message.Image):
|
elif isinstance(me, platform_message.Image):
|
||||||
if self.ap.provider_cfg.data['enable-vision'] and query.use_model.vision_supported:
|
if self.ap.provider_cfg.data['enable-vision'] and (self.ap.provider_cfg.data['runner'] != 'local-agent' or query.use_model.vision_supported):
|
||||||
if me.url is not None:
|
if me.url is not None:
|
||||||
content_list.append(
|
content_list.append(
|
||||||
llm_entities.ContentElement.from_image_url(str(me.url))
|
llm_entities.ContentElement.from_image_url(str(me.url))
|
||||||
)
|
)
|
||||||
|
|
||||||
query.user_message = llm_entities.Message( # TODO 适配多模态输入
|
query.user_message = llm_entities.Message(
|
||||||
role='user',
|
role='user',
|
||||||
content=content_list
|
content=content_list
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user