Prechádzať zdrojové kódy

fix(api/core/tools/entities/tool_entities.py): Fix type define. (#7250)

-LAN- 8 mesiacov pred
rodič
commit
48d2febebf
1 zmenil súbory, kde vykonal 14 pridanie a 14 odobranie
  1. 14 14
      api/core/tools/entities/tool_entities.py

+ 14 - 14
api/core/tools/entities/tool_entities.py

@@ -46,7 +46,7 @@ class ToolProviderType(Enum):
             if mode.value == value:
             if mode.value == value:
                 return mode
                 return mode
         raise ValueError(f'invalid mode value {value}')
         raise ValueError(f'invalid mode value {value}')
-    
+
 class ApiProviderSchemaType(Enum):
 class ApiProviderSchemaType(Enum):
     """
     """
     Enum class for api provider schema type.
     Enum class for api provider schema type.
@@ -68,7 +68,7 @@ class ApiProviderSchemaType(Enum):
             if mode.value == value:
             if mode.value == value:
                 return mode
                 return mode
         raise ValueError(f'invalid mode value {value}')
         raise ValueError(f'invalid mode value {value}')
-    
+
 class ApiProviderAuthType(Enum):
 class ApiProviderAuthType(Enum):
     """
     """
     Enum class for api provider auth type.
     Enum class for api provider auth type.
@@ -103,8 +103,8 @@ class ToolInvokeMessage(BaseModel):
     """
     """
         plain text, image url or link url
         plain text, image url or link url
     """
     """
-    message: Union[str, bytes, dict] = None
-    meta: dict[str, Any] = None
+    message: str | bytes | dict | None = None
+    meta: dict[str, Any] | None = None
     save_as: str = ''
     save_as: str = ''
 
 
 class ToolInvokeMessageBinary(BaseModel):
 class ToolInvokeMessageBinary(BaseModel):
@@ -154,8 +154,8 @@ class ToolParameter(BaseModel):
     options: Optional[list[ToolParameterOption]] = None
     options: Optional[list[ToolParameterOption]] = None
 
 
     @classmethod
     @classmethod
-    def get_simple_instance(cls, 
-                       name: str, llm_description: str, type: ToolParameterType, 
+    def get_simple_instance(cls,
+                       name: str, llm_description: str, type: ToolParameterType,
                        required: bool, options: Optional[list[str]] = None) -> 'ToolParameter':
                        required: bool, options: Optional[list[str]] = None) -> 'ToolParameter':
         """
         """
             get a simple tool parameter
             get a simple tool parameter
@@ -222,7 +222,7 @@ class ToolProviderCredentials(BaseModel):
                 if mode.value == value:
                 if mode.value == value:
                     return mode
                     return mode
             raise ValueError(f'invalid mode value {value}')
             raise ValueError(f'invalid mode value {value}')
-        
+
         @staticmethod
         @staticmethod
         def default(value: str) -> str:
         def default(value: str) -> str:
             return ""
             return ""
@@ -290,7 +290,7 @@ class ToolRuntimeVariablePool(BaseModel):
             'tenant_id': self.tenant_id,
             'tenant_id': self.tenant_id,
             'pool': [variable.model_dump() for variable in self.pool],
             'pool': [variable.model_dump() for variable in self.pool],
         }
         }
-    
+
     def set_text(self, tool_name: str, name: str, value: str) -> None:
     def set_text(self, tool_name: str, name: str, value: str) -> None:
         """
         """
             set a text variable
             set a text variable
@@ -301,7 +301,7 @@ class ToolRuntimeVariablePool(BaseModel):
                     variable = cast(ToolRuntimeTextVariable, variable)
                     variable = cast(ToolRuntimeTextVariable, variable)
                     variable.value = value
                     variable.value = value
                     return
                     return
-                
+
         variable = ToolRuntimeTextVariable(
         variable = ToolRuntimeTextVariable(
             type=ToolRuntimeVariableType.TEXT,
             type=ToolRuntimeVariableType.TEXT,
             name=name,
             name=name,
@@ -334,7 +334,7 @@ class ToolRuntimeVariablePool(BaseModel):
                     variable = cast(ToolRuntimeImageVariable, variable)
                     variable = cast(ToolRuntimeImageVariable, variable)
                     variable.value = value
                     variable.value = value
                     return
                     return
-                
+
         variable = ToolRuntimeImageVariable(
         variable = ToolRuntimeImageVariable(
             type=ToolRuntimeVariableType.IMAGE,
             type=ToolRuntimeVariableType.IMAGE,
             name=name,
             name=name,
@@ -388,21 +388,21 @@ class ToolInvokeMeta(BaseModel):
         Get an empty instance of ToolInvokeMeta
         Get an empty instance of ToolInvokeMeta
         """
         """
         return cls(time_cost=0.0, error=None, tool_config={})
         return cls(time_cost=0.0, error=None, tool_config={})
-    
+
     @classmethod
     @classmethod
     def error_instance(cls, error: str) -> 'ToolInvokeMeta':
     def error_instance(cls, error: str) -> 'ToolInvokeMeta':
         """
         """
         Get an instance of ToolInvokeMeta with error
         Get an instance of ToolInvokeMeta with error
         """
         """
         return cls(time_cost=0.0, error=error, tool_config={})
         return cls(time_cost=0.0, error=error, tool_config={})
-    
+
     def to_dict(self) -> dict:
     def to_dict(self) -> dict:
         return {
         return {
             'time_cost': self.time_cost,
             'time_cost': self.time_cost,
             'error': self.error,
             'error': self.error,
             'tool_config': self.tool_config,
             'tool_config': self.tool_config,
         }
         }
-    
+
 class ToolLabel(BaseModel):
 class ToolLabel(BaseModel):
     """
     """
     Tool label
     Tool label
@@ -416,4 +416,4 @@ class ToolInvokeFrom(Enum):
     Enum class for tool invoke
     Enum class for tool invoke
     """
     """
     WORKFLOW = "workflow"
     WORKFLOW = "workflow"
-    AGENT = "agent"
+    AGENT = "agent"