From 3314a7a9e9a824d293e6c24d631f1c4b3f5a48e5 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Tue, 17 Dec 2024 01:17:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9C=A8=E8=AE=BE=E7=BD=AEmodel?= =?UTF-8?q?=E4=B8=BA=E9=9D=9E=E8=A7=86=E8=A7=89=E6=A8=A1=E5=9E=8B=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E9=9D=9Elocal-agent=E7=9A=84runner=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=8E=B7=E5=BE=97=E5=9B=BE=E7=89=87=E6=B6=88=E6=81=AF=20(#948)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/dify_service_api/v1/client.py | 4 ---- pkg/pipeline/preproc/preproc.py | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libs/dify_service_api/v1/client.py b/libs/dify_service_api/v1/client.py index efa70ea5..70a804b7 100644 --- a/libs/dify_service_api/v1/client.py +++ b/libs/dify_service_api/v1/client.py @@ -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, diff --git a/pkg/pipeline/preproc/preproc.py b/pkg/pipeline/preproc/preproc.py index 3a71a841..4fa32c65 100644 --- a/pkg/pipeline/preproc/preproc.py +++ b/pkg/pipeline/preproc/preproc.py @@ -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 )