Browse Source

fix: summary and create_file_by_url

Yeuoly 6 months ago
parent
commit
b10d6051ba

+ 7 - 5
api/controllers/inner_api/plugin/plugin.py

@@ -242,11 +242,13 @@ class PluginInvokeSummaryApi(Resource):
     def post(self, user_model: Account | EndUser, tenant_model: Tenant, payload: RequestInvokeSummary):
         try:
             return BaseBackwardsInvocationResponse(
-                data=PluginModelBackwardsInvocation.invoke_summary(
-                    user_id=user_model.id,
-                    tenant=tenant_model,
-                    payload=payload,
-                )
+                data={
+                    "summary": PluginModelBackwardsInvocation.invoke_summary(
+                        user_id=user_model.id,
+                        tenant=tenant_model,
+                        payload=payload,
+                    )
+                }
             ).model_dump()
         except Exception as e:
             return BaseBackwardsInvocationResponse(error=str(e)).model_dump()

+ 2 - 3
api/core/tools/tool_file_manager.py

@@ -8,9 +8,8 @@ from mimetypes import guess_extension, guess_type
 from typing import Optional, Union
 from uuid import uuid4
 
-from httpx import get
-
 from configs import dify_config
+from core.helper import ssrf_proxy
 from extensions.ext_database import db
 from extensions.ext_storage import storage
 from models.model import MessageFile
@@ -94,7 +93,7 @@ class ToolFileManager:
     ) -> ToolFile:
         # try to download image
         try:
-            response = get(file_url)
+            response = ssrf_proxy.get(file_url)
             response.raise_for_status()
             blob = response.content
         except Exception as e:

+ 0 - 3
api/core/tools/utils/message_transformer.py

@@ -30,9 +30,6 @@ class ToolFileMessageTransformer:
             ):
                 # try to download image
                 try:
-                    if not conversation_id:
-                        raise
-
                     assert isinstance(message.message, ToolInvokeMessage.TextMessage)
 
                     file = ToolFileManager.create_file_by_url(