fix: 在设置model为非视觉模型时,非local-agent的runner无法获得图片消息 (#948)

This commit is contained in:
Junyan Qin
2024-12-17 01:17:57 +08:00
parent 793d64303e
commit 3314a7a9e9
2 changed files with 3 additions and 7 deletions

View File

@@ -105,10 +105,6 @@ class AsyncDifyServiceClient:
timeout: float = 30.0,
) -> 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(
base_url=self.base_url,
trust_env=True,

View File

@@ -45,7 +45,7 @@ class PreProcessor(stage.PipelineStage):
# 检查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:
if isinstance(msg.content, list):
for me in msg.content:
@@ -60,13 +60,13 @@ class PreProcessor(stage.PipelineStage):
llm_entities.ContentElement.from_text(me.text)
)
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:
content_list.append(
llm_entities.ContentElement.from_image_url(str(me.url))
)
query.user_message = llm_entities.Message( # TODO 适配多模态输入
query.user_message = llm_entities.Message(
role='user',
content=content_list
)