mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
chore: apply ruff's pyupgrade linter rules to modernize Python code with targeted version (#2419)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
@ -18,7 +18,7 @@ class ApiBasedToolBundle(BaseModel):
|
||||
# operation_id
|
||||
operation_id: str = None
|
||||
# parameters
|
||||
parameters: Optional[List[ToolParameter]] = None
|
||||
parameters: Optional[list[ToolParameter]] = None
|
||||
# author
|
||||
author: str
|
||||
# icon
|
||||
@ -31,6 +31,6 @@ class AppToolBundle(BaseModel):
|
||||
This class is used to store the schema information of an tool for an app.
|
||||
"""
|
||||
type: ToolProviderType
|
||||
credential: Optional[Dict[str, Any]] = None
|
||||
credential: Optional[dict[str, Any]] = None
|
||||
provider_id: str
|
||||
tool_name: str
|
||||
@ -1,5 +1,5 @@
|
||||
from enum import Enum
|
||||
from typing import Any, Dict, List, Optional, Union, cast
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
@ -82,7 +82,7 @@ class ToolInvokeMessage(BaseModel):
|
||||
plain text, image url or link url
|
||||
"""
|
||||
message: Union[str, bytes] = None
|
||||
meta: Dict[str, Any] = None
|
||||
meta: dict[str, Any] = None
|
||||
save_as: str = ''
|
||||
|
||||
class ToolInvokeMessageBinary(BaseModel):
|
||||
@ -116,12 +116,12 @@ class ToolParameter(BaseModel):
|
||||
default: Optional[str] = None
|
||||
min: Optional[Union[float, int]] = None
|
||||
max: Optional[Union[float, int]] = None
|
||||
options: Optional[List[ToolParameterOption]] = None
|
||||
options: Optional[list[ToolParameterOption]] = None
|
||||
|
||||
@classmethod
|
||||
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
|
||||
|
||||
@ -192,7 +192,7 @@ class ToolProviderCredentials(BaseModel):
|
||||
type: CredentialsType = Field(..., description="The type of the credentials")
|
||||
required: bool = False
|
||||
default: Optional[str] = None
|
||||
options: Optional[List[ToolCredentialsOption]] = None
|
||||
options: Optional[list[ToolCredentialsOption]] = None
|
||||
label: Optional[I18nObject] = None
|
||||
help: Optional[I18nObject] = None
|
||||
url: Optional[str] = None
|
||||
@ -232,7 +232,7 @@ class ToolRuntimeVariablePool(BaseModel):
|
||||
user_id: str = Field(..., description="The user id")
|
||||
tenant_id: str = Field(..., description="The tenant id of assistant")
|
||||
|
||||
pool: List[ToolRuntimeVariable] = Field(..., description="The pool of variables")
|
||||
pool: list[ToolRuntimeVariable] = Field(..., description="The pool of variables")
|
||||
|
||||
def __init__(self, **data: Any):
|
||||
pool = data.get('pool', [])
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from enum import Enum
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
@ -40,11 +40,11 @@ class UserToolProvider(BaseModel):
|
||||
}
|
||||
|
||||
class UserToolProviderCredentials(BaseModel):
|
||||
credentials: Dict[str, ToolProviderCredentials]
|
||||
credentials: dict[str, ToolProviderCredentials]
|
||||
|
||||
class UserTool(BaseModel):
|
||||
author: str
|
||||
name: str # identifier
|
||||
label: I18nObject # label
|
||||
description: I18nObject
|
||||
parameters: Optional[List[ToolParameter]]
|
||||
parameters: Optional[list[ToolParameter]]
|
||||
Reference in New Issue
Block a user