feat: add support for dark icons in provider and tool entities (#22081)
This commit is contained in:
@@ -123,6 +123,8 @@ class ProviderEntity(BaseModel):
|
|||||||
description: Optional[I18nObject] = None
|
description: Optional[I18nObject] = None
|
||||||
icon_small: Optional[I18nObject] = None
|
icon_small: Optional[I18nObject] = None
|
||||||
icon_large: Optional[I18nObject] = None
|
icon_large: Optional[I18nObject] = None
|
||||||
|
icon_small_dark: Optional[I18nObject] = None
|
||||||
|
icon_large_dark: Optional[I18nObject] = None
|
||||||
background: Optional[str] = None
|
background: Optional[str] = None
|
||||||
help: Optional[ProviderHelpEntity] = None
|
help: Optional[ProviderHelpEntity] = None
|
||||||
supported_model_types: Sequence[ModelType]
|
supported_model_types: Sequence[ModelType]
|
||||||
|
@@ -79,6 +79,7 @@ class PluginDeclaration(BaseModel):
|
|||||||
name: str = Field(..., pattern=r"^[a-z0-9_-]{1,128}$")
|
name: str = Field(..., pattern=r"^[a-z0-9_-]{1,128}$")
|
||||||
description: I18nObject
|
description: I18nObject
|
||||||
icon: str
|
icon: str
|
||||||
|
icon_dark: Optional[str] = Field(default=None)
|
||||||
label: I18nObject
|
label: I18nObject
|
||||||
category: PluginCategory
|
category: PluginCategory
|
||||||
created_at: datetime.datetime
|
created_at: datetime.datetime
|
||||||
|
@@ -28,6 +28,7 @@ class ToolProviderApiEntity(BaseModel):
|
|||||||
name: str # identifier
|
name: str # identifier
|
||||||
description: I18nObject
|
description: I18nObject
|
||||||
icon: str | dict
|
icon: str | dict
|
||||||
|
icon_dark: Optional[str | dict] = Field(default=None, description="The dark icon of the tool")
|
||||||
label: I18nObject # label
|
label: I18nObject # label
|
||||||
type: ToolProviderType
|
type: ToolProviderType
|
||||||
masked_credentials: Optional[dict] = None
|
masked_credentials: Optional[dict] = None
|
||||||
@@ -72,6 +73,7 @@ class ToolProviderApiEntity(BaseModel):
|
|||||||
"plugin_unique_identifier": self.plugin_unique_identifier,
|
"plugin_unique_identifier": self.plugin_unique_identifier,
|
||||||
"description": self.description.to_dict(),
|
"description": self.description.to_dict(),
|
||||||
"icon": self.icon,
|
"icon": self.icon,
|
||||||
|
"icon_dark": self.icon_dark,
|
||||||
"label": self.label.to_dict(),
|
"label": self.label.to_dict(),
|
||||||
"type": self.type.value,
|
"type": self.type.value,
|
||||||
"team_credentials": self.masked_credentials,
|
"team_credentials": self.masked_credentials,
|
||||||
|
@@ -317,6 +317,7 @@ class ToolProviderIdentity(BaseModel):
|
|||||||
name: str = Field(..., description="The name of the tool")
|
name: str = Field(..., description="The name of the tool")
|
||||||
description: I18nObject = Field(..., description="The description of the tool")
|
description: I18nObject = Field(..., description="The description of the tool")
|
||||||
icon: str = Field(..., description="The icon of the tool")
|
icon: str = Field(..., description="The icon of the tool")
|
||||||
|
icon_dark: Optional[str] = Field(default=None, description="The dark icon of the tool")
|
||||||
label: I18nObject = Field(..., description="The label of the tool")
|
label: I18nObject = Field(..., description="The label of the tool")
|
||||||
tags: Optional[list[ToolLabelEnum]] = Field(
|
tags: Optional[list[ToolLabelEnum]] = Field(
|
||||||
default=[],
|
default=[],
|
||||||
|
@@ -339,10 +339,12 @@ class ToolNode(BaseNode[ToolNodeData]):
|
|||||||
if provider.name == dict_metadata["provider"]
|
if provider.name == dict_metadata["provider"]
|
||||||
)
|
)
|
||||||
icon = builtin_tool.icon
|
icon = builtin_tool.icon
|
||||||
|
icon_dark = builtin_tool.icon_dark
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
dict_metadata["icon"] = icon
|
dict_metadata["icon"] = icon
|
||||||
|
dict_metadata["icon_dark"] = icon_dark
|
||||||
message.message.metadata = dict_metadata
|
message.message.metadata = dict_metadata
|
||||||
agent_log = AgentLogEvent(
|
agent_log = AgentLogEvent(
|
||||||
id=message.message.id,
|
id=message.message.id,
|
||||||
|
@@ -75,10 +75,18 @@ class ToolTransformService:
|
|||||||
provider.icon = ToolTransformService.get_plugin_icon_url(
|
provider.icon = ToolTransformService.get_plugin_icon_url(
|
||||||
tenant_id=tenant_id, filename=provider.icon
|
tenant_id=tenant_id, filename=provider.icon
|
||||||
)
|
)
|
||||||
|
if isinstance(provider.icon_dark, str) and provider.icon_dark:
|
||||||
|
provider.icon_dark = ToolTransformService.get_plugin_icon_url(
|
||||||
|
tenant_id=tenant_id, filename=provider.icon_dark
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
provider.icon = ToolTransformService.get_tool_provider_icon_url(
|
provider.icon = ToolTransformService.get_tool_provider_icon_url(
|
||||||
provider_type=provider.type.value, provider_name=provider.name, icon=provider.icon
|
provider_type=provider.type.value, provider_name=provider.name, icon=provider.icon
|
||||||
)
|
)
|
||||||
|
if provider.icon_dark:
|
||||||
|
provider.icon_dark = ToolTransformService.get_tool_provider_icon_url(
|
||||||
|
provider_type=provider.type.value, provider_name=provider.name, icon=provider.icon_dark
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def builtin_provider_to_user_provider(
|
def builtin_provider_to_user_provider(
|
||||||
@@ -96,6 +104,7 @@ class ToolTransformService:
|
|||||||
name=provider_controller.entity.identity.name,
|
name=provider_controller.entity.identity.name,
|
||||||
description=provider_controller.entity.identity.description,
|
description=provider_controller.entity.identity.description,
|
||||||
icon=provider_controller.entity.identity.icon,
|
icon=provider_controller.entity.identity.icon,
|
||||||
|
icon_dark=provider_controller.entity.identity.icon_dark,
|
||||||
label=provider_controller.entity.identity.label,
|
label=provider_controller.entity.identity.label,
|
||||||
type=ToolProviderType.BUILT_IN,
|
type=ToolProviderType.BUILT_IN,
|
||||||
masked_credentials={},
|
masked_credentials={},
|
||||||
@@ -179,6 +188,7 @@ class ToolTransformService:
|
|||||||
name=provider_controller.entity.identity.name,
|
name=provider_controller.entity.identity.name,
|
||||||
description=provider_controller.entity.identity.description,
|
description=provider_controller.entity.identity.description,
|
||||||
icon=provider_controller.entity.identity.icon,
|
icon=provider_controller.entity.identity.icon,
|
||||||
|
icon_dark=provider_controller.entity.identity.icon_dark,
|
||||||
label=provider_controller.entity.identity.label,
|
label=provider_controller.entity.identity.label,
|
||||||
type=ToolProviderType.WORKFLOW,
|
type=ToolProviderType.WORKFLOW,
|
||||||
masked_credentials={},
|
masked_credentials={},
|
||||||
|
Reference in New Issue
Block a user