diff --git a/api/core/agent/base_agent_runner.py b/api/core/agent/base_agent_runner.py
index d09a9956a4..55fd8825de 100644
--- a/api/core/agent/base_agent_runner.py
+++ b/api/core/agent/base_agent_runner.py
@@ -32,13 +32,13 @@ from core.model_runtime.entities.message_entities import (
from core.model_runtime.entities.model_entities import ModelFeature
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
from core.model_runtime.utils.encoders import jsonable_encoder
+from core.tools.__base.tool import Tool
from core.tools.entities.tool_entities import (
ToolParameter,
ToolRuntimeVariablePool,
)
-from core.tools.tool.dataset_retriever_tool import DatasetRetrieverTool
-from core.tools.tool.tool import Tool
from core.tools.tool_manager import ToolManager
+from core.tools.utils.dataset_retriever_tool import DatasetRetrieverTool
from core.tools.utils.tool_parameter_converter import ToolParameterConverter
from extensions.ext_database import db
from models.model import Conversation, Message, MessageAgentThought
diff --git a/api/core/agent/cot_agent_runner.py b/api/core/agent/cot_agent_runner.py
index ebe04bf260..0d74b1e5eb 100644
--- a/api/core/agent/cot_agent_runner.py
+++ b/api/core/agent/cot_agent_runner.py
@@ -17,8 +17,8 @@ from core.model_runtime.entities.message_entities import (
)
from core.ops.ops_trace_manager import TraceQueueManager
from core.prompt.agent_history_prompt_transform import AgentHistoryPromptTransform
+from core.tools.__base.tool import Tool
from core.tools.entities.tool_entities import ToolInvokeMeta
-from core.tools.tool.tool import Tool
from core.tools.tool_engine import ToolEngine
from models.model import Message
diff --git a/api/core/rag/retrieval/dataset_retrieval.py b/api/core/rag/retrieval/dataset_retrieval.py
index 286ecd4c03..05f6fe6e26 100644
--- a/api/core/rag/retrieval/dataset_retrieval.py
+++ b/api/core/rag/retrieval/dataset_retrieval.py
@@ -24,9 +24,7 @@ from core.rag.models.document import Document
from core.rag.retrieval.retrieval_methods import RetrievalMethod
from core.rag.retrieval.router.multi_dataset_function_call_router import FunctionCallMultiDatasetRouter
from core.rag.retrieval.router.multi_dataset_react_route import ReactMultiDatasetRouter
-from core.tools.tool.dataset_retriever.dataset_multi_retriever_tool import DatasetMultiRetrieverTool
-from core.tools.tool.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool
-from core.tools.tool.dataset_retriever.dataset_retriever_tool import DatasetRetrieverTool
+from core.tools.utils.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool
from extensions.ext_database import db
from models.dataset import Dataset, DatasetQuery, DocumentSegment
from models.dataset import Document as DatasetDocument
@@ -371,7 +369,7 @@ class DatasetRetrieval:
db.session.commit()
# get tracing instance
- trace_manager: TraceQueueManager = (
+ trace_manager: TraceQueueManager | None = (
self.application_generate_entity.trace_manager if self.application_generate_entity else None
)
if trace_manager:
@@ -494,7 +492,8 @@ class DatasetRetrieval:
score_threshold_enabled = retrieval_model_config.get("score_threshold_enabled")
if score_threshold_enabled:
score_threshold = retrieval_model_config.get("score_threshold")
-
+
+ from core.tools.utils.dataset_retriever.dataset_retriever_tool import DatasetRetrieverTool
tool = DatasetRetrieverTool.from_dataset(
dataset=dataset,
top_k=top_k,
@@ -506,6 +505,7 @@ class DatasetRetrieval:
tools.append(tool)
elif retrieve_config.retrieve_strategy == DatasetRetrieveConfigEntity.RetrieveStrategy.MULTIPLE:
+ from core.tools.utils.dataset_retriever.dataset_multi_retriever_tool import DatasetMultiRetrieverTool
tool = DatasetMultiRetrieverTool.from_dataset(
dataset_ids=[dataset.id for dataset in available_datasets],
tenant_id=tenant_id,
diff --git a/api/core/tools/tool/tool.py b/api/core/tools/__base/tool.py
similarity index 100%
rename from api/core/tools/tool/tool.py
rename to api/core/tools/__base/tool.py
diff --git a/api/core/tools/provider/tool_provider.py b/api/core/tools/__base/tool_provider.py
similarity index 99%
rename from api/core/tools/provider/tool_provider.py
rename to api/core/tools/__base/tool_provider.py
index f07af649ad..7960ed5f84 100644
--- a/api/core/tools/provider/tool_provider.py
+++ b/api/core/tools/__base/tool_provider.py
@@ -4,12 +4,12 @@ from typing import Any
from pydantic import BaseModel, ConfigDict, Field
from core.entities.provider_entities import ProviderConfig
+from core.tools.__base.tool import Tool
from core.tools.entities.tool_entities import (
ToolProviderIdentity,
ToolProviderType,
)
from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.tool.tool import Tool
class ToolProviderController(BaseModel, ABC):
diff --git a/api/core/tools/builtin_tool/_position.yaml b/api/core/tools/builtin_tool/_position.yaml
new file mode 100644
index 0000000000..b5875e2075
--- /dev/null
+++ b/api/core/tools/builtin_tool/_position.yaml
@@ -0,0 +1,3 @@
+- code
+- time
+- qrcode
diff --git a/api/core/tools/provider/builtin_tool_provider.py b/api/core/tools/builtin_tool/provider.py
similarity index 92%
rename from api/core/tools/provider/builtin_tool_provider.py
rename to api/core/tools/builtin_tool/provider.py
index 2a966d3999..7d1775b7f5 100644
--- a/api/core/tools/provider/builtin_tool_provider.py
+++ b/api/core/tools/builtin_tool/provider.py
@@ -6,13 +6,13 @@ from pydantic import Field
from core.entities.provider_entities import ProviderConfig
from core.helper.module_import_helper import load_single_subclass_from_source
+from core.tools.__base.tool_provider import ToolProviderController
+from core.tools.builtin_tool.tool import BuiltinTool
from core.tools.entities.tool_entities import ToolProviderType
from core.tools.entities.values import ToolLabelEnum, default_tool_label_dict
from core.tools.errors import (
ToolProviderNotFoundError,
)
-from core.tools.provider.tool_provider import ToolProviderController
-from core.tools.tool.builtin_tool import BuiltinTool
from core.tools.utils.yaml_utils import load_yaml_file
@@ -26,7 +26,7 @@ class BuiltinToolProviderController(ToolProviderController):
# load provider yaml
provider = self.__class__.__module__.split(".")[-1]
- yaml_path = path.join(path.dirname(path.realpath(__file__)), "builtin", provider, f"{provider}.yaml")
+ yaml_path = path.join(path.dirname(path.realpath(__file__)), "providers", provider, f"{provider}.yaml")
try:
provider_yaml = load_yaml_file(yaml_path, ignore_error=False)
except Exception as e:
@@ -52,7 +52,7 @@ class BuiltinToolProviderController(ToolProviderController):
return self.tools
provider = self.identity.name
- tool_path = path.join(path.dirname(path.realpath(__file__)), "builtin", provider, "tools")
+ tool_path = path.join(path.dirname(path.realpath(__file__)), "providers", provider, "tools")
# get all the yaml files in the tool path
tool_files = list(filter(lambda x: x.endswith(".yaml") and not x.startswith("__"), listdir(tool_path)))
tools = []
@@ -63,9 +63,10 @@ class BuiltinToolProviderController(ToolProviderController):
# get tool class, import the module
assistant_tool_class = load_single_subclass_from_source(
- module_name=f"core.tools.provider.builtin.{provider}.tools.{tool_name}",
+ module_name=f"core.tools.builtin_tool.providers.{provider}.tools.{tool_name}",
script_path=path.join(
- path.dirname(path.realpath(__file__)), "builtin", provider, "tools", f"{tool_name}.py"
+ path.dirname(path.realpath(__file__)),
+ "builtin_tool", "providers", provider, "tools", f"{tool_name}.py"
),
parent_type=BuiltinTool,
)
diff --git a/api/core/tools/provider/builtin/__init__.py b/api/core/tools/builtin_tool/providers/__init__.py
similarity index 100%
rename from api/core/tools/provider/builtin/__init__.py
rename to api/core/tools/builtin_tool/providers/__init__.py
diff --git a/api/core/tools/provider/builtin/_positions.py b/api/core/tools/builtin_tool/providers/_positions.py
similarity index 100%
rename from api/core/tools/provider/builtin/_positions.py
rename to api/core/tools/builtin_tool/providers/_positions.py
diff --git a/api/core/tools/provider/builtin/code/_assets/icon.svg b/api/core/tools/builtin_tool/providers/code/_assets/icon.svg
similarity index 100%
rename from api/core/tools/provider/builtin/code/_assets/icon.svg
rename to api/core/tools/builtin_tool/providers/code/_assets/icon.svg
diff --git a/api/core/tools/provider/builtin/code/code.py b/api/core/tools/builtin_tool/providers/code/code.py
similarity index 66%
rename from api/core/tools/provider/builtin/code/code.py
rename to api/core/tools/builtin_tool/providers/code/code.py
index 211417c9a4..53210e9c43 100644
--- a/api/core/tools/provider/builtin/code/code.py
+++ b/api/core/tools/builtin_tool/providers/code/code.py
@@ -1,6 +1,6 @@
from typing import Any
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
+from core.tools.builtin_tool.provider import BuiltinToolProviderController
class CodeToolProvider(BuiltinToolProviderController):
diff --git a/api/core/tools/provider/builtin/code/code.yaml b/api/core/tools/builtin_tool/providers/code/code.yaml
similarity index 100%
rename from api/core/tools/provider/builtin/code/code.yaml
rename to api/core/tools/builtin_tool/providers/code/code.yaml
diff --git a/api/core/tools/provider/builtin/code/tools/simple_code.py b/api/core/tools/builtin_tool/providers/code/tools/simple_code.py
similarity index 93%
rename from api/core/tools/provider/builtin/code/tools/simple_code.py
rename to api/core/tools/builtin_tool/providers/code/tools/simple_code.py
index 632c9fc7f1..14ff1969ff 100644
--- a/api/core/tools/provider/builtin/code/tools/simple_code.py
+++ b/api/core/tools/builtin_tool/providers/code/tools/simple_code.py
@@ -1,8 +1,8 @@
from typing import Any
from core.helper.code_executor.code_executor import CodeExecutor, CodeLanguage
+from core.tools.builtin_tool.tool import BuiltinTool
from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
class SimpleCode(BuiltinTool):
diff --git a/api/core/tools/provider/builtin/code/tools/simple_code.yaml b/api/core/tools/builtin_tool/providers/code/tools/simple_code.yaml
similarity index 100%
rename from api/core/tools/provider/builtin/code/tools/simple_code.yaml
rename to api/core/tools/builtin_tool/providers/code/tools/simple_code.yaml
diff --git a/api/core/tools/provider/builtin/qrcode/_assets/icon.svg b/api/core/tools/builtin_tool/providers/qrcode/_assets/icon.svg
similarity index 100%
rename from api/core/tools/provider/builtin/qrcode/_assets/icon.svg
rename to api/core/tools/builtin_tool/providers/qrcode/_assets/icon.svg
diff --git a/api/core/tools/provider/builtin/qrcode/qrcode.py b/api/core/tools/builtin_tool/providers/qrcode/qrcode.py
similarity index 71%
rename from api/core/tools/provider/builtin/qrcode/qrcode.py
rename to api/core/tools/builtin_tool/providers/qrcode/qrcode.py
index 8466b9a26b..542ee7b63e 100644
--- a/api/core/tools/provider/builtin/qrcode/qrcode.py
+++ b/api/core/tools/builtin_tool/providers/qrcode/qrcode.py
@@ -1,8 +1,8 @@
from typing import Any
+from core.tools.builtin_tool.provider import BuiltinToolProviderController
+from core.tools.builtin_tool.providers.qrcode.tools.qrcode_generator import QRCodeGeneratorTool
from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.qrcode.tools.qrcode_generator import QRCodeGeneratorTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
class QRCodeProvider(BuiltinToolProviderController):
diff --git a/api/core/tools/provider/builtin/qrcode/qrcode.yaml b/api/core/tools/builtin_tool/providers/qrcode/qrcode.yaml
similarity index 100%
rename from api/core/tools/provider/builtin/qrcode/qrcode.yaml
rename to api/core/tools/builtin_tool/providers/qrcode/qrcode.yaml
diff --git a/api/core/tools/provider/builtin/qrcode/tools/qrcode_generator.py b/api/core/tools/builtin_tool/providers/qrcode/tools/qrcode_generator.py
similarity index 97%
rename from api/core/tools/provider/builtin/qrcode/tools/qrcode_generator.py
rename to api/core/tools/builtin_tool/providers/qrcode/tools/qrcode_generator.py
index d8ca20bde6..081ad30231 100644
--- a/api/core/tools/provider/builtin/qrcode/tools/qrcode_generator.py
+++ b/api/core/tools/builtin_tool/providers/qrcode/tools/qrcode_generator.py
@@ -7,8 +7,8 @@ from qrcode.image.base import BaseImage
from qrcode.image.pure import PyPNGImage
from qrcode.main import QRCode
+from core.tools.builtin_tool.tool import BuiltinTool
from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
class QRCodeGeneratorTool(BuiltinTool):
diff --git a/api/core/tools/provider/builtin/qrcode/tools/qrcode_generator.yaml b/api/core/tools/builtin_tool/providers/qrcode/tools/qrcode_generator.yaml
similarity index 100%
rename from api/core/tools/provider/builtin/qrcode/tools/qrcode_generator.yaml
rename to api/core/tools/builtin_tool/providers/qrcode/tools/qrcode_generator.yaml
diff --git a/api/core/tools/provider/builtin/time/_assets/icon.svg b/api/core/tools/builtin_tool/providers/time/_assets/icon.svg
similarity index 100%
rename from api/core/tools/provider/builtin/time/_assets/icon.svg
rename to api/core/tools/builtin_tool/providers/time/_assets/icon.svg
diff --git a/api/core/tools/provider/builtin/time/time.py b/api/core/tools/builtin_tool/providers/time/time.py
similarity index 73%
rename from api/core/tools/provider/builtin/time/time.py
rename to api/core/tools/builtin_tool/providers/time/time.py
index e4df8d616c..234ca9d9d6 100644
--- a/api/core/tools/provider/builtin/time/time.py
+++ b/api/core/tools/builtin_tool/providers/time/time.py
@@ -1,8 +1,8 @@
from typing import Any
+from core.tools.builtin_tool.provider import BuiltinToolProviderController
+from core.tools.builtin_tool.providers.time.tools.current_time import CurrentTimeTool
from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.time.tools.current_time import CurrentTimeTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
class WikiPediaProvider(BuiltinToolProviderController):
diff --git a/api/core/tools/provider/builtin/time/time.yaml b/api/core/tools/builtin_tool/providers/time/time.yaml
similarity index 100%
rename from api/core/tools/provider/builtin/time/time.yaml
rename to api/core/tools/builtin_tool/providers/time/time.yaml
diff --git a/api/core/tools/provider/builtin/time/tools/current_time.py b/api/core/tools/builtin_tool/providers/time/tools/current_time.py
similarity index 94%
rename from api/core/tools/provider/builtin/time/tools/current_time.py
rename to api/core/tools/builtin_tool/providers/time/tools/current_time.py
index cc38739c16..a403c49296 100644
--- a/api/core/tools/provider/builtin/time/tools/current_time.py
+++ b/api/core/tools/builtin_tool/providers/time/tools/current_time.py
@@ -3,8 +3,8 @@ from typing import Any, Union
from pytz import timezone as pytz_timezone
+from core.tools.builtin_tool.tool import BuiltinTool
from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
class CurrentTimeTool(BuiltinTool):
diff --git a/api/core/tools/provider/builtin/time/tools/current_time.yaml b/api/core/tools/builtin_tool/providers/time/tools/current_time.yaml
similarity index 100%
rename from api/core/tools/provider/builtin/time/tools/current_time.yaml
rename to api/core/tools/builtin_tool/providers/time/tools/current_time.yaml
diff --git a/api/core/tools/provider/builtin/time/tools/weekday.py b/api/core/tools/builtin_tool/providers/time/tools/weekday.py
similarity index 91%
rename from api/core/tools/provider/builtin/time/tools/weekday.py
rename to api/core/tools/builtin_tool/providers/time/tools/weekday.py
index b327e54e17..570ab62413 100644
--- a/api/core/tools/provider/builtin/time/tools/weekday.py
+++ b/api/core/tools/builtin_tool/providers/time/tools/weekday.py
@@ -2,8 +2,8 @@ import calendar
from datetime import datetime
from typing import Any, Union
+from core.tools.builtin_tool.tool import BuiltinTool
from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
class WeekdayTool(BuiltinTool):
@@ -17,6 +17,8 @@ class WeekdayTool(BuiltinTool):
"""
year = tool_parameters.get("year")
month = tool_parameters.get("month")
+ if month is None:
+ raise ValueError("Month is required")
day = tool_parameters.get("day")
date_obj = self.convert_datetime(year, month, day)
diff --git a/api/core/tools/provider/builtin/time/tools/weekday.yaml b/api/core/tools/builtin_tool/providers/time/tools/weekday.yaml
similarity index 100%
rename from api/core/tools/provider/builtin/time/tools/weekday.yaml
rename to api/core/tools/builtin_tool/providers/time/tools/weekday.yaml
diff --git a/api/core/tools/tool/builtin_tool.py b/api/core/tools/builtin_tool/tool.py
similarity index 96%
rename from api/core/tools/tool/builtin_tool.py
rename to api/core/tools/builtin_tool/tool.py
index 8edaf7c0e6..243d99dee3 100644
--- a/api/core/tools/tool/builtin_tool.py
+++ b/api/core/tools/builtin_tool/tool.py
@@ -1,7 +1,7 @@
from core.model_runtime.entities.llm_entities import LLMResult
from core.model_runtime.entities.message_entities import PromptMessage, SystemPromptMessage, UserPromptMessage
+from core.tools.__base.tool import Tool
from core.tools.entities.tool_entities import ToolProviderType
-from core.tools.tool.tool import Tool
from core.tools.utils.model_invocation_utils import ModelInvocationUtils
from core.tools.utils.web_reader_tool import get_url
@@ -32,7 +32,7 @@ class BuiltinTool(Tool):
# invoke model
return ModelInvocationUtils.invoke(
user_id=user_id,
- tenant_id=self.runtime.tenant_id,
+ tenant_id=self.runtime.tenant_id or "",
tool_type="builtin",
tool_name=self.identity.name,
prompt_messages=prompt_messages,
@@ -124,7 +124,7 @@ class BuiltinTool(Tool):
return result
- def get_url(self, url: str, user_agent: str = None) -> str:
+ def get_url(self, url: str, user_agent: str | None = None) -> str:
"""
get url
"""
diff --git a/api/core/tools/provider/api_tool_provider.py b/api/core/tools/custom_tool/provider.py
similarity index 97%
rename from api/core/tools/provider/api_tool_provider.py
rename to api/core/tools/custom_tool/provider.py
index 307cc0a0d9..7ebaa6c5c6 100644
--- a/api/core/tools/provider/api_tool_provider.py
+++ b/api/core/tools/custom_tool/provider.py
@@ -1,14 +1,14 @@
from pydantic import Field
from core.entities.provider_entities import ProviderConfig
+from core.tools.__base.tool_provider import ToolProviderController
+from core.tools.custom_tool.tool import ApiTool
from core.tools.entities.common_entities import I18nObject
from core.tools.entities.tool_bundle import ApiToolBundle
from core.tools.entities.tool_entities import (
ApiProviderAuthType,
ToolProviderType,
)
-from core.tools.provider.tool_provider import ToolProviderController
-from core.tools.tool.api_tool import ApiTool
from extensions.ext_database import db
from models.tools import ApiToolProvider
@@ -67,7 +67,8 @@ class ApiToolProviderController(ToolProviderController):
else:
raise ValueError(f"invalid auth type {auth_type}")
- user_name = db_provider.user.name if db_provider.user_id else ""
+ user = db_provider.user
+ user_name = user.name if user else ""
return ApiToolProviderController(
**{
diff --git a/api/core/tools/tool/api_tool.py b/api/core/tools/custom_tool/tool.py
similarity index 96%
rename from api/core/tools/tool/api_tool.py
rename to api/core/tools/custom_tool/tool.py
index 87f2514ce2..9a728bb684 100644
--- a/api/core/tools/tool/api_tool.py
+++ b/api/core/tools/custom_tool/tool.py
@@ -7,10 +7,10 @@ from urllib.parse import urlencode
import httpx
from core.helper import ssrf_proxy
+from core.tools.__base.tool import Tool
from core.tools.entities.tool_bundle import ApiToolBundle
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolProviderType
from core.tools.errors import ToolInvokeError, ToolParameterValidationError, ToolProviderCredentialValidationError
-from core.tools.tool.tool import Tool
API_TOOL_DEFAULT_TIMEOUT = (
int(getenv("API_TOOL_DEFAULT_CONNECT_TIMEOUT", "10")),
@@ -33,10 +33,10 @@ class ApiTool(Tool):
:return: the new tool
"""
return self.__class__(
- identity=self.identity.model_copy() if self.identity else None,
- parameters=self.parameters.copy() if self.parameters else None,
+ identity=self.identity.model_copy(),
+ parameters=self.parameters.copy() if self.parameters else [],
description=self.description.model_copy() if self.description else None,
- api_bundle=self.api_bundle.model_copy() if self.api_bundle else None,
+ api_bundle=self.api_bundle.model_copy(),
runtime=Tool.Runtime(**runtime),
)
@@ -60,6 +60,9 @@ class ApiTool(Tool):
return ToolProviderType.API
def assembling_request(self, parameters: dict[str, Any]) -> dict[str, Any]:
+ if self.runtime == None:
+ raise ToolProviderCredentialValidationError("runtime not initialized")
+
headers = {}
credentials = self.runtime.credentials or {}
@@ -88,7 +91,7 @@ class ApiTool(Tool):
headers[api_key_header] = credentials["api_key_value"]
- needed_parameters = [parameter for parameter in self.api_bundle.parameters if parameter.required]
+ needed_parameters = [parameter for parameter in (self.api_bundle.parameters or []) if parameter.required]
for parameter in needed_parameters:
if parameter.required and parameter.name not in parameters:
raise ToolParameterValidationError(f"Missing required parameter {parameter.name}")
@@ -204,7 +207,7 @@ class ApiTool(Tool):
)
return response
else:
- raise ValueError(f"Invalid http method {self.method}")
+ raise ValueError(f"Invalid http method {method}")
def _convert_body_property_any_of(
self, property: dict[str, Any], value: Any, any_of: list[dict[str, Any]], max_recursive=10
diff --git a/api/core/tools/entities/api_entities.py b/api/core/tools/entities/api_entities.py
index ae84338cdc..b3a98b4a6d 100644
--- a/api/core/tools/entities/api_entities.py
+++ b/api/core/tools/entities/api_entities.py
@@ -4,9 +4,9 @@ from pydantic import BaseModel, Field
from core.entities.provider_entities import ProviderConfig
from core.model_runtime.utils.encoders import jsonable_encoder
+from core.tools.__base.tool import ToolParameter
from core.tools.entities.common_entities import I18nObject
from core.tools.entities.tool_entities import ToolProviderType
-from core.tools.tool.tool import ToolParameter
class UserTool(BaseModel):
diff --git a/api/core/tools/entities/tool_entities.py b/api/core/tools/entities/tool_entities.py
index d8383539bb..cc84f6eaad 100644
--- a/api/core/tools/entities/tool_entities.py
+++ b/api/core/tools/entities/tool_entities.py
@@ -32,6 +32,7 @@ class ToolProviderType(str, Enum):
Enum class for tool provider
"""
+ PLUGIN = "plugin"
BUILT_IN = "builtin"
WORKFLOW = "workflow"
API = "api"
diff --git a/api/core/tools/plugin_tool/plugin_tool_provider.py b/api/core/tools/plugin_tool/plugin_tool_provider.py
new file mode 100644
index 0000000000..47a78ee318
--- /dev/null
+++ b/api/core/tools/plugin_tool/plugin_tool_provider.py
@@ -0,0 +1,30 @@
+
+
+from core.entities.provider_entities import ProviderConfig
+from core.tools.__base.tool import Tool
+from core.tools.__base.tool_provider import ToolProviderController
+from core.tools.entities.tool_entities import ToolProviderType
+
+
+class PluginToolProvider(ToolProviderController):
+ @property
+ def provider_type(self) -> ToolProviderType:
+ """
+ returns the type of the provider
+
+ :return: type of the provider
+ """
+ return ToolProviderType.PLUGIN
+
+ def get_tool(self, tool_name: str) -> Tool:
+ """
+ return tool with given name
+ """
+ return super().get_tool(tool_name)
+
+ def get_credentials_schema(self) -> dict[str, ProviderConfig]:
+ """
+ get credentials schema
+ """
+ return super().get_credentials_schema()
+
\ No newline at end of file
diff --git a/api/core/tools/provider/_position.yaml b/api/core/tools/provider/_position.yaml
deleted file mode 100644
index 40c3356116..0000000000
--- a/api/core/tools/provider/_position.yaml
+++ /dev/null
@@ -1,38 +0,0 @@
-- google
-- bing
-- perplexity
-- duckduckgo
-- searchapi
-- serper
-- searxng
-- dalle
-- azuredalle
-- stability
-- wikipedia
-- nominatim
-- yahoo
-- alphavantage
-- arxiv
-- pubmed
-- stablediffusion
-- webscraper
-- jina
-- aippt
-- youtube
-- code
-- wolframalpha
-- maths
-- github
-- chart
-- time
-- vectorizer
-- gaode
-- wecom
-- qrcode
-- dingtalk
-- feishu
-- feishu_base
-- feishu_document
-- feishu_message
-- slack
-- tianditu
diff --git a/api/core/tools/provider/app_tool_provider.py b/api/core/tools/provider/app_tool_provider.py
deleted file mode 100644
index 09f328cd1f..0000000000
--- a/api/core/tools/provider/app_tool_provider.py
+++ /dev/null
@@ -1,103 +0,0 @@
-import logging
-from typing import Any
-
-from core.tools.entities.common_entities import I18nObject
-from core.tools.entities.tool_entities import ToolParameter, ToolParameterOption, ToolProviderType
-from core.tools.provider.tool_provider import ToolProviderController
-from core.tools.tool.tool import Tool
-from extensions.ext_database import db
-from models.model import App, AppModelConfig
-from models.tools import PublishedAppTool
-
-logger = logging.getLogger(__name__)
-
-
-class AppToolProviderEntity(ToolProviderController):
- @property
- def provider_type(self) -> ToolProviderType:
- return ToolProviderType.APP
-
- def _validate_credentials(self, tool_name: str, credentials: dict[str, Any]) -> None:
- pass
-
- def validate_parameters(self, tool_name: str, tool_parameters: dict[str, Any]) -> None:
- pass
-
- def get_tools(self, user_id: str) -> list[Tool]:
- db_tools: list[PublishedAppTool] = (
- db.session.query(PublishedAppTool)
- .filter(
- PublishedAppTool.user_id == user_id,
- )
- .all()
- )
-
- if not db_tools or len(db_tools) == 0:
- return []
-
- tools: list[Tool] = []
-
- for db_tool in db_tools:
- tool = {
- "identity": {
- "author": db_tool.author,
- "name": db_tool.tool_name,
- "label": {"en_US": db_tool.tool_name, "zh_Hans": db_tool.tool_name},
- "icon": "",
- },
- "description": {
- "human": {"en_US": db_tool.description_i18n.en_US, "zh_Hans": db_tool.description_i18n.zh_Hans},
- "llm": db_tool.llm_description,
- },
- "parameters": [],
- }
- # get app from db
- app: App = db_tool.app
-
- if not app:
- logger.error(f"app {db_tool.app_id} not found")
- continue
-
- app_model_config: AppModelConfig = app.app_model_config
- user_input_form_list = app_model_config.user_input_form_list
- for input_form in user_input_form_list:
- # get type
- form_type = input_form.keys()[0]
- default = input_form[form_type]["default"]
- required = input_form[form_type]["required"]
- label = input_form[form_type]["label"]
- variable_name = input_form[form_type]["variable_name"]
- options = input_form[form_type].get("options", [])
- if form_type in {"paragraph", "text-input"}:
- tool["parameters"].append(
- ToolParameter(
- name=variable_name,
- label=I18nObject(en_US=label, zh_Hans=label),
- human_description=I18nObject(en_US=label, zh_Hans=label),
- llm_description=label,
- form=ToolParameter.ToolParameterForm.FORM,
- type=ToolParameter.ToolParameterType.STRING,
- required=required,
- default=default,
- )
- )
- elif form_type == "select":
- tool["parameters"].append(
- ToolParameter(
- name=variable_name,
- label=I18nObject(en_US=label, zh_Hans=label),
- human_description=I18nObject(en_US=label, zh_Hans=label),
- llm_description=label,
- form=ToolParameter.ToolParameterForm.FORM,
- type=ToolParameter.ToolParameterType.SELECT,
- required=required,
- default=default,
- options=[
- ToolParameterOption(value=option, label=I18nObject(en_US=option, zh_Hans=option))
- for option in options
- ],
- )
- )
-
- tools.append(Tool(**tool))
- return tools
diff --git a/api/core/tools/provider/builtin/aippt/_assets/icon.png b/api/core/tools/provider/builtin/aippt/_assets/icon.png
deleted file mode 100644
index b70618b487..0000000000
Binary files a/api/core/tools/provider/builtin/aippt/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/aippt/aippt.py b/api/core/tools/provider/builtin/aippt/aippt.py
deleted file mode 100644
index e0cbbd2992..0000000000
--- a/api/core/tools/provider/builtin/aippt/aippt.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.aippt.tools.aippt import AIPPTGenerateTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class AIPPTProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- AIPPTGenerateTool._get_api_token(credentials, user_id="__dify_system__")
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/aippt/aippt.yaml b/api/core/tools/provider/builtin/aippt/aippt.yaml
deleted file mode 100644
index 9b1b45d0f2..0000000000
--- a/api/core/tools/provider/builtin/aippt/aippt.yaml
+++ /dev/null
@@ -1,45 +0,0 @@
-identity:
- author: Dify
- name: aippt
- label:
- en_US: AIPPT
- zh_Hans: AIPPT
- description:
- en_US: AI-generated PPT with one click, input your content topic, and let AI serve you one-stop
- zh_Hans: AI一键生成PPT,输入你的内容主题,让AI为你一站式服务到底
- icon: icon.png
- tags:
- - productivity
- - design
-credentials_for_provider:
- aippt_access_key:
- type: secret-input
- required: true
- label:
- en_US: AIPPT API key
- zh_Hans: AIPPT API key
- pt_BR: AIPPT API key
- help:
- en_US: Please input your AIPPT API key
- zh_Hans: 请输入你的 AIPPT API key
- pt_BR: Please input your AIPPT API key
- placeholder:
- en_US: Please input your AIPPT API key
- zh_Hans: 请输入你的 AIPPT API key
- pt_BR: Please input your AIPPT API key
- url: https://www.aippt.cn
- aippt_secret_key:
- type: secret-input
- required: true
- label:
- en_US: AIPPT Secret key
- zh_Hans: AIPPT Secret key
- pt_BR: AIPPT Secret key
- help:
- en_US: Please input your AIPPT Secret key
- zh_Hans: 请输入你的 AIPPT Secret key
- pt_BR: Please input your AIPPT Secret key
- placeholder:
- en_US: Please input your AIPPT Secret key
- zh_Hans: 请输入你的 AIPPT Secret key
- pt_BR: Please input your AIPPT Secret key
diff --git a/api/core/tools/provider/builtin/aippt/tools/aippt.py b/api/core/tools/provider/builtin/aippt/tools/aippt.py
deleted file mode 100644
index dd9371f70d..0000000000
--- a/api/core/tools/provider/builtin/aippt/tools/aippt.py
+++ /dev/null
@@ -1,498 +0,0 @@
-from base64 import b64encode
-from hashlib import sha1
-from hmac import new as hmac_new
-from json import loads as json_loads
-from threading import Lock
-from time import sleep, time
-from typing import Any, Optional
-
-from httpx import get, post
-from requests import get as requests_get
-from yarl import URL
-
-from core.tools.entities.common_entities import I18nObject
-from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameter, ToolParameterOption
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class AIPPTGenerateTool(BuiltinTool):
- """
- A tool for generating a ppt
- """
-
- _api_base_url = URL("https://co.aippt.cn/api")
- _api_token_cache = {}
- _api_token_cache_lock: Optional[Lock] = None
- _style_cache = {}
- _style_cache_lock: Optional[Lock] = None
-
- _task = {}
- _task_type_map = {
- "auto": 1,
- "markdown": 7,
- }
-
- def __init__(self, **kwargs: Any):
- super().__init__(**kwargs)
- self._api_token_cache_lock = Lock()
- self._style_cache_lock = Lock()
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage | list[ToolInvokeMessage]:
- """
- Invokes the AIPPT generate tool with the given user ID and tool parameters.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Any]): The parameters for the tool
-
- Returns:
- ToolInvokeMessage | list[ToolInvokeMessage]: The result of the tool invocation,
- which can be a single message or a list of messages.
- """
- title = tool_parameters.get("title", "")
- if not title:
- return self.create_text_message("Please provide a title for the ppt")
-
- model = tool_parameters.get("model", "aippt")
- if not model:
- return self.create_text_message("Please provide a model for the ppt")
-
- outline = tool_parameters.get("outline", "")
-
- # create task
- task_id = self._create_task(
- type=self._task_type_map["auto" if not outline else "markdown"],
- title=title,
- content=outline,
- user_id=user_id,
- )
-
- # get suit
- color = tool_parameters.get("color")
- style = tool_parameters.get("style")
-
- if color == "__default__":
- color_id = ""
- else:
- color_id = int(color.split("-")[1])
-
- if style == "__default__":
- style_id = ""
- else:
- style_id = int(style.split("-")[1])
-
- suit_id = self._get_suit(style_id=style_id, colour_id=color_id)
-
- # generate outline
- if not outline:
- self._generate_outline(task_id=task_id, model=model, user_id=user_id)
-
- # generate content
- self._generate_content(task_id=task_id, model=model, user_id=user_id)
-
- # generate ppt
- _, ppt_url = self._generate_ppt(task_id=task_id, suit_id=suit_id, user_id=user_id)
-
- return self.create_text_message(
- """the ppt has been created successfully,"""
- f"""the ppt url is {ppt_url}"""
- """please give the ppt url to user and direct user to download it."""
- )
-
- def _create_task(self, type: int, title: str, content: str, user_id: str) -> str:
- """
- Create a task
-
- :param type: the task type
- :param title: the task title
- :param content: the task content
-
- :return: the task ID
- """
- headers = {
- "x-channel": "",
- "x-api-key": self.runtime.credentials["aippt_access_key"],
- "x-token": self._get_api_token(credentials=self.runtime.credentials, user_id=user_id),
- }
- response = post(
- str(self._api_base_url / "ai" / "chat" / "v2" / "task"),
- headers=headers,
- files={"type": ("", str(type)), "title": ("", title), "content": ("", content)},
- )
-
- if response.status_code != 200:
- raise Exception(f"Failed to connect to aippt: {response.text}")
-
- response = response.json()
- if response.get("code") != 0:
- raise Exception(f'Failed to create task: {response.get("msg")}')
-
- return response.get("data", {}).get("id")
-
- def _generate_outline(self, task_id: str, model: str, user_id: str) -> str:
- api_url = (
- self._api_base_url / "ai" / "chat" / "outline"
- if model == "aippt"
- else self._api_base_url / "ai" / "chat" / "wx" / "outline"
- )
- api_url %= {"task_id": task_id}
-
- headers = {
- "x-channel": "",
- "x-api-key": self.runtime.credentials["aippt_access_key"],
- "x-token": self._get_api_token(credentials=self.runtime.credentials, user_id=user_id),
- }
-
- response = requests_get(url=api_url, headers=headers, stream=True, timeout=(10, 60))
-
- if response.status_code != 200:
- raise Exception(f"Failed to connect to aippt: {response.text}")
-
- outline = ""
- for chunk in response.iter_lines(delimiter=b"\n\n"):
- if not chunk:
- continue
-
- event = ""
- lines = chunk.decode("utf-8").split("\n")
- for line in lines:
- if line.startswith("event:"):
- event = line[6:]
- elif line.startswith("data:"):
- data = line[5:]
- if event == "message":
- try:
- data = json_loads(data)
- outline += data.get("content", "")
- except Exception as e:
- pass
- elif event == "close":
- break
- elif event in {"error", "filter"}:
- raise Exception(f"Failed to generate outline: {data}")
-
- return outline
-
- def _generate_content(self, task_id: str, model: str, user_id: str) -> str:
- api_url = (
- self._api_base_url / "ai" / "chat" / "content"
- if model == "aippt"
- else self._api_base_url / "ai" / "chat" / "wx" / "content"
- )
- api_url %= {"task_id": task_id}
-
- headers = {
- "x-channel": "",
- "x-api-key": self.runtime.credentials["aippt_access_key"],
- "x-token": self._get_api_token(credentials=self.runtime.credentials, user_id=user_id),
- }
-
- response = requests_get(url=api_url, headers=headers, stream=True, timeout=(10, 60))
-
- if response.status_code != 200:
- raise Exception(f"Failed to connect to aippt: {response.text}")
-
- if model == "aippt":
- content = ""
- for chunk in response.iter_lines(delimiter=b"\n\n"):
- if not chunk:
- continue
-
- event = ""
- lines = chunk.decode("utf-8").split("\n")
- for line in lines:
- if line.startswith("event:"):
- event = line[6:]
- elif line.startswith("data:"):
- data = line[5:]
- if event == "message":
- try:
- data = json_loads(data)
- content += data.get("content", "")
- except Exception as e:
- pass
- elif event == "close":
- break
- elif event in {"error", "filter"}:
- raise Exception(f"Failed to generate content: {data}")
-
- return content
- elif model == "wenxin":
- response = response.json()
- if response.get("code") != 0:
- raise Exception(f'Failed to generate content: {response.get("msg")}')
-
- return response.get("data", "")
-
- return ""
-
- def _generate_ppt(self, task_id: str, suit_id: int, user_id) -> tuple[str, str]:
- """
- Generate a ppt
-
- :param task_id: the task ID
- :param suit_id: the suit ID
- :return: the cover url of the ppt and the ppt url
- """
- headers = {
- "x-channel": "",
- "x-api-key": self.runtime.credentials["aippt_access_key"],
- "x-token": self._get_api_token(credentials=self.runtime.credentials, user_id=user_id),
- }
-
- response = post(
- str(self._api_base_url / "design" / "v2" / "save"),
- headers=headers,
- data={"task_id": task_id, "template_id": suit_id},
- )
-
- if response.status_code != 200:
- raise Exception(f"Failed to connect to aippt: {response.text}")
-
- response = response.json()
- if response.get("code") != 0:
- raise Exception(f'Failed to generate ppt: {response.get("msg")}')
-
- id = response.get("data", {}).get("id")
- cover_url = response.get("data", {}).get("cover_url")
-
- response = post(
- str(self._api_base_url / "download" / "export" / "file"),
- headers=headers,
- data={"id": id, "format": "ppt", "files_to_zip": False, "edit": True},
- )
-
- if response.status_code != 200:
- raise Exception(f"Failed to connect to aippt: {response.text}")
-
- response = response.json()
- if response.get("code") != 0:
- raise Exception(f'Failed to generate ppt: {response.get("msg")}')
-
- export_code = response.get("data")
- if not export_code:
- raise Exception("Failed to generate ppt, the export code is empty")
-
- current_iteration = 0
- while current_iteration < 50:
- # get ppt url
- response = post(
- str(self._api_base_url / "download" / "export" / "file" / "result"),
- headers=headers,
- data={"task_key": export_code},
- )
-
- if response.status_code != 200:
- raise Exception(f"Failed to connect to aippt: {response.text}")
-
- response = response.json()
- if response.get("code") != 0:
- raise Exception(f'Failed to generate ppt: {response.get("msg")}')
-
- if response.get("msg") == "导出中":
- current_iteration += 1
- sleep(2)
- continue
-
- ppt_url = response.get("data", [])
- if len(ppt_url) == 0:
- raise Exception("Failed to generate ppt, the ppt url is empty")
-
- return cover_url, ppt_url[0]
-
- raise Exception("Failed to generate ppt, the export is timeout")
-
- @classmethod
- def _get_api_token(cls, credentials: dict[str, str], user_id: str) -> str:
- """
- Get API token
-
- :param credentials: the credentials
- :return: the API token
- """
- access_key = credentials["aippt_access_key"]
- secret_key = credentials["aippt_secret_key"]
-
- cache_key = f"{access_key}#@#{user_id}"
-
- with cls._api_token_cache_lock:
- # clear expired tokens
- now = time()
- for key in list(cls._api_token_cache.keys()):
- if cls._api_token_cache[key]["expire"] < now:
- del cls._api_token_cache[key]
-
- if cache_key in cls._api_token_cache:
- return cls._api_token_cache[cache_key]["token"]
-
- # get token
- headers = {
- "x-api-key": access_key,
- "x-timestamp": str(int(now)),
- "x-signature": cls._calculate_sign(access_key, secret_key, int(now)),
- }
-
- param = {"uid": user_id, "channel": ""}
-
- response = get(str(cls._api_base_url / "grant" / "token"), params=param, headers=headers)
-
- if response.status_code != 200:
- raise Exception(f"Failed to connect to aippt: {response.text}")
- response = response.json()
- if response.get("code") != 0:
- raise Exception(f'Failed to connect to aippt: {response.get("msg")}')
-
- token = response.get("data", {}).get("token")
- expire = response.get("data", {}).get("time_expire")
-
- with cls._api_token_cache_lock:
- cls._api_token_cache[cache_key] = {"token": token, "expire": now + expire}
-
- return token
-
- @classmethod
- def _calculate_sign(cls, access_key: str, secret_key: str, timestamp: int) -> str:
- return b64encode(
- hmac_new(
- key=secret_key.encode("utf-8"), msg=f"GET@/api/grant/token/@{timestamp}".encode(), digestmod=sha1
- ).digest()
- ).decode("utf-8")
-
- @classmethod
- def _get_styles(cls, credentials: dict[str, str], user_id: str) -> tuple[list[dict], list[dict]]:
- """
- Get styles
- """
-
- # check cache
- with cls._style_cache_lock:
- # clear expired styles
- now = time()
- for key in list(cls._style_cache.keys()):
- if cls._style_cache[key]["expire"] < now:
- del cls._style_cache[key]
-
- key = f'{credentials["aippt_access_key"]}#@#{user_id}'
- if key in cls._style_cache:
- return cls._style_cache[key]["colors"], cls._style_cache[key]["styles"]
-
- headers = {
- "x-channel": "",
- "x-api-key": credentials["aippt_access_key"],
- "x-token": cls._get_api_token(credentials=credentials, user_id=user_id),
- }
- response = get(str(cls._api_base_url / "template_component" / "suit" / "select"), headers=headers)
-
- if response.status_code != 200:
- raise Exception(f"Failed to connect to aippt: {response.text}")
-
- response = response.json()
-
- if response.get("code") != 0:
- raise Exception(f'Failed to connect to aippt: {response.get("msg")}')
-
- colors = [
- {
- "id": f'id-{item.get("id")}',
- "name": item.get("name"),
- "en_name": item.get("en_name", item.get("name")),
- }
- for item in response.get("data", {}).get("colour") or []
- ]
- styles = [
- {
- "id": f'id-{item.get("id")}',
- "name": item.get("title"),
- }
- for item in response.get("data", {}).get("suit_style") or []
- ]
-
- with cls._style_cache_lock:
- cls._style_cache[key] = {"colors": colors, "styles": styles, "expire": now + 60 * 60}
-
- return colors, styles
-
- def get_styles(self, user_id: str) -> tuple[list[dict], list[dict]]:
- """
- Get styles
-
- :param credentials: the credentials
- :return: Tuple[list[dict[id, color]], list[dict[id, style]]
- """
- if not self.runtime.credentials.get("aippt_access_key") or not self.runtime.credentials.get("aippt_secret_key"):
- raise Exception("Please provide aippt credentials")
-
- return self._get_styles(credentials=self.runtime.credentials, user_id=user_id)
-
- def _get_suit(self, style_id: int, colour_id: int) -> int:
- """
- Get suit
- """
- headers = {
- "x-channel": "",
- "x-api-key": self.runtime.credentials["aippt_access_key"],
- "x-token": self._get_api_token(credentials=self.runtime.credentials, user_id="__dify_system__"),
- }
- response = get(
- str(self._api_base_url / "template_component" / "suit" / "search"),
- headers=headers,
- params={"style_id": style_id, "colour_id": colour_id, "page": 1, "page_size": 1},
- )
-
- if response.status_code != 200:
- raise Exception(f"Failed to connect to aippt: {response.text}")
-
- response = response.json()
-
- if response.get("code") != 0:
- raise Exception(f'Failed to connect to aippt: {response.get("msg")}')
-
- if len(response.get("data", {}).get("list") or []) > 0:
- return response.get("data", {}).get("list")[0].get("id")
-
- raise Exception("Failed to get suit, the suit does not exist, please check the style and color")
-
- def get_runtime_parameters(self) -> list[ToolParameter]:
- """
- Get runtime parameters
-
- Override this method to add runtime parameters to the tool.
- """
- try:
- colors, styles = self.get_styles(user_id="__dify_system__")
- except Exception as e:
- colors, styles = (
- [{"id": "-1", "name": "__default__", "en_name": "__default__"}],
- [{"id": "-1", "name": "__default__", "en_name": "__default__"}],
- )
-
- return [
- ToolParameter(
- name="color",
- label=I18nObject(zh_Hans="颜色", en_US="Color"),
- human_description=I18nObject(zh_Hans="颜色", en_US="Color"),
- type=ToolParameter.ToolParameterType.SELECT,
- form=ToolParameter.ToolParameterForm.FORM,
- required=False,
- default=colors[0]["id"],
- options=[
- ToolParameterOption(
- value=color["id"], label=I18nObject(zh_Hans=color["name"], en_US=color["en_name"])
- )
- for color in colors
- ],
- ),
- ToolParameter(
- name="style",
- label=I18nObject(zh_Hans="风格", en_US="Style"),
- human_description=I18nObject(zh_Hans="风格", en_US="Style"),
- type=ToolParameter.ToolParameterType.SELECT,
- form=ToolParameter.ToolParameterForm.FORM,
- required=False,
- default=styles[0]["id"],
- options=[
- ToolParameterOption(value=style["id"], label=I18nObject(zh_Hans=style["name"], en_US=style["name"]))
- for style in styles
- ],
- ),
- ]
diff --git a/api/core/tools/provider/builtin/aippt/tools/aippt.yaml b/api/core/tools/provider/builtin/aippt/tools/aippt.yaml
deleted file mode 100644
index d35798ad66..0000000000
--- a/api/core/tools/provider/builtin/aippt/tools/aippt.yaml
+++ /dev/null
@@ -1,54 +0,0 @@
-identity:
- name: aippt
- author: Dify
- label:
- en_US: AIPPT
- zh_Hans: AIPPT
-description:
- human:
- en_US: AI-generated PPT with one click, input your content topic, and let AI serve you one-stop
- zh_Hans: AI一键生成PPT,输入你的内容主题,让AI为你一站式服务到底
- llm: A tool used to generate PPT with AI, input your content topic, and let AI generate PPT for you.
-parameters:
- - name: title
- type: string
- required: true
- label:
- en_US: Title
- zh_Hans: 标题
- human_description:
- en_US: The title of the PPT.
- zh_Hans: PPT的标题。
- llm_description: The title of the PPT, which will be used to generate the PPT outline.
- form: llm
- - name: outline
- type: string
- required: false
- label:
- en_US: Outline
- zh_Hans: 大纲
- human_description:
- en_US: The outline of the PPT
- zh_Hans: PPT的大纲
- llm_description: The outline of the PPT, which will be used to generate the PPT content. provide it if you have.
- form: llm
- - name: llm
- type: select
- required: true
- label:
- en_US: LLM model
- zh_Hans: 生成大纲的LLM
- options:
- - value: aippt
- label:
- en_US: AIPPT default model
- zh_Hans: AIPPT默认模型
- - value: wenxin
- label:
- en_US: Wenxin ErnieBot
- zh_Hans: 文心一言
- default: aippt
- human_description:
- en_US: The LLM model used for generating PPT outline.
- zh_Hans: 用于生成PPT大纲的LLM模型。
- form: form
diff --git a/api/core/tools/provider/builtin/alphavantage/_assets/icon.svg b/api/core/tools/provider/builtin/alphavantage/_assets/icon.svg
deleted file mode 100644
index 785432943b..0000000000
--- a/api/core/tools/provider/builtin/alphavantage/_assets/icon.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/alphavantage/alphavantage.py b/api/core/tools/provider/builtin/alphavantage/alphavantage.py
deleted file mode 100644
index a84630e5aa..0000000000
--- a/api/core/tools/provider/builtin/alphavantage/alphavantage.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.alphavantage.tools.query_stock import QueryStockTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class AlphaVantageProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- QueryStockTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "code": "AAPL", # Apple Inc.
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/alphavantage/alphavantage.yaml b/api/core/tools/provider/builtin/alphavantage/alphavantage.yaml
deleted file mode 100644
index 710510cfd8..0000000000
--- a/api/core/tools/provider/builtin/alphavantage/alphavantage.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-identity:
- author: zhuhao
- name: alphavantage
- label:
- en_US: AlphaVantage
- zh_Hans: AlphaVantage
- pt_BR: AlphaVantage
- description:
- en_US: AlphaVantage is an online platform that provides financial market data and APIs, making it convenient for individual investors and developers to access stock quotes, technical indicators, and stock analysis.
- zh_Hans: AlphaVantage是一个在线平台,它提供金融市场数据和API,便于个人投资者和开发者获取股票报价、技术指标和股票分析。
- pt_BR: AlphaVantage is an online platform that provides financial market data and APIs, making it convenient for individual investors and developers to access stock quotes, technical indicators, and stock analysis.
- icon: icon.svg
- tags:
- - finance
-credentials_for_provider:
- api_key:
- type: secret-input
- required: true
- label:
- en_US: AlphaVantage API key
- zh_Hans: AlphaVantage API key
- pt_BR: AlphaVantage API key
- placeholder:
- en_US: Please input your AlphaVantage API key
- zh_Hans: 请输入你的 AlphaVantage API key
- pt_BR: Please input your AlphaVantage API key
- help:
- en_US: Get your AlphaVantage API key from AlphaVantage
- zh_Hans: 从 AlphaVantage 获取您的 AlphaVantage API key
- pt_BR: Get your AlphaVantage API key from AlphaVantage
- url: https://www.alphavantage.co/support/#api-key
diff --git a/api/core/tools/provider/builtin/alphavantage/tools/query_stock.py b/api/core/tools/provider/builtin/alphavantage/tools/query_stock.py
deleted file mode 100644
index d06611acd0..0000000000
--- a/api/core/tools/provider/builtin/alphavantage/tools/query_stock.py
+++ /dev/null
@@ -1,48 +0,0 @@
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-ALPHAVANTAGE_API_URL = "https://www.alphavantage.co/query"
-
-
-class QueryStockTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- stock_code = tool_parameters.get("code", "")
- if not stock_code:
- return self.create_text_message("Please tell me your stock code")
-
- if "api_key" not in self.runtime.credentials or not self.runtime.credentials.get("api_key"):
- return self.create_text_message("Alpha Vantage API key is required.")
-
- params = {
- "function": "TIME_SERIES_DAILY",
- "symbol": stock_code,
- "outputsize": "compact",
- "datatype": "json",
- "apikey": self.runtime.credentials["api_key"],
- }
- response = requests.get(url=ALPHAVANTAGE_API_URL, params=params)
- response.raise_for_status()
- result = self._handle_response(response.json())
- return self.create_json_message(result)
-
- def _handle_response(self, response: dict[str, Any]) -> dict[str, Any]:
- result = response.get("Time Series (Daily)", {})
- if not result:
- return {}
- stock_result = {}
- for k, v in result.items():
- stock_result[k] = {}
- stock_result[k]["open"] = v.get("1. open")
- stock_result[k]["high"] = v.get("2. high")
- stock_result[k]["low"] = v.get("3. low")
- stock_result[k]["close"] = v.get("4. close")
- stock_result[k]["volume"] = v.get("5. volume")
- return stock_result
diff --git a/api/core/tools/provider/builtin/alphavantage/tools/query_stock.yaml b/api/core/tools/provider/builtin/alphavantage/tools/query_stock.yaml
deleted file mode 100644
index d89f34e373..0000000000
--- a/api/core/tools/provider/builtin/alphavantage/tools/query_stock.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-identity:
- name: query_stock
- author: zhuhao
- label:
- en_US: query_stock
- zh_Hans: query_stock
- pt_BR: query_stock
-description:
- human:
- en_US: Retrieve information such as daily opening price, daily highest price, daily lowest price, daily closing price, and daily trading volume for a specified stock symbol.
- zh_Hans: 获取指定股票代码的每日开盘价、每日最高价、每日最低价、每日收盘价和每日交易量等信息。
- pt_BR: Retrieve information such as daily opening price, daily highest price, daily lowest price, daily closing price, and daily trading volume for a specified stock symbol
- llm: Retrieve information such as daily opening price, daily highest price, daily lowest price, daily closing price, and daily trading volume for a specified stock symbol
-parameters:
- - name: code
- type: string
- required: true
- label:
- en_US: stock code
- zh_Hans: 股票代码
- pt_BR: stock code
- human_description:
- en_US: stock code
- zh_Hans: 股票代码
- pt_BR: stock code
- llm_description: stock code for query from alphavantage
- form: llm
diff --git a/api/core/tools/provider/builtin/arxiv/_assets/icon.svg b/api/core/tools/provider/builtin/arxiv/_assets/icon.svg
deleted file mode 100644
index 0e60f63573..0000000000
--- a/api/core/tools/provider/builtin/arxiv/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/arxiv/arxiv.py b/api/core/tools/provider/builtin/arxiv/arxiv.py
deleted file mode 100644
index ebb2d1a8c4..0000000000
--- a/api/core/tools/provider/builtin/arxiv/arxiv.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.arxiv.tools.arxiv_search import ArxivSearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class ArxivProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- ArxivSearchTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "query": "John Doe",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/arxiv/arxiv.yaml b/api/core/tools/provider/builtin/arxiv/arxiv.yaml
deleted file mode 100644
index d26993b336..0000000000
--- a/api/core/tools/provider/builtin/arxiv/arxiv.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-identity:
- author: Yash Parmar
- name: arxiv
- label:
- en_US: ArXiv
- zh_Hans: ArXiv
- description:
- en_US: Access to a vast repository of scientific papers and articles in various fields of research.
- zh_Hans: 访问各个研究领域大量科学论文和文章的存储库。
- icon: icon.svg
- tags:
- - search
diff --git a/api/core/tools/provider/builtin/arxiv/tools/arxiv_search.py b/api/core/tools/provider/builtin/arxiv/tools/arxiv_search.py
deleted file mode 100644
index 2d65ba2d6f..0000000000
--- a/api/core/tools/provider/builtin/arxiv/tools/arxiv_search.py
+++ /dev/null
@@ -1,119 +0,0 @@
-import logging
-from typing import Any, Optional
-
-import arxiv
-from pydantic import BaseModel, Field
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-logger = logging.getLogger(__name__)
-
-
-class ArxivAPIWrapper(BaseModel):
- """Wrapper around ArxivAPI.
-
- To use, you should have the ``arxiv`` python package installed.
- https://lukasschwab.me/arxiv.py/index.html
- This wrapper will use the Arxiv API to conduct searches and
- fetch document summaries. By default, it will return the document summaries
- of the top-k results.
- It limits the Document content by doc_content_chars_max.
- Set doc_content_chars_max=None if you don't want to limit the content size.
-
- Args:
- top_k_results: number of the top-scored document used for the arxiv tool
- ARXIV_MAX_QUERY_LENGTH: the cut limit on the query used for the arxiv tool.
- load_max_docs: a limit to the number of loaded documents
- load_all_available_meta:
- if True: the `metadata` of the loaded Documents contains all available
- meta info (see https://lukasschwab.me/arxiv.py/index.html#Result),
- if False: the `metadata` contains only the published date, title,
- authors and summary.
- doc_content_chars_max: an optional cut limit for the length of a document's
- content
-
- Example:
- .. code-block:: python
-
- arxiv = ArxivAPIWrapper(
- top_k_results = 3,
- ARXIV_MAX_QUERY_LENGTH = 300,
- load_max_docs = 3,
- load_all_available_meta = False,
- doc_content_chars_max = 40000
- )
- arxiv.run("tree of thought llm)
- """
-
- arxiv_search: type[arxiv.Search] = arxiv.Search #: :meta private:
- arxiv_http_error: tuple[type[Exception]] = (arxiv.ArxivError, arxiv.UnexpectedEmptyPageError, arxiv.HTTPError)
- top_k_results: int = 3
- ARXIV_MAX_QUERY_LENGTH: int = 300
- load_max_docs: int = 100
- load_all_available_meta: bool = False
- doc_content_chars_max: Optional[int] = 4000
-
- def run(self, query: str) -> str:
- """
- Performs an arxiv search and A single string
- with the publish date, title, authors, and summary
- for each article separated by two newlines.
-
- If an error occurs or no documents found, error text
- is returned instead. Wrapper for
- https://lukasschwab.me/arxiv.py/index.html#Search
-
- Args:
- query: a plaintext search query
- """
- try:
- results = self.arxiv_search( # type: ignore
- query[: self.ARXIV_MAX_QUERY_LENGTH], max_results=self.top_k_results
- ).results()
- except arxiv_http_error as ex:
- return f"Arxiv exception: {ex}"
- docs = [
- f"Published: {result.updated.date()}\n"
- f"Title: {result.title}\n"
- f"Authors: {', '.join(a.name for a in result.authors)}\n"
- f"Summary: {result.summary}"
- for result in results
- ]
- if docs:
- return "\n\n".join(docs)[: self.doc_content_chars_max]
- else:
- return "No good Arxiv Result was found"
-
-
-class ArxivSearchInput(BaseModel):
- query: str = Field(..., description="Search query.")
-
-
-class ArxivSearchTool(BuiltinTool):
- """
- A tool for searching articles on Arxiv.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage | list[ToolInvokeMessage]:
- """
- Invokes the Arxiv search tool with the given user ID and tool parameters.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Any]): The parameters for the tool, including the 'query' parameter.
-
- Returns:
- ToolInvokeMessage | list[ToolInvokeMessage]: The result of the tool invocation,
- which can be a single message or a list of messages.
- """
- query = tool_parameters.get("query", "")
-
- if not query:
- return self.create_text_message("Please input query")
-
- arxiv = ArxivAPIWrapper()
-
- response = arxiv.run(query)
-
- return self.create_text_message(self.summary(user_id=user_id, content=response))
diff --git a/api/core/tools/provider/builtin/arxiv/tools/arxiv_search.yaml b/api/core/tools/provider/builtin/arxiv/tools/arxiv_search.yaml
deleted file mode 100644
index 7439a48658..0000000000
--- a/api/core/tools/provider/builtin/arxiv/tools/arxiv_search.yaml
+++ /dev/null
@@ -1,23 +0,0 @@
-identity:
- name: arxiv_search
- author: Yash Parmar
- label:
- en_US: Arxiv Search
- zh_Hans: Arxiv 搜索
-description:
- human:
- en_US: A tool for searching scientific papers and articles from the Arxiv repository. Input can be an Arxiv ID or an author's name.
- zh_Hans: 一个用于从Arxiv存储库搜索科学论文和文章的工具。 输入可以是Arxiv ID或作者姓名。
- llm: A tool for searching scientific papers and articles from the Arxiv repository. Input can be an Arxiv ID or an author's name.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query string
- zh_Hans: 查询字符串
- human_description:
- en_US: The Arxiv ID or author's name used for searching.
- zh_Hans: 用于搜索的Arxiv ID或作者姓名。
- llm_description: The Arxiv ID or author's name used for searching.
- form: llm
diff --git a/api/core/tools/provider/builtin/aws/_assets/icon.svg b/api/core/tools/provider/builtin/aws/_assets/icon.svg
deleted file mode 100644
index ecfcfc08d4..0000000000
--- a/api/core/tools/provider/builtin/aws/_assets/icon.svg
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/aws/aws.py b/api/core/tools/provider/builtin/aws/aws.py
deleted file mode 100644
index f81b5dbd27..0000000000
--- a/api/core/tools/provider/builtin/aws/aws.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.aws.tools.sagemaker_text_rerank import SageMakerReRankTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class SageMakerProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- SageMakerReRankTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "sagemaker_endpoint": "",
- "query": "misaka mikoto",
- "candidate_texts": "hello$$$hello world",
- "topk": 5,
- "aws_region": "",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/aws/aws.yaml b/api/core/tools/provider/builtin/aws/aws.yaml
deleted file mode 100644
index 847c6824a5..0000000000
--- a/api/core/tools/provider/builtin/aws/aws.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-identity:
- author: AWS
- name: aws
- label:
- en_US: AWS
- zh_Hans: 亚马逊云科技
- pt_BR: AWS
- description:
- en_US: Services on AWS.
- zh_Hans: 亚马逊云科技的各类服务
- pt_BR: Services on AWS.
- icon: icon.svg
- tags:
- - search
-credentials_for_provider:
diff --git a/api/core/tools/provider/builtin/aws/tools/apply_guardrail.py b/api/core/tools/provider/builtin/aws/tools/apply_guardrail.py
deleted file mode 100644
index a04f5c0fe9..0000000000
--- a/api/core/tools/provider/builtin/aws/tools/apply_guardrail.py
+++ /dev/null
@@ -1,90 +0,0 @@
-import json
-import logging
-from typing import Any, Union
-
-import boto3
-from botocore.exceptions import BotoCoreError
-from pydantic import BaseModel, Field
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-logging.basicConfig(level=logging.INFO)
-logger = logging.getLogger(__name__)
-
-
-class GuardrailParameters(BaseModel):
- guardrail_id: str = Field(..., description="The identifier of the guardrail")
- guardrail_version: str = Field(..., description="The version of the guardrail")
- source: str = Field(..., description="The source of the content")
- text: str = Field(..., description="The text to apply the guardrail to")
- aws_region: str = Field(..., description="AWS region for the Bedrock client")
-
-
-class ApplyGuardrailTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke the ApplyGuardrail tool
- """
- try:
- # Validate and parse input parameters
- params = GuardrailParameters(**tool_parameters)
-
- # Initialize AWS client
- bedrock_client = boto3.client("bedrock-runtime", region_name=params.aws_region)
-
- # Apply guardrail
- response = bedrock_client.apply_guardrail(
- guardrailIdentifier=params.guardrail_id,
- guardrailVersion=params.guardrail_version,
- source=params.source,
- content=[{"text": {"text": params.text}}],
- )
-
- logger.info(f"Raw response from AWS: {json.dumps(response, indent=2)}")
-
- # Check for empty response
- if not response:
- return self.create_text_message(text="Received empty response from AWS Bedrock.")
-
- # Process the result
- action = response.get("action", "No action specified")
- outputs = response.get("outputs", [])
- output = outputs[0].get("text", "No output received") if outputs else "No output received"
- assessments = response.get("assessments", [])
-
- # Format assessments
- formatted_assessments = []
- for assessment in assessments:
- for policy_type, policy_data in assessment.items():
- if isinstance(policy_data, dict) and "topics" in policy_data:
- for topic in policy_data["topics"]:
- formatted_assessments.append(
- f"Policy: {policy_type}, Topic: {topic['name']}, Type: {topic['type']},"
- f" Action: {topic['action']}"
- )
- else:
- formatted_assessments.append(f"Policy: {policy_type}, Data: {policy_data}")
-
- result = f"Action: {action}\n "
- result += f"Output: {output}\n "
- if formatted_assessments:
- result += "Assessments:\n " + "\n ".join(formatted_assessments) + "\n "
- # result += f"Full response: {json.dumps(response, indent=2, ensure_ascii=False)}"
-
- return self.create_text_message(text=result)
-
- except BotoCoreError as e:
- error_message = f"AWS service error: {str(e)}"
- logger.error(error_message, exc_info=True)
- return self.create_text_message(text=error_message)
- except json.JSONDecodeError as e:
- error_message = f"JSON parsing error: {str(e)}"
- logger.error(error_message, exc_info=True)
- return self.create_text_message(text=error_message)
- except Exception as e:
- error_message = f"An unexpected error occurred: {str(e)}"
- logger.error(error_message, exc_info=True)
- return self.create_text_message(text=error_message)
diff --git a/api/core/tools/provider/builtin/aws/tools/apply_guardrail.yaml b/api/core/tools/provider/builtin/aws/tools/apply_guardrail.yaml
deleted file mode 100644
index 66044e4ea8..0000000000
--- a/api/core/tools/provider/builtin/aws/tools/apply_guardrail.yaml
+++ /dev/null
@@ -1,67 +0,0 @@
-identity:
- name: apply_guardrail
- author: AWS
- label:
- en_US: Content Moderation Guardrails
- zh_Hans: 内容审查护栏
-description:
- human:
- en_US: Content Moderation Guardrails utilizes the ApplyGuardrail API, a feature of Guardrails for Amazon Bedrock. This API is capable of evaluating input prompts and model responses for all Foundation Models (FMs), including those on Amazon Bedrock, custom FMs, and third-party FMs. By implementing this functionality, organizations can achieve centralized governance across all their generative AI applications, thereby enhancing control and consistency in content moderation.
- zh_Hans: 内容审查护栏采用 Guardrails for Amazon Bedrock 功能中的 ApplyGuardrail API 。ApplyGuardrail 可以评估所有基础模型(FMs)的输入提示和模型响应,包括 Amazon Bedrock 上的 FMs、自定义 FMs 和第三方 FMs。通过实施这一功能, 组织可以在所有生成式 AI 应用程序中实现集中化的治理,从而增强内容审核的控制力和一致性。
- llm: Content Moderation Guardrails utilizes the ApplyGuardrail API, a feature of Guardrails for Amazon Bedrock. This API is capable of evaluating input prompts and model responses for all Foundation Models (FMs), including those on Amazon Bedrock, custom FMs, and third-party FMs. By implementing this functionality, organizations can achieve centralized governance across all their generative AI applications, thereby enhancing control and consistency in content moderation.
-parameters:
- - name: guardrail_id
- type: string
- required: true
- label:
- en_US: Guardrail ID
- zh_Hans: Guardrail ID
- human_description:
- en_US: Please enter the ID of the Guardrail that has already been created on Amazon Bedrock, for example 'qk5nk0e4b77b'.
- zh_Hans: 请输入已经在 Amazon Bedrock 上创建好的 Guardrail ID, 例如 'qk5nk0e4b77b'.
- llm_description: Please enter the ID of the Guardrail that has already been created on Amazon Bedrock, for example 'qk5nk0e4b77b'.
- form: form
- - name: guardrail_version
- type: string
- required: true
- label:
- en_US: Guardrail Version Number
- zh_Hans: Guardrail 版本号码
- human_description:
- en_US: Please enter the published version of the Guardrail ID that has already been created on Amazon Bedrock. This is typically a version number, such as 2.
- zh_Hans: 请输入已经在Amazon Bedrock 上创建好的Guardrail ID发布的版本, 通常使用版本号, 例如2.
- llm_description: Please enter the published version of the Guardrail ID that has already been created on Amazon Bedrock. This is typically a version number, such as 2.
- form: form
- - name: source
- type: string
- required: true
- label:
- en_US: Content Source (INPUT or OUTPUT)
- zh_Hans: 内容来源 (INPUT or OUTPUT)
- human_description:
- en_US: The source of data used in the request to apply the guardrail. Valid Values "INPUT | OUTPUT"
- zh_Hans: 用于应用护栏的请求中所使用的数据来源。有效值为 "INPUT | OUTPUT"
- llm_description: The source of data used in the request to apply the guardrail. Valid Values "INPUT | OUTPUT"
- form: form
- - name: text
- type: string
- required: true
- label:
- en_US: Content to be reviewed
- zh_Hans: 待审查内容
- human_description:
- en_US: The content used for requesting guardrail review, which can be either user input or LLM output.
- zh_Hans: 用于请求护栏审查的内容,可以是用户输入或 LLM 输出。
- llm_description: The content used for requesting guardrail review, which can be either user input or LLM output.
- form: llm
- - name: aws_region
- type: string
- required: true
- label:
- en_US: AWS Region
- zh_Hans: AWS 区域
- human_description:
- en_US: Please enter the AWS region for the Bedrock client, for example 'us-east-1'.
- zh_Hans: 请输入 Bedrock 客户端的 AWS 区域,例如 'us-east-1'。
- llm_description: Please enter the AWS region for the Bedrock client, for example 'us-east-1'.
- form: form
diff --git a/api/core/tools/provider/builtin/aws/tools/lambda_translate_utils.py b/api/core/tools/provider/builtin/aws/tools/lambda_translate_utils.py
deleted file mode 100644
index 48755753ac..0000000000
--- a/api/core/tools/provider/builtin/aws/tools/lambda_translate_utils.py
+++ /dev/null
@@ -1,91 +0,0 @@
-import json
-from typing import Any, Union
-
-import boto3
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class LambdaTranslateUtilsTool(BuiltinTool):
- lambda_client: Any = None
-
- def _invoke_lambda(self, text_content, src_lang, dest_lang, model_id, dictionary_name, request_type, lambda_name):
- msg = {
- "src_content": text_content,
- "src_lang": src_lang,
- "dest_lang": dest_lang,
- "dictionary_id": dictionary_name,
- "request_type": request_type,
- "model_id": model_id,
- }
-
- invoke_response = self.lambda_client.invoke(
- FunctionName=lambda_name, InvocationType="RequestResponse", Payload=json.dumps(msg)
- )
- response_body = invoke_response["Payload"]
-
- response_str = response_body.read().decode("unicode_escape")
-
- return response_str
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- line = 0
- try:
- if not self.lambda_client:
- aws_region = tool_parameters.get("aws_region")
- if aws_region:
- self.lambda_client = boto3.client("lambda", region_name=aws_region)
- else:
- self.lambda_client = boto3.client("lambda")
-
- line = 1
- text_content = tool_parameters.get("text_content", "")
- if not text_content:
- return self.create_text_message("Please input text_content")
-
- line = 2
- src_lang = tool_parameters.get("src_lang", "")
- if not src_lang:
- return self.create_text_message("Please input src_lang")
-
- line = 3
- dest_lang = tool_parameters.get("dest_lang", "")
- if not dest_lang:
- return self.create_text_message("Please input dest_lang")
-
- line = 4
- lambda_name = tool_parameters.get("lambda_name", "")
- if not lambda_name:
- return self.create_text_message("Please input lambda_name")
-
- line = 5
- request_type = tool_parameters.get("request_type", "")
- if not request_type:
- return self.create_text_message("Please input request_type")
-
- line = 6
- model_id = tool_parameters.get("model_id", "")
- if not model_id:
- return self.create_text_message("Please input model_id")
-
- line = 7
- dictionary_name = tool_parameters.get("dictionary_name", "")
- if not dictionary_name:
- return self.create_text_message("Please input dictionary_name")
-
- result = self._invoke_lambda(
- text_content, src_lang, dest_lang, model_id, dictionary_name, request_type, lambda_name
- )
-
- return self.create_text_message(text=result)
-
- except Exception as e:
- return self.create_text_message(f"Exception {str(e)}, line : {line}")
diff --git a/api/core/tools/provider/builtin/aws/tools/lambda_translate_utils.yaml b/api/core/tools/provider/builtin/aws/tools/lambda_translate_utils.yaml
deleted file mode 100644
index 3bb133c7ec..0000000000
--- a/api/core/tools/provider/builtin/aws/tools/lambda_translate_utils.yaml
+++ /dev/null
@@ -1,134 +0,0 @@
-identity:
- name: lambda_translate_utils
- author: AWS
- label:
- en_US: TranslateTool
- zh_Hans: 翻译工具
- pt_BR: TranslateTool
- icon: icon.svg
-description:
- human:
- en_US: A util tools for LLM translation, extra deployment is needed on AWS. Please refer Github Repo - https://github.com/ybalbert001/dynamodb-rag
- zh_Hans: 大语言模型翻译工具(专词映射获取),需要在AWS上进行额外部署,可参考Github Repo - https://github.com/ybalbert001/dynamodb-rag
- pt_BR: A util tools for LLM translation, specific Lambda Function deployment is needed on AWS. Please refer Github Repo - https://github.com/ybalbert001/dynamodb-rag
- llm: A util tools for translation.
-parameters:
- - name: text_content
- type: string
- required: true
- label:
- en_US: source content for translation
- zh_Hans: 待翻译原文
- pt_BR: source content for translation
- human_description:
- en_US: source content for translation
- zh_Hans: 待翻译原文
- pt_BR: source content for translation
- llm_description: source content for translation
- form: llm
- - name: src_lang
- type: string
- required: true
- label:
- en_US: source language code
- zh_Hans: 原文语言代号
- pt_BR: source language code
- human_description:
- en_US: source language code
- zh_Hans: 原文语言代号
- pt_BR: source language code
- llm_description: source language code
- form: llm
- - name: dest_lang
- type: string
- required: true
- label:
- en_US: target language code
- zh_Hans: 目标语言代号
- pt_BR: target language code
- human_description:
- en_US: target language code
- zh_Hans: 目标语言代号
- pt_BR: target language code
- llm_description: target language code
- form: llm
- - name: aws_region
- type: string
- required: false
- label:
- en_US: region of Lambda
- zh_Hans: Lambda 所在的region
- pt_BR: region of Lambda
- human_description:
- en_US: region of Lambda
- zh_Hans: Lambda 所在的region
- pt_BR: region of Lambda
- llm_description: region of Lambda
- form: form
- - name: model_id
- type: string
- required: false
- default: anthropic.claude-3-sonnet-20240229-v1:0
- label:
- en_US: LLM model_id in bedrock
- zh_Hans: bedrock上的大语言模型model_id
- pt_BR: LLM model_id in bedrock
- human_description:
- en_US: LLM model_id in bedrock
- zh_Hans: bedrock上的大语言模型model_id
- pt_BR: LLM model_id in bedrock
- llm_description: LLM model_id in bedrock
- form: form
- - name: dictionary_name
- type: string
- required: false
- label:
- en_US: dictionary name for term mapping
- zh_Hans: 专词映射表名称
- pt_BR: dictionary name for term mapping
- human_description:
- en_US: dictionary name for term mapping
- zh_Hans: 专词映射表名称
- pt_BR: dictionary name for term mapping
- llm_description: dictionary name for term mapping
- form: form
- - name: request_type
- type: select
- required: false
- label:
- en_US: request type
- zh_Hans: 请求类型
- pt_BR: request type
- human_description:
- en_US: request type
- zh_Hans: 请求类型
- pt_BR: request type
- default: term_mapping
- options:
- - value: term_mapping
- label:
- en_US: term_mapping
- zh_Hans: 专词映射
- - value: segment_only
- label:
- en_US: segment_only
- zh_Hans: 仅切词
- - value: translate
- label:
- en_US: translate
- zh_Hans: 翻译内容
- form: form
- - name: lambda_name
- type: string
- default: "translate_tool"
- required: true
- label:
- en_US: AWS Lambda for term mapping retrieval
- zh_Hans: 专词召回映射 - AWS Lambda
- pt_BR: lambda name for term mapping retrieval
- human_description:
- en_US: AWS Lambda for term mapping retrieval
- zh_Hans: 专词召回映射 - AWS Lambda
- pt_BR: AWS Lambda for term mapping retrieval
- llm_description: AWS Lambda for term mapping retrieval
- form: form
diff --git a/api/core/tools/provider/builtin/aws/tools/lambda_yaml_to_json.py b/api/core/tools/provider/builtin/aws/tools/lambda_yaml_to_json.py
deleted file mode 100644
index f43f3b6fe0..0000000000
--- a/api/core/tools/provider/builtin/aws/tools/lambda_yaml_to_json.py
+++ /dev/null
@@ -1,70 +0,0 @@
-import json
-import logging
-from typing import Any, Union
-
-import boto3
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-logging.basicConfig(level=logging.INFO)
-logger = logging.getLogger(__name__)
-
-console_handler = logging.StreamHandler()
-logger.addHandler(console_handler)
-
-
-class LambdaYamlToJsonTool(BuiltinTool):
- lambda_client: Any = None
-
- def _invoke_lambda(self, lambda_name: str, yaml_content: str) -> str:
- msg = {"body": yaml_content}
- logger.info(json.dumps(msg))
-
- invoke_response = self.lambda_client.invoke(
- FunctionName=lambda_name, InvocationType="RequestResponse", Payload=json.dumps(msg)
- )
- response_body = invoke_response["Payload"]
-
- response_str = response_body.read().decode("utf-8")
- resp_json = json.loads(response_str)
-
- logger.info(resp_json)
- if resp_json["statusCode"] != 200:
- raise Exception(f"Invalid status code: {response_str}")
-
- return resp_json["body"]
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- try:
- if not self.lambda_client:
- aws_region = tool_parameters.get("aws_region") # todo: move aws_region out, and update client region
- if aws_region:
- self.lambda_client = boto3.client("lambda", region_name=aws_region)
- else:
- self.lambda_client = boto3.client("lambda")
-
- yaml_content = tool_parameters.get("yaml_content", "")
- if not yaml_content:
- return self.create_text_message("Please input yaml_content")
-
- lambda_name = tool_parameters.get("lambda_name", "")
- if not lambda_name:
- return self.create_text_message("Please input lambda_name")
- logger.debug(f"{json.dumps(tool_parameters, indent=2, ensure_ascii=False)}")
-
- result = self._invoke_lambda(lambda_name, yaml_content)
- logger.debug(result)
-
- return self.create_text_message(result)
- except Exception as e:
- return self.create_text_message(f"Exception: {str(e)}")
-
- console_handler.flush()
diff --git a/api/core/tools/provider/builtin/aws/tools/lambda_yaml_to_json.yaml b/api/core/tools/provider/builtin/aws/tools/lambda_yaml_to_json.yaml
deleted file mode 100644
index 919c285348..0000000000
--- a/api/core/tools/provider/builtin/aws/tools/lambda_yaml_to_json.yaml
+++ /dev/null
@@ -1,53 +0,0 @@
-identity:
- name: lambda_yaml_to_json
- author: AWS
- label:
- en_US: LambdaYamlToJson
- zh_Hans: LambdaYamlToJson
- pt_BR: LambdaYamlToJson
- icon: icon.svg
-description:
- human:
- en_US: A tool to convert yaml to json using AWS Lambda.
- zh_Hans: 将 YAML 转为 JSON 的工具(通过AWS Lambda)。
- pt_BR: A tool to convert yaml to json using AWS Lambda.
- llm: A tool to convert yaml to json.
-parameters:
- - name: yaml_content
- type: string
- required: true
- label:
- en_US: YAML content to convert for
- zh_Hans: YAML 内容
- pt_BR: YAML content to convert for
- human_description:
- en_US: YAML content to convert for
- zh_Hans: YAML 内容
- pt_BR: YAML content to convert for
- llm_description: YAML content to convert for
- form: llm
- - name: aws_region
- type: string
- required: false
- label:
- en_US: region of lambda
- zh_Hans: Lambda 所在的region
- pt_BR: region of lambda
- human_description:
- en_US: region of lambda
- zh_Hans: Lambda 所在的region
- pt_BR: region of lambda
- llm_description: region of lambda
- form: form
- - name: lambda_name
- type: string
- required: false
- label:
- en_US: name of lambda
- zh_Hans: Lambda 名称
- pt_BR: name of lambda
- human_description:
- en_US: name of lambda
- zh_Hans: Lambda 名称
- pt_BR: name of lambda
- form: form
diff --git a/api/core/tools/provider/builtin/aws/tools/sagemaker_text_rerank.py b/api/core/tools/provider/builtin/aws/tools/sagemaker_text_rerank.py
deleted file mode 100644
index bffcd058b5..0000000000
--- a/api/core/tools/provider/builtin/aws/tools/sagemaker_text_rerank.py
+++ /dev/null
@@ -1,81 +0,0 @@
-import json
-import operator
-from typing import Any, Union
-
-import boto3
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class SageMakerReRankTool(BuiltinTool):
- sagemaker_client: Any = None
- sagemaker_endpoint: str = None
- topk: int = None
-
- def _sagemaker_rerank(self, query_input: str, docs: list[str], rerank_endpoint: str):
- inputs = [query_input] * len(docs)
- response_model = self.sagemaker_client.invoke_endpoint(
- EndpointName=rerank_endpoint,
- Body=json.dumps({"inputs": inputs, "docs": docs}),
- ContentType="application/json",
- )
- json_str = response_model["Body"].read().decode("utf8")
- json_obj = json.loads(json_str)
- scores = json_obj["scores"]
- return scores if isinstance(scores, list) else [scores]
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- line = 0
- try:
- if not self.sagemaker_client:
- aws_region = tool_parameters.get("aws_region")
- if aws_region:
- self.sagemaker_client = boto3.client("sagemaker-runtime", region_name=aws_region)
- else:
- self.sagemaker_client = boto3.client("sagemaker-runtime")
-
- line = 1
- if not self.sagemaker_endpoint:
- self.sagemaker_endpoint = tool_parameters.get("sagemaker_endpoint")
-
- line = 2
- if not self.topk:
- self.topk = tool_parameters.get("topk", 5)
-
- line = 3
- query = tool_parameters.get("query", "")
- if not query:
- return self.create_text_message("Please input query")
-
- line = 4
- candidate_texts = tool_parameters.get("candidate_texts")
- if not candidate_texts:
- return self.create_text_message("Please input candidate_texts")
-
- line = 5
- candidate_docs = json.loads(candidate_texts)
- docs = [item.get("content") for item in candidate_docs]
-
- line = 6
- scores = self._sagemaker_rerank(query_input=query, docs=docs, rerank_endpoint=self.sagemaker_endpoint)
-
- line = 7
- for idx in range(len(candidate_docs)):
- candidate_docs[idx]["score"] = scores[idx]
-
- line = 8
- sorted_candidate_docs = sorted(candidate_docs, key=operator.itemgetter("score"), reverse=True)
-
- line = 9
- return [self.create_json_message(res) for res in sorted_candidate_docs[: self.topk]]
-
- except Exception as e:
- return self.create_text_message(f"Exception {str(e)}, line : {line}")
diff --git a/api/core/tools/provider/builtin/aws/tools/sagemaker_text_rerank.yaml b/api/core/tools/provider/builtin/aws/tools/sagemaker_text_rerank.yaml
deleted file mode 100644
index d1dfdb9f84..0000000000
--- a/api/core/tools/provider/builtin/aws/tools/sagemaker_text_rerank.yaml
+++ /dev/null
@@ -1,82 +0,0 @@
-identity:
- name: sagemaker_text_rerank
- author: AWS
- label:
- en_US: SagemakerRerank
- zh_Hans: Sagemaker重排序
- pt_BR: SagemakerRerank
- icon: icon.svg
-description:
- human:
- en_US: A tool for performing text similarity ranking. You can find deploy notebook on Github Repo - https://github.com/aws-samples/dify-aws-tool
- zh_Hans: Sagemaker重排序工具, 请参考 Github Repo - https://github.com/aws-samples/dify-aws-tool上的部署脚本
- pt_BR: A tool for performing text similarity ranking.
- llm: A tool for performing text similarity ranking. You can find deploy notebook on Github Repo - https://github.com/aws-samples/dify-aws-tool
-parameters:
- - name: sagemaker_endpoint
- type: string
- required: true
- label:
- en_US: sagemaker endpoint for reranking
- zh_Hans: 重排序的SageMaker 端点
- pt_BR: sagemaker endpoint for reranking
- human_description:
- en_US: sagemaker endpoint for reranking
- zh_Hans: 重排序的SageMaker 端点
- pt_BR: sagemaker endpoint for reranking
- llm_description: sagemaker endpoint for reranking
- form: form
- - name: query
- type: string
- required: true
- label:
- en_US: Query string
- zh_Hans: 查询语句
- pt_BR: Query string
- human_description:
- en_US: key words for searching
- zh_Hans: 查询关键词
- pt_BR: key words for searching
- llm_description: key words for searching
- form: llm
- - name: candidate_texts
- type: string
- required: true
- label:
- en_US: text candidates
- zh_Hans: 候选文本
- pt_BR: text candidates
- human_description:
- en_US: searched candidates by query
- zh_Hans: 查询文本搜到候选文本
- pt_BR: searched candidates by query
- llm_description: searched candidates by query
- form: llm
- - name: topk
- type: number
- required: false
- form: form
- label:
- en_US: Limit for results count
- zh_Hans: 返回个数限制
- pt_BR: Limit for results count
- human_description:
- en_US: Limit for results count
- zh_Hans: 返回个数限制
- pt_BR: Limit for results count
- min: 1
- max: 10
- default: 5
- - name: aws_region
- type: string
- required: false
- label:
- en_US: region of sagemaker endpoint
- zh_Hans: SageMaker 端点所在的region
- pt_BR: region of sagemaker endpoint
- human_description:
- en_US: region of sagemaker endpoint
- zh_Hans: SageMaker 端点所在的region
- pt_BR: region of sagemaker endpoint
- llm_description: region of sagemaker endpoint
- form: form
diff --git a/api/core/tools/provider/builtin/aws/tools/sagemaker_tts.py b/api/core/tools/provider/builtin/aws/tools/sagemaker_tts.py
deleted file mode 100644
index bceeaab745..0000000000
--- a/api/core/tools/provider/builtin/aws/tools/sagemaker_tts.py
+++ /dev/null
@@ -1,101 +0,0 @@
-import json
-from enum import Enum
-from typing import Any, Union
-
-import boto3
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class TTSModelType(Enum):
- PresetVoice = "PresetVoice"
- CloneVoice = "CloneVoice"
- CloneVoice_CrossLingual = "CloneVoice_CrossLingual"
- InstructVoice = "InstructVoice"
-
-
-class SageMakerTTSTool(BuiltinTool):
- sagemaker_client: Any = None
- sagemaker_endpoint: str = None
- s3_client: Any = None
- comprehend_client: Any = None
-
- def _detect_lang_code(self, content: str, map_dict: dict = None):
- map_dict = {"zh": "<|zh|>", "en": "<|en|>", "ja": "<|jp|>", "zh-TW": "<|yue|>", "ko": "<|ko|>"}
-
- response = self.comprehend_client.detect_dominant_language(Text=content)
- language_code = response["Languages"][0]["LanguageCode"]
- return map_dict.get(language_code, "<|zh|>")
-
- def _build_tts_payload(
- self,
- model_type: str,
- content_text: str,
- model_role: str,
- prompt_text: str,
- prompt_audio: str,
- instruct_text: str,
- ):
- if model_type == TTSModelType.PresetVoice.value and model_role:
- return {"tts_text": content_text, "role": model_role}
- if model_type == TTSModelType.CloneVoice.value and prompt_text and prompt_audio:
- return {"tts_text": content_text, "prompt_text": prompt_text, "prompt_audio": prompt_audio}
- if model_type == TTSModelType.CloneVoice_CrossLingual.value and prompt_audio:
- lang_tag = self._detect_lang_code(content_text)
- return {"tts_text": f"{content_text}", "prompt_audio": prompt_audio, "lang_tag": lang_tag}
- if model_type == TTSModelType.InstructVoice.value and instruct_text and model_role:
- return {"tts_text": content_text, "role": model_role, "instruct_text": instruct_text}
-
- raise RuntimeError(f"Invalid params for {model_type}")
-
- def _invoke_sagemaker(self, payload: dict, endpoint: str):
- response_model = self.sagemaker_client.invoke_endpoint(
- EndpointName=endpoint,
- Body=json.dumps(payload),
- ContentType="application/json",
- )
- json_str = response_model["Body"].read().decode("utf8")
- json_obj = json.loads(json_str)
- return json_obj
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- try:
- if not self.sagemaker_client:
- aws_region = tool_parameters.get("aws_region")
- if aws_region:
- self.sagemaker_client = boto3.client("sagemaker-runtime", region_name=aws_region)
- self.s3_client = boto3.client("s3", region_name=aws_region)
- self.comprehend_client = boto3.client("comprehend", region_name=aws_region)
- else:
- self.sagemaker_client = boto3.client("sagemaker-runtime")
- self.s3_client = boto3.client("s3")
- self.comprehend_client = boto3.client("comprehend")
-
- if not self.sagemaker_endpoint:
- self.sagemaker_endpoint = tool_parameters.get("sagemaker_endpoint")
-
- tts_text = tool_parameters.get("tts_text")
- tts_infer_type = tool_parameters.get("tts_infer_type")
-
- voice = tool_parameters.get("voice")
- mock_voice_audio = tool_parameters.get("mock_voice_audio")
- mock_voice_text = tool_parameters.get("mock_voice_text")
- voice_instruct_prompt = tool_parameters.get("voice_instruct_prompt")
- payload = self._build_tts_payload(
- tts_infer_type, tts_text, voice, mock_voice_text, mock_voice_audio, voice_instruct_prompt
- )
-
- result = self._invoke_sagemaker(payload, self.sagemaker_endpoint)
-
- return self.create_text_message(text=result["s3_presign_url"])
-
- except Exception as e:
- return self.create_text_message(f"Exception {str(e)}")
diff --git a/api/core/tools/provider/builtin/aws/tools/sagemaker_tts.yaml b/api/core/tools/provider/builtin/aws/tools/sagemaker_tts.yaml
deleted file mode 100644
index a6a61dd4aa..0000000000
--- a/api/core/tools/provider/builtin/aws/tools/sagemaker_tts.yaml
+++ /dev/null
@@ -1,149 +0,0 @@
-identity:
- name: sagemaker_tts
- author: AWS
- label:
- en_US: SagemakerTTS
- zh_Hans: Sagemaker语音合成
- pt_BR: SagemakerTTS
- icon: icon.svg
-description:
- human:
- en_US: A tool for Speech synthesis - https://github.com/aws-samples/dify-aws-tool
- zh_Hans: Sagemaker语音合成工具, 请参考 Github Repo - https://github.com/aws-samples/dify-aws-tool上的部署脚本
- pt_BR: A tool for Speech synthesis.
- llm: A tool for Speech synthesis. You can find deploy notebook on Github Repo - https://github.com/aws-samples/dify-aws-tool
-parameters:
- - name: sagemaker_endpoint
- type: string
- required: true
- label:
- en_US: sagemaker endpoint for tts
- zh_Hans: 语音生成的SageMaker端点
- pt_BR: sagemaker endpoint for tts
- human_description:
- en_US: sagemaker endpoint for tts
- zh_Hans: 语音生成的SageMaker端点
- pt_BR: sagemaker endpoint for tts
- llm_description: sagemaker endpoint for tts
- form: form
- - name: tts_text
- type: string
- required: true
- label:
- en_US: tts text
- zh_Hans: 语音合成原文
- pt_BR: tts text
- human_description:
- en_US: tts text
- zh_Hans: 语音合成原文
- pt_BR: tts text
- llm_description: tts text
- form: llm
- - name: tts_infer_type
- type: select
- required: false
- label:
- en_US: tts infer type
- zh_Hans: 合成方式
- pt_BR: tts infer type
- human_description:
- en_US: tts infer type
- zh_Hans: 合成方式
- pt_BR: tts infer type
- llm_description: tts infer type
- options:
- - value: PresetVoice
- label:
- en_US: preset voice
- zh_Hans: 预置音色
- - value: CloneVoice
- label:
- en_US: clone voice
- zh_Hans: 克隆音色
- - value: CloneVoice_CrossLingual
- label:
- en_US: clone crossLingual voice
- zh_Hans: 克隆音色(跨语言)
- - value: InstructVoice
- label:
- en_US: instruct voice
- zh_Hans: 指令音色
- form: form
- - name: voice
- type: select
- required: false
- label:
- en_US: preset voice
- zh_Hans: 预置音色
- pt_BR: preset voice
- human_description:
- en_US: preset voice
- zh_Hans: 预置音色
- pt_BR: preset voice
- llm_description: preset voice
- options:
- - value: 中文男
- label:
- en_US: zh-cn male
- zh_Hans: 中文男
- - value: 中文女
- label:
- en_US: zh-cn female
- zh_Hans: 中文女
- - value: 粤语女
- label:
- en_US: zh-TW female
- zh_Hans: 粤语女
- form: form
- - name: mock_voice_audio
- type: string
- required: false
- label:
- en_US: clone voice link
- zh_Hans: 克隆音频链接
- pt_BR: clone voice link
- human_description:
- en_US: clone voice link
- zh_Hans: 克隆音频链接
- pt_BR: clone voice link
- llm_description: clone voice link
- form: llm
- - name: mock_voice_text
- type: string
- required: false
- label:
- en_US: text of clone voice
- zh_Hans: 克隆音频对应文本
- pt_BR: text of clone voice
- human_description:
- en_US: text of clone voice
- zh_Hans: 克隆音频对应文本
- pt_BR: text of clone voice
- llm_description: text of clone voice
- form: llm
- - name: voice_instruct_prompt
- type: string
- required: false
- label:
- en_US: instruct prompt for voice
- zh_Hans: 音色指令文本
- pt_BR: instruct prompt for voice
- human_description:
- en_US: instruct prompt for voice
- zh_Hans: 音色指令文本
- pt_BR: instruct prompt for voice
- llm_description: instruct prompt for voice
- form: llm
- - name: aws_region
- type: string
- required: false
- label:
- en_US: region of sagemaker endpoint
- zh_Hans: SageMaker 端点所在的region
- pt_BR: region of sagemaker endpoint
- human_description:
- en_US: region of sagemaker endpoint
- zh_Hans: SageMaker 端点所在的region
- pt_BR: region of sagemaker endpoint
- llm_description: region of sagemaker endpoint
- form: form
diff --git a/api/core/tools/provider/builtin/azuredalle/__init__.py b/api/core/tools/provider/builtin/azuredalle/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/api/core/tools/provider/builtin/azuredalle/_assets/icon.png b/api/core/tools/provider/builtin/azuredalle/_assets/icon.png
deleted file mode 100644
index 7083a3f638..0000000000
Binary files a/api/core/tools/provider/builtin/azuredalle/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/azuredalle/azuredalle.py b/api/core/tools/provider/builtin/azuredalle/azuredalle.py
deleted file mode 100644
index 1fab0d03a2..0000000000
--- a/api/core/tools/provider/builtin/azuredalle/azuredalle.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.azuredalle.tools.dalle3 import DallE3Tool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class AzureDALLEProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- DallE3Tool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={"prompt": "cute girl, blue eyes, white hair, anime style", "size": "square", "n": 1},
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/azuredalle/azuredalle.yaml b/api/core/tools/provider/builtin/azuredalle/azuredalle.yaml
deleted file mode 100644
index 4353e0c486..0000000000
--- a/api/core/tools/provider/builtin/azuredalle/azuredalle.yaml
+++ /dev/null
@@ -1,76 +0,0 @@
-identity:
- author: Leslie
- name: azuredalle
- label:
- en_US: Azure DALL-E
- zh_Hans: Azure DALL-E 绘画
- pt_BR: Azure DALL-E
- description:
- en_US: Azure DALL-E art
- zh_Hans: Azure DALL-E 绘画
- pt_BR: Azure DALL-E art
- icon: icon.png
- tags:
- - image
- - productivity
-credentials_for_provider:
- azure_openai_api_key:
- type: secret-input
- required: true
- label:
- en_US: API key
- zh_Hans: 密钥
- pt_BR: API key
- help:
- en_US: Please input your Azure OpenAI API key
- zh_Hans: 请输入你的 Azure OpenAI API key
- pt_BR: Introduza a sua chave de API OpenAI do Azure
- placeholder:
- en_US: Please input your Azure OpenAI API key
- zh_Hans: 请输入你的 Azure OpenAI API key
- pt_BR: Introduza a sua chave de API OpenAI do Azure
- azure_openai_api_model_name:
- type: text-input
- required: true
- label:
- en_US: Deployment Name
- zh_Hans: 部署名称
- pt_BR: Nome da Implantação
- help:
- en_US: Please input the name of your Azure Openai DALL-E API deployment
- zh_Hans: 请输入你的 Azure Openai DALL-E API 部署名称
- pt_BR: Insira o nome da implantação da API DALL-E do Azure Openai
- placeholder:
- en_US: Please input the name of your Azure Openai DALL-E API deployment
- zh_Hans: 请输入你的 Azure Openai DALL-E API 部署名称
- pt_BR: Insira o nome da implantação da API DALL-E do Azure Openai
- azure_openai_base_url:
- type: text-input
- required: true
- label:
- en_US: API Endpoint URL
- zh_Hans: API 域名
- pt_BR: API Endpoint URL
- help:
- en_US: Please input your Azure OpenAI Endpoint URL, e.g. https://xxx.openai.azure.com/
- zh_Hans: 请输入你的 Azure OpenAI API域名,例如:https://xxx.openai.azure.com/
- pt_BR: Introduza a URL do Azure OpenAI Endpoint, e.g. https://xxx.openai.azure.com/
- placeholder:
- en_US: Please input your Azure OpenAI Endpoint URL, e.g. https://xxx.openai.azure.com/
- zh_Hans: 请输入你的 Azure OpenAI API域名,例如:https://xxx.openai.azure.com/
- pt_BR: Introduza a URL do Azure OpenAI Endpoint, e.g. https://xxx.openai.azure.com/
- azure_openai_api_version:
- type: text-input
- required: true
- label:
- en_US: API Version
- zh_Hans: API 版本
- pt_BR: API Version
- help:
- en_US: Please input your Azure OpenAI API Version,e.g. 2023-12-01-preview
- zh_Hans: 请输入你的 Azure OpenAI API 版本,例如:2023-12-01-preview
- pt_BR: Introduza a versão da API OpenAI do Azure,e.g. 2023-12-01-preview
- placeholder:
- en_US: Please input your Azure OpenAI API Version,e.g. 2023-12-01-preview
- zh_Hans: 请输入你的 Azure OpenAI API 版本,例如:2023-12-01-preview
- pt_BR: Introduza a versão da API OpenAI do Azure,e.g. 2023-12-01-preview
diff --git a/api/core/tools/provider/builtin/azuredalle/tools/dalle3.py b/api/core/tools/provider/builtin/azuredalle/tools/dalle3.py
deleted file mode 100644
index cfa3cfb092..0000000000
--- a/api/core/tools/provider/builtin/azuredalle/tools/dalle3.py
+++ /dev/null
@@ -1,83 +0,0 @@
-import random
-from base64 import b64decode
-from typing import Any, Union
-
-from openai import AzureOpenAI
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class DallE3Tool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- client = AzureOpenAI(
- api_version=self.runtime.credentials["azure_openai_api_version"],
- azure_endpoint=self.runtime.credentials["azure_openai_base_url"],
- api_key=self.runtime.credentials["azure_openai_api_key"],
- )
-
- SIZE_MAPPING = {
- "square": "1024x1024",
- "vertical": "1024x1792",
- "horizontal": "1792x1024",
- }
-
- # prompt
- prompt = tool_parameters.get("prompt", "")
- if not prompt:
- return self.create_text_message("Please input prompt")
- # get size
- size = SIZE_MAPPING[tool_parameters.get("size", "square")]
- # get n
- n = tool_parameters.get("n", 1)
- # get quality
- quality = tool_parameters.get("quality", "standard")
- if quality not in {"standard", "hd"}:
- return self.create_text_message("Invalid quality")
- # get style
- style = tool_parameters.get("style", "vivid")
- if style not in {"natural", "vivid"}:
- return self.create_text_message("Invalid style")
- # set extra body
- seed_id = tool_parameters.get("seed_id", self._generate_random_id(8))
- extra_body = {"seed": seed_id}
-
- # call openapi dalle3
- model = self.runtime.credentials["azure_openai_api_model_name"]
- response = client.images.generate(
- prompt=prompt,
- model=model,
- size=size,
- n=n,
- extra_body=extra_body,
- style=style,
- quality=quality,
- response_format="b64_json",
- )
-
- result = []
-
- for image in response.data:
- result.append(
- self.create_blob_message(
- blob=b64decode(image.b64_json),
- meta={"mime_type": "image/png"},
- save_as=self.VariableKey.IMAGE.value,
- )
- )
- result.append(self.create_text_message(f"\nGenerate image source to Seed ID: {seed_id}"))
-
- return result
-
- @staticmethod
- def _generate_random_id(length=8):
- characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
- random_id = "".join(random.choices(characters, k=length))
- return random_id
diff --git a/api/core/tools/provider/builtin/azuredalle/tools/dalle3.yaml b/api/core/tools/provider/builtin/azuredalle/tools/dalle3.yaml
deleted file mode 100644
index e256748e8f..0000000000
--- a/api/core/tools/provider/builtin/azuredalle/tools/dalle3.yaml
+++ /dev/null
@@ -1,136 +0,0 @@
-identity:
- name: azure_dalle3
- author: Leslie
- label:
- en_US: Azure DALL-E 3
- zh_Hans: Azure DALL-E 3 绘画
- pt_BR: Azure DALL-E 3
- description:
- en_US: DALL-E 3 is a powerful drawing tool that can draw the image you want based on your prompt, compared to DallE 2, DallE 3 has stronger drawing ability, but it will consume more resources
- zh_Hans: DALL-E 3 是一个强大的绘画工具,它可以根据您的提示词绘制出您想要的图像,相比于DallE 2, DallE 3拥有更强的绘画能力,但会消耗更多的资源
- pt_BR: DALL-E 3 é uma poderosa ferramenta de desenho que pode desenhar a imagem que você deseja com base em seu prompt, em comparação com DallE 2, DallE 3 tem uma capacidade de desenho mais forte, mas consumirá mais recursos
-description:
- human:
- en_US: DALL-E is a text to image tool
- zh_Hans: DALL-E 是一个文本到图像的工具
- pt_BR: DALL-E é uma ferramenta de texto para imagem
- llm: DALL-E is a tool used to generate images from text
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: Prompt
- zh_Hans: 提示词
- pt_BR: Prompt
- human_description:
- en_US: Image prompt, you can check the official documentation of DallE 3
- zh_Hans: 图像提示词,您可以查看 DallE 3 的官方文档
- pt_BR: Imagem prompt, você pode verificar a documentação oficial do DallE 3
- llm_description: Image prompt of DallE 3, you should describe the image you want to generate as a list of words as possible as detailed
- form: llm
- - name: seed_id
- type: string
- required: false
- label:
- en_US: Seed ID
- zh_Hans: 种子ID
- pt_BR: ID da semente
- human_description:
- en_US: Image generation seed ID to ensure consistency of series generated images
- zh_Hans: 图像生成种子ID,确保系列生成图像的一致性
- pt_BR: ID de semente de geração de imagem para garantir a consistência das imagens geradas em série
- llm_description: If the user requests image consistency, extract the seed ID from the user's question or context.The seed id consists of an 8-bit string containing uppercase and lowercase letters and numbers
- form: llm
- - name: size
- type: select
- required: true
- human_description:
- en_US: selecting the image size
- zh_Hans: 选择图像大小
- pt_BR: seleccionar o tamanho da imagem
- label:
- en_US: Image size
- zh_Hans: 图像大小
- pt_BR: Tamanho da imagem
- form: form
- options:
- - value: square
- label:
- en_US: Squre(1024x1024)
- zh_Hans: 方(1024x1024)
- pt_BR: Squire(1024x1024)
- - value: vertical
- label:
- en_US: Vertical(1024x1792)
- zh_Hans: 竖屏(1024x1792)
- pt_BR: Vertical(1024x1792)
- - value: horizontal
- label:
- en_US: Horizontal(1792x1024)
- zh_Hans: 横屏(1792x1024)
- pt_BR: Horizontal(1792x1024)
- default: square
- - name: n
- type: number
- required: true
- human_description:
- en_US: selecting the number of images
- zh_Hans: 选择图像数量
- pt_BR: seleccionar o número de imagens
- label:
- en_US: Number of images
- zh_Hans: 图像数量
- pt_BR: Número de imagens
- form: form
- min: 1
- max: 1
- default: 1
- - name: quality
- type: select
- required: true
- human_description:
- en_US: selecting the image quality
- zh_Hans: 选择图像质量
- pt_BR: seleccionar a qualidade da imagem
- label:
- en_US: Image quality
- zh_Hans: 图像质量
- pt_BR: Qualidade da imagem
- form: form
- options:
- - value: standard
- label:
- en_US: Standard
- zh_Hans: 标准
- pt_BR: Normal
- - value: hd
- label:
- en_US: HD
- zh_Hans: 高清
- pt_BR: HD
- default: standard
- - name: style
- type: select
- required: true
- human_description:
- en_US: selecting the image style
- zh_Hans: 选择图像风格
- pt_BR: seleccionar o estilo da imagem
- label:
- en_US: Image style
- zh_Hans: 图像风格
- pt_BR: Estilo da imagem
- form: form
- options:
- - value: vivid
- label:
- en_US: Vivid
- zh_Hans: 生动
- pt_BR: Vívido
- - value: natural
- label:
- en_US: Natural
- zh_Hans: 自然
- pt_BR: Natural
- default: vivid
diff --git a/api/core/tools/provider/builtin/bing/_assets/icon.svg b/api/core/tools/provider/builtin/bing/_assets/icon.svg
deleted file mode 100644
index a94de7971d..0000000000
--- a/api/core/tools/provider/builtin/bing/_assets/icon.svg
+++ /dev/null
@@ -1,40 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/bing/bing.py b/api/core/tools/provider/builtin/bing/bing.py
deleted file mode 100644
index c71128be4a..0000000000
--- a/api/core/tools/provider/builtin/bing/bing.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.bing.tools.bing_web_search import BingSearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class BingProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- BingSearchTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).validate_credentials(
- credentials=credentials,
- tool_parameters={
- "query": "test",
- "result_type": "link",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/bing/bing.yaml b/api/core/tools/provider/builtin/bing/bing.yaml
deleted file mode 100644
index 1ab17d5294..0000000000
--- a/api/core/tools/provider/builtin/bing/bing.yaml
+++ /dev/null
@@ -1,107 +0,0 @@
-identity:
- author: Dify
- name: bing
- label:
- en_US: Bing
- zh_Hans: Bing
- pt_BR: Bing
- description:
- en_US: Bing Search
- zh_Hans: Bing 搜索
- pt_BR: Bing Search
- icon: icon.svg
- tags:
- - search
-credentials_for_provider:
- subscription_key:
- type: secret-input
- required: true
- label:
- en_US: Bing subscription key
- zh_Hans: Bing subscription key
- pt_BR: Bing subscription key
- placeholder:
- en_US: Please input your Bing subscription key
- zh_Hans: 请输入你的 Bing subscription key
- pt_BR: Please input your Bing subscription key
- help:
- en_US: Get your Bing subscription key from Bing
- zh_Hans: 从 Bing 获取您的 Bing subscription key
- pt_BR: Get your Bing subscription key from Bing
- url: https://www.microsoft.com/cognitive-services/en-us/bing-web-search-api
- server_url:
- type: text-input
- required: false
- label:
- en_US: Bing endpoint
- zh_Hans: Bing endpoint
- pt_BR: Bing endpoint
- placeholder:
- en_US: Please input your Bing endpoint
- zh_Hans: 请输入你的 Bing 端点
- pt_BR: Please input your Bing endpoint
- help:
- en_US: An endpoint is like "https://api.bing.microsoft.com/v7.0/search"
- zh_Hans: 例如 "https://api.bing.microsoft.com/v7.0/search"
- pt_BR: An endpoint is like "https://api.bing.microsoft.com/v7.0/search"
- default: https://api.bing.microsoft.com/v7.0/search
- allow_entities:
- type: boolean
- required: false
- label:
- en_US: Allow Entities Search
- zh_Hans: 支持实体搜索
- pt_BR: Allow Entities Search
- help:
- en_US: Does your subscription plan allow entity search
- zh_Hans: 您的订阅计划是否支持实体搜索
- pt_BR: Does your subscription plan allow entity search
- default: true
- allow_web_pages:
- type: boolean
- required: false
- label:
- en_US: Allow Web Pages Search
- zh_Hans: 支持网页搜索
- pt_BR: Allow Web Pages Search
- help:
- en_US: Does your subscription plan allow web pages search
- zh_Hans: 您的订阅计划是否支持网页搜索
- pt_BR: Does your subscription plan allow web pages search
- default: true
- allow_computation:
- type: boolean
- required: false
- label:
- en_US: Allow Computation Search
- zh_Hans: 支持计算搜索
- pt_BR: Allow Computation Search
- help:
- en_US: Does your subscription plan allow computation search
- zh_Hans: 您的订阅计划是否支持计算搜索
- pt_BR: Does your subscription plan allow computation search
- default: false
- allow_news:
- type: boolean
- required: false
- label:
- en_US: Allow News Search
- zh_Hans: 支持新闻搜索
- pt_BR: Allow News Search
- help:
- en_US: Does your subscription plan allow news search
- zh_Hans: 您的订阅计划是否支持新闻搜索
- pt_BR: Does your subscription plan allow news search
- default: false
- allow_related_searches:
- type: boolean
- required: false
- label:
- en_US: Allow Related Searches
- zh_Hans: 支持相关搜索
- pt_BR: Allow Related Searches
- help:
- en_US: Does your subscription plan allow related searches
- zh_Hans: 您的订阅计划是否支持相关搜索
- pt_BR: Does your subscription plan allow related searches
- default: false
diff --git a/api/core/tools/provider/builtin/bing/tools/bing_web_search.py b/api/core/tools/provider/builtin/bing/tools/bing_web_search.py
deleted file mode 100644
index 8bed2c556c..0000000000
--- a/api/core/tools/provider/builtin/bing/tools/bing_web_search.py
+++ /dev/null
@@ -1,202 +0,0 @@
-from typing import Any, Union
-from urllib.parse import quote
-
-from requests import get
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class BingSearchTool(BuiltinTool):
- url: str = "https://api.bing.microsoft.com/v7.0/search"
-
- def _invoke_bing(
- self,
- user_id: str,
- server_url: str,
- subscription_key: str,
- query: str,
- limit: int,
- result_type: str,
- market: str,
- lang: str,
- filters: list[str],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke bing search
- """
- market_code = f"{lang}-{market}"
- accept_language = f"{lang},{market_code};q=0.9"
- headers = {"Ocp-Apim-Subscription-Key": subscription_key, "Accept-Language": accept_language}
-
- query = quote(query)
- server_url = f'{server_url}?q={query}&mkt={market_code}&count={limit}&responseFilter={",".join(filters)}'
- response = get(server_url, headers=headers)
-
- if response.status_code != 200:
- raise Exception(f"Error {response.status_code}: {response.text}")
-
- response = response.json()
- search_results = response["webPages"]["value"][:limit] if "webPages" in response else []
- related_searches = response["relatedSearches"]["value"] if "relatedSearches" in response else []
- entities = response["entities"]["value"] if "entities" in response else []
- news = response["news"]["value"] if "news" in response else []
- computation = response["computation"]["value"] if "computation" in response else None
-
- if result_type == "link":
- results = []
- if search_results:
- for result in search_results:
- url = f': {result["url"]}' if "url" in result else ""
- results.append(self.create_text_message(text=f'{result["name"]}{url}'))
-
- if entities:
- for entity in entities:
- url = f': {entity["url"]}' if "url" in entity else ""
- results.append(self.create_text_message(text=f'{entity.get("name", "")}{url}'))
-
- if news:
- for news_item in news:
- url = f': {news_item["url"]}' if "url" in news_item else ""
- results.append(self.create_text_message(text=f'{news_item.get("name", "")}{url}'))
-
- if related_searches:
- for related in related_searches:
- url = f': {related["displayText"]}' if "displayText" in related else ""
- results.append(self.create_text_message(text=f'{related.get("displayText", "")}{url}'))
-
- return results
- else:
- # construct text
- text = ""
- if search_results:
- for i, result in enumerate(search_results):
- text += f'{i + 1}: {result.get("name", "")} - {result.get("snippet", "")}\n'
-
- if computation and "expression" in computation and "value" in computation:
- text += "\nComputation:\n"
- text += f'{computation["expression"]} = {computation["value"]}\n'
-
- if entities:
- text += "\nEntities:\n"
- for entity in entities:
- url = f'- {entity["url"]}' if "url" in entity else ""
- text += f'{entity.get("name", "")}{url}\n'
-
- if news:
- text += "\nNews:\n"
- for news_item in news:
- url = f'- {news_item["url"]}' if "url" in news_item else ""
- text += f'{news_item.get("name", "")}{url}\n'
-
- if related_searches:
- text += "\n\nRelated Searches:\n"
- for related in related_searches:
- url = f'- {related["webSearchUrl"]}' if "webSearchUrl" in related else ""
- text += f'{related.get("displayText", "")}{url}\n'
-
- return self.create_text_message(text=self.summary(user_id=user_id, content=text))
-
- def validate_credentials(self, credentials: dict[str, Any], tool_parameters: dict[str, Any]) -> None:
- key = credentials.get("subscription_key")
- if not key:
- raise Exception("subscription_key is required")
-
- server_url = credentials.get("server_url")
- if not server_url:
- server_url = self.url
-
- query = tool_parameters.get("query")
- if not query:
- raise Exception("query is required")
-
- limit = min(tool_parameters.get("limit", 5), 10)
- result_type = tool_parameters.get("result_type", "text") or "text"
-
- market = tool_parameters.get("market", "US")
- lang = tool_parameters.get("language", "en")
- filter = []
-
- if credentials.get("allow_entities", False):
- filter.append("Entities")
-
- if credentials.get("allow_computation", False):
- filter.append("Computation")
-
- if credentials.get("allow_news", False):
- filter.append("News")
-
- if credentials.get("allow_related_searches", False):
- filter.append("RelatedSearches")
-
- if credentials.get("allow_web_pages", False):
- filter.append("WebPages")
-
- if not filter:
- raise Exception("At least one filter is required")
-
- self._invoke_bing(
- user_id="test",
- server_url=server_url,
- subscription_key=key,
- query=query,
- limit=limit,
- result_type=result_type,
- market=market,
- lang=lang,
- filters=filter,
- )
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
-
- key = self.runtime.credentials.get("subscription_key", None)
- if not key:
- raise Exception("subscription_key is required")
-
- server_url = self.runtime.credentials.get("server_url", None)
- if not server_url:
- server_url = self.url
-
- query = tool_parameters.get("query")
- if not query:
- raise Exception("query is required")
-
- limit = min(tool_parameters.get("limit", 5), 10)
- result_type = tool_parameters.get("result_type", "text") or "text"
-
- market = tool_parameters.get("market", "US")
- lang = tool_parameters.get("language", "en")
- filter = []
-
- if tool_parameters.get("enable_computation", False):
- filter.append("Computation")
- if tool_parameters.get("enable_entities", False):
- filter.append("Entities")
- if tool_parameters.get("enable_news", False):
- filter.append("News")
- if tool_parameters.get("enable_related_search", False):
- filter.append("RelatedSearches")
- if tool_parameters.get("enable_webpages", False):
- filter.append("WebPages")
-
- if not filter:
- raise Exception("At least one filter is required")
-
- return self._invoke_bing(
- user_id=user_id,
- server_url=server_url,
- subscription_key=key,
- query=query,
- limit=limit,
- result_type=result_type,
- market=market,
- lang=lang,
- filters=filter,
- )
diff --git a/api/core/tools/provider/builtin/bing/tools/bing_web_search.yaml b/api/core/tools/provider/builtin/bing/tools/bing_web_search.yaml
deleted file mode 100644
index a3f60bb09b..0000000000
--- a/api/core/tools/provider/builtin/bing/tools/bing_web_search.yaml
+++ /dev/null
@@ -1,584 +0,0 @@
-identity:
- name: bing_web_search
- author: Dify
- label:
- en_US: BingWebSearch
- zh_Hans: 必应网页搜索
- pt_BR: BingWebSearch
-description:
- human:
- en_US: A tool for performing a Bing SERP search and extracting snippets and webpages.Input should be a search query.
- zh_Hans: 一个用于执行 Bing SERP 搜索并提取片段和网页的工具。输入应该是一个搜索查询。
- pt_BR: A tool for performing a Bing SERP search and extracting snippets and webpages.Input should be a search query.
- llm: A tool for performing a Bing SERP search and extracting snippets and webpages.Input should be a search query.
-parameters:
- - name: query
- type: string
- required: true
- form: llm
- label:
- en_US: Query string
- zh_Hans: 查询语句
- pt_BR: Query string
- human_description:
- en_US: used for searching
- zh_Hans: 用于搜索网页内容
- pt_BR: used for searching
- llm_description: key words for searching
- - name: enable_computation
- type: boolean
- required: false
- form: form
- label:
- en_US: Enable computation
- zh_Hans: 启用计算
- pt_BR: Enable computation
- human_description:
- en_US: enable computation
- zh_Hans: 启用计算
- pt_BR: enable computation
- default: false
- - name: enable_entities
- type: boolean
- required: false
- form: form
- label:
- en_US: Enable entities
- zh_Hans: 启用实体搜索
- pt_BR: Enable entities
- human_description:
- en_US: enable entities
- zh_Hans: 启用实体搜索
- pt_BR: enable entities
- default: true
- - name: enable_news
- type: boolean
- required: false
- form: form
- label:
- en_US: Enable news
- zh_Hans: 启用新闻搜索
- pt_BR: Enable news
- human_description:
- en_US: enable news
- zh_Hans: 启用新闻搜索
- pt_BR: enable news
- default: false
- - name: enable_related_search
- type: boolean
- required: false
- form: form
- label:
- en_US: Enable related search
- zh_Hans: 启用相关搜索
- pt_BR: Enable related search
- human_description:
- en_US: enable related search
- zh_Hans: 启用相关搜索
- pt_BR: enable related search
- default: false
- - name: enable_webpages
- type: boolean
- required: false
- form: form
- label:
- en_US: Enable webpages search
- zh_Hans: 启用网页搜索
- pt_BR: Enable webpages search
- human_description:
- en_US: enable webpages search
- zh_Hans: 启用网页搜索
- pt_BR: enable webpages search
- default: true
- - name: limit
- type: number
- required: true
- form: form
- label:
- en_US: Limit for results length
- zh_Hans: 返回长度限制
- pt_BR: Limit for results length
- human_description:
- en_US: limit the number of results
- zh_Hans: 限制返回结果的数量
- pt_BR: limit the number of results
- min: 1
- max: 10
- default: 5
- - name: result_type
- type: select
- required: true
- label:
- en_US: result type
- zh_Hans: 结果类型
- pt_BR: result type
- human_description:
- en_US: return a list of links or texts
- zh_Hans: 返回一个连接列表还是纯文本内容
- pt_BR: return a list of links or texts
- default: text
- options:
- - value: link
- label:
- en_US: Link
- zh_Hans: 链接
- pt_BR: Link
- - value: text
- label:
- en_US: Text
- zh_Hans: 文本
- pt_BR: Text
- form: form
- - name: market
- type: select
- label:
- en_US: Market
- zh_Hans: 市场
- pt_BR: Market
- human_description:
- en_US: market takes responsibility for the region
- zh_Hans: 市场决定了搜索结果的地区
- pt_BR: market takes responsibility for the region
- required: false
- form: form
- default: US
- options:
- - value: AR
- label:
- en_US: Argentina
- zh_Hans: 阿根廷
- pt_BR: Argentina
- - value: AU
- label:
- en_US: Australia
- zh_Hans: 澳大利亚
- pt_BR: Australia
- - value: AT
- label:
- en_US: Austria
- zh_Hans: 奥地利
- pt_BR: Austria
- - value: BE
- label:
- en_US: Belgium
- zh_Hans: 比利时
- pt_BR: Belgium
- - value: BR
- label:
- en_US: Brazil
- zh_Hans: 巴西
- pt_BR: Brazil
- - value: CA
- label:
- en_US: Canada
- zh_Hans: 加拿大
- pt_BR: Canada
- - value: CL
- label:
- en_US: Chile
- zh_Hans: 智利
- pt_BR: Chile
- - value: CO
- label:
- en_US: Colombia
- zh_Hans: 哥伦比亚
- pt_BR: Colombia
- - value: CN
- label:
- en_US: China
- zh_Hans: 中国
- pt_BR: China
- - value: CZ
- label:
- en_US: Czech Republic
- zh_Hans: 捷克共和国
- pt_BR: Czech Republic
- - value: DK
- label:
- en_US: Denmark
- zh_Hans: 丹麦
- pt_BR: Denmark
- - value: FI
- label:
- en_US: Finland
- zh_Hans: 芬兰
- pt_BR: Finland
- - value: FR
- label:
- en_US: France
- zh_Hans: 法国
- pt_BR: France
- - value: DE
- label:
- en_US: Germany
- zh_Hans: 德国
- pt_BR: Germany
- - value: HK
- label:
- en_US: Hong Kong
- zh_Hans: 香港
- pt_BR: Hong Kong
- - value: IN
- label:
- en_US: India
- zh_Hans: 印度
- pt_BR: India
- - value: ID
- label:
- en_US: Indonesia
- zh_Hans: 印度尼西亚
- pt_BR: Indonesia
- - value: IT
- label:
- en_US: Italy
- zh_Hans: 意大利
- pt_BR: Italy
- - value: JP
- label:
- en_US: Japan
- zh_Hans: 日本
- pt_BR: Japan
- - value: KR
- label:
- en_US: Korea
- zh_Hans: 韩国
- pt_BR: Korea
- - value: MY
- label:
- en_US: Malaysia
- zh_Hans: 马来西亚
- pt_BR: Malaysia
- - value: MX
- label:
- en_US: Mexico
- zh_Hans: 墨西哥
- pt_BR: Mexico
- - value: NL
- label:
- en_US: Netherlands
- zh_Hans: 荷兰
- pt_BR: Netherlands
- - value: NZ
- label:
- en_US: New Zealand
- zh_Hans: 新西兰
- pt_BR: New Zealand
- - value: 'NO'
- label:
- en_US: Norway
- zh_Hans: 挪威
- pt_BR: Norway
- - value: PH
- label:
- en_US: Philippines
- zh_Hans: 菲律宾
- pt_BR: Philippines
- - value: PL
- label:
- en_US: Poland
- zh_Hans: 波兰
- pt_BR: Poland
- - value: PT
- label:
- en_US: Portugal
- zh_Hans: 葡萄牙
- pt_BR: Portugal
- - value: RU
- label:
- en_US: Russia
- zh_Hans: 俄罗斯
- pt_BR: Russia
- - value: SA
- label:
- en_US: Saudi Arabia
- zh_Hans: 沙特阿拉伯
- pt_BR: Saudi Arabia
- - value: SG
- label:
- en_US: Singapore
- zh_Hans: 新加坡
- pt_BR: Singapore
- - value: ZA
- label:
- en_US: South Africa
- zh_Hans: 南非
- pt_BR: South Africa
- - value: ES
- label:
- en_US: Spain
- zh_Hans: 西班牙
- pt_BR: Spain
- - value: SE
- label:
- en_US: Sweden
- zh_Hans: 瑞典
- pt_BR: Sweden
- - value: CH
- label:
- en_US: Switzerland
- zh_Hans: 瑞士
- pt_BR: Switzerland
- - value: TW
- label:
- en_US: Taiwan
- zh_Hans: 台湾
- pt_BR: Taiwan
- - value: TH
- label:
- en_US: Thailand
- zh_Hans: 泰国
- pt_BR: Thailand
- - value: TR
- label:
- en_US: Turkey
- zh_Hans: 土耳其
- pt_BR: Turkey
- - value: GB
- label:
- en_US: United Kingdom
- zh_Hans: 英国
- pt_BR: United Kingdom
- - value: US
- label:
- en_US: United States
- zh_Hans: 美国
- pt_BR: United States
- - name: language
- type: select
- label:
- en_US: Language
- zh_Hans: 语言
- pt_BR: Language
- human_description:
- en_US: language takes responsibility for the language of the search result
- zh_Hans: 语言决定了搜索结果的语言
- pt_BR: language takes responsibility for the language of the search result
- required: false
- default: en
- form: form
- options:
- - value: ar
- label:
- en_US: Arabic
- zh_Hans: 阿拉伯语
- pt_BR: Arabic
- - value: bg
- label:
- en_US: Bulgarian
- zh_Hans: 保加利亚语
- pt_BR: Bulgarian
- - value: ca
- label:
- en_US: Catalan
- zh_Hans: 加泰罗尼亚语
- pt_BR: Catalan
- - value: zh-hans
- label:
- en_US: Chinese (Simplified)
- zh_Hans: 中文(简体)
- pt_BR: Chinese (Simplified)
- - value: zh-hant
- label:
- en_US: Chinese (Traditional)
- zh_Hans: 中文(繁体)
- pt_BR: Chinese (Traditional)
- - value: cs
- label:
- en_US: Czech
- zh_Hans: 捷克语
- pt_BR: Czech
- - value: da
- label:
- en_US: Danish
- zh_Hans: 丹麦语
- pt_BR: Danish
- - value: nl
- label:
- en_US: Dutch
- zh_Hans: 荷兰语
- pt_BR: Dutch
- - value: en
- label:
- en_US: English
- zh_Hans: 英语
- pt_BR: English
- - value: et
- label:
- en_US: Estonian
- zh_Hans: 爱沙尼亚语
- pt_BR: Estonian
- - value: fi
- label:
- en_US: Finnish
- zh_Hans: 芬兰语
- pt_BR: Finnish
- - value: fr
- label:
- en_US: French
- zh_Hans: 法语
- pt_BR: French
- - value: de
- label:
- en_US: German
- zh_Hans: 德语
- pt_BR: German
- - value: el
- label:
- en_US: Greek
- zh_Hans: 希腊语
- pt_BR: Greek
- - value: he
- label:
- en_US: Hebrew
- zh_Hans: 希伯来语
- pt_BR: Hebrew
- - value: hi
- label:
- en_US: Hindi
- zh_Hans: 印地语
- pt_BR: Hindi
- - value: hu
- label:
- en_US: Hungarian
- zh_Hans: 匈牙利语
- pt_BR: Hungarian
- - value: id
- label:
- en_US: Indonesian
- zh_Hans: 印尼语
- pt_BR: Indonesian
- - value: it
- label:
- en_US: Italian
- zh_Hans: 意大利语
- pt_BR: Italian
- - value: jp
- label:
- en_US: Japanese
- zh_Hans: 日语
- pt_BR: Japanese
- - value: kn
- label:
- en_US: Kannada
- zh_Hans: 卡纳达语
- pt_BR: Kannada
- - value: ko
- label:
- en_US: Korean
- zh_Hans: 韩语
- pt_BR: Korean
- - value: lv
- label:
- en_US: Latvian
- zh_Hans: 拉脱维亚语
- pt_BR: Latvian
- - value: lt
- label:
- en_US: Lithuanian
- zh_Hans: 立陶宛语
- pt_BR: Lithuanian
- - value: ms
- label:
- en_US: Malay
- zh_Hans: 马来语
- pt_BR: Malay
- - value: ml
- label:
- en_US: Malayalam
- zh_Hans: 马拉雅拉姆语
- pt_BR: Malayalam
- - value: mr
- label:
- en_US: Marathi
- zh_Hans: 马拉地语
- pt_BR: Marathi
- - value: nb
- label:
- en_US: Norwegian
- zh_Hans: 挪威语
- pt_BR: Norwegian
- - value: pl
- label:
- en_US: Polish
- zh_Hans: 波兰语
- pt_BR: Polish
- - value: pt-br
- label:
- en_US: Portuguese (Brazil)
- zh_Hans: 葡萄牙语(巴西)
- pt_BR: Portuguese (Brazil)
- - value: pt-pt
- label:
- en_US: Portuguese (Portugal)
- zh_Hans: 葡萄牙语(葡萄牙)
- pt_BR: Portuguese (Portugal)
- - value: pa
- label:
- en_US: Punjabi
- zh_Hans: 旁遮普语
- pt_BR: Punjabi
- - value: ro
- label:
- en_US: Romanian
- zh_Hans: 罗马尼亚语
- pt_BR: Romanian
- - value: ru
- label:
- en_US: Russian
- zh_Hans: 俄语
- pt_BR: Russian
- - value: sr
- label:
- en_US: Serbian
- zh_Hans: 塞尔维亚语
- pt_BR: Serbian
- - value: sk
- label:
- en_US: Slovak
- zh_Hans: 斯洛伐克语
- pt_BR: Slovak
- - value: sl
- label:
- en_US: Slovenian
- zh_Hans: 斯洛文尼亚语
- pt_BR: Slovenian
- - value: es
- label:
- en_US: Spanish
- zh_Hans: 西班牙语
- pt_BR: Spanish
- - value: sv
- label:
- en_US: Swedish
- zh_Hans: 瑞典语
- pt_BR: Swedish
- - value: ta
- label:
- en_US: Tamil
- zh_Hans: 泰米尔语
- pt_BR: Tamil
- - value: te
- label:
- en_US: Telugu
- zh_Hans: 泰卢固语
- pt_BR: Telugu
- - value: th
- label:
- en_US: Thai
- zh_Hans: 泰语
- pt_BR: Thai
- - value: tr
- label:
- en_US: Turkish
- zh_Hans: 土耳其语
- pt_BR: Turkish
- - value: uk
- label:
- en_US: Ukrainian
- zh_Hans: 乌克兰语
- pt_BR: Ukrainian
- - value: vi
- label:
- en_US: Vietnamese
- zh_Hans: 越南语
- pt_BR: Vietnamese
diff --git a/api/core/tools/provider/builtin/brave/_assets/icon.svg b/api/core/tools/provider/builtin/brave/_assets/icon.svg
deleted file mode 100644
index d059f7c516..0000000000
--- a/api/core/tools/provider/builtin/brave/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/brave/brave.py b/api/core/tools/provider/builtin/brave/brave.py
deleted file mode 100644
index c24ee67334..0000000000
--- a/api/core/tools/provider/builtin/brave/brave.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.brave.tools.brave_search import BraveSearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class BraveProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- BraveSearchTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "query": "Sachin Tendulkar",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/brave/brave.yaml b/api/core/tools/provider/builtin/brave/brave.yaml
deleted file mode 100644
index 2b0dcc0188..0000000000
--- a/api/core/tools/provider/builtin/brave/brave.yaml
+++ /dev/null
@@ -1,39 +0,0 @@
-identity:
- author: Yash Parmar
- name: brave
- label:
- en_US: Brave
- zh_Hans: Brave
- pt_BR: Brave
- description:
- en_US: Brave
- zh_Hans: Brave
- pt_BR: Brave
- icon: icon.svg
- tags:
- - search
-credentials_for_provider:
- brave_search_api_key:
- type: secret-input
- required: true
- label:
- en_US: Brave Search API key
- zh_Hans: Brave Search API key
- pt_BR: Brave Search API key
- placeholder:
- en_US: Please input your Brave Search API key
- zh_Hans: 请输入你的 Brave Search API key
- pt_BR: Please input your Brave Search API key
- help:
- en_US: Get your Brave Search API key from Brave
- zh_Hans: 从 Brave 获取您的 Brave Search API key
- pt_BR: Get your Brave Search API key from Brave
- url: https://brave.com/search/api/
- base_url:
- type: text-input
- required: false
- label:
- en_US: Brave server's Base URL
- zh_Hans: Brave服务器的API URL
- placeholder:
- en_US: https://api.search.brave.com/res/v1/web/search
diff --git a/api/core/tools/provider/builtin/brave/tools/brave_search.py b/api/core/tools/provider/builtin/brave/tools/brave_search.py
deleted file mode 100644
index c34362ae52..0000000000
--- a/api/core/tools/provider/builtin/brave/tools/brave_search.py
+++ /dev/null
@@ -1,138 +0,0 @@
-import json
-from typing import Any, Optional
-
-import requests
-from pydantic import BaseModel, Field
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-BRAVE_BASE_URL = "https://api.search.brave.com/res/v1/web/search"
-
-
-class BraveSearchWrapper(BaseModel):
- """Wrapper around the Brave search engine."""
-
- api_key: str
- """The API key to use for the Brave search engine."""
- search_kwargs: dict = Field(default_factory=dict)
- """Additional keyword arguments to pass to the search request."""
- base_url: str = BRAVE_BASE_URL
- """The base URL for the Brave search engine."""
- ensure_ascii: bool = True
- """Ensure the JSON output is ASCII encoded."""
-
- def run(self, query: str) -> str:
- """Query the Brave search engine and return the results as a JSON string.
-
- Args:
- query: The query to search for.
-
- Returns: The results as a JSON string.
-
- """
- web_search_results = self._search_request(query=query)
- final_results = [
- {
- "title": item.get("title"),
- "link": item.get("url"),
- "snippet": item.get("description"),
- }
- for item in web_search_results
- ]
- return json.dumps(final_results, ensure_ascii=self.ensure_ascii)
-
- def _search_request(self, query: str) -> list[dict]:
- headers = {
- "X-Subscription-Token": self.api_key,
- "Accept": "application/json",
- }
- req = requests.PreparedRequest()
- params = {**self.search_kwargs, **{"q": query}}
- req.prepare_url(self.base_url, params)
- if req.url is None:
- raise ValueError("prepared url is None, this should not happen")
-
- response = requests.get(req.url, headers=headers)
- if not response.ok:
- raise Exception(f"HTTP error {response.status_code}")
-
- return response.json().get("web", {}).get("results", [])
-
-
-class BraveSearch(BaseModel):
- """Tool that queries the BraveSearch."""
-
- name: str = "brave_search"
- description: str = (
- "a search engine. "
- "useful for when you need to answer questions about current events."
- " input should be a search query."
- )
- search_wrapper: BraveSearchWrapper
-
- @classmethod
- def from_api_key(
- cls, api_key: str, base_url: str, search_kwargs: Optional[dict] = None, ensure_ascii: bool = True, **kwargs: Any
- ) -> "BraveSearch":
- """Create a tool from an api key.
-
- Args:
- api_key: The api key to use.
- search_kwargs: Any additional kwargs to pass to the search wrapper.
- **kwargs: Any additional kwargs to pass to the tool.
-
- Returns:
- A tool.
- """
- wrapper = BraveSearchWrapper(
- api_key=api_key, base_url=base_url, search_kwargs=search_kwargs or {}, ensure_ascii=ensure_ascii
- )
- return cls(search_wrapper=wrapper, **kwargs)
-
- def _run(
- self,
- query: str,
- ) -> str:
- """Use the tool."""
- return self.search_wrapper.run(query)
-
-
-class BraveSearchTool(BuiltinTool):
- """
- Tool for performing a search using Brave search engine.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage | list[ToolInvokeMessage]:
- """
- Invoke the Brave search tool.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Any]): The parameters for the tool invocation.
-
- Returns:
- ToolInvokeMessage | list[ToolInvokeMessage]: The result of the tool invocation.
- """
- query = tool_parameters.get("query", "")
- count = tool_parameters.get("count", 3)
- api_key = self.runtime.credentials["brave_search_api_key"]
- base_url = self.runtime.credentials.get("base_url", BRAVE_BASE_URL)
- ensure_ascii = tool_parameters.get("ensure_ascii", True)
-
- if len(base_url) == 0:
- base_url = BRAVE_BASE_URL
-
- if not query:
- return self.create_text_message("Please input query")
-
- tool = BraveSearch.from_api_key(
- api_key=api_key, base_url=base_url, search_kwargs={"count": count}, ensure_ascii=ensure_ascii
- )
-
- results = tool._run(query)
-
- if not results:
- return self.create_text_message(f"No results found for '{query}' in Tavily")
- else:
- return self.create_text_message(text=results)
diff --git a/api/core/tools/provider/builtin/brave/tools/brave_search.yaml b/api/core/tools/provider/builtin/brave/tools/brave_search.yaml
deleted file mode 100644
index 5222a375f8..0000000000
--- a/api/core/tools/provider/builtin/brave/tools/brave_search.yaml
+++ /dev/null
@@ -1,53 +0,0 @@
-identity:
- name: brave_search
- author: Yash Parmar
- label:
- en_US: BraveSearch
- zh_Hans: BraveSearch
- pt_BR: BraveSearch
-description:
- human:
- en_US: BraveSearch is a privacy-focused search engine that leverages its own index to deliver unbiased, independent, and fast search results. It's designed to respect user privacy by not tracking searches or personal information, making it a secure choice for those concerned about online privacy.
- zh_Hans: BraveSearch 是一个注重隐私的搜索引擎,它利用自己的索引来提供公正、独立和快速的搜索结果。它旨在通过不跟踪搜索或个人信息来尊重用户隐私,为那些关注在线隐私的用户提供了一个安全的选择。
- pt_BR: BraveSearch é um mecanismo de busca focado na privacidade que utiliza seu próprio índice para entregar resultados de busca imparciais, independentes e rápidos. Ele é projetado para respeitar a privacidade do usuário, não rastreando buscas ou informações pessoais, tornando-se uma escolha segura para aqueles preocupados com a privacidade online.
- llm: BraveSearch is a privacy-centric search engine utilizing its unique index to offer unbiased, independent, and swift search results. It aims to protect user privacy by avoiding the tracking of search activities or personal data, presenting a secure option for users mindful of their online privacy.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query string
- zh_Hans: 查询语句
- pt_BR: Query string
- human_description:
- en_US: The text input used for initiating searches on the web, focusing on delivering relevant and accurate results without compromising user privacy.
- zh_Hans: 用于在网上启动搜索的文本输入,专注于提供相关且准确的结果,同时不妨碍用户隐私。
- pt_BR: A entrada de texto usada para iniciar pesquisas na web, focada em entregar resultados relevantes e precisos sem comprometer a privacidade do usuário.
- llm_description: Keywords or phrases entered to perform searches, aimed at providing relevant and precise results while ensuring the privacy of the user is maintained.
- form: llm
- - name: count
- type: number
- required: false
- default: 3
- label:
- en_US: Result count
- zh_Hans: 结果数量
- pt_BR: Contagem de resultados
- human_description:
- en_US: The number of search results to return, allowing users to control the breadth of their search output.
- zh_Hans: 要返回的搜索结果数量,允许用户控制他们搜索输出的广度。
- pt_BR: O número de resultados de pesquisa a serem retornados, permitindo que os usuários controlem a amplitude de sua saída de pesquisa.
- llm_description: Specifies the amount of search results to be displayed, offering users the ability to adjust the scope of their search findings.
- form: llm
- - name: ensure_ascii
- type: boolean
- default: true
- label:
- en_US: Ensure ASCII
- zh_Hans: 确保 ASCII
- pt_BR: Ensure ASCII
- human_description:
- en_US: Ensure the JSON output is ASCII encoded
- zh_Hans: 确保输出的 JSON 是 ASCII 编码
- pt_BR: Ensure the JSON output is ASCII encoded
- form: form
diff --git a/api/core/tools/provider/builtin/chart/_assets/icon.png b/api/core/tools/provider/builtin/chart/_assets/icon.png
deleted file mode 100644
index 878e56a051..0000000000
Binary files a/api/core/tools/provider/builtin/chart/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/chart/chart.py b/api/core/tools/provider/builtin/chart/chart.py
deleted file mode 100644
index 8a24d33428..0000000000
--- a/api/core/tools/provider/builtin/chart/chart.py
+++ /dev/null
@@ -1,77 +0,0 @@
-import matplotlib.pyplot as plt
-from fontTools.ttLib import TTFont
-from matplotlib.font_manager import findSystemFonts
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.chart.tools.line import LinearChartTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-# use a business theme
-plt.style.use("seaborn-v0_8-darkgrid")
-plt.rcParams["axes.unicode_minus"] = False
-
-
-def init_fonts():
- fonts = findSystemFonts()
-
- popular_unicode_fonts = [
- "Arial Unicode MS",
- "DejaVu Sans",
- "DejaVu Sans Mono",
- "DejaVu Serif",
- "FreeMono",
- "FreeSans",
- "FreeSerif",
- "Liberation Mono",
- "Liberation Sans",
- "Liberation Serif",
- "Noto Mono",
- "Noto Sans",
- "Noto Serif",
- "Open Sans",
- "Roboto",
- "Source Code Pro",
- "Source Sans Pro",
- "Source Serif Pro",
- "Ubuntu",
- "Ubuntu Mono",
- ]
-
- supported_fonts = []
-
- for font_path in fonts:
- try:
- font = TTFont(font_path)
- # get family name
- family_name = font["name"].getName(1, 3, 1).toUnicode()
- if family_name in popular_unicode_fonts:
- supported_fonts.append(family_name)
- except:
- pass
-
- plt.rcParams["font.family"] = "sans-serif"
- # sort by order of popular_unicode_fonts
- for font in popular_unicode_fonts:
- if font in supported_fonts:
- plt.rcParams["font.sans-serif"] = font
- break
-
-
-init_fonts()
-
-
-class ChartProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- LinearChartTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "data": "1,3,5,7,9,2,4,6,8,10",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/chart/chart.yaml b/api/core/tools/provider/builtin/chart/chart.yaml
deleted file mode 100644
index ad0d9a6cd6..0000000000
--- a/api/core/tools/provider/builtin/chart/chart.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-identity:
- author: Dify
- name: chart
- label:
- en_US: ChartGenerator
- zh_Hans: 图表生成
- pt_BR: Gerador de gráficos
- description:
- en_US: Chart Generator is a tool for generating statistical charts like bar chart, line chart, pie chart, etc.
- zh_Hans: 图表生成是一个用于生成可视化图表的工具,你可以通过它来生成柱状图、折线图、饼图等各类图表
- pt_BR: O Gerador de gráficos é uma ferramenta para gerar gráficos estatísticos como gráfico de barras, gráfico de linhas, gráfico de pizza, etc.
- icon: icon.png
- tags:
- - design
- - productivity
- - utilities
-credentials_for_provider:
diff --git a/api/core/tools/provider/builtin/chart/tools/bar.py b/api/core/tools/provider/builtin/chart/tools/bar.py
deleted file mode 100644
index 3a47c0cfc0..0000000000
--- a/api/core/tools/provider/builtin/chart/tools/bar.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import io
-from typing import Any, Union
-
-import matplotlib.pyplot as plt
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class BarChartTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- data = tool_parameters.get("data", "")
- if not data:
- return self.create_text_message("Please input data")
- data = data.split(";")
-
- # if all data is int, convert to int
- if all(i.isdigit() for i in data):
- data = [int(i) for i in data]
- else:
- data = [float(i) for i in data]
-
- axis = tool_parameters.get("x_axis") or None
- if axis:
- axis = axis.split(";")
- if len(axis) != len(data):
- axis = None
-
- flg, ax = plt.subplots(figsize=(10, 8))
-
- if axis:
- axis = [label[:10] + "..." if len(label) > 10 else label for label in axis]
- ax.set_xticklabels(axis, rotation=45, ha="right")
- ax.bar(axis, data)
- else:
- ax.bar(range(len(data)), data)
-
- buf = io.BytesIO()
- flg.savefig(buf, format="png")
- buf.seek(0)
- plt.close(flg)
-
- return [
- self.create_text_message("the bar chart is saved as an image."),
- self.create_blob_message(blob=buf.read(), meta={"mime_type": "image/png"}),
- ]
diff --git a/api/core/tools/provider/builtin/chart/tools/bar.yaml b/api/core/tools/provider/builtin/chart/tools/bar.yaml
deleted file mode 100644
index ee7405f681..0000000000
--- a/api/core/tools/provider/builtin/chart/tools/bar.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
-identity:
- name: bar_chart
- author: Dify
- label:
- en_US: Bar Chart
- zh_Hans: 柱状图
- pt_BR: Gráfico de barras
- icon: icon.svg
-description:
- human:
- en_US: Bar chart
- zh_Hans: 柱状图
- pt_BR: Gráfico de barras
- llm: generate a bar chart with input data
-parameters:
- - name: data
- type: string
- required: true
- label:
- en_US: data
- zh_Hans: 数据
- pt_BR: dados
- human_description:
- en_US: data for generating chart, each number should be separated by ";"
- zh_Hans: 用于生成柱状图的数据,每个数字之间用 ";" 分隔
- pt_BR: dados para gerar gráfico de barras, cada número deve ser separado por ";"
- llm_description: data for generating bar chart, data should be a string contains a list of numbers like "1;2;3;4;5"
- form: llm
- - name: x_axis
- type: string
- required: false
- label:
- en_US: X Axis
- zh_Hans: x 轴
- pt_BR: Eixo X
- human_description:
- en_US: X axis for chart, each text should be separated by ";"
- zh_Hans: 柱状图的 x 轴,每个文本之间用 ";" 分隔
- pt_BR: Eixo X para gráfico de barras, cada texto deve ser separado por ";"
- llm_description: x axis for bar chart, x axis should be a string contains a list of texts like "a;b;c;1;2" in order to match the data
- form: llm
diff --git a/api/core/tools/provider/builtin/chart/tools/line.py b/api/core/tools/provider/builtin/chart/tools/line.py
deleted file mode 100644
index 39e8caac7e..0000000000
--- a/api/core/tools/provider/builtin/chart/tools/line.py
+++ /dev/null
@@ -1,50 +0,0 @@
-import io
-from typing import Any, Union
-
-import matplotlib.pyplot as plt
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class LinearChartTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- data = tool_parameters.get("data", "")
- if not data:
- return self.create_text_message("Please input data")
- data = data.split(";")
-
- axis = tool_parameters.get("x_axis") or None
- if axis:
- axis = axis.split(";")
- if len(axis) != len(data):
- axis = None
-
- # if all data is int, convert to int
- if all(i.isdigit() for i in data):
- data = [int(i) for i in data]
- else:
- data = [float(i) for i in data]
-
- flg, ax = plt.subplots(figsize=(10, 8))
-
- if axis:
- axis = [label[:10] + "..." if len(label) > 10 else label for label in axis]
- ax.set_xticklabels(axis, rotation=45, ha="right")
- ax.plot(axis, data)
- else:
- ax.plot(data)
-
- buf = io.BytesIO()
- flg.savefig(buf, format="png")
- buf.seek(0)
- plt.close(flg)
-
- return [
- self.create_text_message("the linear chart is saved as an image."),
- self.create_blob_message(blob=buf.read(), meta={"mime_type": "image/png"}),
- ]
diff --git a/api/core/tools/provider/builtin/chart/tools/line.yaml b/api/core/tools/provider/builtin/chart/tools/line.yaml
deleted file mode 100644
index 35ebe3b68b..0000000000
--- a/api/core/tools/provider/builtin/chart/tools/line.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
-identity:
- name: line_chart
- author: Dify
- label:
- en_US: Linear Chart
- zh_Hans: 线性图表
- pt_BR: Gráfico linear
- icon: icon.svg
-description:
- human:
- en_US: linear chart
- zh_Hans: 线性图表
- pt_BR: Gráfico linear
- llm: generate a linear chart with input data
-parameters:
- - name: data
- type: string
- required: true
- label:
- en_US: data
- zh_Hans: 数据
- pt_BR: dados
- human_description:
- en_US: data for generating chart, each number should be separated by ";"
- zh_Hans: 用于生成线性图表的数据,每个数字之间用 ";" 分隔
- pt_BR: dados para gerar gráfico linear, cada número deve ser separado por ";"
- llm_description: data for generating linear chart, data should be a string contains a list of numbers like "1;2;3;4;5"
- form: llm
- - name: x_axis
- type: string
- required: false
- label:
- en_US: X Axis
- zh_Hans: x 轴
- pt_BR: Eixo X
- human_description:
- en_US: X axis for chart, each text should be separated by ";"
- zh_Hans: 线性图表的 x 轴,每个文本之间用 ";" 分隔
- pt_BR: Eixo X para gráfico linear, cada texto deve ser separado por ";"
- llm_description: x axis for linear chart, x axis should be a string contains a list of texts like "a;b;c;1;2" in order to match the data
- form: llm
diff --git a/api/core/tools/provider/builtin/chart/tools/pie.py b/api/core/tools/provider/builtin/chart/tools/pie.py
deleted file mode 100644
index 2c3b8a733e..0000000000
--- a/api/core/tools/provider/builtin/chart/tools/pie.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import io
-from typing import Any, Union
-
-import matplotlib.pyplot as plt
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class PieChartTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- data = tool_parameters.get("data", "")
- if not data:
- return self.create_text_message("Please input data")
- data = data.split(";")
- categories = tool_parameters.get("categories") or None
-
- # if all data is int, convert to int
- if all(i.isdigit() for i in data):
- data = [int(i) for i in data]
- else:
- data = [float(i) for i in data]
-
- flg, ax = plt.subplots()
-
- if categories:
- categories = categories.split(";")
- if len(categories) != len(data):
- categories = None
-
- if categories:
- ax.pie(data, labels=categories)
- else:
- ax.pie(data)
-
- buf = io.BytesIO()
- flg.savefig(buf, format="png")
- buf.seek(0)
- plt.close(flg)
-
- return [
- self.create_text_message("the pie chart is saved as an image."),
- self.create_blob_message(blob=buf.read(), meta={"mime_type": "image/png"}),
- ]
diff --git a/api/core/tools/provider/builtin/chart/tools/pie.yaml b/api/core/tools/provider/builtin/chart/tools/pie.yaml
deleted file mode 100644
index 541715cb7d..0000000000
--- a/api/core/tools/provider/builtin/chart/tools/pie.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
-identity:
- name: pie_chart
- author: Dify
- label:
- en_US: Pie Chart
- zh_Hans: 饼图
- pt_BR: Gráfico de pizza
- icon: icon.svg
-description:
- human:
- en_US: Pie chart
- zh_Hans: 饼图
- pt_BR: Gráfico de pizza
- llm: generate a pie chart with input data
-parameters:
- - name: data
- type: string
- required: true
- label:
- en_US: data
- zh_Hans: 数据
- pt_BR: dados
- human_description:
- en_US: data for generating chart, each number should be separated by ";"
- zh_Hans: 用于生成饼图的数据,每个数字之间用 ";" 分隔
- pt_BR: dados para gerar gráfico de pizza, cada número deve ser separado por ";"
- llm_description: data for generating pie chart, data should be a string contains a list of numbers like "1;2;3;4;5"
- form: llm
- - name: categories
- type: string
- required: true
- label:
- en_US: Categories
- zh_Hans: 分类
- pt_BR: Categorias
- human_description:
- en_US: Categories for chart, each category should be separated by ";"
- zh_Hans: 饼图的分类,每个分类之间用 ";" 分隔
- pt_BR: Categorias para gráfico de pizza, cada categoria deve ser separada por ";"
- llm_description: categories for pie chart, categories should be a string contains a list of texts like "a;b;c;1;2" in order to match the data, each category should be split by ";"
- form: llm
diff --git a/api/core/tools/provider/builtin/cogview/__init__.py b/api/core/tools/provider/builtin/cogview/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/api/core/tools/provider/builtin/cogview/_assets/icon.png b/api/core/tools/provider/builtin/cogview/_assets/icon.png
deleted file mode 100644
index f0c1c24a02..0000000000
Binary files a/api/core/tools/provider/builtin/cogview/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/cogview/cogview.py b/api/core/tools/provider/builtin/cogview/cogview.py
deleted file mode 100644
index 6941ce8649..0000000000
--- a/api/core/tools/provider/builtin/cogview/cogview.py
+++ /dev/null
@@ -1,28 +0,0 @@
-"""Provide the input parameters type for the cogview provider class"""
-
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.cogview.tools.cogview3 import CogView3Tool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class COGVIEWProvider(BuiltinToolProviderController):
- """cogview provider"""
-
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- CogView3Tool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "prompt": "一个城市在水晶瓶中欢快生活的场景,水彩画风格,展现出微观与珠宝般的美丽。",
- "size": "square",
- "n": 1,
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e)) from e
diff --git a/api/core/tools/provider/builtin/cogview/cogview.yaml b/api/core/tools/provider/builtin/cogview/cogview.yaml
deleted file mode 100644
index 374b0e98d9..0000000000
--- a/api/core/tools/provider/builtin/cogview/cogview.yaml
+++ /dev/null
@@ -1,61 +0,0 @@
-identity:
- author: Waffle
- name: cogview
- label:
- en_US: CogView
- zh_Hans: CogView 绘画
- pt_BR: CogView
- description:
- en_US: CogView art
- zh_Hans: CogView 绘画
- pt_BR: CogView art
- icon: icon.png
- tags:
- - image
- - productivity
-credentials_for_provider:
- zhipuai_api_key:
- type: secret-input
- required: true
- label:
- en_US: ZhipuAI API key
- zh_Hans: ZhipuAI API key
- pt_BR: ZhipuAI API key
- help:
- en_US: Please input your ZhipuAI API key
- zh_Hans: 请输入你的 ZhipuAI API key
- pt_BR: Please input your ZhipuAI API key
- placeholder:
- en_US: Please input your ZhipuAI API key
- zh_Hans: 请输入你的 ZhipuAI API key
- pt_BR: Please input your ZhipuAI API key
- zhipuai_organizaion_id:
- type: text-input
- required: false
- label:
- en_US: ZhipuAI organization ID
- zh_Hans: ZhipuAI organization ID
- pt_BR: ZhipuAI organization ID
- help:
- en_US: Please input your ZhipuAI organization ID
- zh_Hans: 请输入你的 ZhipuAI organization ID
- pt_BR: Please input your ZhipuAI organization ID
- placeholder:
- en_US: Please input your ZhipuAI organization ID
- zh_Hans: 请输入你的 ZhipuAI organization ID
- pt_BR: Please input your ZhipuAI organization ID
- zhipuai_base_url:
- type: text-input
- required: false
- label:
- en_US: ZhipuAI base URL
- zh_Hans: ZhipuAI base URL
- pt_BR: ZhipuAI base URL
- help:
- en_US: Please input your ZhipuAI base URL
- zh_Hans: 请输入你的 ZhipuAI base URL
- pt_BR: Please input your ZhipuAI base URL
- placeholder:
- en_US: Please input your ZhipuAI base URL
- zh_Hans: 请输入你的 ZhipuAI base URL
- pt_BR: Please input your ZhipuAI base URL
diff --git a/api/core/tools/provider/builtin/cogview/tools/cogview3.py b/api/core/tools/provider/builtin/cogview/tools/cogview3.py
deleted file mode 100644
index 9039708588..0000000000
--- a/api/core/tools/provider/builtin/cogview/tools/cogview3.py
+++ /dev/null
@@ -1,72 +0,0 @@
-import random
-from typing import Any, Union
-
-from core.model_runtime.model_providers.zhipuai.zhipuai_sdk._client import ZhipuAI
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class CogView3Tool(BuiltinTool):
- """CogView3 Tool"""
-
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke CogView3 tool
- """
- client = ZhipuAI(
- base_url=self.runtime.credentials["zhipuai_base_url"],
- api_key=self.runtime.credentials["zhipuai_api_key"],
- )
- size_mapping = {
- "square": "1024x1024",
- "vertical": "1024x1792",
- "horizontal": "1792x1024",
- }
- # prompt
- prompt = tool_parameters.get("prompt", "")
- if not prompt:
- return self.create_text_message("Please input prompt")
- # get size
- size = size_mapping[tool_parameters.get("size", "square")]
- # get n
- n = tool_parameters.get("n", 1)
- # get quality
- quality = tool_parameters.get("quality", "standard")
- if quality not in {"standard", "hd"}:
- return self.create_text_message("Invalid quality")
- # get style
- style = tool_parameters.get("style", "vivid")
- if style not in {"natural", "vivid"}:
- return self.create_text_message("Invalid style")
- # set extra body
- seed_id = tool_parameters.get("seed_id", self._generate_random_id(8))
- extra_body = {"seed": seed_id}
- response = client.images.generations(
- prompt=prompt,
- model="cogview-3",
- size=size,
- n=n,
- extra_body=extra_body,
- style=style,
- quality=quality,
- response_format="b64_json",
- )
- result = []
- for image in response.data:
- result.append(self.create_image_message(image=image.url))
- result.append(
- self.create_json_message(
- {
- "url": image.url,
- }
- )
- )
- return result
-
- @staticmethod
- def _generate_random_id(length=8):
- characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
- random_id = "".join(random.choices(characters, k=length))
- return random_id
diff --git a/api/core/tools/provider/builtin/cogview/tools/cogview3.yaml b/api/core/tools/provider/builtin/cogview/tools/cogview3.yaml
deleted file mode 100644
index 1de3f599b6..0000000000
--- a/api/core/tools/provider/builtin/cogview/tools/cogview3.yaml
+++ /dev/null
@@ -1,123 +0,0 @@
-identity:
- name: cogview3
- author: Waffle
- label:
- en_US: CogView 3
- zh_Hans: CogView 3 绘画
- pt_BR: CogView 3
- description:
- en_US: CogView 3 is a powerful drawing tool that can draw the image you want based on your prompt
- zh_Hans: CogView 3 是一个强大的绘画工具,它可以根据您的提示词绘制出您想要的图像
- pt_BR: CogView 3 is a powerful drawing tool that can draw the image you want based on your prompt
-description:
- human:
- en_US: CogView 3 is a text to image tool
- zh_Hans: CogView 3 是一个文本到图像的工具
- pt_BR: CogView 3 is a text to image tool
- llm: CogView 3 is a tool used to generate images from text
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: Prompt
- zh_Hans: 提示词
- pt_BR: Prompt
- human_description:
- en_US: Image prompt, you can check the official documentation of CogView 3
- zh_Hans: 图像提示词,您可以查看 CogView 3 的官方文档
- pt_BR: Image prompt, you can check the official documentation of CogView 3
- llm_description: Image prompt of CogView 3, you should describe the image you want to generate as a list of words as possible as detailed
- form: llm
- - name: size
- type: select
- required: true
- human_description:
- en_US: selecting the image size
- zh_Hans: 选择图像大小
- pt_BR: selecting the image size
- label:
- en_US: Image size
- zh_Hans: 图像大小
- pt_BR: Image size
- form: form
- options:
- - value: square
- label:
- en_US: Squre(1024x1024)
- zh_Hans: 方(1024x1024)
- pt_BR: Squre(1024x1024)
- - value: vertical
- label:
- en_US: Vertical(1024x1792)
- zh_Hans: 竖屏(1024x1792)
- pt_BR: Vertical(1024x1792)
- - value: horizontal
- label:
- en_US: Horizontal(1792x1024)
- zh_Hans: 横屏(1792x1024)
- pt_BR: Horizontal(1792x1024)
- default: square
- - name: n
- type: number
- required: true
- human_description:
- en_US: selecting the number of images
- zh_Hans: 选择图像数量
- pt_BR: selecting the number of images
- label:
- en_US: Number of images
- zh_Hans: 图像数量
- pt_BR: Number of images
- form: form
- min: 1
- max: 1
- default: 1
- - name: quality
- type: select
- required: true
- human_description:
- en_US: selecting the image quality
- zh_Hans: 选择图像质量
- pt_BR: selecting the image quality
- label:
- en_US: Image quality
- zh_Hans: 图像质量
- pt_BR: Image quality
- form: form
- options:
- - value: standard
- label:
- en_US: Standard
- zh_Hans: 标准
- pt_BR: Standard
- - value: hd
- label:
- en_US: HD
- zh_Hans: 高清
- pt_BR: HD
- default: standard
- - name: style
- type: select
- required: true
- human_description:
- en_US: selecting the image style
- zh_Hans: 选择图像风格
- pt_BR: selecting the image style
- label:
- en_US: Image style
- zh_Hans: 图像风格
- pt_BR: Image style
- form: form
- options:
- - value: vivid
- label:
- en_US: Vivid
- zh_Hans: 生动
- pt_BR: Vivid
- - value: natural
- label:
- en_US: Natural
- zh_Hans: 自然
- pt_BR: Natural
- default: vivid
diff --git a/api/core/tools/provider/builtin/comfyui/_assets/icon.png b/api/core/tools/provider/builtin/comfyui/_assets/icon.png
deleted file mode 100644
index 958ec5c5cf..0000000000
Binary files a/api/core/tools/provider/builtin/comfyui/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/comfyui/comfyui.py b/api/core/tools/provider/builtin/comfyui/comfyui.py
deleted file mode 100644
index 7013a0b93c..0000000000
--- a/api/core/tools/provider/builtin/comfyui/comfyui.py
+++ /dev/null
@@ -1,17 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.comfyui.tools.comfyui_stable_diffusion import ComfyuiStableDiffusionTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class ComfyUIProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- ComfyuiStableDiffusionTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).validate_models()
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/comfyui/comfyui.yaml b/api/core/tools/provider/builtin/comfyui/comfyui.yaml
deleted file mode 100644
index 066fd85308..0000000000
--- a/api/core/tools/provider/builtin/comfyui/comfyui.yaml
+++ /dev/null
@@ -1,42 +0,0 @@
-identity:
- author: Qun
- name: comfyui
- label:
- en_US: ComfyUI
- zh_Hans: ComfyUI
- pt_BR: ComfyUI
- description:
- en_US: ComfyUI is a tool for generating images which can be deployed locally.
- zh_Hans: ComfyUI 是一个可以在本地部署的图片生成的工具。
- pt_BR: ComfyUI is a tool for generating images which can be deployed locally.
- icon: icon.png
- tags:
- - image
-credentials_for_provider:
- base_url:
- type: text-input
- required: true
- label:
- en_US: Base URL
- zh_Hans: ComfyUI服务器的Base URL
- pt_BR: Base URL
- placeholder:
- en_US: Please input your ComfyUI server's Base URL
- zh_Hans: 请输入你的 ComfyUI 服务器的 Base URL
- pt_BR: Please input your ComfyUI server's Base URL
- model:
- type: text-input
- required: true
- label:
- en_US: Model with suffix
- zh_Hans: 模型, 需要带后缀
- pt_BR: Model with suffix
- placeholder:
- en_US: Please input your model
- zh_Hans: 请输入你的模型名称
- pt_BR: Please input your model
- help:
- en_US: The checkpoint name of the ComfyUI server, e.g. xxx.safetensors
- zh_Hans: ComfyUI服务器的模型名称, 比如 xxx.safetensors
- pt_BR: The checkpoint name of the ComfyUI server, e.g. xxx.safetensors
- url: https://docs.dify.ai/tutorials/tool-configuration/comfyui
diff --git a/api/core/tools/provider/builtin/comfyui/tools/comfyui_stable_diffusion.py b/api/core/tools/provider/builtin/comfyui/tools/comfyui_stable_diffusion.py
deleted file mode 100644
index 81fc8cc985..0000000000
--- a/api/core/tools/provider/builtin/comfyui/tools/comfyui_stable_diffusion.py
+++ /dev/null
@@ -1,475 +0,0 @@
-import json
-import os
-import random
-import uuid
-from copy import deepcopy
-from enum import Enum
-from typing import Any, Union
-
-import websocket
-from httpx import get, post
-from yarl import URL
-
-from core.tools.entities.common_entities import I18nObject
-from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameter, ToolParameterOption
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.tool.builtin_tool import BuiltinTool
-
-SD_TXT2IMG_OPTIONS = {}
-LORA_NODE = {
- "inputs": {"lora_name": "", "strength_model": 1, "strength_clip": 1, "model": ["11", 0], "clip": ["11", 1]},
- "class_type": "LoraLoader",
- "_meta": {"title": "Load LoRA"},
-}
-FluxGuidanceNode = {
- "inputs": {"guidance": 3.5, "conditioning": ["6", 0]},
- "class_type": "FluxGuidance",
- "_meta": {"title": "FluxGuidance"},
-}
-
-
-class ModelType(Enum):
- SD15 = 1
- SDXL = 2
- SD3 = 3
- FLUX = 4
-
-
-class ComfyuiStableDiffusionTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- # base url
- base_url = self.runtime.credentials.get("base_url", "")
- if not base_url:
- return self.create_text_message("Please input base_url")
-
- if tool_parameters.get("model"):
- self.runtime.credentials["model"] = tool_parameters["model"]
-
- model = self.runtime.credentials.get("model", None)
- if not model:
- return self.create_text_message("Please input model")
-
- # prompt
- prompt = tool_parameters.get("prompt", "")
- if not prompt:
- return self.create_text_message("Please input prompt")
-
- # get negative prompt
- negative_prompt = tool_parameters.get("negative_prompt", "")
-
- # get size
- width = tool_parameters.get("width", 1024)
- height = tool_parameters.get("height", 1024)
-
- # get steps
- steps = tool_parameters.get("steps", 1)
-
- # get sampler_name
- sampler_name = tool_parameters.get("sampler_name", "euler")
-
- # scheduler
- scheduler = tool_parameters.get("scheduler", "normal")
-
- # get cfg
- cfg = tool_parameters.get("cfg", 7.0)
-
- # get model type
- model_type = tool_parameters.get("model_type", ModelType.SD15.name)
-
- # get lora
- # supports up to 3 loras
- lora_list = []
- lora_strength_list = []
- if tool_parameters.get("lora_1"):
- lora_list.append(tool_parameters["lora_1"])
- lora_strength_list.append(tool_parameters.get("lora_strength_1", 1))
- if tool_parameters.get("lora_2"):
- lora_list.append(tool_parameters["lora_2"])
- lora_strength_list.append(tool_parameters.get("lora_strength_2", 1))
- if tool_parameters.get("lora_3"):
- lora_list.append(tool_parameters["lora_3"])
- lora_strength_list.append(tool_parameters.get("lora_strength_3", 1))
-
- return self.text2img(
- base_url=base_url,
- model=model,
- model_type=model_type,
- prompt=prompt,
- negative_prompt=negative_prompt,
- width=width,
- height=height,
- steps=steps,
- sampler_name=sampler_name,
- scheduler=scheduler,
- cfg=cfg,
- lora_list=lora_list,
- lora_strength_list=lora_strength_list,
- )
-
- def get_checkpoints(self) -> list[str]:
- """
- get checkpoints
- """
- try:
- base_url = self.runtime.credentials.get("base_url", None)
- if not base_url:
- return []
- api_url = str(URL(base_url) / "models" / "checkpoints")
- response = get(url=api_url, timeout=(2, 10))
- if response.status_code != 200:
- return []
- else:
- return response.json()
- except Exception as e:
- return []
-
- def get_loras(self) -> list[str]:
- """
- get loras
- """
- try:
- base_url = self.runtime.credentials.get("base_url", None)
- if not base_url:
- return []
- api_url = str(URL(base_url) / "models" / "loras")
- response = get(url=api_url, timeout=(2, 10))
- if response.status_code != 200:
- return []
- else:
- return response.json()
- except Exception as e:
- return []
-
- def get_sample_methods(self) -> tuple[list[str], list[str]]:
- """
- get sample method
- """
- try:
- base_url = self.runtime.credentials.get("base_url", None)
- if not base_url:
- return [], []
- api_url = str(URL(base_url) / "object_info" / "KSampler")
- response = get(url=api_url, timeout=(2, 10))
- if response.status_code != 200:
- return [], []
- else:
- data = response.json()["KSampler"]["input"]["required"]
- return data["sampler_name"][0], data["scheduler"][0]
- except Exception as e:
- return [], []
-
- def validate_models(self) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- validate models
- """
- try:
- base_url = self.runtime.credentials.get("base_url", None)
- if not base_url:
- raise ToolProviderCredentialValidationError("Please input base_url")
- model = self.runtime.credentials.get("model", None)
- if not model:
- raise ToolProviderCredentialValidationError("Please input model")
-
- api_url = str(URL(base_url) / "models" / "checkpoints")
- response = get(url=api_url, timeout=(2, 10))
- if response.status_code != 200:
- raise ToolProviderCredentialValidationError("Failed to get models")
- else:
- models = response.json()
- if len([d for d in models if d == model]) > 0:
- return self.create_text_message(json.dumps(models))
- else:
- raise ToolProviderCredentialValidationError(f"model {model} does not exist")
- except Exception as e:
- raise ToolProviderCredentialValidationError(f"Failed to get models, {e}")
-
- def get_history(self, base_url, prompt_id):
- """
- get history
- """
- url = str(URL(base_url) / "history")
- respond = get(url, params={"prompt_id": prompt_id}, timeout=(2, 10))
- return respond.json()
-
- def download_image(self, base_url, filename, subfolder, folder_type):
- """
- download image
- """
- url = str(URL(base_url) / "view")
- response = get(url, params={"filename": filename, "subfolder": subfolder, "type": folder_type}, timeout=(2, 10))
- return response.content
-
- def queue_prompt_image(self, base_url, client_id, prompt):
- """
- send prompt task and rotate
- """
- # initiate task execution
- url = str(URL(base_url) / "prompt")
- respond = post(url, data=json.dumps({"client_id": client_id, "prompt": prompt}), timeout=(2, 10))
- prompt_id = respond.json()["prompt_id"]
-
- ws = websocket.WebSocket()
- if "https" in base_url:
- ws_url = base_url.replace("https", "ws")
- else:
- ws_url = base_url.replace("http", "ws")
- ws.connect(str(URL(f"{ws_url}") / "ws") + f"?clientId={client_id}", timeout=120)
-
- # websocket rotate execution status
- output_images = {}
- while True:
- out = ws.recv()
- if isinstance(out, str):
- message = json.loads(out)
- if message["type"] == "executing":
- data = message["data"]
- if data["node"] is None and data["prompt_id"] == prompt_id:
- break # Execution is done
- elif message["type"] == "status":
- data = message["data"]
- if data["status"]["exec_info"]["queue_remaining"] == 0 and data.get("sid"):
- break # Execution is done
- else:
- continue # previews are binary data
-
- # download image when execution finished
- history = self.get_history(base_url, prompt_id)[prompt_id]
- for o in history["outputs"]:
- for node_id in history["outputs"]:
- node_output = history["outputs"][node_id]
- if "images" in node_output:
- images_output = []
- for image in node_output["images"]:
- image_data = self.download_image(base_url, image["filename"], image["subfolder"], image["type"])
- images_output.append(image_data)
- output_images[node_id] = images_output
-
- ws.close()
-
- return output_images
-
- def text2img(
- self,
- base_url: str,
- model: str,
- model_type: str,
- prompt: str,
- negative_prompt: str,
- width: int,
- height: int,
- steps: int,
- sampler_name: str,
- scheduler: str,
- cfg: float,
- lora_list: list,
- lora_strength_list: list,
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- generate image
- """
- if not SD_TXT2IMG_OPTIONS:
- current_dir = os.path.dirname(os.path.realpath(__file__))
- with open(os.path.join(current_dir, "txt2img.json")) as file:
- SD_TXT2IMG_OPTIONS.update(json.load(file))
-
- draw_options = deepcopy(SD_TXT2IMG_OPTIONS)
- draw_options["3"]["inputs"]["steps"] = steps
- draw_options["3"]["inputs"]["sampler_name"] = sampler_name
- draw_options["3"]["inputs"]["scheduler"] = scheduler
- draw_options["3"]["inputs"]["cfg"] = cfg
- # generate different image when using same prompt next time
- draw_options["3"]["inputs"]["seed"] = random.randint(0, 100000000)
- draw_options["4"]["inputs"]["ckpt_name"] = model
- draw_options["5"]["inputs"]["width"] = width
- draw_options["5"]["inputs"]["height"] = height
- draw_options["6"]["inputs"]["text"] = prompt
- draw_options["7"]["inputs"]["text"] = negative_prompt
- # if the model is SD3 or FLUX series, the Latent class should be corresponding to SD3 Latent
- if model_type in {ModelType.SD3.name, ModelType.FLUX.name}:
- draw_options["5"]["class_type"] = "EmptySD3LatentImage"
-
- if lora_list:
- # last Lora node link to KSampler node
- draw_options["3"]["inputs"]["model"][0] = "10"
- # last Lora node link to positive and negative Clip node
- draw_options["6"]["inputs"]["clip"][0] = "10"
- draw_options["7"]["inputs"]["clip"][0] = "10"
- # every Lora node link to next Lora node, and Checkpoints node link to first Lora node
- for i, (lora, strength) in enumerate(zip(lora_list, lora_strength_list), 10):
- if i - 10 == len(lora_list) - 1:
- next_node_id = "4"
- else:
- next_node_id = str(i + 1)
- lora_node = deepcopy(LORA_NODE)
- lora_node["inputs"]["lora_name"] = lora
- lora_node["inputs"]["strength_model"] = strength
- lora_node["inputs"]["strength_clip"] = strength
- lora_node["inputs"]["model"][0] = next_node_id
- lora_node["inputs"]["clip"][0] = next_node_id
- draw_options[str(i)] = lora_node
-
- # FLUX need to add FluxGuidance Node
- if model_type == ModelType.FLUX.name:
- last_node_id = str(10 + len(lora_list))
- draw_options[last_node_id] = deepcopy(FluxGuidanceNode)
- draw_options[last_node_id]["inputs"]["conditioning"][0] = "6"
- draw_options["3"]["inputs"]["positive"][0] = last_node_id
-
- try:
- client_id = str(uuid.uuid4())
- result = self.queue_prompt_image(base_url, client_id, prompt=draw_options)
-
- # get first image
- image = b""
- for node in result:
- for img in result[node]:
- if img:
- image = img
- break
-
- return self.create_blob_message(
- blob=image, meta={"mime_type": "image/png"}, save_as=self.VARIABLE_KEY.IMAGE.value
- )
-
- except Exception as e:
- return self.create_text_message(f"Failed to generate image: {str(e)}")
-
- def get_runtime_parameters(self) -> list[ToolParameter]:
- parameters = [
- ToolParameter(
- name="prompt",
- label=I18nObject(en_US="Prompt", zh_Hans="Prompt"),
- human_description=I18nObject(
- en_US="Image prompt, you can check the official documentation of Stable Diffusion",
- zh_Hans="图像提示词,您可以查看 Stable Diffusion 的官方文档",
- ),
- type=ToolParameter.ToolParameterType.STRING,
- form=ToolParameter.ToolParameterForm.LLM,
- llm_description="Image prompt of Stable Diffusion, you should describe the image "
- "you want to generate as a list of words as possible as detailed, "
- "the prompt must be written in English.",
- required=True,
- ),
- ]
- if self.runtime.credentials:
- try:
- models = self.get_checkpoints()
- if len(models) != 0:
- parameters.append(
- ToolParameter(
- name="model",
- label=I18nObject(en_US="Model", zh_Hans="Model"),
- human_description=I18nObject(
- en_US="Model of Stable Diffusion or FLUX, "
- "you can check the official documentation of Stable Diffusion or FLUX",
- zh_Hans="Stable Diffusion 或者 FLUX 的模型,您可以查看 Stable Diffusion 的官方文档",
- ),
- type=ToolParameter.ToolParameterType.SELECT,
- form=ToolParameter.ToolParameterForm.FORM,
- llm_description="Model of Stable Diffusion or FLUX, "
- "you can check the official documentation of Stable Diffusion or FLUX",
- required=True,
- default=models[0],
- options=[
- ToolParameterOption(value=i, label=I18nObject(en_US=i, zh_Hans=i)) for i in models
- ],
- )
- )
- loras = self.get_loras()
- if len(loras) != 0:
- for n in range(1, 4):
- parameters.append(
- ToolParameter(
- name=f"lora_{n}",
- label=I18nObject(en_US=f"Lora {n}", zh_Hans=f"Lora {n}"),
- human_description=I18nObject(
- en_US="Lora of Stable Diffusion, "
- "you can check the official documentation of Stable Diffusion",
- zh_Hans="Stable Diffusion 的 Lora 模型,您可以查看 Stable Diffusion 的官方文档",
- ),
- type=ToolParameter.ToolParameterType.SELECT,
- form=ToolParameter.ToolParameterForm.FORM,
- llm_description="Lora of Stable Diffusion, "
- "you can check the official documentation of "
- "Stable Diffusion",
- required=False,
- options=[
- ToolParameterOption(value=i, label=I18nObject(en_US=i, zh_Hans=i)) for i in loras
- ],
- )
- )
- sample_methods, schedulers = self.get_sample_methods()
- if len(sample_methods) != 0:
- parameters.append(
- ToolParameter(
- name="sampler_name",
- label=I18nObject(en_US="Sampling method", zh_Hans="Sampling method"),
- human_description=I18nObject(
- en_US="Sampling method of Stable Diffusion, "
- "you can check the official documentation of Stable Diffusion",
- zh_Hans="Stable Diffusion 的Sampling method,您可以查看 Stable Diffusion 的官方文档",
- ),
- type=ToolParameter.ToolParameterType.SELECT,
- form=ToolParameter.ToolParameterForm.FORM,
- llm_description="Sampling method of Stable Diffusion, "
- "you can check the official documentation of Stable Diffusion",
- required=True,
- default=sample_methods[0],
- options=[
- ToolParameterOption(value=i, label=I18nObject(en_US=i, zh_Hans=i))
- for i in sample_methods
- ],
- )
- )
- if len(schedulers) != 0:
- parameters.append(
- ToolParameter(
- name="scheduler",
- label=I18nObject(en_US="Scheduler", zh_Hans="Scheduler"),
- human_description=I18nObject(
- en_US="Scheduler of Stable Diffusion, "
- "you can check the official documentation of Stable Diffusion",
- zh_Hans="Stable Diffusion 的Scheduler,您可以查看 Stable Diffusion 的官方文档",
- ),
- type=ToolParameter.ToolParameterType.SELECT,
- form=ToolParameter.ToolParameterForm.FORM,
- llm_description="Scheduler of Stable Diffusion, "
- "you can check the official documentation of Stable Diffusion",
- required=True,
- default=schedulers[0],
- options=[
- ToolParameterOption(value=i, label=I18nObject(en_US=i, zh_Hans=i)) for i in schedulers
- ],
- )
- )
- parameters.append(
- ToolParameter(
- name="model_type",
- label=I18nObject(en_US="Model Type", zh_Hans="Model Type"),
- human_description=I18nObject(
- en_US="Model Type of Stable Diffusion or Flux, "
- "you can check the official documentation of Stable Diffusion or Flux",
- zh_Hans="Stable Diffusion 或 FLUX 的模型类型,"
- "您可以查看 Stable Diffusion 或 Flux 的官方文档",
- ),
- type=ToolParameter.ToolParameterType.SELECT,
- form=ToolParameter.ToolParameterForm.FORM,
- llm_description="Model Type of Stable Diffusion or Flux, "
- "you can check the official documentation of Stable Diffusion or Flux",
- required=True,
- default=ModelType.SD15.name,
- options=[
- ToolParameterOption(value=i, label=I18nObject(en_US=i, zh_Hans=i))
- for i in ModelType.__members__
- ],
- )
- )
- except:
- pass
-
- return parameters
diff --git a/api/core/tools/provider/builtin/comfyui/tools/comfyui_stable_diffusion.yaml b/api/core/tools/provider/builtin/comfyui/tools/comfyui_stable_diffusion.yaml
deleted file mode 100644
index 4f4a6942b3..0000000000
--- a/api/core/tools/provider/builtin/comfyui/tools/comfyui_stable_diffusion.yaml
+++ /dev/null
@@ -1,212 +0,0 @@
-identity:
- name: txt2img workflow
- author: Qun
- label:
- en_US: Txt2Img Workflow
- zh_Hans: Txt2Img Workflow
- pt_BR: Txt2Img Workflow
-description:
- human:
- en_US: a pre-defined comfyui workflow that can use one model and up to 3 loras to generate images. Support SD1.5, SDXL, SD3 and FLUX which contain text encoders/clip, but does not support models that requires a triple clip loader.
- zh_Hans: 一个预定义的 ComfyUI 工作流,可以使用一个模型和最多3个loras来生成图像。支持包含文本编码器/clip的SD1.5、SDXL、SD3和FLUX,但不支持需要clip加载器的模型。
- pt_BR: a pre-defined comfyui workflow that can use one model and up to 3 loras to generate images. Support SD1.5, SDXL, SD3 and FLUX which contain text encoders/clip, but does not support models that requires a triple clip loader.
- llm: draw the image you want based on your prompt.
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: Prompt
- zh_Hans: 提示词
- pt_BR: Prompt
- human_description:
- en_US: Image prompt, you can check the official documentation of Stable Diffusion or FLUX
- zh_Hans: 图像提示词,您可以查看 Stable Diffusion 或者 FLUX 的官方文档
- pt_BR: Image prompt, you can check the official documentation of Stable Diffusion or FLUX
- llm_description: Image prompt of Stable Diffusion, you should describe the image you want to generate as a list of words as possible as detailed, the prompt must be written in English.
- form: llm
- - name: model
- type: string
- required: true
- label:
- en_US: Model Name
- zh_Hans: 模型名称
- pt_BR: Model Name
- human_description:
- en_US: Model Name
- zh_Hans: 模型名称
- pt_BR: Model Name
- form: form
- - name: model_type
- type: string
- required: true
- label:
- en_US: Model Type
- zh_Hans: 模型类型
- pt_BR: Model Type
- human_description:
- en_US: Model Type
- zh_Hans: 模型类型
- pt_BR: Model Type
- form: form
- - name: lora_1
- type: string
- required: false
- label:
- en_US: Lora 1
- zh_Hans: Lora 1
- pt_BR: Lora 1
- human_description:
- en_US: Lora 1
- zh_Hans: Lora 1
- pt_BR: Lora 1
- form: form
- - name: lora_strength_1
- type: number
- required: false
- label:
- en_US: Lora Strength 1
- zh_Hans: Lora Strength 1
- pt_BR: Lora Strength 1
- human_description:
- en_US: Lora Strength 1
- zh_Hans: Lora模型的权重
- pt_BR: Lora Strength 1
- form: form
- - name: steps
- type: number
- required: false
- label:
- en_US: Steps
- zh_Hans: Steps
- pt_BR: Steps
- human_description:
- en_US: Steps
- zh_Hans: Steps
- pt_BR: Steps
- form: form
- default: 20
- - name: width
- type: number
- required: false
- label:
- en_US: Width
- zh_Hans: Width
- pt_BR: Width
- human_description:
- en_US: Width
- zh_Hans: Width
- pt_BR: Width
- form: form
- default: 1024
- - name: height
- type: number
- required: false
- label:
- en_US: Height
- zh_Hans: Height
- pt_BR: Height
- human_description:
- en_US: Height
- zh_Hans: Height
- pt_BR: Height
- form: form
- default: 1024
- - name: negative_prompt
- type: string
- required: false
- label:
- en_US: Negative prompt
- zh_Hans: Negative prompt
- pt_BR: Negative prompt
- human_description:
- en_US: Negative prompt
- zh_Hans: Negative prompt
- pt_BR: Negative prompt
- form: form
- default: bad art, ugly, deformed, watermark, duplicated, discontinuous lines
- - name: cfg
- type: number
- required: false
- label:
- en_US: CFG Scale
- zh_Hans: CFG Scale
- pt_BR: CFG Scale
- human_description:
- en_US: CFG Scale
- zh_Hans: 提示词相关性(CFG Scale)
- pt_BR: CFG Scale
- form: form
- default: 7.0
- - name: sampler_name
- type: string
- required: false
- label:
- en_US: Sampling method
- zh_Hans: Sampling method
- pt_BR: Sampling method
- human_description:
- en_US: Sampling method
- zh_Hans: Sampling method
- pt_BR: Sampling method
- form: form
- - name: scheduler
- type: string
- required: false
- label:
- en_US: Scheduler
- zh_Hans: Scheduler
- pt_BR: Scheduler
- human_description:
- en_US: Scheduler
- zh_Hans: Scheduler
- pt_BR: Scheduler
- form: form
- - name: lora_2
- type: string
- required: false
- label:
- en_US: Lora 2
- zh_Hans: Lora 2
- pt_BR: Lora 2
- human_description:
- en_US: Lora 2
- zh_Hans: Lora 2
- pt_BR: Lora 2
- form: form
- - name: lora_strength_2
- type: number
- required: false
- label:
- en_US: Lora Strength 2
- zh_Hans: Lora Strength 2
- pt_BR: Lora Strength 2
- human_description:
- en_US: Lora Strength 2
- zh_Hans: Lora模型的权重
- pt_BR: Lora Strength 2
- form: form
- - name: lora_3
- type: string
- required: false
- label:
- en_US: Lora 3
- zh_Hans: Lora 3
- pt_BR: Lora 3
- human_description:
- en_US: Lora 3
- zh_Hans: Lora 3
- pt_BR: Lora 3
- form: form
- - name: lora_strength_3
- type: number
- required: false
- label:
- en_US: Lora Strength 3
- zh_Hans: Lora Strength 3
- pt_BR: Lora Strength 3
- human_description:
- en_US: Lora Strength 3
- zh_Hans: Lora模型的权重
- pt_BR: Lora Strength 3
- form: form
diff --git a/api/core/tools/provider/builtin/comfyui/tools/txt2img.json b/api/core/tools/provider/builtin/comfyui/tools/txt2img.json
deleted file mode 100644
index 8ea869ff10..0000000000
--- a/api/core/tools/provider/builtin/comfyui/tools/txt2img.json
+++ /dev/null
@@ -1,107 +0,0 @@
-{
- "3": {
- "inputs": {
- "seed": 156680208700286,
- "steps": 20,
- "cfg": 8,
- "sampler_name": "euler",
- "scheduler": "normal",
- "denoise": 1,
- "model": [
- "4",
- 0
- ],
- "positive": [
- "6",
- 0
- ],
- "negative": [
- "7",
- 0
- ],
- "latent_image": [
- "5",
- 0
- ]
- },
- "class_type": "KSampler",
- "_meta": {
- "title": "KSampler"
- }
- },
- "4": {
- "inputs": {
- "ckpt_name": "3dAnimationDiffusion_v10.safetensors"
- },
- "class_type": "CheckpointLoaderSimple",
- "_meta": {
- "title": "Load Checkpoint"
- }
- },
- "5": {
- "inputs": {
- "width": 512,
- "height": 512,
- "batch_size": 1
- },
- "class_type": "EmptyLatentImage",
- "_meta": {
- "title": "Empty Latent Image"
- }
- },
- "6": {
- "inputs": {
- "text": "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,",
- "clip": [
- "4",
- 1
- ]
- },
- "class_type": "CLIPTextEncode",
- "_meta": {
- "title": "CLIP Text Encode (Prompt)"
- }
- },
- "7": {
- "inputs": {
- "text": "text, watermark",
- "clip": [
- "4",
- 1
- ]
- },
- "class_type": "CLIPTextEncode",
- "_meta": {
- "title": "CLIP Text Encode (Prompt)"
- }
- },
- "8": {
- "inputs": {
- "samples": [
- "3",
- 0
- ],
- "vae": [
- "4",
- 2
- ]
- },
- "class_type": "VAEDecode",
- "_meta": {
- "title": "VAE Decode"
- }
- },
- "9": {
- "inputs": {
- "filename_prefix": "ComfyUI",
- "images": [
- "8",
- 0
- ]
- },
- "class_type": "SaveImage",
- "_meta": {
- "title": "Save Image"
- }
- }
-}
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/crossref/_assets/icon.svg b/api/core/tools/provider/builtin/crossref/_assets/icon.svg
deleted file mode 100644
index aa629de7cb..0000000000
--- a/api/core/tools/provider/builtin/crossref/_assets/icon.svg
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
diff --git a/api/core/tools/provider/builtin/crossref/crossref.py b/api/core/tools/provider/builtin/crossref/crossref.py
deleted file mode 100644
index 8ba3c1b48a..0000000000
--- a/api/core/tools/provider/builtin/crossref/crossref.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.crossref.tools.query_doi import CrossRefQueryDOITool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class CrossRefProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- CrossRefQueryDOITool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "doi": "10.1007/s00894-022-05373-8",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/crossref/crossref.yaml b/api/core/tools/provider/builtin/crossref/crossref.yaml
deleted file mode 100644
index da67fbec3a..0000000000
--- a/api/core/tools/provider/builtin/crossref/crossref.yaml
+++ /dev/null
@@ -1,29 +0,0 @@
-identity:
- author: Sakura4036
- name: crossref
- label:
- en_US: CrossRef
- zh_Hans: CrossRef
- description:
- en_US: Crossref is a cross-publisher reference linking registration query system using DOI technology created in 2000. Crossref establishes cross-database links between the reference list and citation full text of papers, making it very convenient for readers to access the full text of papers.
- zh_Hans: Crossref是于2000年创建的使用DOI技术的跨出版商参考文献链接注册查询系统。Crossref建立了在论文的参考文献列表和引文全文之间的跨数据库链接,使得读者能够非常便捷地获取文献全文。
- icon: icon.svg
- tags:
- - search
-credentials_for_provider:
- mailto:
- type: text-input
- required: true
- label:
- en_US: email address
- zh_Hans: email地址
- pt_BR: email address
- placeholder:
- en_US: Please input your email address
- zh_Hans: 请输入你的email地址
- pt_BR: Please input your email address
- help:
- en_US: According to the requirements of Crossref, an email address is required
- zh_Hans: 根据Crossref的要求,需要提供一个邮箱地址
- pt_BR: According to the requirements of Crossref, an email address is required
- url: https://api.crossref.org/swagger-ui/index.html
diff --git a/api/core/tools/provider/builtin/crossref/tools/query_doi.py b/api/core/tools/provider/builtin/crossref/tools/query_doi.py
deleted file mode 100644
index 746139dd69..0000000000
--- a/api/core/tools/provider/builtin/crossref/tools/query_doi.py
+++ /dev/null
@@ -1,28 +0,0 @@
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.errors import ToolParameterValidationError
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class CrossRefQueryDOITool(BuiltinTool):
- """
- Tool for querying the metadata of a publication using its DOI.
- """
-
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- doi = tool_parameters.get("doi")
- if not doi:
- raise ToolParameterValidationError("doi is required.")
- # doc: https://github.com/CrossRef/rest-api-doc
- url = f"https://api.crossref.org/works/{doi}"
- response = requests.get(url)
- response.raise_for_status()
- response = response.json()
- message = response.get("message", {})
-
- return self.create_json_message(message)
diff --git a/api/core/tools/provider/builtin/crossref/tools/query_doi.yaml b/api/core/tools/provider/builtin/crossref/tools/query_doi.yaml
deleted file mode 100644
index 9c16da25ed..0000000000
--- a/api/core/tools/provider/builtin/crossref/tools/query_doi.yaml
+++ /dev/null
@@ -1,23 +0,0 @@
-identity:
- name: crossref_query_doi
- author: Sakura4036
- label:
- en_US: CrossRef Query DOI
- zh_Hans: CrossRef DOI 查询
- pt_BR: CrossRef Query DOI
-description:
- human:
- en_US: A tool for searching literature information using CrossRef by DOI.
- zh_Hans: 一个使用CrossRef通过DOI获取文献信息的工具。
- pt_BR: A tool for searching literature information using CrossRef by DOI.
- llm: A tool for searching literature information using CrossRef by DOI.
-parameters:
- - name: doi
- type: string
- required: true
- label:
- en_US: DOI
- zh_Hans: DOI
- pt_BR: DOI
- llm_description: DOI for searching in CrossRef
- form: llm
diff --git a/api/core/tools/provider/builtin/crossref/tools/query_title.py b/api/core/tools/provider/builtin/crossref/tools/query_title.py
deleted file mode 100644
index e245238183..0000000000
--- a/api/core/tools/provider/builtin/crossref/tools/query_title.py
+++ /dev/null
@@ -1,143 +0,0 @@
-import time
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-def convert_time_str_to_seconds(time_str: str) -> int:
- """
- Convert a time string to seconds.
- example: 1s -> 1, 1m30s -> 90, 1h30m -> 5400, 1h30m30s -> 5430
- """
- time_str = time_str.lower().strip().replace(" ", "")
- seconds = 0
- if "h" in time_str:
- hours, time_str = time_str.split("h")
- seconds += int(hours) * 3600
- if "m" in time_str:
- minutes, time_str = time_str.split("m")
- seconds += int(minutes) * 60
- if "s" in time_str:
- seconds += int(time_str.replace("s", ""))
- return seconds
-
-
-class CrossRefQueryTitleAPI:
- """
- Tool for querying the metadata of a publication using its title.
- Crossref API doc: https://github.com/CrossRef/rest-api-doc
- """
-
- query_url_template: str = "https://api.crossref.org/works?query.bibliographic={query}&rows={rows}&offset={offset}&sort={sort}&order={order}&mailto={mailto}"
- rate_limit: int = 50
- rate_interval: float = 1
- max_limit: int = 1000
-
- def __init__(self, mailto: str):
- self.mailto = mailto
-
- def _query(
- self,
- query: str,
- rows: int = 5,
- offset: int = 0,
- sort: str = "relevance",
- order: str = "desc",
- fuzzy_query: bool = False,
- ) -> list[dict]:
- """
- Query the metadata of a publication using its title.
- :param query: the title of the publication
- :param rows: the number of results to return
- :param sort: the sort field
- :param order: the sort order
- :param fuzzy_query: whether to return all items that match the query
- """
- url = self.query_url_template.format(
- query=query, rows=rows, offset=offset, sort=sort, order=order, mailto=self.mailto
- )
- response = requests.get(url)
- response.raise_for_status()
- rate_limit = int(response.headers["x-ratelimit-limit"])
- # convert time string to seconds
- rate_interval = convert_time_str_to_seconds(response.headers["x-ratelimit-interval"])
-
- self.rate_limit = rate_limit
- self.rate_interval = rate_interval
-
- response = response.json()
- if response["status"] != "ok":
- return []
-
- message = response["message"]
- if fuzzy_query:
- # fuzzy query return all items
- return message["items"]
- else:
- for paper in message["items"]:
- title = paper["title"][0]
- if title.lower() != query.lower():
- continue
- return [paper]
- return []
-
- def query(
- self, query: str, rows: int = 5, sort: str = "relevance", order: str = "desc", fuzzy_query: bool = False
- ) -> list[dict]:
- """
- Query the metadata of a publication using its title.
- :param query: the title of the publication
- :param rows: the number of results to return
- :param sort: the sort field
- :param order: the sort order
- :param fuzzy_query: whether to return all items that match the query
- """
- rows = min(rows, self.max_limit)
- if rows > self.rate_limit:
- # query multiple times
- query_times = rows // self.rate_limit + 1
- results = []
-
- for i in range(query_times):
- result = self._query(
- query,
- rows=self.rate_limit,
- offset=i * self.rate_limit,
- sort=sort,
- order=order,
- fuzzy_query=fuzzy_query,
- )
- if fuzzy_query:
- results.extend(result)
- else:
- # fuzzy_query=False, only one result
- if result:
- return result
- time.sleep(self.rate_interval)
- return results
- else:
- # query once
- return self._query(query, rows, sort=sort, order=order, fuzzy_query=fuzzy_query)
-
-
-class CrossRefQueryTitleTool(BuiltinTool):
- """
- Tool for querying the metadata of a publication using its title.
- """
-
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- query = tool_parameters.get("query")
- fuzzy_query = tool_parameters.get("fuzzy_query", False)
- rows = tool_parameters.get("rows", 3)
- sort = tool_parameters.get("sort", "relevance")
- order = tool_parameters.get("order", "desc")
- mailto = self.runtime.credentials["mailto"]
-
- result = CrossRefQueryTitleAPI(mailto).query(query, rows, sort, order, fuzzy_query)
-
- return [self.create_json_message(r) for r in result]
diff --git a/api/core/tools/provider/builtin/crossref/tools/query_title.yaml b/api/core/tools/provider/builtin/crossref/tools/query_title.yaml
deleted file mode 100644
index 5579c77f52..0000000000
--- a/api/core/tools/provider/builtin/crossref/tools/query_title.yaml
+++ /dev/null
@@ -1,105 +0,0 @@
-identity:
- name: crossref_query_title
- author: Sakura4036
- label:
- en_US: CrossRef Title Query
- zh_Hans: CrossRef 标题查询
- pt_BR: CrossRef Title Query
-description:
- human:
- en_US: A tool for querying literature information using CrossRef by title.
- zh_Hans: 一个使用CrossRef通过标题搜索文献信息的工具。
- pt_BR: A tool for querying literature information using CrossRef by title.
- llm: A tool for querying literature information using CrossRef by title.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: 标题
- zh_Hans: 查询语句
- pt_BR: 标题
- human_description:
- en_US: Query bibliographic information, useful for citation look up. Includes titles, authors, ISSNs and publication years
- zh_Hans: 用于搜索文献信息,有助于查找引用。包括标题,作者,ISSN和出版年份
- pt_BR: Query bibliographic information, useful for citation look up. Includes titles, authors, ISSNs and publication years
- llm_description: key words for querying in Web of Science
- form: llm
- - name: fuzzy_query
- type: boolean
- default: false
- label:
- en_US: Whether to fuzzy search
- zh_Hans: 是否模糊搜索
- pt_BR: Whether to fuzzy search
- human_description:
- en_US: used for selecting the query type, fuzzy query returns more results, precise query returns 1 or none
- zh_Hans: 用于选择搜索类型,模糊搜索返回更多结果,精确搜索返回1条结果或无
- pt_BR: used for selecting the query type, fuzzy query returns more results, precise query returns 1 or none
- form: form
- - name: limit
- type: number
- required: false
- label:
- en_US: max query number
- zh_Hans: 最大搜索数
- pt_BR: max query number
- human_description:
- en_US: max query number(fuzzy search returns the maximum number of results or precise search the maximum number of matches)
- zh_Hans: 最大搜索数(模糊搜索返回的最大结果数或精确搜索最大匹配数)
- pt_BR: max query number(fuzzy search returns the maximum number of results or precise search the maximum number of matches)
- form: llm
- default: 50
- - name: sort
- type: select
- required: true
- options:
- - value: relevance
- label:
- en_US: relevance
- zh_Hans: 相关性
- pt_BR: relevance
- - value: published
- label:
- en_US: publication date
- zh_Hans: 出版日期
- pt_BR: publication date
- - value: references-count
- label:
- en_US: references-count
- zh_Hans: 引用次数
- pt_BR: references-count
- default: relevance
- label:
- en_US: sorting field
- zh_Hans: 排序字段
- pt_BR: sorting field
- human_description:
- en_US: Sorting of query results
- zh_Hans: 检索结果的排序字段
- pt_BR: Sorting of query results
- form: form
- - name: order
- type: select
- required: true
- options:
- - value: desc
- label:
- en_US: descending
- zh_Hans: 降序
- pt_BR: descending
- - value: asc
- label:
- en_US: ascending
- zh_Hans: 升序
- pt_BR: ascending
- default: desc
- label:
- en_US: Order
- zh_Hans: 排序
- pt_BR: Order
- human_description:
- en_US: Order of query results
- zh_Hans: 检索结果的排序方式
- pt_BR: Order of query results
- form: form
diff --git a/api/core/tools/provider/builtin/dalle/__init__.py b/api/core/tools/provider/builtin/dalle/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/api/core/tools/provider/builtin/dalle/_assets/icon.png b/api/core/tools/provider/builtin/dalle/_assets/icon.png
deleted file mode 100644
index 5155a73059..0000000000
Binary files a/api/core/tools/provider/builtin/dalle/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/dalle/dalle.py b/api/core/tools/provider/builtin/dalle/dalle.py
deleted file mode 100644
index 5bd16e49e8..0000000000
--- a/api/core/tools/provider/builtin/dalle/dalle.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.dalle.tools.dalle2 import DallE2Tool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class DALLEProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- DallE2Tool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={"prompt": "cute girl, blue eyes, white hair, anime style", "size": "small", "n": 1},
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/dalle/dalle.yaml b/api/core/tools/provider/builtin/dalle/dalle.yaml
deleted file mode 100644
index 37cf93c28a..0000000000
--- a/api/core/tools/provider/builtin/dalle/dalle.yaml
+++ /dev/null
@@ -1,61 +0,0 @@
-identity:
- author: Dify
- name: dalle
- label:
- en_US: DALL-E
- zh_Hans: DALL-E 绘画
- pt_BR: DALL-E
- description:
- en_US: DALL-E art
- zh_Hans: DALL-E 绘画
- pt_BR: DALL-E art
- icon: icon.png
- tags:
- - image
- - productivity
-credentials_for_provider:
- openai_api_key:
- type: secret-input
- required: true
- label:
- en_US: OpenAI API key
- zh_Hans: OpenAI API key
- pt_BR: OpenAI API key
- help:
- en_US: Please input your OpenAI API key
- zh_Hans: 请输入你的 OpenAI API key
- pt_BR: Please input your OpenAI API key
- placeholder:
- en_US: Please input your OpenAI API key
- zh_Hans: 请输入你的 OpenAI API key
- pt_BR: Please input your OpenAI API key
- openai_organization_id:
- type: text-input
- required: false
- label:
- en_US: OpenAI organization ID
- zh_Hans: OpenAI organization ID
- pt_BR: OpenAI organization ID
- help:
- en_US: Please input your OpenAI organization ID
- zh_Hans: 请输入你的 OpenAI organization ID
- pt_BR: Please input your OpenAI organization ID
- placeholder:
- en_US: Please input your OpenAI organization ID
- zh_Hans: 请输入你的 OpenAI organization ID
- pt_BR: Please input your OpenAI organization ID
- openai_base_url:
- type: text-input
- required: false
- label:
- en_US: OpenAI base URL
- zh_Hans: OpenAI base URL
- pt_BR: OpenAI base URL
- help:
- en_US: Please input your OpenAI base URL
- zh_Hans: 请输入你的 OpenAI base URL
- pt_BR: Please input your OpenAI base URL
- placeholder:
- en_US: Please input your OpenAI base URL
- zh_Hans: 请输入你的 OpenAI base URL
- pt_BR: Please input your OpenAI base URL
diff --git a/api/core/tools/provider/builtin/dalle/tools/dalle2.py b/api/core/tools/provider/builtin/dalle/tools/dalle2.py
deleted file mode 100644
index fbd7397292..0000000000
--- a/api/core/tools/provider/builtin/dalle/tools/dalle2.py
+++ /dev/null
@@ -1,66 +0,0 @@
-from base64 import b64decode
-from typing import Any, Union
-
-from openai import OpenAI
-from yarl import URL
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class DallE2Tool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- openai_organization = self.runtime.credentials.get("openai_organization_id", None)
- if not openai_organization:
- openai_organization = None
- openai_base_url = self.runtime.credentials.get("openai_base_url", None)
- if not openai_base_url:
- openai_base_url = None
- else:
- openai_base_url = str(URL(openai_base_url) / "v1")
-
- client = OpenAI(
- api_key=self.runtime.credentials["openai_api_key"],
- base_url=openai_base_url,
- organization=openai_organization,
- )
-
- SIZE_MAPPING = {
- "small": "256x256",
- "medium": "512x512",
- "large": "1024x1024",
- }
-
- # prompt
- prompt = tool_parameters.get("prompt", "")
- if not prompt:
- return self.create_text_message("Please input prompt")
-
- # get size
- size = SIZE_MAPPING[tool_parameters.get("size", "large")]
-
- # get n
- n = tool_parameters.get("n", 1)
-
- # call openapi dalle2
- response = client.images.generate(prompt=prompt, model="dall-e-2", size=size, n=n, response_format="b64_json")
-
- result = []
-
- for image in response.data:
- result.append(
- self.create_blob_message(
- blob=b64decode(image.b64_json),
- meta={"mime_type": "image/png"},
- save_as=self.VariableKey.IMAGE.value,
- )
- )
-
- return result
diff --git a/api/core/tools/provider/builtin/dalle/tools/dalle2.yaml b/api/core/tools/provider/builtin/dalle/tools/dalle2.yaml
deleted file mode 100644
index e43e5df8cd..0000000000
--- a/api/core/tools/provider/builtin/dalle/tools/dalle2.yaml
+++ /dev/null
@@ -1,74 +0,0 @@
-identity:
- name: dalle2
- author: Dify
- label:
- en_US: DALL-E 2
- zh_Hans: DALL-E 2 绘画
- description:
- en_US: DALL-E 2 is a powerful drawing tool that can draw the image you want based on your prompt
- zh_Hans: DALL-E 2 是一个强大的绘画工具,它可以根据您的提示词绘制出您想要的图像
- pt_BR: DALL-E 2 is a powerful drawing tool that can draw the image you want based on your prompt
-description:
- human:
- en_US: DALL-E is a text to image tool
- zh_Hans: DALL-E 是一个文本到图像的工具
- pt_BR: DALL-E is a text to image tool
- llm: DALL-E is a tool used to generate images from text
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: Prompt
- zh_Hans: 提示词
- pt_BR: Prompt
- human_description:
- en_US: Image prompt, you can check the official documentation of DallE 2
- zh_Hans: 图像提示词,您可以查看 DallE 2 的官方文档
- pt_BR: Image prompt, you can check the official documentation of DallE 2
- llm_description: Image prompt of DallE 2, you should describe the image you want to generate as a list of words as possible as detailed
- form: llm
- - name: size
- type: select
- required: true
- human_description:
- en_US: used for selecting the image size
- zh_Hans: 用于选择图像大小
- pt_BR: used for selecting the image size
- label:
- en_US: Image size
- zh_Hans: 图像大小
- pt_BR: Image size
- form: form
- options:
- - value: small
- label:
- en_US: Small(256x256)
- zh_Hans: 小(256x256)
- pt_BR: Small(256x256)
- - value: medium
- label:
- en_US: Medium(512x512)
- zh_Hans: 中(512x512)
- pt_BR: Medium(512x512)
- - value: large
- label:
- en_US: Large(1024x1024)
- zh_Hans: 大(1024x1024)
- pt_BR: Large(1024x1024)
- default: large
- - name: n
- type: number
- required: true
- human_description:
- en_US: used for selecting the number of images
- zh_Hans: 用于选择图像数量
- pt_BR: used for selecting the number of images
- label:
- en_US: Number of images
- zh_Hans: 图像数量
- pt_BR: Number of images
- form: form
- default: 1
- min: 1
- max: 10
diff --git a/api/core/tools/provider/builtin/dalle/tools/dalle3.py b/api/core/tools/provider/builtin/dalle/tools/dalle3.py
deleted file mode 100644
index a8c647d71e..0000000000
--- a/api/core/tools/provider/builtin/dalle/tools/dalle3.py
+++ /dev/null
@@ -1,115 +0,0 @@
-import base64
-import random
-from typing import Any, Union
-
-from openai import OpenAI
-from yarl import URL
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class DallE3Tool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- openai_organization = self.runtime.credentials.get("openai_organization_id", None)
- if not openai_organization:
- openai_organization = None
- openai_base_url = self.runtime.credentials.get("openai_base_url", None)
- if not openai_base_url:
- openai_base_url = None
- else:
- openai_base_url = str(URL(openai_base_url) / "v1")
-
- client = OpenAI(
- api_key=self.runtime.credentials["openai_api_key"],
- base_url=openai_base_url,
- organization=openai_organization,
- )
-
- SIZE_MAPPING = {
- "square": "1024x1024",
- "vertical": "1024x1792",
- "horizontal": "1792x1024",
- }
-
- # prompt
- prompt = tool_parameters.get("prompt", "")
- if not prompt:
- return self.create_text_message("Please input prompt")
- # get size
- size = SIZE_MAPPING[tool_parameters.get("size", "square")]
- # get n
- n = tool_parameters.get("n", 1)
- # get quality
- quality = tool_parameters.get("quality", "standard")
- if quality not in {"standard", "hd"}:
- return self.create_text_message("Invalid quality")
- # get style
- style = tool_parameters.get("style", "vivid")
- if style not in {"natural", "vivid"}:
- return self.create_text_message("Invalid style")
-
- # call openapi dalle3
- response = client.images.generate(
- prompt=prompt, model="dall-e-3", size=size, n=n, style=style, quality=quality, response_format="b64_json"
- )
-
- result = []
-
- for image in response.data:
- mime_type, blob_image = DallE3Tool._decode_image(image.b64_json)
- blob_message = self.create_blob_message(
- blob=blob_image, meta={"mime_type": mime_type}, save_as=self.VariableKey.IMAGE.value
- )
- result.append(blob_message)
- return result
-
- @staticmethod
- def _decode_image(base64_image: str) -> tuple[str, bytes]:
- """
- Decode a base64 encoded image. If the image is not prefixed with a MIME type,
- it assumes 'image/png' as the default.
-
- :param base64_image: Base64 encoded image string
- :return: A tuple containing the MIME type and the decoded image bytes
- """
- if DallE3Tool._is_plain_base64(base64_image):
- return "image/png", base64.b64decode(base64_image)
- else:
- return DallE3Tool._extract_mime_and_data(base64_image)
-
- @staticmethod
- def _is_plain_base64(encoded_str: str) -> bool:
- """
- Check if the given encoded string is plain base64 without a MIME type prefix.
-
- :param encoded_str: Base64 encoded image string
- :return: True if the string is plain base64, False otherwise
- """
- return not encoded_str.startswith("data:image")
-
- @staticmethod
- def _extract_mime_and_data(encoded_str: str) -> tuple[str, bytes]:
- """
- Extract MIME type and image data from a base64 encoded string with a MIME type prefix.
-
- :param encoded_str: Base64 encoded image string with MIME type prefix
- :return: A tuple containing the MIME type and the decoded image bytes
- """
- mime_type = encoded_str.split(";")[0].split(":")[1]
- image_data_base64 = encoded_str.split(",")[1]
- decoded_data = base64.b64decode(image_data_base64)
- return mime_type, decoded_data
-
- @staticmethod
- def _generate_random_id(length=8):
- characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
- random_id = "".join(random.choices(characters, k=length))
- return random_id
diff --git a/api/core/tools/provider/builtin/dalle/tools/dalle3.yaml b/api/core/tools/provider/builtin/dalle/tools/dalle3.yaml
deleted file mode 100644
index 0cea8af761..0000000000
--- a/api/core/tools/provider/builtin/dalle/tools/dalle3.yaml
+++ /dev/null
@@ -1,123 +0,0 @@
-identity:
- name: dalle3
- author: Dify
- label:
- en_US: DALL-E 3
- zh_Hans: DALL-E 3 绘画
- pt_BR: DALL-E 3
- description:
- en_US: DALL-E 3 is a powerful drawing tool that can draw the image you want based on your prompt, compared to DallE 2, DallE 3 has stronger drawing ability, but it will consume more resources
- zh_Hans: DALL-E 3 是一个强大的绘画工具,它可以根据您的提示词绘制出您想要的图像,相比于DallE 2, DallE 3拥有更强的绘画能力,但会消耗更多的资源
- pt_BR: DALL-E 3 is a powerful drawing tool that can draw the image you want based on your prompt, compared to DallE 2, DallE 3 has stronger drawing ability, but it will consume more resources
-description:
- human:
- en_US: DALL-E is a text to image tool
- zh_Hans: DALL-E 是一个文本到图像的工具
- pt_BR: DALL-E is a text to image tool
- llm: DALL-E is a tool used to generate images from text
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: Prompt
- zh_Hans: 提示词
- pt_BR: Prompt
- human_description:
- en_US: Image prompt, you can check the official documentation of DallE 3
- zh_Hans: 图像提示词,您可以查看 DallE 3 的官方文档
- pt_BR: Image prompt, you can check the official documentation of DallE 3
- llm_description: Image prompt of DallE 3, you should describe the image you want to generate as a list of words as possible as detailed
- form: llm
- - name: size
- type: select
- required: true
- human_description:
- en_US: selecting the image size
- zh_Hans: 选择图像大小
- pt_BR: selecting the image size
- label:
- en_US: Image size
- zh_Hans: 图像大小
- pt_BR: Image size
- form: form
- options:
- - value: square
- label:
- en_US: Squre(1024x1024)
- zh_Hans: 方(1024x1024)
- pt_BR: Squre(1024x1024)
- - value: vertical
- label:
- en_US: Vertical(1024x1792)
- zh_Hans: 竖屏(1024x1792)
- pt_BR: Vertical(1024x1792)
- - value: horizontal
- label:
- en_US: Horizontal(1792x1024)
- zh_Hans: 横屏(1792x1024)
- pt_BR: Horizontal(1792x1024)
- default: square
- - name: n
- type: number
- required: true
- human_description:
- en_US: selecting the number of images
- zh_Hans: 选择图像数量
- pt_BR: selecting the number of images
- label:
- en_US: Number of images
- zh_Hans: 图像数量
- pt_BR: Number of images
- form: form
- min: 1
- max: 1
- default: 1
- - name: quality
- type: select
- required: true
- human_description:
- en_US: selecting the image quality
- zh_Hans: 选择图像质量
- pt_BR: selecting the image quality
- label:
- en_US: Image quality
- zh_Hans: 图像质量
- pt_BR: Image quality
- form: form
- options:
- - value: standard
- label:
- en_US: Standard
- zh_Hans: 标准
- pt_BR: Standard
- - value: hd
- label:
- en_US: HD
- zh_Hans: 高清
- pt_BR: HD
- default: standard
- - name: style
- type: select
- required: true
- human_description:
- en_US: selecting the image style
- zh_Hans: 选择图像风格
- pt_BR: selecting the image style
- label:
- en_US: Image style
- zh_Hans: 图像风格
- pt_BR: Image style
- form: form
- options:
- - value: vivid
- label:
- en_US: Vivid
- zh_Hans: 生动
- pt_BR: Vivid
- - value: natural
- label:
- en_US: Natural
- zh_Hans: 自然
- pt_BR: Natural
- default: vivid
diff --git a/api/core/tools/provider/builtin/devdocs/_assets/icon.svg b/api/core/tools/provider/builtin/devdocs/_assets/icon.svg
deleted file mode 100644
index c7a19fabfb..0000000000
--- a/api/core/tools/provider/builtin/devdocs/_assets/icon.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/devdocs/devdocs.py b/api/core/tools/provider/builtin/devdocs/devdocs.py
deleted file mode 100644
index 446c1e5489..0000000000
--- a/api/core/tools/provider/builtin/devdocs/devdocs.py
+++ /dev/null
@@ -1,21 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.devdocs.tools.searchDevDocs import SearchDevDocsTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class DevDocsProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- SearchDevDocsTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "doc": "python~3.12",
- "topic": "library/code",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/devdocs/devdocs.yaml b/api/core/tools/provider/builtin/devdocs/devdocs.yaml
deleted file mode 100644
index 7552f5a497..0000000000
--- a/api/core/tools/provider/builtin/devdocs/devdocs.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-identity:
- author: Richards Tu
- name: devdocs
- label:
- en_US: DevDocs
- zh_Hans: DevDocs
- description:
- en_US: Get official developer documentations on DevDocs.
- zh_Hans: 从DevDocs获取官方开发者文档。
- icon: icon.svg
- tags:
- - search
- - productivity
diff --git a/api/core/tools/provider/builtin/devdocs/tools/searchDevDocs.py b/api/core/tools/provider/builtin/devdocs/tools/searchDevDocs.py
deleted file mode 100644
index 57cf6d7a30..0000000000
--- a/api/core/tools/provider/builtin/devdocs/tools/searchDevDocs.py
+++ /dev/null
@@ -1,47 +0,0 @@
-from typing import Any, Union
-
-import requests
-from pydantic import BaseModel, Field
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class SearchDevDocsInput(BaseModel):
- doc: str = Field(..., description="The name of the documentation.")
- topic: str = Field(..., description="The path of the section/topic.")
-
-
-class SearchDevDocsTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invokes the DevDocs search tool with the given user ID and tool parameters.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Any]): The parameters for the tool, including 'doc' and 'topic'.
-
- Returns:
- ToolInvokeMessage | list[ToolInvokeMessage]: The result of the tool invocation,
- which can be a single message or a list of messages.
- """
- doc = tool_parameters.get("doc", "")
- topic = tool_parameters.get("topic", "")
-
- if not doc:
- return self.create_text_message("Please provide the documentation name.")
- if not topic:
- return self.create_text_message("Please provide the topic path.")
-
- url = f"https://documents.devdocs.io/{doc}/{topic}.html"
- response = requests.get(url)
-
- if response.status_code == 200:
- content = response.text
- return self.create_text_message(self.summary(user_id=user_id, content=content))
- else:
- return self.create_text_message(
- f"Failed to retrieve the documentation. Status code: {response.status_code}"
- )
diff --git a/api/core/tools/provider/builtin/devdocs/tools/searchDevDocs.yaml b/api/core/tools/provider/builtin/devdocs/tools/searchDevDocs.yaml
deleted file mode 100644
index 2476db9da4..0000000000
--- a/api/core/tools/provider/builtin/devdocs/tools/searchDevDocs.yaml
+++ /dev/null
@@ -1,34 +0,0 @@
-identity:
- name: searchDevDocs
- author: Richards Tu
- label:
- en_US: Search Developer Docs
- zh_Hans: 搜索开发者文档
-description:
- human:
- en_US: A tools for searching for a specific topic and path in DevDocs based on the provided documentation name and topic. Don't for get to add some shots in the system prompt; for example, the documentation name should be like \"vuex~4\", \"css\", or \"python~3.12\", while the topic should be like \"guide/actions\" for Vuex 4, \"display-box\" for CSS, or \"library/code\" for Python 3.12.
- zh_Hans: 一个用于根据提供的文档名称和主题,在DevDocs中搜索特定主题和路径的工具。不要忘记在系统提示词中添加一些示例;例如,文档名称应该是\"vuex~4\"、\"css\"或\"python~3.12\",而主题应该是\"guide/actions\"用于Vuex 4,\"display-box\"用于CSS,或\"library/code\"用于Python 3.12。
- llm: A tools for searching for specific developer documentation in DevDocs based on the provided documentation name and topic.
-parameters:
- - name: doc
- type: string
- required: true
- label:
- en_US: Documentation name
- zh_Hans: 文档名称
- human_description:
- en_US: The name of the documentation.
- zh_Hans: 文档名称。
- llm_description: The name of the documentation, such as \"vuex~4\", \"css\", or \"python~3.12\". The exact value should be identified by the user.
- form: llm
- - name: topic
- type: string
- required: true
- label:
- en_US: Topic name
- zh_Hans: 主题名称
- human_description:
- en_US: The path of the section/topic.
- zh_Hans: 文档主题的路径。
- llm_description: The path of the section/topic, such as \"guide/actions\" for Vuex 4, \"display-box\" for CSS, or \"library/code\" for Python 3.12.
- form: llm
diff --git a/api/core/tools/provider/builtin/did/_assets/icon.svg b/api/core/tools/provider/builtin/did/_assets/icon.svg
deleted file mode 100644
index c477d7cb71..0000000000
--- a/api/core/tools/provider/builtin/did/_assets/icon.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/did/did.py b/api/core/tools/provider/builtin/did/did.py
deleted file mode 100644
index 5af78794f6..0000000000
--- a/api/core/tools/provider/builtin/did/did.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.did.tools.talks import TalksTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class DIDProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- # Example validation using the D-ID talks tool
- TalksTool().fork_tool_runtime(runtime={"credentials": credentials}).invoke(
- user_id="",
- tool_parameters={
- "source_url": "https://www.d-id.com/wp-content/uploads/2023/11/Hero-image-1.png",
- "text_input": "Hello, welcome to use D-ID tool in Dify",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/did/did.yaml b/api/core/tools/provider/builtin/did/did.yaml
deleted file mode 100644
index a70b71812e..0000000000
--- a/api/core/tools/provider/builtin/did/did.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-identity:
- author: Matri Qi
- name: did
- label:
- en_US: D-ID
- description:
- en_US: D-ID is a tool enabling the creation of high-quality, custom videos of Digital Humans from a single image.
- icon: icon.svg
- tags:
- - videos
-credentials_for_provider:
- did_api_key:
- type: secret-input
- required: true
- label:
- en_US: D-ID API Key
- placeholder:
- en_US: Please input your D-ID API key
- help:
- en_US: Get your D-ID API key from your D-ID account settings.
- url: https://studio.d-id.com/account-settings
- base_url:
- type: text-input
- required: false
- label:
- en_US: D-ID server's Base URL
- placeholder:
- en_US: https://api.d-id.com
diff --git a/api/core/tools/provider/builtin/did/did_appx.py b/api/core/tools/provider/builtin/did/did_appx.py
deleted file mode 100644
index c68878630d..0000000000
--- a/api/core/tools/provider/builtin/did/did_appx.py
+++ /dev/null
@@ -1,87 +0,0 @@
-import logging
-import time
-from collections.abc import Mapping
-from typing import Any
-
-import requests
-from requests.exceptions import HTTPError
-
-logger = logging.getLogger(__name__)
-
-
-class DIDApp:
- def __init__(self, api_key: str | None = None, base_url: str | None = None):
- self.api_key = api_key
- self.base_url = base_url or "https://api.d-id.com"
- if not self.api_key:
- raise ValueError("API key is required")
-
- def _prepare_headers(self, idempotency_key: str | None = None):
- headers = {"Content-Type": "application/json", "Authorization": f"Basic {self.api_key}"}
- if idempotency_key:
- headers["Idempotency-Key"] = idempotency_key
- return headers
-
- def _request(
- self,
- method: str,
- url: str,
- data: Mapping[str, Any] | None = None,
- headers: Mapping[str, str] | None = None,
- retries: int = 3,
- backoff_factor: float = 0.3,
- ) -> Mapping[str, Any] | None:
- for i in range(retries):
- try:
- response = requests.request(method, url, json=data, headers=headers)
- response.raise_for_status()
- return response.json()
- except requests.exceptions.RequestException as e:
- if i < retries - 1 and isinstance(e, HTTPError) and e.response.status_code >= 500:
- time.sleep(backoff_factor * (2**i))
- else:
- raise
- return None
-
- def talks(self, wait: bool = True, poll_interval: int = 5, idempotency_key: str | None = None, **kwargs):
- endpoint = f"{self.base_url}/talks"
- headers = self._prepare_headers(idempotency_key)
- data = kwargs["params"]
- logger.debug(f"Send request to {endpoint=} body={data}")
- response = self._request("POST", endpoint, data, headers)
- if response is None:
- raise HTTPError("Failed to initiate D-ID talks after multiple retries")
- id: str = response["id"]
- if wait:
- return self._monitor_job_status(id=id, target="talks", poll_interval=poll_interval)
- return id
-
- def animations(self, wait: bool = True, poll_interval: int = 5, idempotency_key: str | None = None, **kwargs):
- endpoint = f"{self.base_url}/animations"
- headers = self._prepare_headers(idempotency_key)
- data = kwargs["params"]
- logger.debug(f"Send request to {endpoint=} body={data}")
- response = self._request("POST", endpoint, data, headers)
- if response is None:
- raise HTTPError("Failed to initiate D-ID talks after multiple retries")
- id: str = response["id"]
- if wait:
- return self._monitor_job_status(target="animations", id=id, poll_interval=poll_interval)
- return id
-
- def check_did_status(self, target: str, id: str):
- endpoint = f"{self.base_url}/{target}/{id}"
- headers = self._prepare_headers()
- response = self._request("GET", endpoint, headers=headers)
- if response is None:
- raise HTTPError(f"Failed to check status for talks {id} after multiple retries")
- return response
-
- def _monitor_job_status(self, target: str, id: str, poll_interval: int):
- while True:
- status = self.check_did_status(target=target, id=id)
- if status["status"] == "done":
- return status
- elif status["status"] == "error" or status["status"] == "rejected":
- raise HTTPError(f'Talks {id} failed: {status["status"]} {status.get("error", {}).get("description")}')
- time.sleep(poll_interval)
diff --git a/api/core/tools/provider/builtin/did/tools/animations.py b/api/core/tools/provider/builtin/did/tools/animations.py
deleted file mode 100644
index bc9d17e40d..0000000000
--- a/api/core/tools/provider/builtin/did/tools/animations.py
+++ /dev/null
@@ -1,49 +0,0 @@
-import json
-from typing import Any, Union
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.provider.builtin.did.did_appx import DIDApp
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class AnimationsTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- app = DIDApp(api_key=self.runtime.credentials["did_api_key"], base_url=self.runtime.credentials["base_url"])
-
- driver_expressions_str = tool_parameters.get("driver_expressions")
- driver_expressions = json.loads(driver_expressions_str) if driver_expressions_str else None
-
- config = {
- "stitch": tool_parameters.get("stitch", True),
- "mute": tool_parameters.get("mute"),
- "result_format": tool_parameters.get("result_format") or "mp4",
- }
- config = {k: v for k, v in config.items() if v is not None and v != ""}
-
- options = {
- "source_url": tool_parameters["source_url"],
- "driver_url": tool_parameters.get("driver_url"),
- "config": config,
- }
- options = {k: v for k, v in options.items() if v is not None and v != ""}
-
- if not options.get("source_url"):
- raise ValueError("Source URL is required")
-
- if config.get("logo_url"):
- if not config.get("logo_x"):
- raise ValueError("Logo X position is required when logo URL is provided")
- if not config.get("logo_y"):
- raise ValueError("Logo Y position is required when logo URL is provided")
-
- animations_result = app.animations(params=options, wait=True)
-
- if not isinstance(animations_result, str):
- animations_result = json.dumps(animations_result, ensure_ascii=False, indent=4)
-
- if not animations_result:
- return self.create_text_message("D-ID animations request failed.")
-
- return self.create_text_message(animations_result)
diff --git a/api/core/tools/provider/builtin/did/tools/animations.yaml b/api/core/tools/provider/builtin/did/tools/animations.yaml
deleted file mode 100644
index 2a2036c7b2..0000000000
--- a/api/core/tools/provider/builtin/did/tools/animations.yaml
+++ /dev/null
@@ -1,86 +0,0 @@
-identity:
- name: animations
- author: Matri Qi
- label:
- en_US: Animations
-description:
- human:
- en_US: Animations enables to create videos matching head movements, expressions, emotions, and voice from a driver video and image.
- llm: Animations enables to create videos matching head movements, expressions, emotions, and voice from a driver video and image.
-parameters:
- - name: source_url
- type: string
- required: true
- label:
- en_US: source url
- human_description:
- en_US: The URL of the source image to be animated by the driver video, or a selection from the list of provided studio actors.
- llm_description: The URL of the source image to be animated by the driver video, or a selection from the list of provided studio actors.
- form: llm
- - name: driver_url
- type: string
- required: false
- label:
- en_US: driver url
- human_description:
- en_US: The URL of the driver video to drive the animation, or a provided driver name from D-ID.
- form: form
- - name: mute
- type: boolean
- required: false
- label:
- en_US: mute
- human_description:
- en_US: Mutes the driver sound in the animated video result, defaults to true
- form: form
- - name: stitch
- type: boolean
- required: false
- label:
- en_US: stitch
- human_description:
- en_US: If enabled, the driver video will be stitched with the animationing head video.
- form: form
- - name: logo_url
- type: string
- required: false
- label:
- en_US: logo url
- human_description:
- en_US: The URL of the logo image to be added to the animation video.
- form: form
- - name: logo_x
- type: number
- required: false
- label:
- en_US: logo position x
- human_description:
- en_US: The x position of the logo image in the animation video. It's required when logo url is provided.
- form: form
- - name: logo_y
- type: number
- required: false
- label:
- en_US: logo position y
- human_description:
- en_US: The y position of the logo image in the animation video. It's required when logo url is provided.
- form: form
- - name: result_format
- type: string
- default: mp4
- required: false
- label:
- en_US: result format
- human_description:
- en_US: The format of the result video.
- form: form
- options:
- - value: mp4
- label:
- en_US: mp4
- - value: gif
- label:
- en_US: gif
- - value: mov
- label:
- en_US: mov
diff --git a/api/core/tools/provider/builtin/did/tools/talks.py b/api/core/tools/provider/builtin/did/tools/talks.py
deleted file mode 100644
index d6f0c7ff17..0000000000
--- a/api/core/tools/provider/builtin/did/tools/talks.py
+++ /dev/null
@@ -1,65 +0,0 @@
-import json
-from typing import Any, Union
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.provider.builtin.did.did_appx import DIDApp
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class TalksTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- app = DIDApp(api_key=self.runtime.credentials["did_api_key"], base_url=self.runtime.credentials["base_url"])
-
- driver_expressions_str = tool_parameters.get("driver_expressions")
- driver_expressions = json.loads(driver_expressions_str) if driver_expressions_str else None
-
- script = {
- "type": tool_parameters.get("script_type") or "text",
- "input": tool_parameters.get("text_input"),
- "audio_url": tool_parameters.get("audio_url"),
- "reduce_noise": tool_parameters.get("audio_reduce_noise", False),
- }
- script = {k: v for k, v in script.items() if v is not None and v != ""}
- config = {
- "stitch": tool_parameters.get("stitch", True),
- "sharpen": tool_parameters.get("sharpen"),
- "fluent": tool_parameters.get("fluent"),
- "result_format": tool_parameters.get("result_format") or "mp4",
- "pad_audio": tool_parameters.get("pad_audio"),
- "driver_expressions": driver_expressions,
- }
- config = {k: v for k, v in config.items() if v is not None and v != ""}
-
- options = {
- "source_url": tool_parameters["source_url"],
- "driver_url": tool_parameters.get("driver_url"),
- "script": script,
- "config": config,
- }
- options = {k: v for k, v in options.items() if v is not None and v != ""}
-
- if not options.get("source_url"):
- raise ValueError("Source URL is required")
-
- if script.get("type") == "audio":
- script.pop("input", None)
- if not script.get("audio_url"):
- raise ValueError("Audio URL is required for audio script type")
-
- if script.get("type") == "text":
- script.pop("audio_url", None)
- script.pop("reduce_noise", None)
- if not script.get("input"):
- raise ValueError("Text input is required for text script type")
-
- talks_result = app.talks(params=options, wait=True)
-
- if not isinstance(talks_result, str):
- talks_result = json.dumps(talks_result, ensure_ascii=False, indent=4)
-
- if not talks_result:
- return self.create_text_message("D-ID talks request failed.")
-
- return self.create_text_message(talks_result)
diff --git a/api/core/tools/provider/builtin/did/tools/talks.yaml b/api/core/tools/provider/builtin/did/tools/talks.yaml
deleted file mode 100644
index 88d4305129..0000000000
--- a/api/core/tools/provider/builtin/did/tools/talks.yaml
+++ /dev/null
@@ -1,126 +0,0 @@
-identity:
- name: talks
- author: Matri Qi
- label:
- en_US: Talks
-description:
- human:
- en_US: Talks enables the creation of realistic talking head videos from text or audio inputs.
- llm: Talks enables the creation of realistic talking head videos from text or audio inputs.
-parameters:
- - name: source_url
- type: string
- required: true
- label:
- en_US: source url
- human_description:
- en_US: The URL of the source image to be animated by the driver video, or a selection from the list of provided studio actors.
- llm_description: The URL of the source image to be animated by the driver video, or a selection from the list of provided studio actors.
- form: llm
- - name: driver_url
- type: string
- required: false
- label:
- en_US: driver url
- human_description:
- en_US: The URL of the driver video to drive the talk, or a provided driver name from D-ID.
- form: form
- - name: script_type
- type: string
- required: false
- label:
- en_US: script type
- human_description:
- en_US: The type of the script.
- form: form
- options:
- - value: text
- label:
- en_US: text
- - value: audio
- label:
- en_US: audio
- - name: text_input
- type: string
- required: false
- label:
- en_US: text input
- human_description:
- en_US: The text input to be spoken by the talking head. Required when script type is text.
- form: form
- - name: audio_url
- type: string
- required: false
- label:
- en_US: audio url
- human_description:
- en_US: The URL of the audio file to be spoken by the talking head. Required when script type is audio.
- form: form
- - name: audio_reduce_noise
- type: boolean
- required: false
- label:
- en_US: audio reduce noise
- human_description:
- en_US: If enabled, the audio will be processed to reduce noise before being spoken by the talking head. It only works when script type is audio.
- form: form
- - name: stitch
- type: boolean
- required: false
- label:
- en_US: stitch
- human_description:
- en_US: If enabled, the driver video will be stitched with the talking head video.
- form: form
- - name: sharpen
- type: boolean
- required: false
- label:
- en_US: sharpen
- human_description:
- en_US: If enabled, the talking head video will be sharpened.
- form: form
- - name: result_format
- type: string
- required: false
- label:
- en_US: result format
- human_description:
- en_US: The format of the result video.
- form: form
- options:
- - value: mp4
- label:
- en_US: mp4
- - value: gif
- label:
- en_US: gif
- - value: mov
- label:
- en_US: mov
- - name: fluent
- type: boolean
- required: false
- label:
- en_US: fluent
- human_description:
- en_US: Interpolate between the last & first frames of the driver video When used together with pad_audio can create a seamless transition between videos of the same driver
- form: form
- - name: pad_audio
- type: number
- required: false
- label:
- en_US: pad audio
- human_description:
- en_US: Pad the audio with silence at the end (given in seconds) Will increase the video duration & the credits it consumes
- form: form
- min: 1
- max: 60
- - name: driver_expressions
- type: string
- required: false
- label:
- en_US: driver expressions
- human_description:
- en_US: timed expressions for animation. It should be an JSON array style string. Take D-ID documentation(https://docs.d-id.com/reference/createtalk) for more information.
- form: form
diff --git a/api/core/tools/provider/builtin/dingtalk/_assets/icon.svg b/api/core/tools/provider/builtin/dingtalk/_assets/icon.svg
deleted file mode 100644
index b60653b7a5..0000000000
--- a/api/core/tools/provider/builtin/dingtalk/_assets/icon.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/dingtalk/dingtalk.py b/api/core/tools/provider/builtin/dingtalk/dingtalk.py
deleted file mode 100644
index be1d5e099c..0000000000
--- a/api/core/tools/provider/builtin/dingtalk/dingtalk.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from core.tools.provider.builtin.dingtalk.tools.dingtalk_group_bot import DingTalkGroupBotTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class DingTalkProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- DingTalkGroupBotTool()
- pass
diff --git a/api/core/tools/provider/builtin/dingtalk/dingtalk.yaml b/api/core/tools/provider/builtin/dingtalk/dingtalk.yaml
deleted file mode 100644
index c922c140a8..0000000000
--- a/api/core/tools/provider/builtin/dingtalk/dingtalk.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-identity:
- author: Bowen Liang
- name: dingtalk
- label:
- en_US: DingTalk
- zh_Hans: 钉钉
- pt_BR: DingTalk
- description:
- en_US: DingTalk group robot
- zh_Hans: 钉钉群机器人
- pt_BR: DingTalk group robot
- icon: icon.svg
- tags:
- - social
- - productivity
-credentials_for_provider:
diff --git a/api/core/tools/provider/builtin/dingtalk/tools/dingtalk_group_bot.py b/api/core/tools/provider/builtin/dingtalk/tools/dingtalk_group_bot.py
deleted file mode 100644
index f33ad5be59..0000000000
--- a/api/core/tools/provider/builtin/dingtalk/tools/dingtalk_group_bot.py
+++ /dev/null
@@ -1,89 +0,0 @@
-import base64
-import hashlib
-import hmac
-import logging
-import time
-import urllib.parse
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class DingTalkGroupBotTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- Dingtalk custom group robot API docs:
- https://open.dingtalk.com/document/orgapp/custom-robot-access
- """
- content = tool_parameters.get("content")
- if not content:
- return self.create_text_message("Invalid parameter content")
-
- access_token = tool_parameters.get("access_token")
- if not access_token:
- return self.create_text_message(
- "Invalid parameter access_token. "
- "Regarding information about security details,"
- "please refer to the DingTalk docs:"
- "https://open.dingtalk.com/document/robots/customize-robot-security-settings"
- )
-
- sign_secret = tool_parameters.get("sign_secret")
- if not sign_secret:
- return self.create_text_message(
- "Invalid parameter sign_secret. "
- "Regarding information about security details,"
- "please refer to the DingTalk docs:"
- "https://open.dingtalk.com/document/robots/customize-robot-security-settings"
- )
-
- msgtype = "text"
- api_url = "https://oapi.dingtalk.com/robot/send"
- headers = {
- "Content-Type": "application/json",
- }
- params = {
- "access_token": access_token,
- }
-
- self._apply_security_mechanism(params, sign_secret)
-
- payload = {
- "msgtype": msgtype,
- "text": {
- "content": content,
- },
- }
-
- try:
- res = httpx.post(api_url, headers=headers, params=params, json=payload)
- if res.is_success:
- return self.create_text_message("Text message sent successfully")
- else:
- return self.create_text_message(
- f"Failed to send the text message, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to send message to group chat bot. {}".format(e))
-
- @staticmethod
- def _apply_security_mechanism(params: dict[str, Any], sign_secret: str):
- try:
- timestamp = str(round(time.time() * 1000))
- secret_enc = sign_secret.encode("utf-8")
- string_to_sign = f"{timestamp}\n{sign_secret}"
- string_to_sign_enc = string_to_sign.encode("utf-8")
- hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
- sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
-
- params["timestamp"] = timestamp
- params["sign"] = sign
- except Exception:
- msg = "Failed to apply security mechanism to the request."
- logging.exception(msg)
diff --git a/api/core/tools/provider/builtin/dingtalk/tools/dingtalk_group_bot.yaml b/api/core/tools/provider/builtin/dingtalk/tools/dingtalk_group_bot.yaml
deleted file mode 100644
index dc8a90b719..0000000000
--- a/api/core/tools/provider/builtin/dingtalk/tools/dingtalk_group_bot.yaml
+++ /dev/null
@@ -1,52 +0,0 @@
-identity:
- name: dingtalk_group_bot
- author: Bowen Liang
- label:
- en_US: Send Group Message
- zh_Hans: 发送群消息
- pt_BR: Send Group Message
- icon: icon.svg
-description:
- human:
- en_US: Sending a group message on DingTalk via the webhook of group bot
- zh_Hans: 通过钉钉的群机器人webhook发送群消息
- pt_BR: Sending a group message on DingTalk via the webhook of group bot
- llm: A tool for sending messages to a chat group on DingTalk(钉钉) .
-parameters:
- - name: access_token
- type: secret-input
- required: true
- label:
- en_US: access token
- zh_Hans: access token
- pt_BR: access token
- human_description:
- en_US: access_token in the group robot webhook
- zh_Hans: 群自定义机器人webhook中access_token字段的值
- pt_BR: access_token in the group robot webhook
- form: form
- - name: sign_secret
- type: secret-input
- required: true
- label:
- en_US: secret key for signing
- zh_Hans: 加签秘钥
- pt_BR: secret key for signing
- human_description:
- en_US: secret key for signing
- zh_Hans: 加签秘钥
- pt_BR: secret key for signing
- form: form
- - name: content
- type: string
- required: true
- label:
- en_US: content
- zh_Hans: 消息内容
- pt_BR: content
- human_description:
- en_US: Content to sent to the group.
- zh_Hans: 群消息文本
- pt_BR: Content to sent to the group.
- llm_description: Content of the message
- form: llm
diff --git a/api/core/tools/provider/builtin/duckduckgo/_assets/icon.svg b/api/core/tools/provider/builtin/duckduckgo/_assets/icon.svg
deleted file mode 100644
index a816a6b49e..0000000000
--- a/api/core/tools/provider/builtin/duckduckgo/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/duckduckgo/duckduckgo.py b/api/core/tools/provider/builtin/duckduckgo/duckduckgo.py
deleted file mode 100644
index 8269167127..0000000000
--- a/api/core/tools/provider/builtin/duckduckgo/duckduckgo.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.duckduckgo.tools.ddgo_search import DuckDuckGoSearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class DuckDuckGoProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- DuckDuckGoSearchTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "query": "John Doe",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/duckduckgo/duckduckgo.yaml b/api/core/tools/provider/builtin/duckduckgo/duckduckgo.yaml
deleted file mode 100644
index f3faa06045..0000000000
--- a/api/core/tools/provider/builtin/duckduckgo/duckduckgo.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-identity:
- author: Yash Parmar
- name: duckduckgo
- label:
- en_US: DuckDuckGo
- zh_Hans: DuckDuckGo
- description:
- en_US: A privacy-focused search engine.
- zh_Hans: 一个注重隐私的搜索引擎。
- icon: icon.svg
- tags:
- - search
diff --git a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_ai.py b/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_ai.py
deleted file mode 100644
index 8bdd638f4a..0000000000
--- a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_ai.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from typing import Any
-
-from duckduckgo_search import DDGS
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class DuckDuckGoAITool(BuiltinTool):
- """
- Tool for performing a search using DuckDuckGo search engine.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage:
- query_dict = {
- "keywords": tool_parameters.get("query"),
- "model": tool_parameters.get("model"),
- }
- response = DDGS().chat(**query_dict)
- return self.create_text_message(text=response)
diff --git a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_ai.yaml b/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_ai.yaml
deleted file mode 100644
index 21cbae6bd3..0000000000
--- a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_ai.yaml
+++ /dev/null
@@ -1,47 +0,0 @@
-identity:
- name: ddgo_ai
- author: hjlarry
- label:
- en_US: DuckDuckGo AI Chat
- zh_Hans: DuckDuckGo AI聊天
-description:
- human:
- en_US: Use the anonymous private chat provided by DuckDuckGo.
- zh_Hans: 使用DuckDuckGo提供的匿名私密聊天。
- llm: Use the anonymous private chat provided by DuckDuckGo.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Chat Content
- zh_Hans: 聊天内容
- human_description:
- en_US: The chat content.
- zh_Hans: 要聊天的内容。
- llm_description: Key words for chat
- form: llm
- - name: model
- type: select
- required: true
- options:
- - value: gpt-4o-mini
- label:
- en_US: GPT-4o-mini
- - value: claude-3-haiku
- label:
- en_US: Claude 3
- - value: llama-3-70b
- label:
- en_US: Llama 3
- - value: mixtral-8x7b
- label:
- en_US: Mixtral
- default: gpt-3.5
- label:
- en_US: Choose Model
- zh_Hans: 选择模型
- human_description:
- en_US: used to select the model for AI chat.
- zh_Hans: 用于选择使用AI聊天的模型
- form: form
diff --git a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_img.py b/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_img.py
deleted file mode 100644
index 396570248a..0000000000
--- a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_img.py
+++ /dev/null
@@ -1,30 +0,0 @@
-from typing import Any
-
-from duckduckgo_search import DDGS
-
-from core.file.file_obj import FileTransferMethod
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class DuckDuckGoImageSearchTool(BuiltinTool):
- """
- Tool for performing an image search using DuckDuckGo search engine.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> list[ToolInvokeMessage]:
- query_dict = {
- "keywords": tool_parameters.get("query"),
- "timelimit": tool_parameters.get("timelimit"),
- "size": tool_parameters.get("size"),
- "max_results": tool_parameters.get("max_results"),
- }
- response = DDGS().images(**query_dict)
- result = []
- for res in response:
- res["transfer_method"] = FileTransferMethod.REMOTE_URL
- msg = ToolInvokeMessage(
- type=ToolInvokeMessage.MessageType.IMAGE_LINK, message=res.get("image"), save_as="", meta=res
- )
- result.append(msg)
- return result
diff --git a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_img.yaml b/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_img.yaml
deleted file mode 100644
index 168cface22..0000000000
--- a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_img.yaml
+++ /dev/null
@@ -1,88 +0,0 @@
-identity:
- name: ddgo_img
- author: hjlarry
- label:
- en_US: DuckDuckGo Image Search
- zh_Hans: DuckDuckGo 图片搜索
-description:
- human:
- en_US: Perform image searches on DuckDuckGo and get results.
- zh_Hans: 在 DuckDuckGo 上进行图片搜索并获取结果。
- llm: Perform image searches on DuckDuckGo and get results.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query string
- zh_Hans: 查询语句
- human_description:
- en_US: The search query.
- zh_Hans: 搜索查询语句。
- llm_description: Key words for searching
- form: llm
- - name: max_results
- type: number
- required: true
- default: 3
- label:
- en_US: Max results
- zh_Hans: 最大结果数量
- human_description:
- en_US: The max results.
- zh_Hans: 最大结果数量
- form: form
- - name: timelimit
- type: select
- required: false
- options:
- - value: Day
- label:
- en_US: current day
- zh_Hans: 当天
- - value: Week
- label:
- en_US: current week
- zh_Hans: 本周
- - value: Month
- label:
- en_US: current month
- zh_Hans: 当月
- - value: Year
- label:
- en_US: current year
- zh_Hans: 今年
- label:
- en_US: Result time limit
- zh_Hans: 结果时间限制
- human_description:
- en_US: Use when querying results within a specific time range only.
- zh_Hans: 只查询一定时间范围内的结果时使用
- form: form
- - name: size
- type: select
- required: false
- options:
- - value: Small
- label:
- en_US: small
- zh_Hans: 小
- - value: Medium
- label:
- en_US: medium
- zh_Hans: 中
- - value: Large
- label:
- en_US: large
- zh_Hans: 大
- - value: Wallpaper
- label:
- en_US: xl
- zh_Hans: 超大
- label:
- en_US: image size
- zh_Hans: 图片大小
- human_description:
- en_US: The size of the image to be searched.
- zh_Hans: 要搜索的图片的大小
- form: form
diff --git a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_search.py b/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_search.py
deleted file mode 100644
index cbd65d2e77..0000000000
--- a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_search.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from typing import Any
-
-from duckduckgo_search import DDGS
-
-from core.model_runtime.entities.message_entities import SystemPromptMessage
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-SUMMARY_PROMPT = """
-User's query:
-{query}
-
-Here is the search engine result:
-{content}
-
-Please summarize the result in a few sentences.
-"""
-
-
-class DuckDuckGoSearchTool(BuiltinTool):
- """
- Tool for performing a search using DuckDuckGo search engine.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage | list[ToolInvokeMessage]:
- query = tool_parameters.get("query")
- max_results = tool_parameters.get("max_results", 5)
- require_summary = tool_parameters.get("require_summary", False)
- response = DDGS().text(query, max_results=max_results)
- if require_summary:
- results = "\n".join([res.get("body") for res in response])
- results = self.summary_results(user_id=user_id, content=results, query=query)
- return self.create_text_message(text=results)
- return [self.create_json_message(res) for res in response]
-
- def summary_results(self, user_id: str, content: str, query: str) -> str:
- prompt = SUMMARY_PROMPT.format(query=query, content=content)
- summary = self.invoke_model(
- user_id=user_id,
- prompt_messages=[
- SystemPromptMessage(content=prompt),
- ],
- stop=[],
- )
- return summary.message.content
diff --git a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_search.yaml b/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_search.yaml
deleted file mode 100644
index 333c0cb093..0000000000
--- a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_search.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
-identity:
- name: ddgo_search
- author: Yash Parmar
- label:
- en_US: DuckDuckGo Search
- zh_Hans: DuckDuckGo 搜索
-description:
- human:
- en_US: Perform searches on DuckDuckGo and get results.
- zh_Hans: 在 DuckDuckGo 上进行搜索并获取结果。
- llm: Perform searches on DuckDuckGo and get results.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query string
- zh_Hans: 查询语句
- human_description:
- en_US: The search query.
- zh_Hans: 搜索查询语句。
- llm_description: Key words for searching
- form: llm
- - name: max_results
- type: number
- required: true
- default: 5
- label:
- en_US: Max results
- zh_Hans: 最大结果数量
- form: form
- - name: require_summary
- type: boolean
- default: false
- label:
- en_US: Require Summary
- zh_Hans: 是否总结
- human_description:
- en_US: Whether to pass the search results to llm for summarization.
- zh_Hans: 是否需要将搜索结果传给大模型总结
- form: form
diff --git a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_translate.py b/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_translate.py
deleted file mode 100644
index 396ce21b18..0000000000
--- a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_translate.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from typing import Any
-
-from duckduckgo_search import DDGS
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class DuckDuckGoTranslateTool(BuiltinTool):
- """
- Tool for performing a search using DuckDuckGo search engine.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage:
- query_dict = {
- "keywords": tool_parameters.get("query"),
- "to": tool_parameters.get("translate_to"),
- }
- response = DDGS().translate(**query_dict)[0].get("translated", "Unable to translate!")
- return self.create_text_message(text=response)
diff --git a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_translate.yaml b/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_translate.yaml
deleted file mode 100644
index 78b5d0b022..0000000000
--- a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_translate.yaml
+++ /dev/null
@@ -1,51 +0,0 @@
-identity:
- name: ddgo_translate
- author: hjlarry
- label:
- en_US: DuckDuckGo Translate
- zh_Hans: DuckDuckGo 翻译
-description:
- human:
- en_US: Use DuckDuckGo's translation feature.
- zh_Hans: 使用DuckDuckGo的翻译功能。
- llm: Use DuckDuckGo's translation feature.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Translate Content
- zh_Hans: 翻译内容
- human_description:
- en_US: The translate content.
- zh_Hans: 要翻译的内容。
- llm_description: Key words for translate
- form: llm
- - name: translate_to
- type: select
- required: true
- options:
- - value: en
- label:
- en_US: English
- zh_Hans: 英语
- - value: zh-Hans
- label:
- en_US: Simplified Chinese
- zh_Hans: 简体中文
- - value: zh-Hant
- label:
- en_US: Traditional Chinese
- zh_Hans: 繁体中文
- - value: ja
- label:
- en_US: Japanese
- zh_Hans: 日语
- default: en
- label:
- en_US: Choose Language
- zh_Hans: 选择语言
- human_description:
- en_US: select the language to translate.
- zh_Hans: 选择要翻译的语言
- form: form
diff --git a/api/core/tools/provider/builtin/feishu/_assets/icon.svg b/api/core/tools/provider/builtin/feishu/_assets/icon.svg
deleted file mode 100644
index bf3c202abf..0000000000
--- a/api/core/tools/provider/builtin/feishu/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/api/core/tools/provider/builtin/feishu/feishu.py b/api/core/tools/provider/builtin/feishu/feishu.py
deleted file mode 100644
index 72a9333619..0000000000
--- a/api/core/tools/provider/builtin/feishu/feishu.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from core.tools.provider.builtin.feishu.tools.feishu_group_bot import FeishuGroupBotTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class FeishuProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- FeishuGroupBotTool()
diff --git a/api/core/tools/provider/builtin/feishu/feishu.yaml b/api/core/tools/provider/builtin/feishu/feishu.yaml
deleted file mode 100644
index a029c7edb8..0000000000
--- a/api/core/tools/provider/builtin/feishu/feishu.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-identity:
- author: Arkii Sun
- name: feishu
- label:
- en_US: Feishu
- zh_Hans: 飞书
- pt_BR: Feishu
- description:
- en_US: Feishu group bot
- zh_Hans: 飞书群机器人
- pt_BR: Feishu group bot
- icon: icon.svg
- tags:
- - social
- - productivity
-credentials_for_provider:
diff --git a/api/core/tools/provider/builtin/feishu/tools/feishu_group_bot.py b/api/core/tools/provider/builtin/feishu/tools/feishu_group_bot.py
deleted file mode 100644
index e82da8ca53..0000000000
--- a/api/core/tools/provider/builtin/feishu/tools/feishu_group_bot.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-from core.tools.utils.uuid_utils import is_valid_uuid
-
-
-class FeishuGroupBotTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- API document: https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot
- """
-
- url = "https://open.feishu.cn/open-apis/bot/v2/hook"
-
- content = tool_parameters.get("content", "")
- if not content:
- return self.create_text_message("Invalid parameter content")
-
- hook_key = tool_parameters.get("hook_key", "")
- if not is_valid_uuid(hook_key):
- return self.create_text_message(f"Invalid parameter hook_key ${hook_key}, not a valid UUID")
-
- msg_type = "text"
- api_url = f"{url}/{hook_key}"
- headers = {
- "Content-Type": "application/json",
- }
- params = {}
- payload = {
- "msg_type": msg_type,
- "content": {
- "text": content,
- },
- }
-
- try:
- res = httpx.post(api_url, headers=headers, params=params, json=payload)
- if res.is_success:
- return self.create_text_message("Text message sent successfully")
- else:
- return self.create_text_message(
- f"Failed to send the text message, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to send message to group chat bot. {}".format(e))
diff --git a/api/core/tools/provider/builtin/feishu/tools/feishu_group_bot.yaml b/api/core/tools/provider/builtin/feishu/tools/feishu_group_bot.yaml
deleted file mode 100644
index 6c3f084e4d..0000000000
--- a/api/core/tools/provider/builtin/feishu/tools/feishu_group_bot.yaml
+++ /dev/null
@@ -1,40 +0,0 @@
-identity:
- name: feishu_group_bot
- author: Arkii Sun
- label:
- en_US: Send Group Message
- zh_Hans: 发送群消息
- pt_BR: Send Group Message
- icon: icon.png
-description:
- human:
- en_US: Sending a group message on Feishu via the webhook of group bot
- zh_Hans: 通过飞书的群机器人webhook发送群消息
- pt_BR: Sending a group message on Feishu via the webhook of group bot
- llm: A tool for sending messages to a chat group on Feishu(飞书) .
-parameters:
- - name: hook_key
- type: secret-input
- required: true
- label:
- en_US: Feishu Group bot webhook key
- zh_Hans: 群机器人webhook的key
- pt_BR: Feishu Group bot webhook key
- human_description:
- en_US: Feishu Group bot webhook key
- zh_Hans: 群机器人webhook的key
- pt_BR: Feishu Group bot webhook key
- form: form
- - name: content
- type: string
- required: true
- label:
- en_US: content
- zh_Hans: 消息内容
- pt_BR: content
- human_description:
- en_US: Content to sent to the group.
- zh_Hans: 群消息文本
- pt_BR: Content to sent to the group.
- llm_description: Content of the message
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_base/_assets/icon.svg b/api/core/tools/provider/builtin/feishu_base/_assets/icon.svg
deleted file mode 100644
index 2663a0f59e..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/_assets/icon.svg
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
diff --git a/api/core/tools/provider/builtin/feishu_base/feishu_base.py b/api/core/tools/provider/builtin/feishu_base/feishu_base.py
deleted file mode 100644
index 04056af53b..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/feishu_base.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from core.tools.provider.builtin.feishu_base.tools.get_tenant_access_token import GetTenantAccessTokenTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class FeishuBaseProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- GetTenantAccessTokenTool()
- pass
diff --git a/api/core/tools/provider/builtin/feishu_base/feishu_base.yaml b/api/core/tools/provider/builtin/feishu_base/feishu_base.yaml
deleted file mode 100644
index f3dcbb6136..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/feishu_base.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-identity:
- author: Doug Lea
- name: feishu_base
- label:
- en_US: Feishu Base
- zh_Hans: 飞书多维表格
- description:
- en_US: Feishu Base
- zh_Hans: 飞书多维表格
- icon: icon.svg
- tags:
- - social
- - productivity
-credentials_for_provider:
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/add_base_record.py b/api/core/tools/provider/builtin/feishu_base/tools/add_base_record.py
deleted file mode 100644
index 4a605fbffe..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/add_base_record.py
+++ /dev/null
@@ -1,56 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class AddBaseRecordTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- url = "https://open.feishu.cn/open-apis/bitable/v1/apps/{app_token}/tables/{table_id}/records"
-
- access_token = tool_parameters.get("Authorization", "")
- if not access_token:
- return self.create_text_message("Invalid parameter access_token")
-
- app_token = tool_parameters.get("app_token", "")
- if not app_token:
- return self.create_text_message("Invalid parameter app_token")
-
- table_id = tool_parameters.get("table_id", "")
- if not table_id:
- return self.create_text_message("Invalid parameter table_id")
-
- fields = tool_parameters.get("fields", "")
- if not fields:
- return self.create_text_message("Invalid parameter fields")
-
- headers = {
- "Content-Type": "application/json",
- "Authorization": f"Bearer {access_token}",
- }
-
- params = {}
- payload = {"fields": json.loads(fields)}
-
- try:
- res = httpx.post(
- url.format(app_token=app_token, table_id=table_id),
- headers=headers,
- params=params,
- json=payload,
- timeout=30,
- )
- res_json = res.json()
- if res.is_success:
- return self.create_text_message(text=json.dumps(res_json))
- else:
- return self.create_text_message(
- f"Failed to add base record, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to add base record. {}".format(e))
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/add_base_record.yaml b/api/core/tools/provider/builtin/feishu_base/tools/add_base_record.yaml
deleted file mode 100644
index 3ce0154efd..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/add_base_record.yaml
+++ /dev/null
@@ -1,66 +0,0 @@
-identity:
- name: add_base_record
- author: Doug Lea
- label:
- en_US: Add Base Record
- zh_Hans: 在多维表格数据表中新增一条记录
-description:
- human:
- en_US: Add Base Record
- zh_Hans: |
- 在多维表格数据表中新增一条记录,详细请参考:https://open.larkoffice.com/document/server-docs/docs/bitable-v1/app-table-record/create
- llm: Add a new record in the multidimensional table data table.
-parameters:
- - name: Authorization
- type: string
- required: true
- label:
- en_US: token
- zh_Hans: 凭证
- human_description:
- en_US: API access token parameter, tenant_access_token or user_access_token
- zh_Hans: API 的访问凭证参数,tenant_access_token 或 user_access_token
- llm_description: API access token parameter, tenant_access_token or user_access_token
- form: llm
-
- - name: app_token
- type: string
- required: true
- label:
- en_US: app_token
- zh_Hans: 多维表格
- human_description:
- en_US: bitable app token
- zh_Hans: 多维表格的唯一标识符 app_token
- llm_description: bitable app token
- form: llm
-
- - name: table_id
- type: string
- required: true
- label:
- en_US: table_id
- zh_Hans: 多维表格的数据表
- human_description:
- en_US: bitable table id
- zh_Hans: 多维表格数据表的唯一标识符 table_id
- llm_description: bitable table id
- form: llm
-
- - name: fields
- type: string
- required: true
- label:
- en_US: fields
- zh_Hans: 数据表的列字段内容
- human_description:
- en_US: The fields of the Base data table are the columns of the data table.
- zh_Hans: |
- 要增加一行多维表格记录,字段结构拼接如下:{"多行文本":"多行文本内容","单选":"选项1","多选":["选项1","选项2"],"复选框":true,"人员":[{"id":"ou_2910013f1e6456f16a0ce75ede950a0a"}],"群组":[{"id":"oc_cd07f55f14d6f4a4f1b51504e7e97f48"}],"电话号码":"13026162666"}
- 当前接口支持的字段类型为:多行文本、单选、条码、多选、日期、人员、附件、复选框、超链接、数字、单向关联、双向关联、电话号码、地理位置。
- 不同类型字段的数据结构请参考数据结构概述:https://open.larkoffice.com/document/server-docs/docs/bitable-v1/bitable-structure
- llm_description: |
- 要增加一行多维表格记录,字段结构拼接如下:{"多行文本":"多行文本内容","单选":"选项1","多选":["选项1","选项2"],"复选框":true,"人员":[{"id":"ou_2910013f1e6456f16a0ce75ede950a0a"}],"群组":[{"id":"oc_cd07f55f14d6f4a4f1b51504e7e97f48"}],"电话号码":"13026162666"}
- 当前接口支持的字段类型为:多行文本、单选、条码、多选、日期、人员、附件、复选框、超链接、数字、单向关联、双向关联、电话号码、地理位置。
- 不同类型字段的数据结构请参考数据结构概述:https://open.larkoffice.com/document/server-docs/docs/bitable-v1/bitable-structure
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/create_base.py b/api/core/tools/provider/builtin/feishu_base/tools/create_base.py
deleted file mode 100644
index 6b755e2007..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/create_base.py
+++ /dev/null
@@ -1,41 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class CreateBaseTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- url = "https://open.feishu.cn/open-apis/bitable/v1/apps"
-
- access_token = tool_parameters.get("Authorization", "")
- if not access_token:
- return self.create_text_message("Invalid parameter access_token")
-
- name = tool_parameters.get("name", "")
- folder_token = tool_parameters.get("folder_token", "")
-
- headers = {
- "Content-Type": "application/json",
- "Authorization": f"Bearer {access_token}",
- }
-
- params = {}
- payload = {"name": name, "folder_token": folder_token}
-
- try:
- res = httpx.post(url, headers=headers, params=params, json=payload, timeout=30)
- res_json = res.json()
- if res.is_success:
- return self.create_text_message(text=json.dumps(res_json))
- else:
- return self.create_text_message(
- f"Failed to create base, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to create base. {}".format(e))
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/create_base.yaml b/api/core/tools/provider/builtin/feishu_base/tools/create_base.yaml
deleted file mode 100644
index 76c76a916d..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/create_base.yaml
+++ /dev/null
@@ -1,47 +0,0 @@
-identity:
- name: create_base
- author: Doug Lea
- label:
- en_US: Create Base
- zh_Hans: 创建多维表格
-description:
- human:
- en_US: Create base
- zh_Hans: 在指定目录下创建多维表格
- llm: A tool for create a multidimensional table in the specified directory.
-parameters:
- - name: Authorization
- type: string
- required: true
- label:
- en_US: token
- zh_Hans: 凭证
- human_description:
- en_US: API access token parameter, tenant_access_token or user_access_token
- zh_Hans: API 的访问凭证参数,tenant_access_token 或 user_access_token
- llm_description: API access token parameter, tenant_access_token or user_access_token
- form: llm
-
- - name: name
- type: string
- required: false
- label:
- en_US: name
- zh_Hans: name
- human_description:
- en_US: Base App Name
- zh_Hans: 多维表格App名字
- llm_description: Base App Name
- form: llm
-
- - name: folder_token
- type: string
- required: false
- label:
- en_US: folder_token
- zh_Hans: 多维表格App归属文件夹
- human_description:
- en_US: Base App home folder. The default is empty, indicating that Base will be created in the cloud space root directory.
- zh_Hans: 多维表格App归属文件夹。默认为空,表示多维表格将被创建在云空间根目录。
- llm_description: Base App home folder. The default is empty, indicating that Base will be created in the cloud space root directory.
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/create_base_table.py b/api/core/tools/provider/builtin/feishu_base/tools/create_base_table.py
deleted file mode 100644
index b05d700113..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/create_base_table.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class CreateBaseTableTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- url = "https://open.feishu.cn/open-apis/bitable/v1/apps/{app_token}/tables"
-
- access_token = tool_parameters.get("Authorization", "")
- if not access_token:
- return self.create_text_message("Invalid parameter access_token")
-
- app_token = tool_parameters.get("app_token", "")
- if not app_token:
- return self.create_text_message("Invalid parameter app_token")
-
- name = tool_parameters.get("name", "")
-
- fields = tool_parameters.get("fields", "")
- if not fields:
- return self.create_text_message("Invalid parameter fields")
-
- headers = {
- "Content-Type": "application/json",
- "Authorization": f"Bearer {access_token}",
- }
-
- params = {}
- payload = {"table": {"name": name, "fields": json.loads(fields)}}
-
- try:
- res = httpx.post(url.format(app_token=app_token), headers=headers, params=params, json=payload, timeout=30)
- res_json = res.json()
- if res.is_success:
- return self.create_text_message(text=json.dumps(res_json))
- else:
- return self.create_text_message(
- f"Failed to create base table, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to create base table. {}".format(e))
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/create_base_table.yaml b/api/core/tools/provider/builtin/feishu_base/tools/create_base_table.yaml
deleted file mode 100644
index 48c46bec14..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/create_base_table.yaml
+++ /dev/null
@@ -1,106 +0,0 @@
-identity:
- name: create_base_table
- author: Doug Lea
- label:
- en_US: Create Base Table
- zh_Hans: 多维表格新增一个数据表
-description:
- human:
- en_US: Create base table
- zh_Hans: |
- 多维表格新增一个数据表,详细请参考:https://open.larkoffice.com/document/server-docs/docs/bitable-v1/app-table/create
- llm: A tool for add a new data table to the multidimensional table.
-parameters:
- - name: Authorization
- type: string
- required: true
- label:
- en_US: token
- zh_Hans: 凭证
- human_description:
- en_US: API access token parameter, tenant_access_token or user_access_token
- zh_Hans: API 的访问凭证参数,tenant_access_token 或 user_access_token
- llm_description: API access token parameter, tenant_access_token or user_access_token
- form: llm
-
- - name: app_token
- type: string
- required: true
- label:
- en_US: app_token
- zh_Hans: 多维表格
- human_description:
- en_US: bitable app token
- zh_Hans: 多维表格的唯一标识符 app_token
- llm_description: bitable app token
- form: llm
-
- - name: name
- type: string
- required: false
- label:
- en_US: name
- zh_Hans: name
- human_description:
- en_US: Multidimensional table data table name
- zh_Hans: 多维表格数据表名称
- llm_description: Multidimensional table data table name
- form: llm
-
- - name: fields
- type: string
- required: true
- label:
- en_US: fields
- zh_Hans: fields
- human_description:
- en_US: Initial fields of the data table
- zh_Hans: |
- 数据表的初始字段,格式为:[{"field_name":"多行文本","type":1},{"field_name":"数字","type":2},{"field_name":"单选","type":3},{"field_name":"多选","type":4},{"field_name":"日期","type":5}]。
- field_name:字段名;
- type: 字段类型;可选值有
- 1:多行文本
- 2:数字
- 3:单选
- 4:多选
- 5:日期
- 7:复选框
- 11:人员
- 13:电话号码
- 15:超链接
- 17:附件
- 18:单向关联
- 20:公式
- 21:双向关联
- 22:地理位置
- 23:群组
- 1001:创建时间
- 1002:最后更新时间
- 1003:创建人
- 1004:修改人
- 1005:自动编号
- llm_description: |
- 数据表的初始字段,格式为:[{"field_name":"多行文本","type":1},{"field_name":"数字","type":2},{"field_name":"单选","type":3},{"field_name":"多选","type":4},{"field_name":"日期","type":5}]。
- field_name:字段名;
- type: 字段类型;可选值有
- 1:多行文本
- 2:数字
- 3:单选
- 4:多选
- 5:日期
- 7:复选框
- 11:人员
- 13:电话号码
- 15:超链接
- 17:附件
- 18:单向关联
- 20:公式
- 21:双向关联
- 22:地理位置
- 23:群组
- 1001:创建时间
- 1002:最后更新时间
- 1003:创建人
- 1004:修改人
- 1005:自动编号
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/delete_base_records.py b/api/core/tools/provider/builtin/feishu_base/tools/delete_base_records.py
deleted file mode 100644
index 862eb2171b..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/delete_base_records.py
+++ /dev/null
@@ -1,56 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class DeleteBaseRecordsTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- url = "https://open.feishu.cn/open-apis/bitable/v1/apps/{app_token}/tables/{table_id}/records/batch_delete"
-
- access_token = tool_parameters.get("Authorization", "")
- if not access_token:
- return self.create_text_message("Invalid parameter access_token")
-
- app_token = tool_parameters.get("app_token", "")
- if not app_token:
- return self.create_text_message("Invalid parameter app_token")
-
- table_id = tool_parameters.get("table_id", "")
- if not table_id:
- return self.create_text_message("Invalid parameter table_id")
-
- record_ids = tool_parameters.get("record_ids", "")
- if not record_ids:
- return self.create_text_message("Invalid parameter record_ids")
-
- headers = {
- "Content-Type": "application/json",
- "Authorization": f"Bearer {access_token}",
- }
-
- params = {}
- payload = {"records": json.loads(record_ids)}
-
- try:
- res = httpx.post(
- url.format(app_token=app_token, table_id=table_id),
- headers=headers,
- params=params,
- json=payload,
- timeout=30,
- )
- res_json = res.json()
- if res.is_success:
- return self.create_text_message(text=json.dumps(res_json))
- else:
- return self.create_text_message(
- f"Failed to delete base records, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to delete base records. {}".format(e))
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/delete_base_records.yaml b/api/core/tools/provider/builtin/feishu_base/tools/delete_base_records.yaml
deleted file mode 100644
index 595b287029..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/delete_base_records.yaml
+++ /dev/null
@@ -1,60 +0,0 @@
-identity:
- name: delete_base_records
- author: Doug Lea
- label:
- en_US: Delete Base Records
- zh_Hans: 在多维表格数据表中删除多条记录
-description:
- human:
- en_US: Delete base records
- zh_Hans: |
- 该接口用于删除多维表格数据表中的多条记录,单次调用中最多删除 500 条记录。
- llm: A tool for delete multiple records in a multidimensional table data table, up to 500 records can be deleted in a single call.
-parameters:
- - name: Authorization
- type: string
- required: true
- label:
- en_US: token
- zh_Hans: 凭证
- human_description:
- en_US: API access token parameter, tenant_access_token or user_access_token
- zh_Hans: API 的访问凭证参数,tenant_access_token 或 user_access_token
- llm_description: API access token parameter, tenant_access_token or user_access_token
- form: llm
-
- - name: app_token
- type: string
- required: true
- label:
- en_US: app_token
- zh_Hans: 多维表格
- human_description:
- en_US: bitable app token
- zh_Hans: 多维表格的唯一标识符 app_token
- llm_description: bitable app token
- form: llm
-
- - name: table_id
- type: string
- required: true
- label:
- en_US: table_id
- zh_Hans: 多维表格的数据表
- human_description:
- en_US: bitable table id
- zh_Hans: 多维表格数据表的唯一标识符 table_id
- llm_description: bitable table id
- form: llm
-
- - name: record_ids
- type: string
- required: true
- label:
- en_US: record_ids
- zh_Hans: record_ids
- human_description:
- en_US: A list of multiple record IDs to be deleted, for example ["recwNXzPQv","recpCsf4ME"]
- zh_Hans: 待删除的多条记录id列表,示例为 ["recwNXzPQv","recpCsf4ME"]
- llm_description: A list of multiple record IDs to be deleted, for example ["recwNXzPQv","recpCsf4ME"]
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/delete_base_tables.py b/api/core/tools/provider/builtin/feishu_base/tools/delete_base_tables.py
deleted file mode 100644
index f512186303..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/delete_base_tables.py
+++ /dev/null
@@ -1,46 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class DeleteBaseTablesTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- url = "https://open.feishu.cn/open-apis/bitable/v1/apps/{app_token}/tables/batch_delete"
-
- access_token = tool_parameters.get("Authorization", "")
- if not access_token:
- return self.create_text_message("Invalid parameter access_token")
-
- app_token = tool_parameters.get("app_token", "")
- if not app_token:
- return self.create_text_message("Invalid parameter app_token")
-
- table_ids = tool_parameters.get("table_ids", "")
- if not table_ids:
- return self.create_text_message("Invalid parameter table_ids")
-
- headers = {
- "Content-Type": "application/json",
- "Authorization": f"Bearer {access_token}",
- }
-
- params = {}
- payload = {"table_ids": json.loads(table_ids)}
-
- try:
- res = httpx.post(url.format(app_token=app_token), headers=headers, params=params, json=payload, timeout=30)
- res_json = res.json()
- if res.is_success:
- return self.create_text_message(text=json.dumps(res_json))
- else:
- return self.create_text_message(
- f"Failed to delete base tables, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to delete base tables. {}".format(e))
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/delete_base_tables.yaml b/api/core/tools/provider/builtin/feishu_base/tools/delete_base_tables.yaml
deleted file mode 100644
index 5d72814363..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/delete_base_tables.yaml
+++ /dev/null
@@ -1,48 +0,0 @@
-identity:
- name: delete_base_tables
- author: Doug Lea
- label:
- en_US: Delete Base Tables
- zh_Hans: 删除多维表格中的数据表
-description:
- human:
- en_US: Delete base tables
- zh_Hans: |
- 删除多维表格中的数据表
- llm: A tool for deleting a data table in a multidimensional table
-parameters:
- - name: Authorization
- type: string
- required: true
- label:
- en_US: token
- zh_Hans: 凭证
- human_description:
- en_US: API access token parameter, tenant_access_token or user_access_token
- zh_Hans: API 的访问凭证参数,tenant_access_token 或 user_access_token
- llm_description: API access token parameter, tenant_access_token or user_access_token
- form: llm
-
- - name: app_token
- type: string
- required: true
- label:
- en_US: app_token
- zh_Hans: 多维表格
- human_description:
- en_US: bitable app token
- zh_Hans: 多维表格的唯一标识符 app_token
- llm_description: bitable app token
- form: llm
-
- - name: table_ids
- type: string
- required: true
- label:
- en_US: table_ids
- zh_Hans: table_ids
- human_description:
- en_US: The ID list of the data tables to be deleted. Currently, a maximum of 50 data tables can be deleted at a time. The example is ["tbl1TkhyTWDkSoZ3","tblsRc9GRRXKqhvW"]
- zh_Hans: 待删除数据表的id列表,当前一次操作最多支持50个数据表,示例为 ["tbl1TkhyTWDkSoZ3","tblsRc9GRRXKqhvW"]
- llm_description: The ID list of the data tables to be deleted. Currently, a maximum of 50 data tables can be deleted at a time. The example is ["tbl1TkhyTWDkSoZ3","tblsRc9GRRXKqhvW"]
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/get_base_info.py b/api/core/tools/provider/builtin/feishu_base/tools/get_base_info.py
deleted file mode 100644
index f664bbeed0..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/get_base_info.py
+++ /dev/null
@@ -1,39 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GetBaseInfoTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- url = "https://open.feishu.cn/open-apis/bitable/v1/apps/{app_token}"
-
- access_token = tool_parameters.get("Authorization", "")
- if not access_token:
- return self.create_text_message("Invalid parameter access_token")
-
- app_token = tool_parameters.get("app_token", "")
- if not app_token:
- return self.create_text_message("Invalid parameter app_token")
-
- headers = {
- "Content-Type": "application/json",
- "Authorization": f"Bearer {access_token}",
- }
-
- try:
- res = httpx.get(url.format(app_token=app_token), headers=headers, timeout=30)
- res_json = res.json()
- if res.is_success:
- return self.create_text_message(text=json.dumps(res_json))
- else:
- return self.create_text_message(
- f"Failed to get base info, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to get base info. {}".format(e))
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/get_base_info.yaml b/api/core/tools/provider/builtin/feishu_base/tools/get_base_info.yaml
deleted file mode 100644
index de08689018..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/get_base_info.yaml
+++ /dev/null
@@ -1,54 +0,0 @@
-identity:
- name: get_base_info
- author: Doug Lea
- label:
- en_US: Get Base Info
- zh_Hans: 获取多维表格元数据
-description:
- human:
- en_US: Get base info
- zh_Hans: |
- 获取多维表格元数据,响应体如下:
- {
- "code": 0,
- "msg": "success",
- "data": {
- "app": {
- "app_token": "appbcbWCzen6D8dezhoCH2RpMAh",
- "name": "mybase",
- "revision": 1,
- "is_advanced": false,
- "time_zone": "Asia/Beijing"
- }
- }
- }
- app_token: 多维表格的 app_token;
- name: 多维表格的名字;
- revision: 多维表格的版本号;
- is_advanced: 多维表格是否开启了高级权限。取值包括:(true-表示开启了高级权限,false-表示关闭了高级权限);
- time_zone: 文档时区;
- llm: A tool to get Base Metadata, imported parameter is Unique Device Identifier app_token of Base, app_token is required.
-parameters:
- - name: Authorization
- type: string
- required: true
- label:
- en_US: token
- zh_Hans: 凭证
- human_description:
- en_US: API access token parameter, tenant_access_token or user_access_token
- zh_Hans: API 的访问凭证参数,tenant_access_token 或 user_access_token
- llm_description: API access token parameter, tenant_access_token or user_access_token
- form: llm
-
- - name: app_token
- type: string
- required: true
- label:
- en_US: app_token
- zh_Hans: 多维表格
- human_description:
- en_US: bitable app token
- zh_Hans: 多维表格的唯一标识符 app_token
- llm_description: bitable app token
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/get_tenant_access_token.py b/api/core/tools/provider/builtin/feishu_base/tools/get_tenant_access_token.py
deleted file mode 100644
index 2ea61d0068..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/get_tenant_access_token.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GetTenantAccessTokenTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- url = "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal"
-
- app_id = tool_parameters.get("app_id", "")
- if not app_id:
- return self.create_text_message("Invalid parameter app_id")
-
- app_secret = tool_parameters.get("app_secret", "")
- if not app_secret:
- return self.create_text_message("Invalid parameter app_secret")
-
- headers = {
- "Content-Type": "application/json",
- }
- params = {}
- payload = {"app_id": app_id, "app_secret": app_secret}
-
- """
- {
- "code": 0,
- "msg": "ok",
- "tenant_access_token": "t-caecc734c2e3328a62489fe0648c4b98779515d3",
- "expire": 7200
- }
- """
- try:
- res = httpx.post(url, headers=headers, params=params, json=payload, timeout=30)
- res_json = res.json()
- if res.is_success:
- return self.create_text_message(text=json.dumps(res_json))
- else:
- return self.create_text_message(
- f"Failed to get tenant access token, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to get tenant access token. {}".format(e))
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/get_tenant_access_token.yaml b/api/core/tools/provider/builtin/feishu_base/tools/get_tenant_access_token.yaml
deleted file mode 100644
index 88acc27e06..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/get_tenant_access_token.yaml
+++ /dev/null
@@ -1,39 +0,0 @@
-identity:
- name: get_tenant_access_token
- author: Doug Lea
- label:
- en_US: Get Tenant Access Token
- zh_Hans: 获取飞书自建应用的 tenant_access_token
-description:
- human:
- en_US: Get tenant access token
- zh_Hans: |
- 获取飞书自建应用的 tenant_access_token,响应体示例:
- {"code":0,"msg":"ok","tenant_access_token":"t-caecc734c2e3328a62489fe0648c4b98779515d3","expire":7200}
- tenant_access_token: 租户访问凭证;
- expire: tenant_access_token 的过期时间,单位为秒;
- llm: A tool for obtaining a tenant access token. The input parameters must include app_id and app_secret.
-parameters:
- - name: app_id
- type: string
- required: true
- label:
- en_US: app_id
- zh_Hans: 应用唯一标识
- human_description:
- en_US: app_id is the unique identifier of the Lark Open Platform application
- zh_Hans: app_id 是飞书开放平台应用的唯一标识
- llm_description: app_id is the unique identifier of the Lark Open Platform application
- form: llm
-
- - name: app_secret
- type: secret-input
- required: true
- label:
- en_US: app_secret
- zh_Hans: 应用秘钥
- human_description:
- en_US: app_secret is the secret key of the application
- zh_Hans: app_secret 是应用的秘钥
- llm_description: app_secret is the secret key of the application
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/list_base_records.py b/api/core/tools/provider/builtin/feishu_base/tools/list_base_records.py
deleted file mode 100644
index e579d02f69..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/list_base_records.py
+++ /dev/null
@@ -1,65 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class ListBaseRecordsTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- url = "https://open.feishu.cn/open-apis/bitable/v1/apps/{app_token}/tables/{table_id}/records/search"
-
- access_token = tool_parameters.get("Authorization", "")
- if not access_token:
- return self.create_text_message("Invalid parameter access_token")
-
- app_token = tool_parameters.get("app_token", "")
- if not app_token:
- return self.create_text_message("Invalid parameter app_token")
-
- table_id = tool_parameters.get("table_id", "")
- if not table_id:
- return self.create_text_message("Invalid parameter table_id")
-
- page_token = tool_parameters.get("page_token", "")
- page_size = tool_parameters.get("page_size", "")
- sort_condition = tool_parameters.get("sort_condition", "")
- filter_condition = tool_parameters.get("filter_condition", "")
-
- headers = {
- "Content-Type": "application/json",
- "Authorization": f"Bearer {access_token}",
- }
-
- params = {
- "page_token": page_token,
- "page_size": page_size,
- }
-
- payload = {"automatic_fields": True}
- if sort_condition:
- payload["sort"] = json.loads(sort_condition)
- if filter_condition:
- payload["filter"] = json.loads(filter_condition)
-
- try:
- res = httpx.post(
- url.format(app_token=app_token, table_id=table_id),
- headers=headers,
- params=params,
- json=payload,
- timeout=30,
- )
- res_json = res.json()
- if res.is_success:
- return self.create_text_message(text=json.dumps(res_json))
- else:
- return self.create_text_message(
- f"Failed to list base records, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to list base records. {}".format(e))
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/list_base_records.yaml b/api/core/tools/provider/builtin/feishu_base/tools/list_base_records.yaml
deleted file mode 100644
index 8647c880a6..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/list_base_records.yaml
+++ /dev/null
@@ -1,108 +0,0 @@
-identity:
- name: list_base_records
- author: Doug Lea
- label:
- en_US: List Base Records
- zh_Hans: 查询多维表格数据表中的现有记录
-description:
- human:
- en_US: List base records
- zh_Hans: |
- 查询多维表格数据表中的现有记录,单次最多查询 500 行记录,支持分页获取。
- llm: Query existing records in a multidimensional table data table. A maximum of 500 rows of records can be queried at a time, and paging retrieval is supported.
-parameters:
- - name: Authorization
- type: string
- required: true
- label:
- en_US: token
- zh_Hans: 凭证
- human_description:
- en_US: API access token parameter, tenant_access_token or user_access_token
- zh_Hans: API 的访问凭证参数,tenant_access_token 或 user_access_token
- llm_description: API access token parameter, tenant_access_token or user_access_token
- form: llm
-
- - name: app_token
- type: string
- required: true
- label:
- en_US: app_token
- zh_Hans: 多维表格
- human_description:
- en_US: bitable app token
- zh_Hans: 多维表格的唯一标识符 app_token
- llm_description: bitable app token
- form: llm
-
- - name: table_id
- type: string
- required: true
- label:
- en_US: table_id
- zh_Hans: 多维表格的数据表
- human_description:
- en_US: bitable table id
- zh_Hans: 多维表格数据表的唯一标识符 table_id
- llm_description: bitable table id
- form: llm
-
- - name: page_token
- type: string
- required: false
- label:
- en_US: page_token
- zh_Hans: 分页标记
- human_description:
- en_US: Pagination mark. If it is not filled in the first request, it means to traverse from the beginning.
- zh_Hans: 分页标记,第一次请求不填,表示从头开始遍历。
- llm_description: 分页标记,第一次请求不填,表示从头开始遍历;分页查询结果还有更多项时会同时返回新的 page_token,下次遍历可采用该 page_token 获取查询结果。
- form: llm
-
- - name: page_size
- type: number
- required: false
- default: 20
- label:
- en_US: page_size
- zh_Hans: 分页大小
- human_description:
- en_US: paging size
- zh_Hans: 分页大小,默认值为 20,最大值为 100。
- llm_description: The default value of paging size is 20 and the maximum value is 100.
- form: llm
-
- - name: sort_condition
- type: string
- required: false
- label:
- en_US: sort_condition
- zh_Hans: 排序条件
- human_description:
- en_US: sort condition
- zh_Hans: |
- 排序条件,格式为:[{"field_name":"多行文本","desc":true}]。
- field_name: 字段名称;
- desc: 是否倒序排序;
- llm_description: |
- Sorting conditions, the format is: [{"field_name":"multi-line text","desc":true}].
- form: llm
-
- - name: filter_condition
- type: string
- required: false
- label:
- en_US: filter_condition
- zh_Hans: 筛选条件
- human_description:
- en_US: filter condition
- zh_Hans: |
- 筛选条件,格式为:{"conjunction":"and","conditions":[{"field_name":"字段1","operator":"is","value":["文本内容"]}]}。
- conjunction:条件逻辑连接词;
- conditions:筛选条件集合;
- field_name:筛选条件的左值,值为字段的名称;
- operator:条件运算符;
- value:目标值;
- llm_description: |
- The format of the filter condition is: {"conjunction":"and","conditions":[{"field_name":"Field 1","operator":"is","value":["text content"]}]}.
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/list_base_tables.py b/api/core/tools/provider/builtin/feishu_base/tools/list_base_tables.py
deleted file mode 100644
index 4ec9a476bc..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/list_base_tables.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class ListBaseTablesTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- url = "https://open.feishu.cn/open-apis/bitable/v1/apps/{app_token}/tables"
-
- access_token = tool_parameters.get("Authorization", "")
- if not access_token:
- return self.create_text_message("Invalid parameter access_token")
-
- app_token = tool_parameters.get("app_token", "")
- if not app_token:
- return self.create_text_message("Invalid parameter app_token")
-
- page_token = tool_parameters.get("page_token", "")
- page_size = tool_parameters.get("page_size", "")
-
- headers = {
- "Content-Type": "application/json",
- "Authorization": f"Bearer {access_token}",
- }
-
- params = {
- "page_token": page_token,
- "page_size": page_size,
- }
-
- try:
- res = httpx.get(url.format(app_token=app_token), headers=headers, params=params, timeout=30)
- res_json = res.json()
- if res.is_success:
- return self.create_text_message(text=json.dumps(res_json))
- else:
- return self.create_text_message(
- f"Failed to list base tables, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to list base tables. {}".format(e))
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/list_base_tables.yaml b/api/core/tools/provider/builtin/feishu_base/tools/list_base_tables.yaml
deleted file mode 100644
index 9887124a28..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/list_base_tables.yaml
+++ /dev/null
@@ -1,65 +0,0 @@
-identity:
- name: list_base_tables
- author: Doug Lea
- label:
- en_US: List Base Tables
- zh_Hans: 根据 app_token 获取多维表格下的所有数据表
-description:
- human:
- en_US: List base tables
- zh_Hans: |
- 根据 app_token 获取多维表格下的所有数据表
- llm: A tool for getting all data tables under a multidimensional table based on app_token.
-parameters:
- - name: Authorization
- type: string
- required: true
- label:
- en_US: token
- zh_Hans: 凭证
- human_description:
- en_US: API access token parameter, tenant_access_token or user_access_token
- zh_Hans: API 的访问凭证参数,tenant_access_token 或 user_access_token
- llm_description: API access token parameter, tenant_access_token or user_access_token
- form: llm
-
- - name: app_token
- type: string
- required: true
- label:
- en_US: app_token
- zh_Hans: 多维表格
- human_description:
- en_US: bitable app token
- zh_Hans: 多维表格的唯一标识符 app_token
- llm_description: bitable app token
- form: llm
-
- - name: page_token
- type: string
- required: false
- label:
- en_US: page_token
- zh_Hans: 分页标记
- human_description:
- en_US: Pagination mark. If it is not filled in the first request, it means to traverse from the beginning.
- zh_Hans: 分页标记,第一次请求不填,表示从头开始遍历。
- llm_description: |
- Pagination token. If it is not filled in the first request, it means to start traversal from the beginning.
- If there are more items in the pagination query result, a new page_token will be returned at the same time.
- The page_token can be used to obtain the query result in the next traversal.
- 分页标记,第一次请求不填,表示从头开始遍历;分页查询结果还有更多项时会同时返回新的 page_token,下次遍历可采用该 page_token 获取查询结果。
- form: llm
-
- - name: page_size
- type: number
- required: false
- default: 20
- label:
- en_US: page_size
- zh_Hans: 分页大小
- human_description:
- en_US: paging size
- zh_Hans: 分页大小,默认值为 20,最大值为 100。
- llm_description: The default value of paging size is 20 and the maximum value is 100.
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/read_base_record.py b/api/core/tools/provider/builtin/feishu_base/tools/read_base_record.py
deleted file mode 100644
index fb818f8380..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/read_base_record.py
+++ /dev/null
@@ -1,49 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class ReadBaseRecordTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- url = "https://open.feishu.cn/open-apis/bitable/v1/apps/{app_token}/tables/{table_id}/records/{record_id}"
-
- access_token = tool_parameters.get("Authorization", "")
- if not access_token:
- return self.create_text_message("Invalid parameter access_token")
-
- app_token = tool_parameters.get("app_token", "")
- if not app_token:
- return self.create_text_message("Invalid parameter app_token")
-
- table_id = tool_parameters.get("table_id", "")
- if not table_id:
- return self.create_text_message("Invalid parameter table_id")
-
- record_id = tool_parameters.get("record_id", "")
- if not record_id:
- return self.create_text_message("Invalid parameter record_id")
-
- headers = {
- "Content-Type": "application/json",
- "Authorization": f"Bearer {access_token}",
- }
-
- try:
- res = httpx.get(
- url.format(app_token=app_token, table_id=table_id, record_id=record_id), headers=headers, timeout=30
- )
- res_json = res.json()
- if res.is_success:
- return self.create_text_message(text=json.dumps(res_json))
- else:
- return self.create_text_message(
- f"Failed to read base record, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to read base record. {}".format(e))
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/read_base_record.yaml b/api/core/tools/provider/builtin/feishu_base/tools/read_base_record.yaml
deleted file mode 100644
index 400e9a1021..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/read_base_record.yaml
+++ /dev/null
@@ -1,60 +0,0 @@
-identity:
- name: read_base_record
- author: Doug Lea
- label:
- en_US: Read Base Record
- zh_Hans: 根据 record_id 的值检索多维表格数据表的记录
-description:
- human:
- en_US: Read base record
- zh_Hans: |
- 根据 record_id 的值检索多维表格数据表的记录
- llm: Retrieve records from a multidimensional table based on the value of record_id
-parameters:
- - name: Authorization
- type: string
- required: true
- label:
- en_US: token
- zh_Hans: 凭证
- human_description:
- en_US: API access token parameter, tenant_access_token or user_access_token
- zh_Hans: API 的访问凭证参数,tenant_access_token 或 user_access_token
- llm_description: API access token parameter, tenant_access_token or user_access_token
- form: llm
-
- - name: app_token
- type: string
- required: true
- label:
- en_US: app_token
- zh_Hans: 多维表格
- human_description:
- en_US: bitable app token
- zh_Hans: 多维表格的唯一标识符 app_token
- llm_description: bitable app token
- form: llm
-
- - name: table_id
- type: string
- required: true
- label:
- en_US: table_id
- zh_Hans: 多维表格的数据表
- human_description:
- en_US: bitable table id
- zh_Hans: 多维表格数据表的唯一标识符 table_id
- llm_description: bitable table id
- form: llm
-
- - name: record_id
- type: string
- required: true
- label:
- en_US: record_id
- zh_Hans: 单条记录的 id
- human_description:
- en_US: The id of a single record
- zh_Hans: 单条记录的 id
- llm_description: The id of a single record
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/update_base_record.py b/api/core/tools/provider/builtin/feishu_base/tools/update_base_record.py
deleted file mode 100644
index 6d7e33f3ff..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/update_base_record.py
+++ /dev/null
@@ -1,60 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class UpdateBaseRecordTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- url = "https://open.feishu.cn/open-apis/bitable/v1/apps/{app_token}/tables/{table_id}/records/{record_id}"
-
- access_token = tool_parameters.get("Authorization", "")
- if not access_token:
- return self.create_text_message("Invalid parameter access_token")
-
- app_token = tool_parameters.get("app_token", "")
- if not app_token:
- return self.create_text_message("Invalid parameter app_token")
-
- table_id = tool_parameters.get("table_id", "")
- if not table_id:
- return self.create_text_message("Invalid parameter table_id")
-
- record_id = tool_parameters.get("record_id", "")
- if not record_id:
- return self.create_text_message("Invalid parameter record_id")
-
- fields = tool_parameters.get("fields", "")
- if not fields:
- return self.create_text_message("Invalid parameter fields")
-
- headers = {
- "Content-Type": "application/json",
- "Authorization": f"Bearer {access_token}",
- }
-
- params = {}
- payload = {"fields": json.loads(fields)}
-
- try:
- res = httpx.put(
- url.format(app_token=app_token, table_id=table_id, record_id=record_id),
- headers=headers,
- params=params,
- json=payload,
- timeout=30,
- )
- res_json = res.json()
- if res.is_success:
- return self.create_text_message(text=json.dumps(res_json))
- else:
- return self.create_text_message(
- f"Failed to update base record, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to update base record. {}".format(e))
diff --git a/api/core/tools/provider/builtin/feishu_base/tools/update_base_record.yaml b/api/core/tools/provider/builtin/feishu_base/tools/update_base_record.yaml
deleted file mode 100644
index 788798c4b3..0000000000
--- a/api/core/tools/provider/builtin/feishu_base/tools/update_base_record.yaml
+++ /dev/null
@@ -1,78 +0,0 @@
-identity:
- name: update_base_record
- author: Doug Lea
- label:
- en_US: Update Base Record
- zh_Hans: 更新多维表格数据表中的一条记录
-description:
- human:
- en_US: Update base record
- zh_Hans: |
- 更新多维表格数据表中的一条记录,详细请参考:https://open.larkoffice.com/document/server-docs/docs/bitable-v1/app-table-record/update
- llm: Update a record in a multidimensional table data table
-parameters:
- - name: Authorization
- type: string
- required: true
- label:
- en_US: token
- zh_Hans: 凭证
- human_description:
- en_US: API access token parameter, tenant_access_token or user_access_token
- zh_Hans: API 的访问凭证参数,tenant_access_token 或 user_access_token
- llm_description: API access token parameter, tenant_access_token or user_access_token
- form: llm
-
- - name: app_token
- type: string
- required: true
- label:
- en_US: app_token
- zh_Hans: 多维表格
- human_description:
- en_US: bitable app token
- zh_Hans: 多维表格的唯一标识符 app_token
- llm_description: bitable app token
- form: llm
-
- - name: table_id
- type: string
- required: true
- label:
- en_US: table_id
- zh_Hans: 多维表格的数据表
- human_description:
- en_US: bitable table id
- zh_Hans: 多维表格数据表的唯一标识符 table_id
- llm_description: bitable table id
- form: llm
-
- - name: record_id
- type: string
- required: true
- label:
- en_US: record_id
- zh_Hans: 单条记录的 id
- human_description:
- en_US: The id of a single record
- zh_Hans: 单条记录的 id
- llm_description: The id of a single record
- form: llm
-
- - name: fields
- type: string
- required: true
- label:
- en_US: fields
- zh_Hans: 数据表的列字段内容
- human_description:
- en_US: The fields of a multidimensional table data table, that is, the columns of the data table.
- zh_Hans: |
- 要更新一行多维表格记录,字段结构拼接如下:{"多行文本":"多行文本内容","单选":"选项1","多选":["选项1","选项2"],"复选框":true,"人员":[{"id":"ou_2910013f1e6456f16a0ce75ede950a0a"}],"群组":[{"id":"oc_cd07f55f14d6f4a4f1b51504e7e97f48"}],"电话号码":"13026162666"}
- 当前接口支持的字段类型为:多行文本、单选、条码、多选、日期、人员、附件、复选框、超链接、数字、单向关联、双向关联、电话号码、地理位置。
- 不同类型字段的数据结构请参考数据结构概述:https://open.larkoffice.com/document/server-docs/docs/bitable-v1/bitable-structure
- llm_description: |
- 要更新一行多维表格记录,字段结构拼接如下:{"多行文本":"多行文本内容","单选":"选项1","多选":["选项1","选项2"],"复选框":true,"人员":[{"id":"ou_2910013f1e6456f16a0ce75ede950a0a"}],"群组":[{"id":"oc_cd07f55f14d6f4a4f1b51504e7e97f48"}],"电话号码":"13026162666"}
- 当前接口支持的字段类型为:多行文本、单选、条码、多选、日期、人员、附件、复选框、超链接、数字、单向关联、双向关联、电话号码、地理位置。
- 不同类型字段的数据结构请参考数据结构概述:https://open.larkoffice.com/document/server-docs/docs/bitable-v1/bitable-structure
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_document/_assets/icon.svg b/api/core/tools/provider/builtin/feishu_document/_assets/icon.svg
deleted file mode 100644
index 5a0a6416b3..0000000000
--- a/api/core/tools/provider/builtin/feishu_document/_assets/icon.svg
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
diff --git a/api/core/tools/provider/builtin/feishu_document/feishu_document.py b/api/core/tools/provider/builtin/feishu_document/feishu_document.py
deleted file mode 100644
index b0a1e393eb..0000000000
--- a/api/core/tools/provider/builtin/feishu_document/feishu_document.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-from core.tools.utils.feishu_api_utils import FeishuRequest
-
-
-class FeishuDocumentProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- app_id = credentials.get("app_id")
- app_secret = credentials.get("app_secret")
- if not app_id or not app_secret:
- raise ToolProviderCredentialValidationError("app_id and app_secret is required")
- try:
- assert FeishuRequest(app_id, app_secret).tenant_access_token is not None
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/feishu_document/feishu_document.yaml b/api/core/tools/provider/builtin/feishu_document/feishu_document.yaml
deleted file mode 100644
index 8eaa6b2704..0000000000
--- a/api/core/tools/provider/builtin/feishu_document/feishu_document.yaml
+++ /dev/null
@@ -1,34 +0,0 @@
-identity:
- author: Doug Lea
- name: feishu_document
- label:
- en_US: Lark Cloud Document
- zh_Hans: 飞书云文档
- description:
- en_US: Lark Cloud Document
- zh_Hans: 飞书云文档
- icon: icon.svg
- tags:
- - social
- - productivity
-credentials_for_provider:
- app_id:
- type: text-input
- required: true
- label:
- en_US: APP ID
- placeholder:
- en_US: Please input your feishu app id
- zh_Hans: 请输入你的飞书 app id
- help:
- en_US: Get your app_id and app_secret from Feishu
- zh_Hans: 从飞书获取您的 app_id 和 app_secret
- url: https://open.feishu.cn
- app_secret:
- type: secret-input
- required: true
- label:
- en_US: APP Secret
- placeholder:
- en_US: Please input your app secret
- zh_Hans: 请输入你的飞书 app secret
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/create_document.py b/api/core/tools/provider/builtin/feishu_document/tools/create_document.py
deleted file mode 100644
index 090a0828e8..0000000000
--- a/api/core/tools/provider/builtin/feishu_document/tools/create_document.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from typing import Any
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-from core.tools.utils.feishu_api_utils import FeishuRequest
-
-
-class CreateDocumentTool(BuiltinTool):
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage:
- app_id = self.runtime.credentials.get("app_id")
- app_secret = self.runtime.credentials.get("app_secret")
- client = FeishuRequest(app_id, app_secret)
-
- title = tool_parameters.get("title")
- content = tool_parameters.get("content")
- folder_token = tool_parameters.get("folder_token")
-
- res = client.create_document(title, content, folder_token)
- return self.create_json_message(res)
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/create_document.yaml b/api/core/tools/provider/builtin/feishu_document/tools/create_document.yaml
deleted file mode 100644
index ddf2729f0e..0000000000
--- a/api/core/tools/provider/builtin/feishu_document/tools/create_document.yaml
+++ /dev/null
@@ -1,47 +0,0 @@
-identity:
- name: create_document
- author: Doug Lea
- label:
- en_US: Create Lark document
- zh_Hans: 创建飞书文档
-description:
- human:
- en_US: Create Lark document
- zh_Hans: 创建飞书文档,支持创建空文档和带内容的文档,支持 markdown 语法创建。
- llm: A tool for creating Feishu documents.
-parameters:
- - name: title
- type: string
- required: false
- label:
- en_US: Document title
- zh_Hans: 文档标题
- human_description:
- en_US: Document title, only supports plain text content.
- zh_Hans: 文档标题,只支持纯文本内容。
- llm_description: 文档标题,只支持纯文本内容,可以为空。
- form: llm
-
- - name: content
- type: string
- required: false
- label:
- en_US: Document content
- zh_Hans: 文档内容
- human_description:
- en_US: Document content, supports markdown syntax, can be empty.
- zh_Hans: 文档内容,支持 markdown 语法,可以为空。
- llm_description: 文档内容,支持 markdown 语法,可以为空。
- form: llm
-
- - name: folder_token
- type: string
- required: false
- label:
- en_US: folder_token
- zh_Hans: 文档所在文件夹的 Token
- human_description:
- en_US: The token of the folder where the document is located. If it is not passed or is empty, it means the root directory.
- zh_Hans: 文档所在文件夹的 Token,不传或传空表示根目录。
- llm_description: 文档所在文件夹的 Token,不传或传空表示根目录。
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/get_document_content.py b/api/core/tools/provider/builtin/feishu_document/tools/get_document_content.py
deleted file mode 100644
index c94a5f70ed..0000000000
--- a/api/core/tools/provider/builtin/feishu_document/tools/get_document_content.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from typing import Any
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-from core.tools.utils.feishu_api_utils import FeishuRequest
-
-
-class GetDocumentRawContentTool(BuiltinTool):
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage:
- app_id = self.runtime.credentials.get("app_id")
- app_secret = self.runtime.credentials.get("app_secret")
- client = FeishuRequest(app_id, app_secret)
-
- document_id = tool_parameters.get("document_id")
- mode = tool_parameters.get("mode")
- lang = tool_parameters.get("lang", 0)
-
- res = client.get_document_content(document_id, mode, lang)
- return self.create_json_message(res)
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/get_document_content.yaml b/api/core/tools/provider/builtin/feishu_document/tools/get_document_content.yaml
deleted file mode 100644
index 51eda73a60..0000000000
--- a/api/core/tools/provider/builtin/feishu_document/tools/get_document_content.yaml
+++ /dev/null
@@ -1,49 +0,0 @@
-identity:
- name: get_document_content
- author: Doug Lea
- label:
- en_US: Get Document Content
- zh_Hans: 获取飞书云文档的内容
-description:
- human:
- en_US: Get document content
- zh_Hans: 获取飞书云文档的内容
- llm: A tool for retrieving content from Feishu cloud documents.
-parameters:
- - name: document_id
- type: string
- required: true
- label:
- en_US: document_id
- zh_Hans: 飞书文档的唯一标识
- human_description:
- en_US: Unique identifier for a Feishu document. You can also input the document's URL.
- zh_Hans: 飞书文档的唯一标识,支持输入文档的 URL。
- llm_description: 飞书文档的唯一标识,支持输入文档的 URL。
- form: llm
-
- - name: mode
- type: string
- required: false
- label:
- en_US: mode
- zh_Hans: 文档返回格式
- human_description:
- en_US: Format of the document return, optional values are text, markdown, can be empty, default is markdown.
- zh_Hans: 文档返回格式,可选值有 text、markdown,可以为空,默认值为 markdown。
- llm_description: 文档返回格式,可选值有 text、markdown,可以为空,默认值为 markdown。
- form: llm
-
- - name: lang
- type: number
- required: false
- default: 0
- label:
- en_US: lang
- zh_Hans: 指定@用户的语言
- human_description:
- en_US: |
- Specifies the language for MentionUser, optional values are [0, 1]. 0: User's default name, 1: User's English name, default is 0.
- zh_Hans: 指定返回的 MentionUser,即 @用户 的语言,可选值有 [0,1]。0:该用户的默认名称,1:该用户的英文名称,默认值为 0。
- llm_description: 指定返回的 MentionUser,即 @用户 的语言,可选值有 [0,1]。0:该用户的默认名称,1:该用户的英文名称,默认值为 0。
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/list_document_blocks.py b/api/core/tools/provider/builtin/feishu_document/tools/list_document_blocks.py
deleted file mode 100644
index 572a7abf28..0000000000
--- a/api/core/tools/provider/builtin/feishu_document/tools/list_document_blocks.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from typing import Any
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-from core.tools.utils.feishu_api_utils import FeishuRequest
-
-
-class ListDocumentBlockTool(BuiltinTool):
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage:
- app_id = self.runtime.credentials.get("app_id")
- app_secret = self.runtime.credentials.get("app_secret")
- client = FeishuRequest(app_id, app_secret)
-
- document_id = tool_parameters.get("document_id")
- page_size = tool_parameters.get("page_size", 500)
- page_token = tool_parameters.get("page_token", "")
-
- res = client.list_document_blocks(document_id, page_token, page_size)
- return self.create_json_message(res)
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/list_document_blocks.yaml b/api/core/tools/provider/builtin/feishu_document/tools/list_document_blocks.yaml
deleted file mode 100644
index 019ac98390..0000000000
--- a/api/core/tools/provider/builtin/feishu_document/tools/list_document_blocks.yaml
+++ /dev/null
@@ -1,74 +0,0 @@
-identity:
- name: list_document_blocks
- author: Doug Lea
- label:
- en_US: List Document Blocks
- zh_Hans: 获取飞书文档所有块
-description:
- human:
- en_US: List document blocks
- zh_Hans: 获取飞书文档所有块的富文本内容并分页返回
- llm: A tool to get all blocks of Feishu documents
-parameters:
- - name: document_id
- type: string
- required: true
- label:
- en_US: document_id
- zh_Hans: 飞书文档的唯一标识
- human_description:
- en_US: Unique identifier for a Feishu document. You can also input the document's URL.
- zh_Hans: 飞书文档的唯一标识,支持输入文档的 URL。
- llm_description: 飞书文档的唯一标识,支持输入文档的 URL。
- form: llm
-
- - name: user_id_type
- type: select
- required: false
- options:
- - value: open_id
- label:
- en_US: open_id
- zh_Hans: open_id
- - value: union_id
- label:
- en_US: union_id
- zh_Hans: union_id
- - value: user_id
- label:
- en_US: user_id
- zh_Hans: user_id
- default: "open_id"
- label:
- en_US: user_id_type
- zh_Hans: 用户 ID 类型
- human_description:
- en_US: User ID type, optional values are open_id, union_id, user_id, with a default value of open_id.
- zh_Hans: 用户 ID 类型,可选值有 open_id、union_id、user_id,默认值为 open_id。
- llm_description: 用户 ID 类型,可选值有 open_id、union_id、user_id,默认值为 open_id。
- form: llm
-
- - name: page_size
- type: number
- required: false
- default: "500"
- label:
- en_US: page_size
- zh_Hans: 分页大小
- human_description:
- en_US: Paging size, the default and maximum value is 500.
- zh_Hans: 分页大小, 默认值和最大值为 500。
- llm_description: 分页大小, 表示一次请求最多返回多少条数据,默认值和最大值为 500。
- form: llm
-
- - name: page_token
- type: string
- required: false
- label:
- en_US: page_token
- zh_Hans: 分页标记
- human_description:
- en_US: Pagination token used to navigate through query results, allowing retrieval of additional items in subsequent requests.
- zh_Hans: 分页标记,用于分页查询结果,以便下次遍历时获取更多项。
- llm_description: 分页标记,第一次请求不填,表示从头开始遍历;分页查询结果还有更多项时会同时返回新的 page_token,下次遍历可采用该 page_token 获取查询结果。
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/write_document.py b/api/core/tools/provider/builtin/feishu_document/tools/write_document.py
deleted file mode 100644
index 6061250e48..0000000000
--- a/api/core/tools/provider/builtin/feishu_document/tools/write_document.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from typing import Any
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-from core.tools.utils.feishu_api_utils import FeishuRequest
-
-
-class CreateDocumentTool(BuiltinTool):
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage:
- app_id = self.runtime.credentials.get("app_id")
- app_secret = self.runtime.credentials.get("app_secret")
- client = FeishuRequest(app_id, app_secret)
-
- document_id = tool_parameters.get("document_id")
- content = tool_parameters.get("content")
- position = tool_parameters.get("position")
-
- res = client.write_document(document_id, content, position)
- return self.create_json_message(res)
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/write_document.yaml b/api/core/tools/provider/builtin/feishu_document/tools/write_document.yaml
deleted file mode 100644
index 4282e3dcf3..0000000000
--- a/api/core/tools/provider/builtin/feishu_document/tools/write_document.yaml
+++ /dev/null
@@ -1,59 +0,0 @@
-identity:
- name: write_document
- author: Doug Lea
- label:
- en_US: Write Document
- zh_Hans: 在飞书文档中新增内容
-description:
- human:
- en_US: Adding new content to Lark documents
- zh_Hans: 在飞书文档中新增内容
- llm: A tool for adding new content to Lark documents.
-parameters:
- - name: document_id
- type: string
- required: true
- label:
- en_US: document_id
- zh_Hans: 飞书文档的唯一标识
- human_description:
- en_US: Unique identifier for a Feishu document. You can also input the document's URL.
- zh_Hans: 飞书文档的唯一标识,支持输入文档的 URL。
- llm_description: 飞书文档的唯一标识,支持输入文档的 URL。
- form: llm
-
- - name: content
- type: string
- required: true
- label:
- en_US: Plain text or Markdown content
- zh_Hans: 纯文本或 Markdown 内容
- human_description:
- en_US: Plain text or Markdown content. Note that embedded tables in the document should not have merged cells.
- zh_Hans: 纯文本或 Markdown 内容。注意文档的内嵌套表格不允许有单元格合并。
- llm_description: 纯文本或 Markdown 内容,注意文档的内嵌套表格不允许有单元格合并。
- form: llm
-
- - name: position
- type: string
- required: false
- label:
- en_US: position
- zh_Hans: 添加位置
- human_description:
- en_US: |
- Enumeration values: start or end. Use 'start' to add content at the beginning of the document, and 'end' to add content at the end. The default value is 'end'.
- zh_Hans: 枚举值:start 或 end。使用 'start' 在文档开头添加内容,使用 'end' 在文档结尾添加内容,默认值为 'end'。
- llm_description: |
- 枚举值 start、end,start: 在文档开头添加内容;end: 在文档结尾添加内容,默认值为 end。
- form: llm
- options:
- - value: start
- label:
- en_US: start
- zh_Hans: 在文档开头添加内容
- - value: end
- label:
- en_US: end
- zh_Hans: 在文档结尾添加内容
- default: start
diff --git a/api/core/tools/provider/builtin/feishu_message/_assets/icon.svg b/api/core/tools/provider/builtin/feishu_message/_assets/icon.svg
deleted file mode 100644
index 222a1571f9..0000000000
--- a/api/core/tools/provider/builtin/feishu_message/_assets/icon.svg
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
diff --git a/api/core/tools/provider/builtin/feishu_message/feishu_message.py b/api/core/tools/provider/builtin/feishu_message/feishu_message.py
deleted file mode 100644
index 7b3adb9293..0000000000
--- a/api/core/tools/provider/builtin/feishu_message/feishu_message.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-from core.tools.utils.feishu_api_utils import FeishuRequest
-
-
-class FeishuMessageProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- app_id = credentials.get("app_id")
- app_secret = credentials.get("app_secret")
- if not app_id or not app_secret:
- raise ToolProviderCredentialValidationError("app_id and app_secret is required")
- try:
- assert FeishuRequest(app_id, app_secret).tenant_access_token is not None
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/feishu_message/feishu_message.yaml b/api/core/tools/provider/builtin/feishu_message/feishu_message.yaml
deleted file mode 100644
index 1bd8953ddd..0000000000
--- a/api/core/tools/provider/builtin/feishu_message/feishu_message.yaml
+++ /dev/null
@@ -1,34 +0,0 @@
-identity:
- author: Doug Lea
- name: feishu_message
- label:
- en_US: Lark Message
- zh_Hans: 飞书消息
- description:
- en_US: Lark Message
- zh_Hans: 飞书消息
- icon: icon.svg
- tags:
- - social
- - productivity
-credentials_for_provider:
- app_id:
- type: text-input
- required: true
- label:
- en_US: APP ID
- placeholder:
- en_US: Please input your feishu app id
- zh_Hans: 请输入你的飞书 app id
- help:
- en_US: Get your app_id and app_secret from Feishu
- zh_Hans: 从飞书获取您的 app_id 和 app_secret
- url: https://open.feishu.cn
- app_secret:
- type: secret-input
- required: true
- label:
- en_US: APP Secret
- placeholder:
- en_US: Please input your app secret
- zh_Hans: 请输入你的飞书 app secret
diff --git a/api/core/tools/provider/builtin/feishu_message/tools/send_bot_message.py b/api/core/tools/provider/builtin/feishu_message/tools/send_bot_message.py
deleted file mode 100644
index 1dd315d0e2..0000000000
--- a/api/core/tools/provider/builtin/feishu_message/tools/send_bot_message.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from typing import Any
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-from core.tools.utils.feishu_api_utils import FeishuRequest
-
-
-class SendBotMessageTool(BuiltinTool):
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage:
- app_id = self.runtime.credentials.get("app_id")
- app_secret = self.runtime.credentials.get("app_secret")
- client = FeishuRequest(app_id, app_secret)
-
- receive_id_type = tool_parameters.get("receive_id_type")
- receive_id = tool_parameters.get("receive_id")
- msg_type = tool_parameters.get("msg_type")
- content = tool_parameters.get("content")
-
- res = client.send_bot_message(receive_id_type, receive_id, msg_type, content)
- return self.create_json_message(res)
diff --git a/api/core/tools/provider/builtin/feishu_message/tools/send_bot_message.yaml b/api/core/tools/provider/builtin/feishu_message/tools/send_bot_message.yaml
deleted file mode 100644
index 6e398b18ab..0000000000
--- a/api/core/tools/provider/builtin/feishu_message/tools/send_bot_message.yaml
+++ /dev/null
@@ -1,91 +0,0 @@
-identity:
- name: send_bot_message
- author: Doug Lea
- label:
- en_US: Send Bot Message
- zh_Hans: 发送飞书应用消息
-description:
- human:
- en_US: Send bot message
- zh_Hans: 发送飞书应用消息
- llm: A tool for sending Feishu application messages.
-parameters:
- - name: receive_id_type
- type: select
- required: true
- options:
- - value: open_id
- label:
- en_US: open id
- zh_Hans: open id
- - value: union_id
- label:
- en_US: union id
- zh_Hans: union id
- - value: user_id
- label:
- en_US: user id
- zh_Hans: user id
- - value: email
- label:
- en_US: email
- zh_Hans: email
- - value: chat_id
- label:
- en_US: chat id
- zh_Hans: chat id
- label:
- en_US: User ID Type
- zh_Hans: 用户 ID 类型
- human_description:
- en_US: User ID Type
- zh_Hans: 用户 ID 类型,可选值有 open_id、union_id、user_id、email、chat_id。
- llm_description: 用户 ID 类型,可选值有 open_id、union_id、user_id、email、chat_id。
- form: llm
-
- - name: receive_id
- type: string
- required: true
- label:
- en_US: Receive Id
- zh_Hans: 消息接收者的 ID
- human_description:
- en_US: The ID of the message receiver. The ID type should correspond to the query parameter receive_id_type.
- zh_Hans: 消息接收者的 ID,ID 类型应与查询参数 receive_id_type 对应。
- llm_description: 消息接收者的 ID,ID 类型应与查询参数 receive_id_type 对应。
- form: llm
-
- - name: msg_type
- type: string
- required: true
- options:
- - value: text
- label:
- en_US: text
- zh_Hans: 文本
- - value: interactive
- label:
- en_US: message card
- zh_Hans: 消息卡片
- label:
- en_US: Message type
- zh_Hans: 消息类型
- human_description:
- en_US: Message type, optional values are, text (text), interactive (message card).
- zh_Hans: 消息类型,可选值有:text(文本)、interactive(消息卡片)。
- llm_description: 消息类型,可选值有:text(文本)、interactive(消息卡片)。
- form: llm
-
- - name: content
- type: string
- required: true
- label:
- en_US: Message content
- zh_Hans: 消息内容
- human_description:
- en_US: Message content
- zh_Hans: |
- 消息内容,JSON 结构序列化后的字符串。不同 msg_type 对应不同内容,
- 具体格式说明参考:https://open.larkoffice.com/document/server-docs/im-v1/message-content-description/create_json
- llm_description: 消息内容,JSON 结构序列化后的字符串。不同 msg_type 对应不同内容。
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_message/tools/send_webhook_message.py b/api/core/tools/provider/builtin/feishu_message/tools/send_webhook_message.py
deleted file mode 100644
index 44e70e0a15..0000000000
--- a/api/core/tools/provider/builtin/feishu_message/tools/send_webhook_message.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from typing import Any
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-from core.tools.utils.feishu_api_utils import FeishuRequest
-
-
-class SendWebhookMessageTool(BuiltinTool):
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage:
- app_id = self.runtime.credentials.get("app_id")
- app_secret = self.runtime.credentials.get("app_secret")
- client = FeishuRequest(app_id, app_secret)
-
- webhook = tool_parameters.get("webhook")
- msg_type = tool_parameters.get("msg_type")
- content = tool_parameters.get("content")
-
- res = client.send_webhook_message(webhook, msg_type, content)
- return self.create_json_message(res)
diff --git a/api/core/tools/provider/builtin/feishu_message/tools/send_webhook_message.yaml b/api/core/tools/provider/builtin/feishu_message/tools/send_webhook_message.yaml
deleted file mode 100644
index 8b39ce4874..0000000000
--- a/api/core/tools/provider/builtin/feishu_message/tools/send_webhook_message.yaml
+++ /dev/null
@@ -1,58 +0,0 @@
-identity:
- name: send_webhook_message
- author: Doug Lea
- label:
- en_US: Send Webhook Message
- zh_Hans: 使用自定义机器人发送飞书消息
-description:
- human:
- en_US: Send webhook message
- zh_Hans: 使用自定义机器人发送飞书消息
- llm: A tool for sending Lark messages using a custom robot.
-parameters:
- - name: webhook
- type: string
- required: true
- label:
- en_US: webhook
- zh_Hans: webhook 的地址
- human_description:
- en_US: The address of the webhook
- zh_Hans: webhook 的地址
- llm_description: webhook 的地址
- form: llm
-
- - name: msg_type
- type: string
- required: true
- options:
- - value: text
- label:
- en_US: text
- zh_Hans: 文本
- - value: interactive
- label:
- en_US: message card
- zh_Hans: 消息卡片
- label:
- en_US: Message type
- zh_Hans: 消息类型
- human_description:
- en_US: Message type, optional values are, text (text), interactive (message card).
- zh_Hans: 消息类型,可选值有:text(文本)、interactive(消息卡片)。
- llm_description: 消息类型,可选值有:text(文本)、interactive(消息卡片)。
- form: llm
-
- - name: content
- type: string
- required: true
- label:
- en_US: Message content
- zh_Hans: 消息内容
- human_description:
- en_US: Message content
- zh_Hans: |
- 消息内容,JSON 结构序列化后的字符串。不同 msg_type 对应不同内容,
- 具体格式说明参考:https://open.larkoffice.com/document/server-docs/im-v1/message-content-description/create_json
- llm_description: 消息内容,JSON 结构序列化后的字符串。不同 msg_type 对应不同内容。
- form: llm
diff --git a/api/core/tools/provider/builtin/firecrawl/_assets/icon.svg b/api/core/tools/provider/builtin/firecrawl/_assets/icon.svg
deleted file mode 100644
index e1e5f54117..0000000000
--- a/api/core/tools/provider/builtin/firecrawl/_assets/icon.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/firecrawl/firecrawl.py b/api/core/tools/provider/builtin/firecrawl/firecrawl.py
deleted file mode 100644
index 01455d7206..0000000000
--- a/api/core/tools/provider/builtin/firecrawl/firecrawl.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.firecrawl.tools.scrape import ScrapeTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class FirecrawlProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- # Example validation using the ScrapeTool, only scraping title for minimize content
- ScrapeTool().fork_tool_runtime(runtime={"credentials": credentials}).invoke(
- user_id="", tool_parameters={"url": "https://google.com", "onlyIncludeTags": "title"}
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/firecrawl/firecrawl.yaml b/api/core/tools/provider/builtin/firecrawl/firecrawl.yaml
deleted file mode 100644
index a48b9d9f54..0000000000
--- a/api/core/tools/provider/builtin/firecrawl/firecrawl.yaml
+++ /dev/null
@@ -1,35 +0,0 @@
-identity:
- author: Richards Tu
- name: firecrawl
- label:
- en_US: Firecrawl
- zh_CN: Firecrawl
- description:
- en_US: Firecrawl API integration for web crawling and scraping.
- zh_Hans: Firecrawl API 集成,用于网页爬取和数据抓取。
- icon: icon.svg
- tags:
- - search
- - utilities
-credentials_for_provider:
- firecrawl_api_key:
- type: secret-input
- required: true
- label:
- en_US: Firecrawl API Key
- zh_Hans: Firecrawl API 密钥
- placeholder:
- en_US: Please input your Firecrawl API key
- zh_Hans: 请输入您的 Firecrawl API 密钥,如果是自托管版本,可以随意填写密钥
- help:
- en_US: Get your Firecrawl API key from your Firecrawl account settings.If you are using a self-hosted version, you may enter any key at your convenience.
- zh_Hans: 从您的 Firecrawl 账户设置中获取 Firecrawl API 密钥。如果是自托管版本,可以随意填写密钥。
- url: https://www.firecrawl.dev/account
- base_url:
- type: text-input
- required: false
- label:
- en_US: Firecrawl server's Base URL
- zh_Hans: Firecrawl服务器的API URL
- placeholder:
- en_US: https://api.firecrawl.dev
diff --git a/api/core/tools/provider/builtin/firecrawl/firecrawl_appx.py b/api/core/tools/provider/builtin/firecrawl/firecrawl_appx.py
deleted file mode 100644
index d9fb6f04bc..0000000000
--- a/api/core/tools/provider/builtin/firecrawl/firecrawl_appx.py
+++ /dev/null
@@ -1,122 +0,0 @@
-import json
-import logging
-import time
-from collections.abc import Mapping
-from typing import Any
-
-import requests
-from requests.exceptions import HTTPError
-
-logger = logging.getLogger(__name__)
-
-
-class FirecrawlApp:
- def __init__(self, api_key: str | None = None, base_url: str | None = None):
- self.api_key = api_key
- self.base_url = base_url or "https://api.firecrawl.dev"
- if not self.api_key:
- raise ValueError("API key is required")
-
- def _prepare_headers(self, idempotency_key: str | None = None):
- headers = {"Content-Type": "application/json", "Authorization": f"Bearer {self.api_key}"}
- if idempotency_key:
- headers["Idempotency-Key"] = idempotency_key
- return headers
-
- def _request(
- self,
- method: str,
- url: str,
- data: Mapping[str, Any] | None = None,
- headers: Mapping[str, str] | None = None,
- retries: int = 3,
- backoff_factor: float = 0.3,
- ) -> Mapping[str, Any] | None:
- if not headers:
- headers = self._prepare_headers()
- for i in range(retries):
- try:
- response = requests.request(method, url, json=data, headers=headers)
- return response.json()
- except requests.exceptions.RequestException:
- if i < retries - 1:
- time.sleep(backoff_factor * (2**i))
- else:
- raise
- return None
-
- def scrape_url(self, url: str, **kwargs):
- endpoint = f"{self.base_url}/v1/scrape"
- data = {"url": url, **kwargs}
- logger.debug(f"Sent request to {endpoint=} body={data}")
- response = self._request("POST", endpoint, data)
- if response is None:
- raise HTTPError("Failed to scrape URL after multiple retries")
- return response
-
- def map(self, url: str, **kwargs):
- endpoint = f"{self.base_url}/v1/map"
- data = {"url": url, **kwargs}
- logger.debug(f"Sent request to {endpoint=} body={data}")
- response = self._request("POST", endpoint, data)
- if response is None:
- raise HTTPError("Failed to perform map after multiple retries")
- return response
-
- def crawl_url(
- self, url: str, wait: bool = True, poll_interval: int = 5, idempotency_key: str | None = None, **kwargs
- ):
- endpoint = f"{self.base_url}/v1/crawl"
- headers = self._prepare_headers(idempotency_key)
- data = {"url": url, **kwargs}
- logger.debug(f"Sent request to {endpoint=} body={data}")
- response = self._request("POST", endpoint, data, headers)
- if response is None:
- raise HTTPError("Failed to initiate crawl after multiple retries")
- elif response.get("success") == False:
- raise HTTPError(f'Failed to crawl: {response.get("error")}')
- job_id: str = response["id"]
- if wait:
- return self._monitor_job_status(job_id=job_id, poll_interval=poll_interval)
- return response
-
- def check_crawl_status(self, job_id: str):
- endpoint = f"{self.base_url}/v1/crawl/{job_id}"
- response = self._request("GET", endpoint)
- if response is None:
- raise HTTPError(f"Failed to check status for job {job_id} after multiple retries")
- return response
-
- def cancel_crawl_job(self, job_id: str):
- endpoint = f"{self.base_url}/v1/crawl/{job_id}"
- response = self._request("DELETE", endpoint)
- if response is None:
- raise HTTPError(f"Failed to cancel job {job_id} after multiple retries")
- return response
-
- def _monitor_job_status(self, job_id: str, poll_interval: int):
- while True:
- status = self.check_crawl_status(job_id)
- if status["status"] == "completed":
- return status
- elif status["status"] == "failed":
- raise HTTPError(f'Job {job_id} failed: {status["error"]}')
- time.sleep(poll_interval)
-
-
-def get_array_params(tool_parameters: dict[str, Any], key):
- param = tool_parameters.get(key)
- if param:
- return param.split(",")
-
-
-def get_json_params(tool_parameters: dict[str, Any], key):
- param = tool_parameters.get(key)
- if param:
- try:
- # support both single quotes and double quotes
- param = param.replace("'", '"')
- param = json.loads(param)
- except Exception:
- raise ValueError(f"Invalid {key} format.")
- return param
diff --git a/api/core/tools/provider/builtin/firecrawl/tools/crawl.py b/api/core/tools/provider/builtin/firecrawl/tools/crawl.py
deleted file mode 100644
index 9675b8eb91..0000000000
--- a/api/core/tools/provider/builtin/firecrawl/tools/crawl.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from typing import Any
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.provider.builtin.firecrawl.firecrawl_appx import FirecrawlApp, get_array_params, get_json_params
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class CrawlTool(BuiltinTool):
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage:
- """
- the api doc:
- https://docs.firecrawl.dev/api-reference/endpoint/crawl
- """
- app = FirecrawlApp(
- api_key=self.runtime.credentials["firecrawl_api_key"], base_url=self.runtime.credentials["base_url"]
- )
-
- scrapeOptions = {}
- payload = {}
-
- wait_for_results = tool_parameters.get("wait_for_results", True)
-
- payload["excludePaths"] = get_array_params(tool_parameters, "excludePaths")
- payload["includePaths"] = get_array_params(tool_parameters, "includePaths")
- payload["maxDepth"] = tool_parameters.get("maxDepth")
- payload["ignoreSitemap"] = tool_parameters.get("ignoreSitemap", False)
- payload["limit"] = tool_parameters.get("limit", 5)
- payload["allowBackwardLinks"] = tool_parameters.get("allowBackwardLinks", False)
- payload["allowExternalLinks"] = tool_parameters.get("allowExternalLinks", False)
- payload["webhook"] = tool_parameters.get("webhook")
-
- scrapeOptions["formats"] = get_array_params(tool_parameters, "formats")
- scrapeOptions["headers"] = get_json_params(tool_parameters, "headers")
- scrapeOptions["includeTags"] = get_array_params(tool_parameters, "includeTags")
- scrapeOptions["excludeTags"] = get_array_params(tool_parameters, "excludeTags")
- scrapeOptions["onlyMainContent"] = tool_parameters.get("onlyMainContent", False)
- scrapeOptions["waitFor"] = tool_parameters.get("waitFor", 0)
- scrapeOptions = {k: v for k, v in scrapeOptions.items() if v not in {None, ""}}
- payload["scrapeOptions"] = scrapeOptions or None
-
- payload = {k: v for k, v in payload.items() if v not in {None, ""}}
-
- crawl_result = app.crawl_url(url=tool_parameters["url"], wait=wait_for_results, **payload)
-
- return self.create_json_message(crawl_result)
diff --git a/api/core/tools/provider/builtin/firecrawl/tools/crawl.yaml b/api/core/tools/provider/builtin/firecrawl/tools/crawl.yaml
deleted file mode 100644
index 0d7dbcac20..0000000000
--- a/api/core/tools/provider/builtin/firecrawl/tools/crawl.yaml
+++ /dev/null
@@ -1,200 +0,0 @@
-identity:
- name: crawl
- author: Richards Tu
- label:
- en_US: Crawl
- zh_Hans: 深度爬取
-description:
- human:
- en_US: Recursively search through a urls subdomains, and gather the content.
- zh_Hans: 递归爬取一个网址的子域名,并收集内容。
- llm: This tool initiates a web crawl to extract data from a specified URL. It allows configuring crawler options such as including or excluding URL patterns, generating alt text for images using LLMs (paid plan required), limiting the maximum number of pages to crawl, and returning only the main content of the page. The tool can return either a list of crawled documents or a list of URLs based on the provided options.
-parameters:
- - name: url
- type: string
- required: true
- label:
- en_US: Start URL
- zh_Hans: 起始URL
- human_description:
- en_US: The base URL to start crawling from.
- zh_Hans: 要爬取网站的起始URL。
- llm_description: The URL of the website that needs to be crawled. This is a required parameter.
- form: llm
- - name: wait_for_results
- type: boolean
- default: true
- label:
- en_US: Wait For Results
- zh_Hans: 等待爬取结果
- human_description:
- en_US: If you choose not to wait, it will directly return a job ID. You can use this job ID to check the crawling results or cancel the crawling task, which is usually very useful for a large-scale crawling task.
- zh_Hans: 如果选择不等待,则会直接返回一个job_id,可以通过job_id查询爬取结果或取消爬取任务,这通常对于一个大型爬取任务来说非常有用。
- form: form
-############## Payload #######################
- - name: excludePaths
- type: string
- label:
- en_US: URL patterns to exclude
- zh_Hans: 要排除的URL模式
- placeholder:
- en_US: Use commas to separate multiple tags
- zh_Hans: 多个标签时使用半角逗号分隔
- human_description:
- en_US: |
- Pages matching these patterns will be skipped. Example: blog/*, about/*
- zh_Hans: 匹配这些模式的页面将被跳过。示例:blog/*, about/*
- form: form
- - name: includePaths
- type: string
- required: false
- label:
- en_US: URL patterns to include
- zh_Hans: 要包含的URL模式
- placeholder:
- en_US: Use commas to separate multiple tags
- zh_Hans: 多个标签时使用半角逗号分隔
- human_description:
- en_US: |
- Only pages matching these patterns will be crawled. Example: blog/*, about/*
- zh_Hans: 只有与这些模式匹配的页面才会被爬取。示例:blog/*, about/*
- form: form
- - name: maxDepth
- type: number
- label:
- en_US: Maximum crawl depth
- zh_Hans: 爬取深度
- human_description:
- en_US: Maximum depth to crawl relative to the entered URL. A maxDepth of 0 scrapes only the entered URL. A maxDepth of 1 scrapes the entered URL and all pages one level deep. A maxDepth of 2 scrapes the entered URL and all pages up to two levels deep. Higher values follow the same pattern.
- zh_Hans: 相对于输入的URL,爬取的最大深度。maxDepth为0时,仅抓取输入的URL。maxDepth为1时,抓取输入的URL以及所有一级深层页面。maxDepth为2时,抓取输入的URL以及所有两级深层页面。更高值遵循相同模式。
- form: form
- min: 0
- default: 2
- - name: ignoreSitemap
- type: boolean
- default: true
- label:
- en_US: ignore Sitemap
- zh_Hans: 忽略站点地图
- human_description:
- en_US: Ignore the website sitemap when crawling.
- zh_Hans: 爬取时忽略网站站点地图。
- form: form
- - name: limit
- type: number
- required: false
- label:
- en_US: Maximum pages to crawl
- zh_Hans: 最大爬取页面数
- human_description:
- en_US: Specify the maximum number of pages to crawl. The crawler will stop after reaching this limit.
- zh_Hans: 指定要爬取的最大页面数。爬虫将在达到此限制后停止。
- form: form
- min: 1
- default: 5
- - name: allowBackwardLinks
- type: boolean
- default: false
- label:
- en_US: allow Backward Crawling
- zh_Hans: 允许向后爬取
- human_description:
- en_US: Enables the crawler to navigate from a specific URL to previously linked pages. For instance, from 'example.com/product/123' back to 'example.com/product'
- zh_Hans: 使爬虫能够从特定URL导航到之前链接的页面。例如,从'example.com/product/123'返回到'example.com/product'
- form: form
- - name: allowExternalLinks
- type: boolean
- default: false
- label:
- en_US: allow External Content Links
- zh_Hans: 允许爬取外链
- human_description:
- en_US: Allows the crawler to follow links to external websites.
- zh_Hans:
- form: form
- - name: webhook
- type: string
- label:
- en_US: webhook
- human_description:
- en_US: |
- The URL to send the webhook to. This will trigger for crawl started (crawl.started) ,every page crawled (crawl.page) and when the crawl is completed (crawl.completed or crawl.failed). The response will be the same as the /scrape endpoint.
- zh_Hans: 发送Webhook的URL。这将在开始爬取(crawl.started)、每爬取一个页面(crawl.page)以及爬取完成(crawl.completed或crawl.failed)时触发。响应将与/scrape端点相同。
- form: form
-############## Scrape Options #######################
- - name: formats
- type: string
- label:
- en_US: Formats
- zh_Hans: 结果的格式
- placeholder:
- en_US: Use commas to separate multiple tags
- zh_Hans: 多个标签时使用半角逗号分隔
- human_description:
- en_US: |
- Formats to include in the output. Available options: markdown, html, rawHtml, links, screenshot
- zh_Hans: |
- 输出中应包含的格式。可以填入: markdown, html, rawHtml, links, screenshot
- form: form
- - name: headers
- type: string
- label:
- en_US: headers
- zh_Hans: 请求头
- human_description:
- en_US: |
- Headers to send with the request. Can be used to send cookies, user-agent, etc. Example: {"cookies": "testcookies"}
- zh_Hans: |
- 随请求发送的头部。可以用来发送cookies、用户代理等。示例:{"cookies": "testcookies"}
- placeholder:
- en_US: Please enter an object that can be serialized in JSON
- zh_Hans: 请输入可以json序列化的对象
- form: form
- - name: includeTags
- type: string
- label:
- en_US: Include Tags
- zh_Hans: 仅抓取这些标签
- placeholder:
- en_US: Use commas to separate multiple tags
- zh_Hans: 多个标签时使用半角逗号分隔
- human_description:
- en_US: |
- Only include tags, classes and ids from the page in the final output. Use comma separated values. Example: script, .ad, #footer
- zh_Hans: |
- 仅在最终输出中包含HTML页面的这些标签,可以通过标签名、类或ID来设定,使用逗号分隔值。示例:script, .ad, #footer
- form: form
- - name: excludeTags
- type: string
- label:
- en_US: Exclude Tags
- zh_Hans: 要移除这些标签
- human_description:
- en_US: |
- Tags, classes and ids to remove from the page. Use comma separated values. Example: script, .ad, #footer
- zh_Hans: |
- 要在最终输出中移除HTML页面的这些标签,可以通过标签名、类或ID来设定,使用逗号分隔值。示例:script, .ad, #footer
- placeholder:
- en_US: Use commas to separate multiple tags
- zh_Hans: 多个标签时使用半角逗号分隔
- form: form
- - name: onlyMainContent
- type: boolean
- default: false
- label:
- en_US: only Main Content
- zh_Hans: 仅抓取主要内容
- human_description:
- en_US: Only return the main content of the page excluding headers, navs, footers, etc.
- zh_Hans: 只返回页面的主要内容,不包括头部、导航栏、尾部等。
- form: form
- - name: waitFor
- type: number
- min: 0
- label:
- en_US: wait For
- zh_Hans: 等待时间
- human_description:
- en_US: Wait x amount of milliseconds for the page to load to fetch content.
- zh_Hans: 等待x毫秒以使页面加载并获取内容。
- form: form
diff --git a/api/core/tools/provider/builtin/firecrawl/tools/crawl_job.py b/api/core/tools/provider/builtin/firecrawl/tools/crawl_job.py
deleted file mode 100644
index 0d2486c7ca..0000000000
--- a/api/core/tools/provider/builtin/firecrawl/tools/crawl_job.py
+++ /dev/null
@@ -1,21 +0,0 @@
-from typing import Any
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.provider.builtin.firecrawl.firecrawl_appx import FirecrawlApp
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class CrawlJobTool(BuiltinTool):
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage:
- app = FirecrawlApp(
- api_key=self.runtime.credentials["firecrawl_api_key"], base_url=self.runtime.credentials["base_url"]
- )
- operation = tool_parameters.get("operation", "get")
- if operation == "get":
- result = app.check_crawl_status(job_id=tool_parameters["job_id"])
- elif operation == "cancel":
- result = app.cancel_crawl_job(job_id=tool_parameters["job_id"])
- else:
- raise ValueError(f"Invalid operation: {operation}")
-
- return self.create_json_message(result)
diff --git a/api/core/tools/provider/builtin/firecrawl/tools/crawl_job.yaml b/api/core/tools/provider/builtin/firecrawl/tools/crawl_job.yaml
deleted file mode 100644
index 78008e4ad4..0000000000
--- a/api/core/tools/provider/builtin/firecrawl/tools/crawl_job.yaml
+++ /dev/null
@@ -1,37 +0,0 @@
-identity:
- name: crawl_job
- author: hjlarry
- label:
- en_US: Crawl Job
- zh_Hans: 爬取任务处理
-description:
- human:
- en_US: Retrieve the scraping results based on the job ID, or cancel the scraping task.
- zh_Hans: 根据爬取任务ID获取爬取结果,或者取消爬取任务
- llm: Retrieve the scraping results based on the job ID, or cancel the scraping task.
-parameters:
- - name: job_id
- type: string
- required: true
- label:
- en_US: Job ID
- human_description:
- en_US: Set wait_for_results to false in the Crawl tool can get the job ID.
- zh_Hans: 在深度爬取工具中将等待爬取结果设置为否可以获取Job ID。
- llm_description: Set wait_for_results to false in the Crawl tool can get the job ID.
- form: llm
- - name: operation
- type: select
- required: true
- options:
- - value: get
- label:
- en_US: get crawl status
- - value: cancel
- label:
- en_US: cancel crawl job
- label:
- en_US: operation
- zh_Hans: 操作
- llm_description: choose the operation to perform. `get` is for getting the crawl status, `cancel` is for cancelling the crawl job.
- form: llm
diff --git a/api/core/tools/provider/builtin/firecrawl/tools/map.py b/api/core/tools/provider/builtin/firecrawl/tools/map.py
deleted file mode 100644
index bdfb5faeb8..0000000000
--- a/api/core/tools/provider/builtin/firecrawl/tools/map.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from typing import Any
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.provider.builtin.firecrawl.firecrawl_appx import FirecrawlApp
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class MapTool(BuiltinTool):
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage:
- """
- the api doc:
- https://docs.firecrawl.dev/api-reference/endpoint/map
- """
- app = FirecrawlApp(
- api_key=self.runtime.credentials["firecrawl_api_key"], base_url=self.runtime.credentials["base_url"]
- )
- payload = {}
- payload["search"] = tool_parameters.get("search")
- payload["ignoreSitemap"] = tool_parameters.get("ignoreSitemap", True)
- payload["includeSubdomains"] = tool_parameters.get("includeSubdomains", False)
- payload["limit"] = tool_parameters.get("limit", 5000)
-
- map_result = app.map(url=tool_parameters["url"], **payload)
-
- return self.create_json_message(map_result)
diff --git a/api/core/tools/provider/builtin/firecrawl/tools/map.yaml b/api/core/tools/provider/builtin/firecrawl/tools/map.yaml
deleted file mode 100644
index 9913756983..0000000000
--- a/api/core/tools/provider/builtin/firecrawl/tools/map.yaml
+++ /dev/null
@@ -1,59 +0,0 @@
-identity:
- name: map
- author: hjlarry
- label:
- en_US: Map
- zh_Hans: 地图式快爬
-description:
- human:
- en_US: Input a website and get all the urls on the website - extremly fast
- zh_Hans: 输入一个网站,快速获取网站上的所有网址。
- llm: Input a website and get all the urls on the website - extremly fast
-parameters:
- - name: url
- type: string
- required: true
- label:
- en_US: Start URL
- zh_Hans: 起始URL
- human_description:
- en_US: The base URL to start crawling from.
- zh_Hans: 要爬取网站的起始URL。
- llm_description: The URL of the website that needs to be crawled. This is a required parameter.
- form: llm
- - name: search
- type: string
- label:
- en_US: search
- zh_Hans: 搜索查询
- human_description:
- en_US: Search query to use for mapping. During the Alpha phase, the 'smart' part of the search functionality is limited to 100 search results. However, if map finds more results, there is no limit applied.
- zh_Hans: 用于映射的搜索查询。在Alpha阶段,搜索功能的“智能”部分限制为最多100个搜索结果。然而,如果地图找到了更多结果,则不施加任何限制。
- llm_description: Search query to use for mapping. During the Alpha phase, the 'smart' part of the search functionality is limited to 100 search results. However, if map finds more results, there is no limit applied.
- form: llm
-############## Page Options #######################
- - name: ignoreSitemap
- type: boolean
- default: true
- label:
- en_US: ignore Sitemap
- zh_Hans: 忽略站点地图
- human_description:
- en_US: Ignore the website sitemap when crawling.
- zh_Hans: 爬取时忽略网站站点地图。
- form: form
- - name: includeSubdomains
- type: boolean
- default: false
- label:
- en_US: include Subdomains
- zh_Hans: 包含子域名
- form: form
- - name: limit
- type: number
- min: 0
- default: 5000
- label:
- en_US: Maximum results
- zh_Hans: 最大结果数量
- form: form
diff --git a/api/core/tools/provider/builtin/firecrawl/tools/scrape.py b/api/core/tools/provider/builtin/firecrawl/tools/scrape.py
deleted file mode 100644
index 538b4a1fcb..0000000000
--- a/api/core/tools/provider/builtin/firecrawl/tools/scrape.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from typing import Any
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.provider.builtin.firecrawl.firecrawl_appx import FirecrawlApp, get_array_params, get_json_params
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class ScrapeTool(BuiltinTool):
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> list[ToolInvokeMessage]:
- """
- the api doc:
- https://docs.firecrawl.dev/api-reference/endpoint/scrape
- """
- app = FirecrawlApp(
- api_key=self.runtime.credentials["firecrawl_api_key"], base_url=self.runtime.credentials["base_url"]
- )
-
- payload = {}
- extract = {}
-
- payload["formats"] = get_array_params(tool_parameters, "formats")
- payload["onlyMainContent"] = tool_parameters.get("onlyMainContent", True)
- payload["includeTags"] = get_array_params(tool_parameters, "includeTags")
- payload["excludeTags"] = get_array_params(tool_parameters, "excludeTags")
- payload["headers"] = get_json_params(tool_parameters, "headers")
- payload["waitFor"] = tool_parameters.get("waitFor", 0)
- payload["timeout"] = tool_parameters.get("timeout", 30000)
-
- extract["schema"] = get_json_params(tool_parameters, "schema")
- extract["systemPrompt"] = tool_parameters.get("systemPrompt")
- extract["prompt"] = tool_parameters.get("prompt")
- extract = {k: v for k, v in extract.items() if v not in {None, ""}}
- payload["extract"] = extract or None
-
- payload = {k: v for k, v in payload.items() if v not in {None, ""}}
-
- crawl_result = app.scrape_url(url=tool_parameters["url"], **payload)
- markdown_result = crawl_result.get("data", {}).get("markdown", "")
- return [self.create_text_message(markdown_result), self.create_json_message(crawl_result)]
diff --git a/api/core/tools/provider/builtin/firecrawl/tools/scrape.yaml b/api/core/tools/provider/builtin/firecrawl/tools/scrape.yaml
deleted file mode 100644
index 8f1f1348a4..0000000000
--- a/api/core/tools/provider/builtin/firecrawl/tools/scrape.yaml
+++ /dev/null
@@ -1,152 +0,0 @@
-identity:
- name: scrape
- author: ahasasjeb
- label:
- en_US: Scrape
- zh_Hans: 单页面抓取
-description:
- human:
- en_US: Turn any url into clean data.
- zh_Hans: 将任何网址转换为干净的数据。
- llm: This tool is designed to scrape URL and output the content in Markdown format.
-parameters:
- - name: url
- type: string
- required: true
- label:
- en_US: URL to scrape
- zh_Hans: 要抓取的URL
- human_description:
- en_US: The URL of the website to scrape and extract data from.
- zh_Hans: 要抓取并提取数据的网站URL。
- llm_description: The URL of the website that needs to be crawled. This is a required parameter.
- form: llm
-############## Payload #######################
- - name: formats
- type: string
- label:
- en_US: Formats
- zh_Hans: 结果的格式
- placeholder:
- en_US: Use commas to separate multiple tags
- zh_Hans: 多个标签时使用半角逗号分隔
- human_description:
- en_US: |
- Formats to include in the output. Available options: markdown, html, rawHtml, links, screenshot, extract, screenshot@fullPage
- zh_Hans: |
- 输出中应包含的格式。可以填入: markdown, html, rawHtml, links, screenshot, extract, screenshot@fullPage
- form: form
- - name: onlyMainContent
- type: boolean
- default: false
- label:
- en_US: only Main Content
- zh_Hans: 仅抓取主要内容
- human_description:
- en_US: Only return the main content of the page excluding headers, navs, footers, etc.
- zh_Hans: 只返回页面的主要内容,不包括头部、导航栏、尾部等。
- form: form
- - name: includeTags
- type: string
- label:
- en_US: Include Tags
- zh_Hans: 仅抓取这些标签
- placeholder:
- en_US: Use commas to separate multiple tags
- zh_Hans: 多个标签时使用半角逗号分隔
- human_description:
- en_US: |
- Only include tags, classes and ids from the page in the final output. Use comma separated values. Example: script, .ad, #footer
- zh_Hans: |
- 仅在最终输出中包含HTML页面的这些标签,可以通过标签名、类或ID来设定,使用逗号分隔值。示例:script, .ad, #footer
- form: form
- - name: excludeTags
- type: string
- label:
- en_US: Exclude Tags
- zh_Hans: 要移除这些标签
- human_description:
- en_US: |
- Tags, classes and ids to remove from the page. Use comma separated values. Example: script, .ad, #footer
- zh_Hans: |
- 要在最终输出中移除HTML页面的这些标签,可以通过标签名、类或ID来设定,使用逗号分隔值。示例:script, .ad, #footer
- placeholder:
- en_US: Use commas to separate multiple tags
- zh_Hans: 多个标签时使用半角逗号分隔
- form: form
- - name: headers
- type: string
- label:
- en_US: headers
- zh_Hans: 请求头
- human_description:
- en_US: |
- Headers to send with the request. Can be used to send cookies, user-agent, etc. Example: {"cookies": "testcookies"}
- zh_Hans: |
- 随请求发送的头部。可以用来发送cookies、用户代理等。示例:{"cookies": "testcookies"}
- placeholder:
- en_US: Please enter an object that can be serialized in JSON
- zh_Hans: 请输入可以json序列化的对象
- form: form
- - name: waitFor
- type: number
- min: 0
- default: 0
- label:
- en_US: wait For
- zh_Hans: 等待时间
- human_description:
- en_US: Wait x amount of milliseconds for the page to load to fetch content.
- zh_Hans: 等待x毫秒以使页面加载并获取内容。
- form: form
- - name: timeout
- type: number
- min: 0
- default: 30000
- label:
- en_US: Timeout
- human_description:
- en_US: Timeout in milliseconds for the request.
- zh_Hans: 请求的超时时间(以毫秒为单位)。
- form: form
-############## Extractor Options #######################
- - name: schema
- type: string
- label:
- en_US: Extractor Schema
- zh_Hans: 提取时的结构
- placeholder:
- en_US: Please enter an object that can be serialized in JSON
- zh_Hans: 请输入可以json序列化的对象
- human_description:
- en_US: |
- The schema for the data to be extracted. Example: {
- "type": "object",
- "properties": {"company_mission": {"type": "string"}},
- "required": ["company_mission"]
- }
- zh_Hans: |
- 使用该结构去提取,示例:{
- "type": "object",
- "properties": {"company_mission": {"type": "string"}},
- "required": ["company_mission"]
- }
- form: form
- - name: systemPrompt
- type: string
- label:
- en_US: Extractor System Prompt
- zh_Hans: 提取时的系统提示词
- human_description:
- en_US: The system prompt to use for the extraction.
- zh_Hans: 用于提取的系统提示。
- form: form
- - name: prompt
- type: string
- label:
- en_US: Extractor Prompt
- zh_Hans: 提取时的提示词
- human_description:
- en_US: The prompt to use for the extraction without a schema.
- zh_Hans: 用于无schema时提取的提示词
- form: form
diff --git a/api/core/tools/provider/builtin/gaode/_assets/icon.svg b/api/core/tools/provider/builtin/gaode/_assets/icon.svg
deleted file mode 100644
index 0f5729e17a..0000000000
--- a/api/core/tools/provider/builtin/gaode/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/gaode/gaode.py b/api/core/tools/provider/builtin/gaode/gaode.py
deleted file mode 100644
index 49a8e537fb..0000000000
--- a/api/core/tools/provider/builtin/gaode/gaode.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import urllib.parse
-
-import requests
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class GaodeProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- if "api_key" not in credentials or not credentials.get("api_key"):
- raise ToolProviderCredentialValidationError("Gaode API key is required.")
-
- try:
- response = requests.get(
- url="https://restapi.amap.com/v3/geocode/geo?address={address}&key={apikey}".format(
- address=urllib.parse.quote("广东省广州市天河区广州塔"), apikey=credentials.get("api_key")
- )
- )
- if response.status_code == 200 and (response.json()).get("info") == "OK":
- pass
- else:
- raise ToolProviderCredentialValidationError((response.json()).get("info"))
- except Exception as e:
- raise ToolProviderCredentialValidationError("Gaode API Key is invalid. {}".format(e))
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/gaode/gaode.yaml b/api/core/tools/provider/builtin/gaode/gaode.yaml
deleted file mode 100644
index 2eb3b161a2..0000000000
--- a/api/core/tools/provider/builtin/gaode/gaode.yaml
+++ /dev/null
@@ -1,34 +0,0 @@
-identity:
- author: CharlieWei
- name: gaode
- label:
- en_US: Autonavi
- zh_Hans: 高德
- pt_BR: Autonavi
- description:
- en_US: Autonavi Open Platform service toolkit.
- zh_Hans: 高德开放平台服务工具包。
- pt_BR: Kit de ferramentas de serviço Autonavi Open Platform.
- icon: icon.svg
- tags:
- - utilities
- - productivity
- - travel
- - weather
-credentials_for_provider:
- api_key:
- type: secret-input
- required: true
- label:
- en_US: API Key
- zh_Hans: API Key
- pt_BR: Fogo a chave
- placeholder:
- en_US: Please enter your Autonavi API Key
- zh_Hans: 请输入你的高德开放平台 API Key
- pt_BR: Insira sua chave de API Autonavi
- help:
- en_US: Get your API Key from Autonavi
- zh_Hans: 从高德获取您的 API Key
- pt_BR: Obtenha sua chave de API do Autonavi
- url: https://console.amap.com/dev/key/app
diff --git a/api/core/tools/provider/builtin/gaode/tools/gaode_weather.py b/api/core/tools/provider/builtin/gaode/tools/gaode_weather.py
deleted file mode 100644
index ea06e2ce61..0000000000
--- a/api/core/tools/provider/builtin/gaode/tools/gaode_weather.py
+++ /dev/null
@@ -1,64 +0,0 @@
-import json
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GaodeRepositoriesTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- city = tool_parameters.get("city", "")
- if not city:
- return self.create_text_message("Please tell me your city")
-
- if "api_key" not in self.runtime.credentials or not self.runtime.credentials.get("api_key"):
- return self.create_text_message("Gaode API key is required.")
-
- try:
- s = requests.session()
- api_domain = "https://restapi.amap.com/v3"
- city_response = s.request(
- method="GET",
- headers={"Content-Type": "application/json; charset=utf-8"},
- url="{url}/config/district?keywords={keywords}&subdistrict=0&extensions=base&key={apikey}".format(
- url=api_domain, keywords=city, apikey=self.runtime.credentials.get("api_key")
- ),
- )
- City_data = city_response.json()
- if city_response.status_code == 200 and City_data.get("info") == "OK":
- if len(City_data.get("districts")) > 0:
- CityCode = City_data["districts"][0]["adcode"]
- weatherInfo_response = s.request(
- method="GET",
- url="{url}/weather/weatherInfo?city={citycode}&extensions=all&key={apikey}&output=json"
- "".format(url=api_domain, citycode=CityCode, apikey=self.runtime.credentials.get("api_key")),
- )
- weatherInfo_data = weatherInfo_response.json()
- if weatherInfo_response.status_code == 200 and weatherInfo_data.get("info") == "OK":
- contents = []
- if len(weatherInfo_data.get("forecasts")) > 0:
- for item in weatherInfo_data["forecasts"][0]["casts"]:
- content = {}
- content["date"] = item.get("date")
- content["week"] = item.get("week")
- content["dayweather"] = item.get("dayweather")
- content["daytemp_float"] = item.get("daytemp_float")
- content["daywind"] = item.get("daywind")
- content["nightweather"] = item.get("nightweather")
- content["nighttemp_float"] = item.get("nighttemp_float")
- contents.append(content)
- s.close()
- return self.create_text_message(
- self.summary(user_id=user_id, content=json.dumps(contents, ensure_ascii=False))
- )
- s.close()
- return self.create_text_message(f"No weather information for {city} was found.")
- except Exception as e:
- return self.create_text_message("Gaode API Key and Api Version is invalid. {}".format(e))
diff --git a/api/core/tools/provider/builtin/gaode/tools/gaode_weather.yaml b/api/core/tools/provider/builtin/gaode/tools/gaode_weather.yaml
deleted file mode 100644
index e41851e188..0000000000
--- a/api/core/tools/provider/builtin/gaode/tools/gaode_weather.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-identity:
- name: gaode_weather
- author: CharlieWei
- label:
- en_US: Weather Forecast
- zh_Hans: 天气预报
- pt_BR: Previsão do tempo
- icon: icon.svg
-description:
- human:
- en_US: Weather forecast inquiry
- zh_Hans: 天气预报查询。
- pt_BR: Inquérito sobre previsão meteorológica.
- llm: A tool when you want to ask about the weather or weather-related question.
-parameters:
- - name: city
- type: string
- required: true
- label:
- en_US: city
- zh_Hans: 城市
- pt_BR: cidade
- human_description:
- en_US: Target city for weather forecast query.
- zh_Hans: 天气预报查询的目标城市。
- pt_BR: Cidade de destino para consulta de previsão do tempo.
- llm_description: If you don't know you can extract the city name from the question or you can reply:Please tell me your city. You have to extract the Chinese city name from the question.
- form: llm
diff --git a/api/core/tools/provider/builtin/getimgai/_assets/icon.svg b/api/core/tools/provider/builtin/getimgai/_assets/icon.svg
deleted file mode 100644
index 6b2513386d..0000000000
--- a/api/core/tools/provider/builtin/getimgai/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/getimgai/getimgai.py b/api/core/tools/provider/builtin/getimgai/getimgai.py
deleted file mode 100644
index bbd07d120f..0000000000
--- a/api/core/tools/provider/builtin/getimgai/getimgai.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.getimgai.tools.text2image import Text2ImageTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class GetImgAIProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- # Example validation using the text2image tool
- Text2ImageTool().fork_tool_runtime(runtime={"credentials": credentials}).invoke(
- user_id="",
- tool_parameters={
- "prompt": "A fire egg",
- "response_format": "url",
- "style": "photorealism",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/getimgai/getimgai.yaml b/api/core/tools/provider/builtin/getimgai/getimgai.yaml
deleted file mode 100644
index c9db0a9e22..0000000000
--- a/api/core/tools/provider/builtin/getimgai/getimgai.yaml
+++ /dev/null
@@ -1,29 +0,0 @@
-identity:
- author: Matri Qi
- name: getimgai
- label:
- en_US: getimg.ai
- zh_CN: getimg.ai
- description:
- en_US: GetImg API integration for image generation and scraping.
- icon: icon.svg
- tags:
- - image
-credentials_for_provider:
- getimg_api_key:
- type: secret-input
- required: true
- label:
- en_US: getimg.ai API Key
- placeholder:
- en_US: Please input your getimg.ai API key
- help:
- en_US: Get your getimg.ai API key from your getimg.ai account settings. If you are using a self-hosted version, you may enter any key at your convenience.
- url: https://dashboard.getimg.ai/api-keys
- base_url:
- type: text-input
- required: false
- label:
- en_US: getimg.ai server's Base URL
- placeholder:
- en_US: https://api.getimg.ai/v1
diff --git a/api/core/tools/provider/builtin/getimgai/getimgai_appx.py b/api/core/tools/provider/builtin/getimgai/getimgai_appx.py
deleted file mode 100644
index 0e95a5f654..0000000000
--- a/api/core/tools/provider/builtin/getimgai/getimgai_appx.py
+++ /dev/null
@@ -1,55 +0,0 @@
-import logging
-import time
-from collections.abc import Mapping
-from typing import Any
-
-import requests
-from requests.exceptions import HTTPError
-
-logger = logging.getLogger(__name__)
-
-
-class GetImgAIApp:
- def __init__(self, api_key: str | None = None, base_url: str | None = None):
- self.api_key = api_key
- self.base_url = base_url or "https://api.getimg.ai/v1"
- if not self.api_key:
- raise ValueError("API key is required")
-
- def _prepare_headers(self):
- headers = {"Content-Type": "application/json", "Authorization": f"Bearer {self.api_key}"}
- return headers
-
- def _request(
- self,
- method: str,
- url: str,
- data: Mapping[str, Any] | None = None,
- headers: Mapping[str, str] | None = None,
- retries: int = 3,
- backoff_factor: float = 0.3,
- ) -> Mapping[str, Any] | None:
- for i in range(retries):
- try:
- response = requests.request(method, url, json=data, headers=headers)
- response.raise_for_status()
- return response.json()
- except requests.exceptions.RequestException as e:
- if i < retries - 1 and isinstance(e, HTTPError) and e.response.status_code >= 500:
- time.sleep(backoff_factor * (2**i))
- else:
- raise
- return None
-
- def text2image(self, mode: str, **kwargs):
- data = kwargs["params"]
- if not data.get("prompt"):
- raise ValueError("Prompt is required")
-
- endpoint = f"{self.base_url}/{mode}/text-to-image"
- headers = self._prepare_headers()
- logger.debug(f"Send request to {endpoint=} body={data}")
- response = self._request("POST", endpoint, data, headers)
- if response is None:
- raise HTTPError("Failed to initiate getimg.ai after multiple retries")
- return response
diff --git a/api/core/tools/provider/builtin/getimgai/tools/text2image.py b/api/core/tools/provider/builtin/getimgai/tools/text2image.py
deleted file mode 100644
index c556749552..0000000000
--- a/api/core/tools/provider/builtin/getimgai/tools/text2image.py
+++ /dev/null
@@ -1,39 +0,0 @@
-import json
-from typing import Any, Union
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.provider.builtin.getimgai.getimgai_appx import GetImgAIApp
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class Text2ImageTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- app = GetImgAIApp(
- api_key=self.runtime.credentials["getimg_api_key"], base_url=self.runtime.credentials["base_url"]
- )
-
- options = {
- "style": tool_parameters.get("style"),
- "prompt": tool_parameters.get("prompt"),
- "aspect_ratio": tool_parameters.get("aspect_ratio"),
- "output_format": tool_parameters.get("output_format", "jpeg"),
- "response_format": tool_parameters.get("response_format", "url"),
- "width": tool_parameters.get("width"),
- "height": tool_parameters.get("height"),
- "steps": tool_parameters.get("steps"),
- "negative_prompt": tool_parameters.get("negative_prompt"),
- "prompt_2": tool_parameters.get("prompt_2"),
- }
- options = {k: v for k, v in options.items() if v}
-
- text2image_result = app.text2image(mode=tool_parameters.get("mode", "essential-v2"), params=options, wait=True)
-
- if not isinstance(text2image_result, str):
- text2image_result = json.dumps(text2image_result, ensure_ascii=False, indent=4)
-
- if not text2image_result:
- return self.create_text_message("getimg.ai request failed.")
-
- return self.create_text_message(text2image_result)
diff --git a/api/core/tools/provider/builtin/getimgai/tools/text2image.yaml b/api/core/tools/provider/builtin/getimgai/tools/text2image.yaml
deleted file mode 100644
index d972186f56..0000000000
--- a/api/core/tools/provider/builtin/getimgai/tools/text2image.yaml
+++ /dev/null
@@ -1,167 +0,0 @@
-identity:
- name: text2image
- author: Matri Qi
- label:
- en_US: text2image
- icon: icon.svg
-description:
- human:
- en_US: Generate image via getimg.ai.
- llm: This tool is used to generate image from prompt or image via https://getimg.ai.
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: prompt
- human_description:
- en_US: The text prompt used to generate the image. The getimg.aier will generate an image based on this prompt.
- llm_description: this prompt text will be used to generate image.
- form: llm
- - name: mode
- type: select
- required: false
- label:
- en_US: mode
- human_description:
- en_US: The getimg.ai mode to use. The mode determines the endpoint used to generate the image.
- form: form
- options:
- - value: "essential-v2"
- label:
- en_US: essential-v2
- - value: stable-diffusion-xl
- label:
- en_US: stable-diffusion-xl
- - value: stable-diffusion
- label:
- en_US: stable-diffusion
- - value: latent-consistency
- label:
- en_US: latent-consistency
- - name: style
- type: select
- required: false
- label:
- en_US: style
- human_description:
- en_US: The style preset to use. The style preset guides the generation towards a particular style. It's just efficient for `Essential V2` mode.
- form: form
- options:
- - value: photorealism
- label:
- en_US: photorealism
- - value: anime
- label:
- en_US: anime
- - value: art
- label:
- en_US: art
- - name: aspect_ratio
- type: select
- required: false
- label:
- en_US: "aspect ratio"
- human_description:
- en_US: The aspect ratio of the generated image. It's just efficient for `Essential V2` mode.
- form: form
- options:
- - value: "1:1"
- label:
- en_US: "1:1"
- - value: "4:5"
- label:
- en_US: "4:5"
- - value: "5:4"
- label:
- en_US: "5:4"
- - value: "2:3"
- label:
- en_US: "2:3"
- - value: "3:2"
- label:
- en_US: "3:2"
- - value: "4:7"
- label:
- en_US: "4:7"
- - value: "7:4"
- label:
- en_US: "7:4"
- - name: output_format
- type: select
- required: false
- label:
- en_US: "output format"
- human_description:
- en_US: The file format of the generated image.
- form: form
- options:
- - value: jpeg
- label:
- en_US: jpeg
- - value: png
- label:
- en_US: png
- - name: response_format
- type: select
- required: false
- label:
- en_US: "response format"
- human_description:
- en_US: The format in which the generated images are returned. Must be one of url or b64. URLs are only valid for 1 hour after the image has been generated.
- form: form
- options:
- - value: url
- label:
- en_US: url
- - value: b64
- label:
- en_US: b64
- - name: model
- type: string
- required: false
- label:
- en_US: model
- human_description:
- en_US: Model ID supported by this pipeline and family. It's just efficient for `Stable Diffusion XL`, `Stable Diffusion`, `Latent Consistency` mode.
- form: form
- - name: negative_prompt
- type: string
- required: false
- label:
- en_US: negative prompt
- human_description:
- en_US: Text input that will not guide the image generation. It's just efficient for `Stable Diffusion XL`, `Stable Diffusion`, `Latent Consistency` mode.
- form: form
- - name: prompt_2
- type: string
- required: false
- label:
- en_US: prompt2
- human_description:
- en_US: Prompt sent to second tokenizer and text encoder. If not defined, prompt is used in both text-encoders. It's just efficient for `Stable Diffusion XL` mode.
- form: form
- - name: width
- type: number
- required: false
- label:
- en_US: width
- human_description:
- en_US: he width of the generated image in pixels. Width needs to be multiple of 64.
- form: form
- - name: height
- type: number
- required: false
- label:
- en_US: height
- human_description:
- en_US: he height of the generated image in pixels. Height needs to be multiple of 64.
- form: form
- - name: steps
- type: number
- required: false
- label:
- en_US: steps
- human_description:
- en_US: The number of denoising steps. More steps usually can produce higher quality images, but take more time to generate. It's just efficient for `Stable Diffusion XL`, `Stable Diffusion`, `Latent Consistency` mode.
- form: form
diff --git a/api/core/tools/provider/builtin/github/_assets/icon.svg b/api/core/tools/provider/builtin/github/_assets/icon.svg
deleted file mode 100644
index d56adb2c2f..0000000000
--- a/api/core/tools/provider/builtin/github/_assets/icon.svg
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/github/github.py b/api/core/tools/provider/builtin/github/github.py
deleted file mode 100644
index 87a34ac3e8..0000000000
--- a/api/core/tools/provider/builtin/github/github.py
+++ /dev/null
@@ -1,32 +0,0 @@
-import requests
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class GithubProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- if "access_tokens" not in credentials or not credentials.get("access_tokens"):
- raise ToolProviderCredentialValidationError("Github API Access Tokens is required.")
- if "api_version" not in credentials or not credentials.get("api_version"):
- api_version = "2022-11-28"
- else:
- api_version = credentials.get("api_version")
-
- try:
- headers = {
- "Content-Type": "application/vnd.github+json",
- "Authorization": f"Bearer {credentials.get('access_tokens')}",
- "X-GitHub-Api-Version": api_version,
- }
-
- response = requests.get(
- url="https://api.github.com/search/users?q={account}".format(account="charli117"), headers=headers
- )
- if response.status_code != 200:
- raise ToolProviderCredentialValidationError((response.json()).get("message"))
- except Exception as e:
- raise ToolProviderCredentialValidationError("Github API Key and Api Version is invalid. {}".format(e))
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/github/github.yaml b/api/core/tools/provider/builtin/github/github.yaml
deleted file mode 100644
index c3d85fc3f6..0000000000
--- a/api/core/tools/provider/builtin/github/github.yaml
+++ /dev/null
@@ -1,48 +0,0 @@
-identity:
- author: CharlieWei
- name: github
- label:
- en_US: Github
- zh_Hans: Github
- pt_BR: Github
- description:
- en_US: GitHub is an online software source code hosting service.
- zh_Hans: GitHub是一个在线软件源代码托管服务平台。
- pt_BR: GitHub é uma plataforma online para serviços de hospedagem de código fonte de software.
- icon: icon.svg
- tags:
- - utilities
-credentials_for_provider:
- access_tokens:
- type: secret-input
- required: true
- label:
- en_US: Access Tokens
- zh_Hans: Access Tokens
- pt_BR: Tokens de acesso
- placeholder:
- en_US: Please input your Github Access Tokens
- zh_Hans: 请输入你的 Github Access Tokens
- pt_BR: Insira seus Tokens de Acesso do Github
- help:
- en_US: Get your Access Tokens from Github
- zh_Hans: 从 Github 获取您的 Access Tokens
- pt_BR: Obtenha sua chave da API do Google no Google
- url: https://github.com/settings/tokens?type=beta
- api_version:
- type: text-input
- required: false
- default: '2022-11-28'
- label:
- en_US: API Version
- zh_Hans: API Version
- pt_BR: Versão da API
- placeholder:
- en_US: Please input your Github API Version
- zh_Hans: 请输入你的 Github API Version
- pt_BR: Insira sua versão da API do Github
- help:
- en_US: Get your API Version from Github
- zh_Hans: 从 Github 获取您的 API Version
- pt_BR: Obtenha sua versão da API do Github
- url: https://docs.github.com/en/rest/about-the-rest-api/api-versions?apiVersion=2022-11-28
diff --git a/api/core/tools/provider/builtin/github/tools/github_repositories.py b/api/core/tools/provider/builtin/github/tools/github_repositories.py
deleted file mode 100644
index 32f9922e65..0000000000
--- a/api/core/tools/provider/builtin/github/tools/github_repositories.py
+++ /dev/null
@@ -1,70 +0,0 @@
-import json
-from datetime import datetime
-from typing import Any, Union
-from urllib.parse import quote
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GithubRepositoriesTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- top_n = tool_parameters.get("top_n", 5)
- query = tool_parameters.get("query", "")
- if not query:
- return self.create_text_message("Please input symbol")
-
- if "access_tokens" not in self.runtime.credentials or not self.runtime.credentials.get("access_tokens"):
- return self.create_text_message("Github API Access Tokens is required.")
- if "api_version" not in self.runtime.credentials or not self.runtime.credentials.get("api_version"):
- api_version = "2022-11-28"
- else:
- api_version = self.runtime.credentials.get("api_version")
-
- try:
- headers = {
- "Content-Type": "application/vnd.github+json",
- "Authorization": f"Bearer {self.runtime.credentials.get('access_tokens')}",
- "X-GitHub-Api-Version": api_version,
- }
- s = requests.session()
- api_domain = "https://api.github.com"
- response = s.request(
- method="GET",
- headers=headers,
- url=f"{api_domain}/search/repositories?q={quote(query)}&sort=stars&per_page={top_n}&order=desc",
- )
- response_data = response.json()
- if response.status_code == 200 and isinstance(response_data.get("items"), list):
- contents = []
- if len(response_data.get("items")) > 0:
- for item in response_data.get("items"):
- content = {}
- updated_at_object = datetime.strptime(item["updated_at"], "%Y-%m-%dT%H:%M:%SZ")
- content["owner"] = item["owner"]["login"]
- content["name"] = item["name"]
- content["description"] = (
- item["description"][:100] + "..." if len(item["description"]) > 100 else item["description"]
- )
- content["url"] = item["html_url"]
- content["star"] = item["watchers"]
- content["forks"] = item["forks"]
- content["updated"] = updated_at_object.strftime("%Y-%m-%d")
- contents.append(content)
- s.close()
- return self.create_text_message(
- self.summary(user_id=user_id, content=json.dumps(contents, ensure_ascii=False))
- )
- else:
- return self.create_text_message(f"No items related to {query} were found.")
- else:
- return self.create_text_message((response.json()).get("message"))
- except Exception as e:
- return self.create_text_message("Github API Key and Api Version is invalid. {}".format(e))
diff --git a/api/core/tools/provider/builtin/github/tools/github_repositories.yaml b/api/core/tools/provider/builtin/github/tools/github_repositories.yaml
deleted file mode 100644
index c170aee797..0000000000
--- a/api/core/tools/provider/builtin/github/tools/github_repositories.yaml
+++ /dev/null
@@ -1,42 +0,0 @@
-identity:
- name: github_repositories
- author: CharlieWei
- label:
- en_US: Search Repositories
- zh_Hans: 仓库搜索
- pt_BR: Pesquisar Repositórios
- icon: icon.svg
-description:
- human:
- en_US: Search the Github repository to retrieve the open source projects you need
- zh_Hans: 搜索Github仓库,检索你需要的开源项目。
- pt_BR: Pesquise o repositório do Github para recuperar os projetos de código aberto necessários.
- llm: A tool when you wants to search for popular warehouses or open source projects for any keyword. format query condition like "keywords+language:js", language can be other dev languages.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: query
- zh_Hans: 关键字
- pt_BR: consulta
- human_description:
- en_US: You want to find the project development language, keywords, For example. Find 10 Python developed PDF document parsing projects.
- zh_Hans: 你想要找的项目开发语言、关键字,如:找10个Python开发的PDF文档解析项目。
- pt_BR: Você deseja encontrar a linguagem de desenvolvimento do projeto, palavras-chave, Por exemplo. Encontre 10 projetos de análise de documentos PDF desenvolvidos em Python.
- llm_description: The query of you want to search, format query condition like "keywords+language:js", language can be other dev languages.
- form: llm
- - name: top_n
- type: number
- default: 5
- required: true
- label:
- en_US: Top N
- zh_Hans: Top N
- pt_BR: Topo N
- human_description:
- en_US: Number of records returned by sorting based on stars. 5 is returned by default.
- zh_Hans: 基于stars排序返回的记录数, 默认返回5条。
- pt_BR: Número de registros retornados por classificação com base em estrelas. 5 é retornado por padrão.
- llm_description: Extract the first N records from the returned result.
- form: llm
diff --git a/api/core/tools/provider/builtin/gitlab/_assets/gitlab.svg b/api/core/tools/provider/builtin/gitlab/_assets/gitlab.svg
deleted file mode 100644
index 07734077d5..0000000000
--- a/api/core/tools/provider/builtin/gitlab/_assets/gitlab.svg
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/gitlab/gitlab.py b/api/core/tools/provider/builtin/gitlab/gitlab.py
deleted file mode 100644
index 9bd4a0bd52..0000000000
--- a/api/core/tools/provider/builtin/gitlab/gitlab.py
+++ /dev/null
@@ -1,32 +0,0 @@
-from typing import Any
-
-import requests
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class GitlabProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- if "access_tokens" not in credentials or not credentials.get("access_tokens"):
- raise ToolProviderCredentialValidationError("Gitlab Access Tokens is required.")
-
- if "site_url" not in credentials or not credentials.get("site_url"):
- site_url = "https://gitlab.com"
- else:
- site_url = credentials.get("site_url")
-
- try:
- headers = {
- "Content-Type": "application/vnd.text+json",
- "Authorization": f"Bearer {credentials.get('access_tokens')}",
- }
-
- response = requests.get(url=f"{site_url}/api/v4/user", headers=headers)
- if response.status_code != 200:
- raise ToolProviderCredentialValidationError((response.json()).get("message"))
- except Exception as e:
- raise ToolProviderCredentialValidationError("Gitlab Access Tokens is invalid. {}".format(e))
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/gitlab/gitlab.yaml b/api/core/tools/provider/builtin/gitlab/gitlab.yaml
deleted file mode 100644
index 22d7ebf73a..0000000000
--- a/api/core/tools/provider/builtin/gitlab/gitlab.yaml
+++ /dev/null
@@ -1,38 +0,0 @@
-identity:
- author: Leo.Wang
- name: gitlab
- label:
- en_US: GitLab
- zh_Hans: GitLab
- description:
- en_US: GitLab plugin, API v4 only.
- zh_Hans: 用于获取GitLab内容的插件,目前仅支持 API v4。
- icon: gitlab.svg
-credentials_for_provider:
- access_tokens:
- type: secret-input
- required: true
- label:
- en_US: GitLab access token
- zh_Hans: GitLab access token
- placeholder:
- en_US: Please input your GitLab access token
- zh_Hans: 请输入你的 GitLab access token
- help:
- en_US: Get your GitLab access token from GitLab
- zh_Hans: 从 GitLab 获取您的 access token
- url: https://docs.gitlab.com/16.9/ee/api/oauth2.html
- site_url:
- type: text-input
- required: false
- default: 'https://gitlab.com'
- label:
- en_US: GitLab site url
- zh_Hans: GitLab site url
- placeholder:
- en_US: Please input your GitLab site url
- zh_Hans: 请输入你的 GitLab site url
- help:
- en_US: Find your GitLab url
- zh_Hans: 找到你的 GitLab url
- url: https://gitlab.com/help
diff --git a/api/core/tools/provider/builtin/gitlab/tools/gitlab_commits.py b/api/core/tools/provider/builtin/gitlab/tools/gitlab_commits.py
deleted file mode 100644
index 45ab15f437..0000000000
--- a/api/core/tools/provider/builtin/gitlab/tools/gitlab_commits.py
+++ /dev/null
@@ -1,142 +0,0 @@
-import json
-import urllib.parse
-from datetime import datetime, timedelta
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GitlabCommitsTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- project = tool_parameters.get("project", "")
- repository = tool_parameters.get("repository", "")
- employee = tool_parameters.get("employee", "")
- start_time = tool_parameters.get("start_time", "")
- end_time = tool_parameters.get("end_time", "")
- change_type = tool_parameters.get("change_type", "all")
-
- if not project and not repository:
- return self.create_text_message("Either project or repository is required")
-
- if not start_time:
- start_time = (datetime.utcnow() - timedelta(days=1)).isoformat()
- if not end_time:
- end_time = datetime.utcnow().isoformat()
-
- access_token = self.runtime.credentials.get("access_tokens")
- site_url = self.runtime.credentials.get("site_url")
-
- if "access_tokens" not in self.runtime.credentials or not self.runtime.credentials.get("access_tokens"):
- return self.create_text_message("Gitlab API Access Tokens is required.")
- if "site_url" not in self.runtime.credentials or not self.runtime.credentials.get("site_url"):
- site_url = "https://gitlab.com"
-
- # Get commit content
- if repository:
- result = self.fetch_commits(
- site_url, access_token, repository, employee, start_time, end_time, change_type, is_repository=True
- )
- else:
- result = self.fetch_commits(
- site_url, access_token, project, employee, start_time, end_time, change_type, is_repository=False
- )
-
- return [self.create_json_message(item) for item in result]
-
- def fetch_commits(
- self,
- site_url: str,
- access_token: str,
- identifier: str,
- employee: str,
- start_time: str,
- end_time: str,
- change_type: str,
- is_repository: bool,
- ) -> list[dict[str, Any]]:
- domain = site_url
- headers = {"PRIVATE-TOKEN": access_token}
- results = []
-
- try:
- if is_repository:
- # URL encode the repository path
- encoded_identifier = urllib.parse.quote(identifier, safe="")
- commits_url = f"{domain}/api/v4/projects/{encoded_identifier}/repository/commits"
- else:
- # Get all projects
- url = f"{domain}/api/v4/projects"
- response = requests.get(url, headers=headers)
- response.raise_for_status()
- projects = response.json()
-
- filtered_projects = [p for p in projects if identifier == "*" or p["name"] == identifier]
-
- for project in filtered_projects:
- project_id = project["id"]
- project_name = project["name"]
- print(f"Project: {project_name}")
-
- commits_url = f"{domain}/api/v4/projects/{project_id}/repository/commits"
-
- params = {"since": start_time, "until": end_time}
- if employee:
- params["author"] = employee
-
- commits_response = requests.get(commits_url, headers=headers, params=params)
- commits_response.raise_for_status()
- commits = commits_response.json()
-
- for commit in commits:
- commit_sha = commit["id"]
- author_name = commit["author_name"]
-
- if is_repository:
- diff_url = f"{domain}/api/v4/projects/{encoded_identifier}/repository/commits/{commit_sha}/diff"
- else:
- diff_url = f"{domain}/api/v4/projects/{project_id}/repository/commits/{commit_sha}/diff"
-
- diff_response = requests.get(diff_url, headers=headers)
- diff_response.raise_for_status()
- diffs = diff_response.json()
-
- for diff in diffs:
- # Calculate code lines of changes
- added_lines = diff["diff"].count("\n+")
- removed_lines = diff["diff"].count("\n-")
- total_changes = added_lines + removed_lines
-
- if change_type == "new":
- if added_lines > 1:
- final_code = "".join(
- [
- line[1:]
- for line in diff["diff"].split("\n")
- if line.startswith("+") and not line.startswith("+++")
- ]
- )
- results.append({"commit_sha": commit_sha, "author_name": author_name, "diff": final_code})
- else:
- if total_changes > 1:
- final_code = "".join(
- [
- line[1:]
- for line in diff["diff"].split("\n")
- if (line.startswith("+") or line.startswith("-"))
- and not line.startswith("+++")
- and not line.startswith("---")
- ]
- )
- final_code_escaped = json.dumps(final_code)[1:-1] # Escape the final code
- results.append(
- {"commit_sha": commit_sha, "author_name": author_name, "diff": final_code_escaped}
- )
- except requests.RequestException as e:
- print(f"Error fetching data from GitLab: {e}")
-
- return results
diff --git a/api/core/tools/provider/builtin/gitlab/tools/gitlab_commits.yaml b/api/core/tools/provider/builtin/gitlab/tools/gitlab_commits.yaml
deleted file mode 100644
index 669378ac97..0000000000
--- a/api/core/tools/provider/builtin/gitlab/tools/gitlab_commits.yaml
+++ /dev/null
@@ -1,88 +0,0 @@
-identity:
- name: gitlab_commits
- author: Leo.Wang
- label:
- en_US: GitLab Commits
- zh_Hans: GitLab 提交内容查询
-description:
- human:
- en_US: A tool for query GitLab commits, Input should be a exists username or project.
- zh_Hans: 一个用于查询 GitLab 代码提交内容的工具,输入的内容应该是一个已存在的用户名或者项目名。
- llm: A tool for query GitLab commits, Input should be a exists username or project.
-parameters:
- - name: username
- type: string
- required: false
- label:
- en_US: username
- zh_Hans: 员工用户名
- human_description:
- en_US: username
- zh_Hans: 员工用户名
- llm_description: User name for GitLab
- form: llm
- - name: repository
- type: string
- required: false
- label:
- en_US: repository
- zh_Hans: 仓库路径
- human_description:
- en_US: repository
- zh_Hans: 仓库路径,以namespace/project_name的形式。
- llm_description: Repository path for GitLab, like namespace/project_name.
- form: llm
- - name: project
- type: string
- required: false
- label:
- en_US: project
- zh_Hans: 项目名
- human_description:
- en_US: project
- zh_Hans: 项目名
- llm_description: project for GitLab
- form: llm
- - name: start_time
- type: string
- required: false
- label:
- en_US: start_time
- zh_Hans: 开始时间
- human_description:
- en_US: start_time
- zh_Hans: 开始时间
- llm_description: Start time for GitLab
- form: llm
- - name: end_time
- type: string
- required: false
- label:
- en_US: end_time
- zh_Hans: 结束时间
- human_description:
- en_US: end_time
- zh_Hans: 结束时间
- llm_description: End time for GitLab
- form: llm
- - name: change_type
- type: select
- required: false
- options:
- - value: all
- label:
- en_US: all
- zh_Hans: 所有
- - value: new
- label:
- en_US: new
- zh_Hans: 新增
- default: all
- label:
- en_US: change_type
- zh_Hans: 变更类型
- human_description:
- en_US: change_type
- zh_Hans: 变更类型
- llm_description: Content change type for GitLab
- form: llm
diff --git a/api/core/tools/provider/builtin/gitlab/tools/gitlab_files.py b/api/core/tools/provider/builtin/gitlab/tools/gitlab_files.py
deleted file mode 100644
index 1e77f3c6df..0000000000
--- a/api/core/tools/provider/builtin/gitlab/tools/gitlab_files.py
+++ /dev/null
@@ -1,103 +0,0 @@
-import urllib.parse
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GitlabFilesTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- project = tool_parameters.get("project", "")
- repository = tool_parameters.get("repository", "")
- branch = tool_parameters.get("branch", "")
- path = tool_parameters.get("path", "")
-
- if not project and not repository:
- return self.create_text_message("Either project or repository is required")
- if not branch:
- return self.create_text_message("Branch is required")
- if not path:
- return self.create_text_message("Path is required")
-
- access_token = self.runtime.credentials.get("access_tokens")
- site_url = self.runtime.credentials.get("site_url")
-
- if "access_tokens" not in self.runtime.credentials or not self.runtime.credentials.get("access_tokens"):
- return self.create_text_message("Gitlab API Access Tokens is required.")
- if "site_url" not in self.runtime.credentials or not self.runtime.credentials.get("site_url"):
- site_url = "https://gitlab.com"
-
- # Get file content
- if repository:
- result = self.fetch_files(site_url, access_token, repository, branch, path, is_repository=True)
- else:
- result = self.fetch_files(site_url, access_token, project, branch, path, is_repository=False)
-
- return [self.create_json_message(item) for item in result]
-
- def fetch_files(
- self, site_url: str, access_token: str, identifier: str, branch: str, path: str, is_repository: bool
- ) -> list[dict[str, Any]]:
- domain = site_url
- headers = {"PRIVATE-TOKEN": access_token}
- results = []
-
- try:
- if is_repository:
- # URL encode the repository path
- encoded_identifier = urllib.parse.quote(identifier, safe="")
- tree_url = f"{domain}/api/v4/projects/{encoded_identifier}/repository/tree?path={path}&ref={branch}"
- else:
- # Get project ID from project name
- project_id = self.get_project_id(site_url, access_token, identifier)
- if not project_id:
- return self.create_text_message(f"Project '{identifier}' not found.")
- tree_url = f"{domain}/api/v4/projects/{project_id}/repository/tree?path={path}&ref={branch}"
-
- response = requests.get(tree_url, headers=headers)
- response.raise_for_status()
- items = response.json()
-
- for item in items:
- item_path = item["path"]
- if item["type"] == "tree": # It's a directory
- results.extend(
- self.fetch_files(site_url, access_token, identifier, branch, item_path, is_repository)
- )
- else: # It's a file
- if is_repository:
- file_url = (
- f"{domain}/api/v4/projects/{encoded_identifier}/repository/files"
- f"/{item_path}/raw?ref={branch}"
- )
- else:
- file_url = (
- f"{domain}/api/v4/projects/{project_id}/repository/files/{item_path}/raw?ref={branch}"
- )
-
- file_response = requests.get(file_url, headers=headers)
- file_response.raise_for_status()
- file_content = file_response.text
- results.append({"path": item_path, "branch": branch, "content": file_content})
- except requests.RequestException as e:
- print(f"Error fetching data from GitLab: {e}")
-
- return results
-
- def get_project_id(self, site_url: str, access_token: str, project_name: str) -> Union[str, None]:
- headers = {"PRIVATE-TOKEN": access_token}
- try:
- url = f"{site_url}/api/v4/projects?search={project_name}"
- response = requests.get(url, headers=headers)
- response.raise_for_status()
- projects = response.json()
- for project in projects:
- if project["name"] == project_name:
- return project["id"]
- except requests.RequestException as e:
- print(f"Error fetching project ID from GitLab: {e}")
- return None
diff --git a/api/core/tools/provider/builtin/gitlab/tools/gitlab_files.yaml b/api/core/tools/provider/builtin/gitlab/tools/gitlab_files.yaml
deleted file mode 100644
index 4c733673f1..0000000000
--- a/api/core/tools/provider/builtin/gitlab/tools/gitlab_files.yaml
+++ /dev/null
@@ -1,56 +0,0 @@
-identity:
- name: gitlab_files
- author: Leo.Wang
- label:
- en_US: GitLab Files
- zh_Hans: GitLab 文件获取
-description:
- human:
- en_US: A tool for query GitLab files, Input should be branch and a exists file or directory path.
- zh_Hans: 一个用于查询 GitLab 文件的工具,输入的内容应该是分支和一个已存在文件或者文件夹路径。
- llm: A tool for query GitLab files, Input should be a exists file or directory path.
-parameters:
- - name: repository
- type: string
- required: false
- label:
- en_US: repository
- zh_Hans: 仓库路径
- human_description:
- en_US: repository
- zh_Hans: 仓库路径,以namespace/project_name的形式。
- llm_description: Repository path for GitLab, like namespace/project_name.
- form: llm
- - name: project
- type: string
- required: false
- label:
- en_US: project
- zh_Hans: 项目
- human_description:
- en_US: project
- zh_Hans: 项目
- llm_description: Project for GitLab
- form: llm
- - name: branch
- type: string
- required: true
- label:
- en_US: branch
- zh_Hans: 分支
- human_description:
- en_US: branch
- zh_Hans: 分支
- llm_description: Branch for GitLab
- form: llm
- - name: path
- type: string
- required: true
- label:
- en_US: path
- zh_Hans: 文件路径
- human_description:
- en_US: path
- zh_Hans: 文件路径
- llm_description: File path for GitLab
- form: llm
diff --git a/api/core/tools/provider/builtin/google/_assets/icon.svg b/api/core/tools/provider/builtin/google/_assets/icon.svg
deleted file mode 100644
index bebbf52d3a..0000000000
--- a/api/core/tools/provider/builtin/google/_assets/icon.svg
+++ /dev/null
@@ -1,6 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/google/google.py b/api/core/tools/provider/builtin/google/google.py
deleted file mode 100644
index 6b5395f9d3..0000000000
--- a/api/core/tools/provider/builtin/google/google.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.google.tools.google_search import GoogleSearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class GoogleProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- GoogleSearchTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={"query": "test", "result_type": "link"},
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/google/google.yaml b/api/core/tools/provider/builtin/google/google.yaml
deleted file mode 100644
index afb4d5b214..0000000000
--- a/api/core/tools/provider/builtin/google/google.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-identity:
- author: Dify
- name: google
- label:
- en_US: Google
- zh_Hans: Google
- pt_BR: Google
- description:
- en_US: Google
- zh_Hans: GoogleSearch
- pt_BR: Google
- icon: icon.svg
- tags:
- - search
-credentials_for_provider:
- serpapi_api_key:
- type: secret-input
- required: true
- label:
- en_US: SerpApi API key
- zh_Hans: SerpApi API key
- pt_BR: SerpApi API key
- placeholder:
- en_US: Please input your SerpApi API key
- zh_Hans: 请输入你的 SerpApi API key
- pt_BR: Please input your SerpApi API key
- help:
- en_US: Get your SerpApi API key from SerpApi
- zh_Hans: 从 SerpApi 获取您的 SerpApi API key
- pt_BR: Get your SerpApi API key from SerpApi
- url: https://serpapi.com/manage-api-key
diff --git a/api/core/tools/provider/builtin/google/tools/google_search.py b/api/core/tools/provider/builtin/google/tools/google_search.py
deleted file mode 100644
index a9f65925d8..0000000000
--- a/api/core/tools/provider/builtin/google/tools/google_search.py
+++ /dev/null
@@ -1,40 +0,0 @@
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-SERP_API_URL = "https://serpapi.com/search"
-
-
-class GoogleSearchTool(BuiltinTool):
- def _parse_response(self, response: dict) -> dict:
- result = {}
- if "knowledge_graph" in response:
- result["title"] = response["knowledge_graph"].get("title", "")
- result["description"] = response["knowledge_graph"].get("description", "")
- if "organic_results" in response:
- result["organic_results"] = [
- {"title": item.get("title", ""), "link": item.get("link", ""), "snippet": item.get("snippet", "")}
- for item in response["organic_results"]
- ]
- return result
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- params = {
- "api_key": self.runtime.credentials["serpapi_api_key"],
- "q": tool_parameters["query"],
- "engine": "google",
- "google_domain": "google.com",
- "gl": "us",
- "hl": "en",
- }
- response = requests.get(url=SERP_API_URL, params=params)
- response.raise_for_status()
- valuable_res = self._parse_response(response.json())
- return self.create_json_message(valuable_res)
diff --git a/api/core/tools/provider/builtin/google/tools/google_search.yaml b/api/core/tools/provider/builtin/google/tools/google_search.yaml
deleted file mode 100644
index 72db3839eb..0000000000
--- a/api/core/tools/provider/builtin/google/tools/google_search.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-identity:
- name: google_search
- author: Dify
- label:
- en_US: GoogleSearch
- zh_Hans: 谷歌搜索
- pt_BR: GoogleSearch
-description:
- human:
- en_US: A tool for performing a Google SERP search and extracting snippets and webpages.Input should be a search query.
- zh_Hans: 一个用于执行 Google SERP 搜索并提取片段和网页的工具。输入应该是一个搜索查询。
- pt_BR: A tool for performing a Google SERP search and extracting snippets and webpages.Input should be a search query.
- llm: A tool for performing a Google SERP search and extracting snippets and webpages.Input should be a search query.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query string
- zh_Hans: 查询语句
- pt_BR: Query string
- human_description:
- en_US: used for searching
- zh_Hans: 用于搜索网页内容
- pt_BR: used for searching
- llm_description: key words for searching
- form: llm
diff --git a/api/core/tools/provider/builtin/google_translate/_assets/icon.svg b/api/core/tools/provider/builtin/google_translate/_assets/icon.svg
deleted file mode 100644
index de69a9c5e5..0000000000
--- a/api/core/tools/provider/builtin/google_translate/_assets/icon.svg
+++ /dev/null
@@ -1,18 +0,0 @@
-
diff --git a/api/core/tools/provider/builtin/google_translate/google_translate.py b/api/core/tools/provider/builtin/google_translate/google_translate.py
deleted file mode 100644
index ea53aa4eeb..0000000000
--- a/api/core/tools/provider/builtin/google_translate/google_translate.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.google_translate.tools.translate import GoogleTranslate
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class JsonExtractProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- GoogleTranslate().invoke(user_id="", tool_parameters={"content": "这是一段测试文本", "dest": "en"})
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/google_translate/google_translate.yaml b/api/core/tools/provider/builtin/google_translate/google_translate.yaml
deleted file mode 100644
index 8bc821a3d5..0000000000
--- a/api/core/tools/provider/builtin/google_translate/google_translate.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-identity:
- author: Ron Liu
- name: google_translate
- label:
- en_US: Google Translate
- zh_Hans: 谷歌翻译
- description:
- en_US: Translate text using Google
- zh_Hans: 使用 Google 进行翻译
- icon: icon.svg
- tags:
- - utilities
diff --git a/api/core/tools/provider/builtin/google_translate/tools/translate.py b/api/core/tools/provider/builtin/google_translate/tools/translate.py
deleted file mode 100644
index ea3f2077d5..0000000000
--- a/api/core/tools/provider/builtin/google_translate/tools/translate.py
+++ /dev/null
@@ -1,47 +0,0 @@
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GoogleTranslate(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- content = tool_parameters.get("content", "")
- if not content:
- return self.create_text_message("Invalid parameter content")
-
- dest = tool_parameters.get("dest", "")
- if not dest:
- return self.create_text_message("Invalid parameter destination language")
-
- try:
- result = self._translate(content, dest)
- return self.create_text_message(str(result))
- except Exception:
- return self.create_text_message("Translation service error, please check the network")
-
- def _translate(self, content: str, dest: str) -> str:
- try:
- url = "https://translate.googleapis.com/translate_a/single"
- params = {"client": "gtx", "sl": "auto", "tl": dest, "dt": "t", "q": content}
-
- headers = {
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)"
- " Chrome/91.0.4472.124 Safari/537.36"
- }
-
- response_json = requests.get(url, params=params, headers=headers).json()
- result = response_json[0]
- translated_text = "".join([item[0] for item in result if item[0]])
- return str(translated_text)
- except Exception as e:
- return str(e)
diff --git a/api/core/tools/provider/builtin/google_translate/tools/translate.yaml b/api/core/tools/provider/builtin/google_translate/tools/translate.yaml
deleted file mode 100644
index a4189cd743..0000000000
--- a/api/core/tools/provider/builtin/google_translate/tools/translate.yaml
+++ /dev/null
@@ -1,215 +0,0 @@
-identity:
- name: translate
- author: Ron Liu
- label:
- en_US: Translate
- zh_Hans: 翻译
-description:
- human:
- en_US: A tool for Google Translate
- zh_Hans: Google 翻译
- llm: A tool for Google Translate
-parameters:
- - name: content
- type: string
- required: true
- label:
- en_US: Text content
- zh_Hans: 文本内容
- human_description:
- en_US: Text content
- zh_Hans: 需要翻译的文本内容
- llm_description: Text content
- form: llm
- - name: dest
- type: select
- required: true
- label:
- en_US: destination language
- zh_Hans: 目标语言
- human_description:
- en_US: The destination language you want to translate.
- zh_Hans: 你想翻译的目标语言
- default: en
- form: form
- options:
- - value: ar
- label:
- en_US: Arabic
- zh_Hans: 阿拉伯语
- - value: bg
- label:
- en_US: Bulgarian
- zh_Hans: 保加利亚语
- - value: ca
- label:
- en_US: Catalan
- zh_Hans: 加泰罗尼亚语
- - value: zh-cn
- label:
- en_US: Chinese (Simplified)
- zh_Hans: 中文(简体)
- - value: zh-tw
- label:
- en_US: Chinese (Traditional)
- zh_Hans: 中文(繁体)
- - value: cs
- label:
- en_US: Czech
- zh_Hans: 捷克语
- - value: da
- label:
- en_US: Danish
- zh_Hans: 丹麦语
- - value: nl
- label:
- en_US: Dutch
- zh_Hans: 荷兰语
- - value: en
- label:
- en_US: English
- zh_Hans: 英语
- - value: et
- label:
- en_US: Estonian
- zh_Hans: 爱沙尼亚语
- - value: fi
- label:
- en_US: Finnish
- zh_Hans: 芬兰语
- - value: fr
- label:
- en_US: French
- zh_Hans: 法语
- - value: de
- label:
- en_US: German
- zh_Hans: 德语
- - value: el
- label:
- en_US: Greek
- zh_Hans: 希腊语
- - value: iw
- label:
- en_US: Hebrew
- zh_Hans: 希伯来语
- - value: hi
- label:
- en_US: Hindi
- zh_Hans: 印地语
- - value: hu
- label:
- en_US: Hungarian
- zh_Hans: 匈牙利语
- - value: id
- label:
- en_US: Indonesian
- zh_Hans: 印尼语
- - value: it
- label:
- en_US: Italian
- zh_Hans: 意大利语
- - value: ja
- label:
- en_US: Japanese
- zh_Hans: 日语
- - value: kn
- label:
- en_US: Kannada
- zh_Hans: 卡纳达语
- - value: ko
- label:
- en_US: Korean
- zh_Hans: 韩语
- - value: lv
- label:
- en_US: Latvian
- zh_Hans: 拉脱维亚语
- - value: lt
- label:
- en_US: Lithuanian
- zh_Hans: 立陶宛语
- - value: my
- label:
- en_US: Malay
- zh_Hans: 马来语
- - value: ml
- label:
- en_US: Malayalam
- zh_Hans: 马拉雅拉姆语
- - value: mr
- label:
- en_US: Marathi
- zh_Hans: 马拉地语
- - value: "no"
- label:
- en_US: Norwegian
- zh_Hans: 挪威语
- - value: pl
- label:
- en_US: Polish
- zh_Hans: 波兰语
- - value: pt-br
- label:
- en_US: Portuguese (Brazil)
- zh_Hans: 葡萄牙语(巴西)
- - value: pt-pt
- label:
- en_US: Portuguese (Portugal)
- zh_Hans: 葡萄牙语(葡萄牙)
- - value: pa
- label:
- en_US: Punjabi
- zh_Hans: 旁遮普语
- - value: ro
- label:
- en_US: Romanian
- zh_Hans: 罗马尼亚语
- - value: ru
- label:
- en_US: Russian
- zh_Hans: 俄语
- - value: sr
- label:
- en_US: Serbian
- zh_Hans: 塞尔维亚语
- - value: sk
- label:
- en_US: Slovak
- zh_Hans: 斯洛伐克语
- - value: sl
- label:
- en_US: Slovenian
- zh_Hans: 斯洛文尼亚语
- - value: es
- label:
- en_US: Spanish
- zh_Hans: 西班牙语
- - value: sv
- label:
- en_US: Swedish
- zh_Hans: 瑞典语
- - value: ta
- label:
- en_US: Tamil
- zh_Hans: 泰米尔语
- - value: te
- label:
- en_US: Telugu
- zh_Hans: 泰卢固语
- - value: th
- label:
- en_US: Thai
- zh_Hans: 泰语
- - value: tr
- label:
- en_US: Turkish
- zh_Hans: 土耳其语
- - value: uk
- label:
- en_US: Ukrainian
- zh_Hans: 乌克兰语
- - value: vi
- label:
- en_US: Vietnamese
- zh_Hans: 越南语
diff --git a/api/core/tools/provider/builtin/hap/_assets/icon.svg b/api/core/tools/provider/builtin/hap/_assets/icon.svg
deleted file mode 100644
index 0fa6f0886f..0000000000
--- a/api/core/tools/provider/builtin/hap/_assets/icon.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
diff --git a/api/core/tools/provider/builtin/hap/hap.py b/api/core/tools/provider/builtin/hap/hap.py
deleted file mode 100644
index cbdf950465..0000000000
--- a/api/core/tools/provider/builtin/hap/hap.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from typing import Any
-
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class HapProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- pass
diff --git a/api/core/tools/provider/builtin/hap/hap.yaml b/api/core/tools/provider/builtin/hap/hap.yaml
deleted file mode 100644
index 25b473cf9d..0000000000
--- a/api/core/tools/provider/builtin/hap/hap.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-identity:
- author: Mingdao
- name: hap
- label:
- en_US: HAP
- zh_Hans: HAP
- pt_BR: HAP
- description:
- en_US: "Hyper application platform that is particularly friendly to AI"
- zh_Hans: "对 AI 特别友好的超级应用平台"
- pt_BR: "Plataforma de aplicação hiper que é particularmente amigável à IA"
- icon: icon.svg
- tags:
- - productivity
-credentials_for_provider:
diff --git a/api/core/tools/provider/builtin/hap/tools/add_worksheet_record.py b/api/core/tools/provider/builtin/hap/tools/add_worksheet_record.py
deleted file mode 100644
index 597adc91db..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/add_worksheet_record.py
+++ /dev/null
@@ -1,52 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class AddWorksheetRecordTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- appkey = tool_parameters.get("appkey", "")
- if not appkey:
- return self.create_text_message("Invalid parameter App Key")
- sign = tool_parameters.get("sign", "")
- if not sign:
- return self.create_text_message("Invalid parameter Sign")
- worksheet_id = tool_parameters.get("worksheet_id", "")
- if not worksheet_id:
- return self.create_text_message("Invalid parameter Worksheet ID")
- record_data = tool_parameters.get("record_data", "")
- if not record_data:
- return self.create_text_message("Invalid parameter Record Row Data")
-
- host = tool_parameters.get("host", "")
- if not host:
- host = "https://api.mingdao.com"
- elif not host.startswith(("http://", "https://")):
- return self.create_text_message("Invalid parameter Host Address")
- else:
- host = f"{host.removesuffix('/')}/api"
-
- url = f"{host}/v2/open/worksheet/addRow"
- headers = {"Content-Type": "application/json"}
- payload = {"appKey": appkey, "sign": sign, "worksheetId": worksheet_id}
-
- try:
- payload["controls"] = json.loads(record_data)
- res = httpx.post(url, headers=headers, json=payload, timeout=60)
- res.raise_for_status()
- res_json = res.json()
- if res_json.get("error_code") != 1:
- return self.create_text_message(f"Failed to add the new record. {res_json['error_msg']}")
- return self.create_text_message(f"New record added successfully. The record ID is {res_json['data']}.")
- except httpx.RequestError as e:
- return self.create_text_message(f"Failed to add the new record, request error: {e}")
- except json.JSONDecodeError as e:
- return self.create_text_message(f"Failed to parse JSON response: {e}")
- except Exception as e:
- return self.create_text_message(f"Failed to add the new record, unexpected error: {e}")
diff --git a/api/core/tools/provider/builtin/hap/tools/add_worksheet_record.yaml b/api/core/tools/provider/builtin/hap/tools/add_worksheet_record.yaml
deleted file mode 100644
index add7742cd7..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/add_worksheet_record.yaml
+++ /dev/null
@@ -1,78 +0,0 @@
-identity:
- name: add_worksheet_record
- author: Ryan Tian
- label:
- en_US: Add Worksheet Record
- zh_Hans: 新增一条工作表记录
-description:
- human:
- en_US: Adds a new record to the specified worksheet
- zh_Hans: 向指定的工作表新增一条记录数据
- llm: A tool to append a new data entry into a specified worksheet.
-parameters:
- - name: appkey
- type: secret-input
- required: true
- label:
- en_US: App Key
- zh_Hans: App Key
- human_description:
- en_US: The AppKey parameter for the HAP application, typically found in the application's API documentation.
- zh_Hans: HAP 应用的 AppKey 参数,可以从应用 API 文档中查找到
- llm_description: the AppKey parameter for the HAP application
- form: form
-
- - name: sign
- type: secret-input
- required: true
- label:
- en_US: Sign
- zh_Hans: Sign
- human_description:
- en_US: The Sign parameter for the HAP application
- zh_Hans: HAP 应用的 Sign 参数
- llm_description: the Sign parameter for the HAP application
- form: form
-
- - name: worksheet_id
- type: string
- required: true
- label:
- en_US: Worksheet ID
- zh_Hans: 工作表 ID
- human_description:
- en_US: The ID of the specified worksheet
- zh_Hans: 要获取字段信息的工作表 ID
- llm_description: The ID of the specified worksheet which to get the fields information.
- form: llm
-
- - name: record_data
- type: string
- required: true
- label:
- en_US: Record Row Data
- zh_Hans: 记录数据
- human_description:
- en_US: The fields with data of the specified record
- zh_Hans: 要新增的记录数据,JSON 对象数组格式。数组元素属性:controlId-字段ID,value-字段值
- llm_description: |
- The fields with data of the specified record which to be created. It is in the format of an array of JSON objects, and the structure is defined as follows:
- ```
- type RowData = {
- controlId: string; // Field ID to be updated
- value: string; // Field value to be updated
- }[];
- ```
- form: llm
-
- - name: host
- type: string
- required: false
- label:
- en_US: Host Address
- zh_Hans: 服务器地址
- human_description:
- en_US: The address for the privately deployed HAP server.
- zh_Hans: 私有部署 HAP 服务器地址,公有云无需填写
- llm_description: the address for the privately deployed HAP server.
- form: form
diff --git a/api/core/tools/provider/builtin/hap/tools/delete_worksheet_record.py b/api/core/tools/provider/builtin/hap/tools/delete_worksheet_record.py
deleted file mode 100644
index 5d42af4c49..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/delete_worksheet_record.py
+++ /dev/null
@@ -1,48 +0,0 @@
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class DeleteWorksheetRecordTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- appkey = tool_parameters.get("appkey", "")
- if not appkey:
- return self.create_text_message("Invalid parameter App Key")
- sign = tool_parameters.get("sign", "")
- if not sign:
- return self.create_text_message("Invalid parameter Sign")
- worksheet_id = tool_parameters.get("worksheet_id", "")
- if not worksheet_id:
- return self.create_text_message("Invalid parameter Worksheet ID")
- row_id = tool_parameters.get("row_id", "")
- if not row_id:
- return self.create_text_message("Invalid parameter Record Row ID")
-
- host = tool_parameters.get("host", "")
- if not host:
- host = "https://api.mingdao.com"
- elif not host.startswith(("http://", "https://")):
- return self.create_text_message("Invalid parameter Host Address")
- else:
- host = f"{host.removesuffix('/')}/api"
-
- url = f"{host}/v2/open/worksheet/deleteRow"
- headers = {"Content-Type": "application/json"}
- payload = {"appKey": appkey, "sign": sign, "worksheetId": worksheet_id, "rowId": row_id}
-
- try:
- res = httpx.post(url, headers=headers, json=payload, timeout=30)
- res.raise_for_status()
- res_json = res.json()
- if res_json.get("error_code") != 1:
- return self.create_text_message(f"Failed to delete the record. {res_json['error_msg']}")
- return self.create_text_message("Successfully deleted the record.")
- except httpx.RequestError as e:
- return self.create_text_message(f"Failed to delete the record, request error: {e}")
- except Exception as e:
- return self.create_text_message(f"Failed to delete the record, unexpected error: {e}")
diff --git a/api/core/tools/provider/builtin/hap/tools/delete_worksheet_record.yaml b/api/core/tools/provider/builtin/hap/tools/delete_worksheet_record.yaml
deleted file mode 100644
index 7c0c2a6439..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/delete_worksheet_record.yaml
+++ /dev/null
@@ -1,71 +0,0 @@
-identity:
- name: delete_worksheet_record
- author: Ryan Tian
- label:
- en_US: Delete Worksheet Record
- zh_Hans: 删除指定的一条工作表记录
-description:
- human:
- en_US: Deletes a single record from a worksheet based on the specified record row ID
- zh_Hans: 根据指定的记录ID删除一条工作表记录数据
- llm: A tool to remove a particular record from a worksheet by specifying its unique record identifier.
-parameters:
- - name: appkey
- type: secret-input
- required: true
- label:
- en_US: App Key
- zh_Hans: App Key
- human_description:
- en_US: The AppKey parameter for the HAP application, typically found in the application's API documentation.
- zh_Hans: HAP 应用的 AppKey 参数,可以从应用 API 文档中查找到
- llm_description: the AppKey parameter for the HAP application
- form: form
-
- - name: sign
- type: secret-input
- required: true
- label:
- en_US: Sign
- zh_Hans: Sign
- human_description:
- en_US: The Sign parameter for the HAP application
- zh_Hans: HAP 应用的 Sign 参数
- llm_description: the Sign parameter for the HAP application
- form: form
-
- - name: worksheet_id
- type: string
- required: true
- label:
- en_US: Worksheet ID
- zh_Hans: 工作表 ID
- human_description:
- en_US: The ID of the specified worksheet
- zh_Hans: 要获取字段信息的工作表 ID
- llm_description: The ID of the specified worksheet which to get the fields information.
- form: llm
-
- - name: row_id
- type: string
- required: true
- label:
- en_US: Record Row ID
- zh_Hans: 记录 ID
- human_description:
- en_US: The row ID of the specified record
- zh_Hans: 要删除的记录 ID
- llm_description: The row ID of the specified record which to be deleted.
- form: llm
-
- - name: host
- type: string
- required: false
- label:
- en_US: Host Address
- zh_Hans: 服务器地址
- human_description:
- en_US: The address for the privately deployed HAP server.
- zh_Hans: 私有部署 HAP 服务器地址,公有云无需填写
- llm_description: the address for the privately deployed HAP server.
- form: form
diff --git a/api/core/tools/provider/builtin/hap/tools/get_worksheet_fields.py b/api/core/tools/provider/builtin/hap/tools/get_worksheet_fields.py
deleted file mode 100644
index 6887b8b4e9..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/get_worksheet_fields.py
+++ /dev/null
@@ -1,152 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GetWorksheetFieldsTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- appkey = tool_parameters.get("appkey", "")
- if not appkey:
- return self.create_text_message("Invalid parameter App Key")
- sign = tool_parameters.get("sign", "")
- if not sign:
- return self.create_text_message("Invalid parameter Sign")
- worksheet_id = tool_parameters.get("worksheet_id", "")
- if not worksheet_id:
- return self.create_text_message("Invalid parameter Worksheet ID")
-
- host = tool_parameters.get("host", "")
- if not host:
- host = "https://api.mingdao.com"
- elif not host.startswith(("http://", "https://")):
- return self.create_text_message("Invalid parameter Host Address")
- else:
- host = f"{host.removesuffix('/')}/api"
-
- url = f"{host}/v2/open/worksheet/getWorksheetInfo"
- headers = {"Content-Type": "application/json"}
- payload = {"appKey": appkey, "sign": sign, "worksheetId": worksheet_id}
-
- try:
- res = httpx.post(url, headers=headers, json=payload, timeout=60)
- res.raise_for_status()
- res_json = res.json()
- if res_json.get("error_code") != 1:
- return self.create_text_message(f"Failed to get the worksheet information. {res_json['error_msg']}")
-
- fields_json, fields_table = self.get_controls(res_json["data"]["controls"])
- result_type = tool_parameters.get("result_type", "table")
- return self.create_text_message(
- text=json.dumps(fields_json, ensure_ascii=False) if result_type == "json" else fields_table
- )
- except httpx.RequestError as e:
- return self.create_text_message(f"Failed to get the worksheet information, request error: {e}")
- except json.JSONDecodeError as e:
- return self.create_text_message(f"Failed to parse JSON response: {e}")
- except Exception as e:
- return self.create_text_message(f"Failed to get the worksheet information, unexpected error: {e}")
-
- def get_field_type_by_id(self, field_type_id: int) -> str:
- field_type_map = {
- 2: "Text",
- 3: "Text-Phone",
- 4: "Text-Phone",
- 5: "Text-Email",
- 6: "Number",
- 7: "Text",
- 8: "Number",
- 9: "Option-Single Choice",
- 10: "Option-Multiple Choices",
- 11: "Option-Single Choice",
- 15: "Date",
- 16: "Date",
- 24: "Option-Region",
- 25: "Text",
- 26: "Option-Member",
- 27: "Option-Department",
- 28: "Number",
- 29: "Option-Linked Record",
- 30: "Unknown Type",
- 31: "Number",
- 32: "Text",
- 33: "Text",
- 35: "Option-Linked Record",
- 36: "Number-Yes1/No0",
- 37: "Number",
- 38: "Date",
- 40: "Location",
- 41: "Text",
- 46: "Time",
- 48: "Option-Organizational Role",
- 50: "Text",
- 51: "Query Record",
- }
- return field_type_map.get(field_type_id, "")
-
- def get_controls(self, controls: list) -> dict:
- fields = []
- fields_list = ["|fieldId|fieldName|fieldType|fieldTypeId|description|options|", "|" + "---|" * 6]
- for control in controls:
- if control["type"] in self._get_ignore_types():
- continue
- field_type_id = control["type"]
- field_type = self.get_field_type_by_id(control["type"])
- if field_type_id == 30:
- source_type = control["sourceControl"]["type"]
- if source_type in self._get_ignore_types():
- continue
- else:
- field_type_id = source_type
- field_type = self.get_field_type_by_id(source_type)
- field = {
- "id": control["controlId"],
- "name": control["controlName"],
- "type": field_type,
- "typeId": field_type_id,
- "description": control["remark"].replace("\n", " ").replace("\t", " "),
- "options": self._extract_options(control),
- }
- fields.append(field)
- fields_list.append(
- f"|{field['id']}|{field['name']}|{field['type']}|{field['typeId']}|{field['description']}"
- f"|{field['options'] or ''}|"
- )
-
- fields.append(
- {
- "id": "ctime",
- "name": "Created Time",
- "type": self.get_field_type_by_id(16),
- "typeId": 16,
- "description": "",
- "options": [],
- }
- )
- fields_list.append("|ctime|Created Time|Date|16|||")
- return fields, "\n".join(fields_list)
-
- def _extract_options(self, control: dict) -> list:
- options = []
- if control["type"] in {9, 10, 11}:
- options.extend([{"key": opt["key"], "value": opt["value"]} for opt in control.get("options", [])])
- elif control["type"] in {28, 36}:
- itemnames = control["advancedSetting"].get("itemnames")
- if itemnames and itemnames.startswith("[{"):
- try:
- options = json.loads(itemnames)
- except json.JSONDecodeError:
- pass
- elif control["type"] == 30:
- source_type = control["sourceControl"]["type"]
- if source_type not in self._get_ignore_types():
- options.extend([{"key": opt["key"], "value": opt["value"]} for opt in control.get("options", [])])
- return options
-
- def _get_ignore_types(self):
- return {14, 21, 22, 34, 42, 43, 45, 47, 49, 10010}
diff --git a/api/core/tools/provider/builtin/hap/tools/get_worksheet_fields.yaml b/api/core/tools/provider/builtin/hap/tools/get_worksheet_fields.yaml
deleted file mode 100644
index f0d4973e85..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/get_worksheet_fields.yaml
+++ /dev/null
@@ -1,80 +0,0 @@
-identity:
- name: get_worksheet_fields
- author: Ryan Tian
- label:
- en_US: Get Worksheet Fields
- zh_Hans: 获取工作表字段结构
-description:
- human:
- en_US: Get fields information of the worksheet
- zh_Hans: 获取指定工作表的所有字段结构信息
- llm: A tool to get fields information of the specific worksheet.
-parameters:
- - name: appkey
- type: secret-input
- required: true
- label:
- en_US: App Key
- zh_Hans: App Key
- human_description:
- en_US: The AppKey parameter for the HAP application, typically found in the application's API documentation.
- zh_Hans: HAP 应用的 AppKey 参数,可以从应用 API 文档中查找到
- llm_description: the AppKey parameter for the HAP application
- form: form
-
- - name: sign
- type: secret-input
- required: true
- label:
- en_US: Sign
- zh_Hans: Sign
- human_description:
- en_US: The Sign parameter for the HAP application
- zh_Hans: HAP 应用的 Sign 参数
- llm_description: the Sign parameter for the HAP application
- form: form
-
- - name: worksheet_id
- type: string
- required: true
- label:
- en_US: Worksheet ID
- zh_Hans: 工作表 ID
- human_description:
- en_US: The ID of the specified worksheet
- zh_Hans: 要获取字段信息的工作表 ID
- llm_description: The ID of the specified worksheet which to get the fields information.
- form: llm
-
- - name: host
- type: string
- required: false
- label:
- en_US: Host Address
- zh_Hans: 服务器地址
- human_description:
- en_US: The address for the privately deployed HAP server.
- zh_Hans: 私有部署 HAP 服务器地址,公有云无需填写
- llm_description: the address for the privately deployed HAP server.
- form: form
-
- - name: result_type
- type: select
- required: true
- options:
- - value: table
- label:
- en_US: table text
- zh_Hans: 表格文本
- - value: json
- label:
- en_US: json text
- zh_Hans: JSON文本
- default: table
- label:
- en_US: Result type
- zh_Hans: 结果类型
- human_description:
- en_US: used for selecting the result type, table styled text or json text
- zh_Hans: 用于选择结果类型,使用表格格式文本还是JSON格式文本
- form: form
diff --git a/api/core/tools/provider/builtin/hap/tools/get_worksheet_pivot_data.py b/api/core/tools/provider/builtin/hap/tools/get_worksheet_pivot_data.py
deleted file mode 100644
index 26d7116869..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/get_worksheet_pivot_data.py
+++ /dev/null
@@ -1,137 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GetWorksheetPivotDataTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- appkey = tool_parameters.get("appkey", "")
- if not appkey:
- return self.create_text_message("Invalid parameter App Key")
- sign = tool_parameters.get("sign", "")
- if not sign:
- return self.create_text_message("Invalid parameter Sign")
- worksheet_id = tool_parameters.get("worksheet_id", "")
- if not worksheet_id:
- return self.create_text_message("Invalid parameter Worksheet ID")
- x_column_fields = tool_parameters.get("x_column_fields", "")
- if not x_column_fields or not x_column_fields.startswith("["):
- return self.create_text_message("Invalid parameter Column Fields")
- y_row_fields = tool_parameters.get("y_row_fields", "")
- if y_row_fields and not y_row_fields.strip().startswith("["):
- return self.create_text_message("Invalid parameter Row Fields")
- elif not y_row_fields:
- y_row_fields = "[]"
- value_fields = tool_parameters.get("value_fields", "")
- if not value_fields or not value_fields.strip().startswith("["):
- return self.create_text_message("Invalid parameter Value Fields")
-
- host = tool_parameters.get("host", "")
- if not host:
- host = "https://api.mingdao.com"
- elif not host.startswith(("http://", "https://")):
- return self.create_text_message("Invalid parameter Host Address")
- else:
- host = f"{host.removesuffix('/')}/api"
-
- url = f"{host}/report/getPivotData"
- headers = {"Content-Type": "application/json"}
- payload = {"appKey": appkey, "sign": sign, "worksheetId": worksheet_id, "options": {"showTotal": True}}
-
- try:
- x_column_fields = json.loads(x_column_fields)
- payload["columns"] = x_column_fields
- y_row_fields = json.loads(y_row_fields)
- if y_row_fields:
- payload["rows"] = y_row_fields
- value_fields = json.loads(value_fields)
- payload["values"] = value_fields
- sort_fields = tool_parameters.get("sort_fields", "")
- if not sort_fields:
- sort_fields = "[]"
- sort_fields = json.loads(sort_fields)
- if sort_fields:
- payload["options"]["sort"] = sort_fields
- res = httpx.post(url, headers=headers, json=payload, timeout=60)
- res.raise_for_status()
- res_json = res.json()
- if res_json.get("status") != 1:
- return self.create_text_message(f"Failed to get the worksheet pivot data. {res_json['msg']}")
-
- pivot_json = self.generate_pivot_json(res_json["data"])
- pivot_table = self.generate_pivot_table(res_json["data"])
- result_type = tool_parameters.get("result_type", "")
- text = pivot_table if result_type == "table" else json.dumps(pivot_json, ensure_ascii=False)
- return self.create_text_message(text)
- except httpx.RequestError as e:
- return self.create_text_message(f"Failed to get the worksheet pivot data, request error: {e}")
- except json.JSONDecodeError as e:
- return self.create_text_message(f"Failed to parse JSON response: {e}")
- except Exception as e:
- return self.create_text_message(f"Failed to get the worksheet pivot data, unexpected error: {e}")
-
- def generate_pivot_table(self, data: dict[str, Any]) -> str:
- columns = data["metadata"]["columns"]
- rows = data["metadata"]["rows"]
- values = data["metadata"]["values"]
-
- rows_data = data["data"]
-
- header = (
- ([row["displayName"] for row in rows] if rows else [])
- + [column["displayName"] for column in columns]
- + [value["displayName"] for value in values]
- )
- line = (["---"] * len(rows) if rows else []) + ["---"] * len(columns) + ["--:"] * len(values)
-
- table = [header, line]
- for row in rows_data:
- row_data = [self.replace_pipe(row["rows"][r["controlId"]]) for r in rows] if rows else []
- row_data.extend([self.replace_pipe(row["columns"][column["controlId"]]) for column in columns])
- row_data.extend([self.replace_pipe(str(row["values"][value["controlId"]])) for value in values])
- table.append(row_data)
-
- return "\n".join([("|" + "|".join(row) + "|") for row in table])
-
- def replace_pipe(self, text: str) -> str:
- return text.replace("|", "▏").replace("\n", " ")
-
- def generate_pivot_json(self, data: dict[str, Any]) -> dict:
- fields = {
- "x-axis": [
- {"fieldId": column["controlId"], "fieldName": column["displayName"]}
- for column in data["metadata"]["columns"]
- ],
- "y-axis": [
- {"fieldId": row["controlId"], "fieldName": row["displayName"]} for row in data["metadata"]["rows"]
- ]
- if data["metadata"]["rows"]
- else [],
- "values": [
- {"fieldId": value["controlId"], "fieldName": value["displayName"]}
- for value in data["metadata"]["values"]
- ],
- }
- # fields = ([
- # {"fieldId": row["controlId"], "fieldName": row["displayName"]}
- # for row in data["metadata"]["rows"]
- # ] if data["metadata"]["rows"] else []) + [
- # {"fieldId": column["controlId"], "fieldName": column["displayName"]}
- # for column in data["metadata"]["columns"]
- # ] + [
- # {"fieldId": value["controlId"], "fieldName": value["displayName"]}
- # for value in data["metadata"]["values"]
- # ]
- rows = []
- for row in data["data"]:
- row_data = row["rows"] or {}
- row_data.update(row["columns"])
- row_data.update(row["values"])
- rows.append(row_data)
- return {"fields": fields, "rows": rows, "summary": data["metadata"]["totalRow"]}
diff --git a/api/core/tools/provider/builtin/hap/tools/get_worksheet_pivot_data.yaml b/api/core/tools/provider/builtin/hap/tools/get_worksheet_pivot_data.yaml
deleted file mode 100644
index cf8c57b262..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/get_worksheet_pivot_data.yaml
+++ /dev/null
@@ -1,248 +0,0 @@
-identity:
- name: get_worksheet_pivot_data
- author: Ryan Tian
- label:
- en_US: Get Worksheet Pivot Data
- zh_Hans: 获取工作表统计透视数据
-description:
- human:
- en_US: Retrieve statistical pivot table data from a specified worksheet
- zh_Hans: 从指定的工作表中检索统计透视表数据
- llm: A tool for extracting statistical pivot table data from a specific worksheet, providing summarized information for analysis and reporting purposes.
-parameters:
- - name: appkey
- type: secret-input
- required: true
- label:
- en_US: App Key
- zh_Hans: App Key
- human_description:
- en_US: The AppKey parameter for the HAP application, typically found in the application's API documentation.
- zh_Hans: HAP 应用的 AppKey 参数,可以从应用 API 文档中查找到
- llm_description: the AppKey parameter for the HAP application
- form: form
-
- - name: sign
- type: secret-input
- required: true
- label:
- en_US: Sign
- zh_Hans: Sign
- human_description:
- en_US: The Sign parameter for the HAP application
- zh_Hans: HAP 应用的 Sign 参数
- llm_description: the Sign parameter for the HAP application
- form: form
-
- - name: worksheet_id
- type: string
- required: true
- label:
- en_US: Worksheet ID
- zh_Hans: 工作表 ID
- human_description:
- en_US: The ID of the specified worksheet
- zh_Hans: 要获取字段信息的工作表 ID
- llm_description: The ID of the specified worksheet which to get the fields information.
- form: llm
-
- - name: x_column_fields
- type: string
- required: true
- label:
- en_US: Columns (X-axis)
- zh_Hans: 统计列字段(X轴)
- human_description:
- en_US: The column fields that make up the pivot table's X-axis groups or other dimensions for the X-axis in pivot charts
- zh_Hans: 组成透视表的统计列或者统计图表的X轴分组及X轴其它维度。JSON 对象数组格式,数组元素属性:controlId-列ID,displayName-显示名称,particleSize(可选)-字段类型是日期或者地区时,通过此参数设置统计维度(日期时间:1-日,2-周,3-月;地区:1-全国,2-省,3-市)
- llm_description: |
- This parameter allows you to specify the columns that make up the pivot table's X-axis groups or other dimensions for the X-axis in pivot charts. It is formatted as a JSON array, with its structure defined as follows:
- ```
- type XColumnFields = { // X-axis or column object array
- controlId: string; // fieldId
- displayName: string; // displayName
- particleSize?: number; // field type is date or area, set the statistical dimension (date time: 1-day, 2-week, 3-month; area: 1-nation, 2-province, 3-city)
- }[];
- ```
- form: llm
-
- - name: y_row_fields
- type: string
- required: false
- label:
- en_US: Rows (Y-axis)
- zh_Hans: 统计行字段(Y轴)
- human_description:
- en_US: The row fields that make up the pivot table's Y-axis groups or other dimensions for the Y-axis in pivot charts
- zh_Hans: 组成透视表的统计行或者统计图表的Y轴分组及Y轴其它维度。JSON 对象数组格式,数组元素属性:controlId-列ID,displayName-显示名称,particleSize(可选)-字段类型是日期或者地区时,通过此参数设置统计维度(日期时间:1-日,2-周,3-月;地区:1-全国,2-省,3-市)
- llm_description: |
- This parameter allows you to specify the rows that make up the pivot table's Y-axis groups or other dimensions for the Y-axis in pivot charts. It is formatted as a JSON array, with its structure defined as follows:
- ```
- type YRowFields = { // Y-axis or row object array
- controlId: string; // fieldId
- displayName: string; // displayName
- particleSize?: number; // field type is date or area, set the statistical dimension (date time: 1-day, 2-week, 3-month; area: 1-nation, 2-province, 3-city)
- }[];
- ```
- form: llm
-
- - name: value_fields
- type: string
- required: true
- label:
- en_US: Aggregated Values
- zh_Hans: 统计值字段
- human_description:
- en_US: The aggregated value fields in the pivot table
- zh_Hans: 透视表中经过聚合计算后的统计值字段。JSON 对象数组格式,数组元素属性:controlId-列ID,displayName-显示名称,aggregation-聚合方式(SUM,AVG,MIN,MAX,COUNT)
- llm_description: |
- This parameter allows you to specify the aggregated value fields in the pivot table. It is formatted as a JSON array, with its structure defined as follows:
- ```
- type ValueFields = { // aggregated value object array
- controlId: string; // fieldId
- displayName: string; // displayName
- aggregation: string; // aggregation method, e.g.: SUM, AVG, MIN, MAX, COUNT
- }[];
- ```
- form: llm
-
- - name: filters
- type: string
- required: false
- label:
- en_US: Filter Set
- zh_Hans: 筛选器组合
- human_description:
- en_US: A combination of filters applied to query records, formatted as a JSON array. See the application's API documentation for details on its structure and usage.
- zh_Hans: 查询记录的筛选条件组合,格式为 JSON 数组,可以从应用 API 文档中了解参数结构详情
- llm_description: |
- This parameter allows you to specify a set of conditions that records must meet to be included in the result set. It is formatted as a JSON array, with its structure defined as follows:
- ```
- type Filters = { // filter object array
- controlId: string; // fieldId
- dataType: number; // fieldTypeId
- spliceType: number; // condition concatenation method, 1: And, 2: Or
- filterType: number; // expression type, refer to the for enumerable values
- values?: string[]; // values in the condition, for option-type fields, multiple values can be passed
- value?: string; // value in the condition, a single value can be passed according to the field type
- dateRange?: number; // date range, mandatory when filterType is 17 or 18, refer to the for enumerable values
- minValue?: string; // minimum value for custom range
- maxValue?: string; // maximum value for custom range
- isAsc?: boolean; // ascending order, false: descending, true: ascending
- }[];
- ```
- For option-type fields, if this option field has `options`, then you need to get the corresponding `key` value from the `options` in the current field information via `value`, and pass it into `values` in array format. Do not use the `options` value of other fields as input conditions.
-
- ### FilterTypeEnum Reference
- ```
- Enum Value, Enum Character, Description
- 1, Like, Contains
- 2, Eq, Is (Equal)
- 3, Start, Starts With
- 4, End, Ends With
- 5, NotLike, Does Not Contain
- 6, Ne, Is Not (Not Equal)
- 7, IsEmpty, Empty
- 8, HasValue, Not Empty
- 11, Between, Within Range
- 12, NotBetween, Outside Range
- 13, Gt, Greater Than
- 14, Gte, Greater Than or Equal To
- 15, Lt, Less Than
- 16, Lte, Less Than or Equal To
- 17, DateEnum, Date Is
- 18, NotDateEnum, Date Is Not
- 21, MySelf, Owned by Me
- 22, UnRead, Unread
- 23, Sub, Owned by Subordinate
- 24, RCEq, Associated Field Is
- 25, RCNe, Associated Field Is Not
- 26, ArrEq, Array Equals
- 27, ArrNe, Array Does Not Equal
- 31, DateBetween, Date Within Range (can only be used with minValue and maxValue)
- 32, DateNotBetween, Date Not Within Range (can only be used with minValue and maxValue)
- 33, DateGt, Date Later Than
- 34, DateGte, Date Later Than or Equal To
- 35, DateLt, Date Earlier Than
- 36, DateLte, Date Earlier Than or Equal To
- ```
-
- ### DateRangeEnum Reference
- ```
- Enum Value, Enum Character, Description
- 1, Today, Today
- 2, Yesterday, Yesterday
- 3, Tomorrow, Tomorrow
- 4, ThisWeek, This Week
- 5, LastWeek, Last Week
- 6, NextWeek, Next Week
- 7, ThisMonth, This Month
- 8, LastMonth, Last Month
- 9, NextMonth, Next Month
- 12, ThisQuarter, This Quarter
- 13, LastQuarter, Last Quarter
- 14, NextQuarter, Next Quarter
- 15, ThisYear, This Year
- 16, LastYear, Last Year
- 17, NextYear, Next Year
- 18, Customize, Custom
- 21, Last7Day, Past 7 Days
- 22, Last14Day, Past 14 Days
- 23, Last30Day, Past 30 Days
- 31, Next7Day, Next 7 Days
- 32, Next14Day, Next 14 Days
- 33, Next33Day, Next 33 Days
- ```
- form: llm
-
- - name: sort_fields
- type: string
- required: false
- label:
- en_US: Sort Fields
- zh_Hans: 排序字段
- human_description:
- en_US: The fields to used for sorting
- zh_Hans: 用于确定排序的字段,不超过3个
- llm_description: |
- This optional parameter specifies the unique identifier of the fields that will be used to sort the results. It is in the format of an array of JSON objects, and its structure is defined as follows:
- ```
- type SortByFields = {
- controlId: string; // Field ID used for sorting
- isAsc: boolean; // Sorting direction, true indicates ascending order, false indicates descending order
- }[];
- ```
- form: llm
-
- - name: host
- type: string
- required: false
- label:
- en_US: Host Address
- zh_Hans: 服务器地址
- human_description:
- en_US: The address for the privately deployed HAP server.
- zh_Hans: 私有部署 HAP 服务器地址,公有云无需填写
- llm_description: the address for the privately deployed HAP server.
- form: form
-
- - name: result_type
- type: select
- required: true
- options:
- - value: table
- label:
- en_US: table text
- zh_Hans: 表格文本
- - value: json
- label:
- en_US: json text
- zh_Hans: JSON文本
- default: table
- label:
- en_US: Result type
- zh_Hans: 结果类型
- human_description:
- en_US: used for selecting the result type, table styled text or json text
- zh_Hans: 用于选择结果类型,使用表格格式文本还是JSON格式文本
- form: form
diff --git a/api/core/tools/provider/builtin/hap/tools/list_worksheet_records.py b/api/core/tools/provider/builtin/hap/tools/list_worksheet_records.py
deleted file mode 100644
index d6ac3688b7..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/list_worksheet_records.py
+++ /dev/null
@@ -1,231 +0,0 @@
-import json
-import re
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class ListWorksheetRecordsTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- appkey = tool_parameters.get("appkey", "")
- if not appkey:
- return self.create_text_message("Invalid parameter App Key")
-
- sign = tool_parameters.get("sign", "")
- if not sign:
- return self.create_text_message("Invalid parameter Sign")
-
- worksheet_id = tool_parameters.get("worksheet_id", "")
- if not worksheet_id:
- return self.create_text_message("Invalid parameter Worksheet ID")
-
- host = tool_parameters.get("host", "")
- if not host:
- host = "https://api.mingdao.com"
- elif not (host.startswith("http://") or host.startswith("https://")):
- return self.create_text_message("Invalid parameter Host Address")
- else:
- host = f"{host.removesuffix('/')}/api"
-
- url_fields = f"{host}/v2/open/worksheet/getWorksheetInfo"
- headers = {"Content-Type": "application/json"}
- payload = {"appKey": appkey, "sign": sign, "worksheetId": worksheet_id}
-
- field_ids = tool_parameters.get("field_ids", "")
-
- try:
- res = httpx.post(url_fields, headers=headers, json=payload, timeout=30)
- res_json = res.json()
- if res.is_success:
- if res_json["error_code"] != 1:
- return self.create_text_message(
- "Failed to get the worksheet information. {}".format(res_json["error_msg"])
- )
- else:
- worksheet_name = res_json["data"]["name"]
- fields, schema, table_header = self.get_schema(res_json["data"]["controls"], field_ids)
- else:
- return self.create_text_message(
- f"Failed to get the worksheet information, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message(
- "Failed to get the worksheet information, something went wrong: {}".format(e)
- )
-
- if field_ids:
- payload["controls"] = [v.strip() for v in field_ids.split(",")] if field_ids else []
- filters = tool_parameters.get("filters", "")
- if filters:
- payload["filters"] = json.loads(filters)
- sort_id = tool_parameters.get("sort_id", "")
- sort_is_asc = tool_parameters.get("sort_is_asc", False)
- if sort_id:
- payload["sortId"] = sort_id
- payload["isAsc"] = sort_is_asc
- limit = tool_parameters.get("limit", 50)
- payload["pageSize"] = limit
- page_index = tool_parameters.get("page_index", 1)
- payload["pageIndex"] = page_index
- payload["useControlId"] = True
- payload["listType"] = 1
-
- url = f"{host}/v2/open/worksheet/getFilterRows"
- try:
- res = httpx.post(url, headers=headers, json=payload, timeout=90)
- res_json = res.json()
- if res.is_success:
- if res_json["error_code"] != 1:
- return self.create_text_message("Failed to get the records. {}".format(res_json["error_msg"]))
- else:
- result = {
- "fields": fields,
- "rows": [],
- "total": res_json.get("data", {}).get("total"),
- "payload": {
- key: payload[key]
- for key in [
- "worksheetId",
- "controls",
- "filters",
- "sortId",
- "isAsc",
- "pageSize",
- "pageIndex",
- ]
- if key in payload
- },
- }
- rows = res_json.get("data", {}).get("rows", [])
- result_type = tool_parameters.get("result_type", "")
- if not result_type:
- result_type = "table"
- if result_type == "json":
- for row in rows:
- result["rows"].append(self.get_row_field_value(row, schema))
- return self.create_text_message(json.dumps(result, ensure_ascii=False))
- else:
- result_text = f"Found {result['total']} rows in worksheet \"{worksheet_name}\"."
- if result["total"] > 0:
- result_text += (
- f" The following are {min(limit, result['total'])}"
- f" pieces of data presented in a table format:\n\n{table_header}"
- )
- for row in rows:
- result_values = []
- for f in fields:
- result_values.append(
- self.handle_value_type(row[f["fieldId"]], schema[f["fieldId"]])
- )
- result_text += "\n|" + "|".join(result_values) + "|"
- return self.create_text_message(result_text)
- else:
- return self.create_text_message(
- f"Failed to get the records, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to get the records, something went wrong: {}".format(e))
-
- def get_row_field_value(self, row: dict, schema: dict):
- row_value = {"rowid": row["rowid"]}
- for field in schema:
- row_value[field] = self.handle_value_type(row[field], schema[field])
- return row_value
-
- def get_schema(self, controls: list, fieldids: str):
- allow_fields = {v.strip() for v in fieldids.split(",")} if fieldids else set()
- fields = []
- schema = {}
- field_names = []
- for control in controls:
- control_type_id = self.get_real_type_id(control)
- if (control_type_id in self._get_ignore_types()) or (
- allow_fields and control["controlId"] not in allow_fields
- ):
- continue
- else:
- fields.append({"fieldId": control["controlId"], "fieldName": control["controlName"]})
- schema[control["controlId"]] = {"typeId": control_type_id, "options": self.set_option(control)}
- field_names.append(control["controlName"])
- if not allow_fields or ("ctime" in allow_fields):
- fields.append({"fieldId": "ctime", "fieldName": "Created Time"})
- schema["ctime"] = {"typeId": 16, "options": {}}
- field_names.append("Created Time")
- fields.append({"fieldId": "rowid", "fieldName": "Record Row ID"})
- schema["rowid"] = {"typeId": 2, "options": {}}
- field_names.append("Record Row ID")
- return fields, schema, "|" + "|".join(field_names) + "|\n|" + "---|" * len(field_names)
-
- def get_real_type_id(self, control: dict) -> int:
- return control["sourceControlType"] if control["type"] == 30 else control["type"]
-
- def set_option(self, control: dict) -> dict:
- options = {}
- if control.get("options"):
- options = {option["key"]: option["value"] for option in control["options"]}
- elif control.get("advancedSetting", {}).get("itemnames"):
- try:
- itemnames = json.loads(control["advancedSetting"]["itemnames"])
- options = {item["key"]: item["value"] for item in itemnames}
- except json.JSONDecodeError:
- pass
- return options
-
- def _get_ignore_types(self):
- return {14, 21, 22, 34, 42, 43, 45, 47, 49, 10010}
-
- def handle_value_type(self, value, field):
- type_id = field.get("typeId")
- if type_id == 10:
- value = value if isinstance(value, str) else "、".join(value)
- elif type_id in {28, 36}:
- value = field.get("options", {}).get(value, value)
- elif type_id in {26, 27, 48, 14}:
- value = self.process_value(value)
- elif type_id in {35, 29}:
- value = self.parse_cascade_or_associated(field, value)
- elif type_id == 40:
- value = self.parse_location(value)
- return self.rich_text_to_plain_text(value) if value else ""
-
- def process_value(self, value):
- if isinstance(value, str):
- if value.startswith('[{"accountId"'):
- value = json.loads(value)
- value = ", ".join([item["fullname"] for item in value])
- elif value.startswith('[{"departmentId"'):
- value = json.loads(value)
- value = "、".join([item["departmentName"] for item in value])
- elif value.startswith('[{"organizeId"'):
- value = json.loads(value)
- value = "、".join([item["organizeName"] for item in value])
- elif value.startswith('[{"file_id"') or value == "[]":
- value = ""
- elif hasattr(value, "accountId"):
- value = value["fullname"]
- return value
-
- def parse_cascade_or_associated(self, field, value):
- if (field["typeId"] == 35 and value.startswith("[")) or (field["typeId"] == 29 and value.startswith("[{")):
- value = json.loads(value)
- value = value[0]["name"] if len(value) > 0 else ""
- else:
- value = ""
- return value
-
- def parse_location(self, value):
- if len(value) > 10:
- parsed_value = json.loads(value)
- value = parsed_value.get("address", "")
- else:
- value = ""
- return value
-
- def rich_text_to_plain_text(self, rich_text):
- text = re.sub(r"<[^>]+>", "", rich_text) if "<" in rich_text else rich_text
- return text.replace("|", "▏").replace("\n", " ")
diff --git a/api/core/tools/provider/builtin/hap/tools/list_worksheet_records.yaml b/api/core/tools/provider/builtin/hap/tools/list_worksheet_records.yaml
deleted file mode 100644
index 3c37746b92..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/list_worksheet_records.yaml
+++ /dev/null
@@ -1,226 +0,0 @@
-identity:
- name: list_worksheet_records
- author: Ryan Tian
- label:
- en_US: List Worksheet Records
- zh_Hans: 查询工作表记录数据
-description:
- human:
- en_US: List records from the worksheet
- zh_Hans: 查询工作表的记录列表数据,一次最多1000行,可分页获取
- llm: A tool to retrieve record data from the specific worksheet.
-parameters:
- - name: appkey
- type: secret-input
- required: true
- label:
- en_US: App Key
- zh_Hans: App Key
- human_description:
- en_US: The AppKey parameter for the HAP application, typically found in the application's API documentation.
- zh_Hans: HAP 应用的 AppKey 参数,可以从应用 API 文档中查找到
- llm_description: the AppKey parameter for the HAP application
- form: form
-
- - name: sign
- type: secret-input
- required: true
- label:
- en_US: Sign
- zh_Hans: Sign
- human_description:
- en_US: The Sign parameter for the HAP application
- zh_Hans: HAP 应用的 Sign 参数
- llm_description: the Sign parameter for the HAP application
- form: form
-
- - name: worksheet_id
- type: string
- required: true
- label:
- en_US: Worksheet ID
- zh_Hans: 工作表 ID
- human_description:
- en_US: The ID of the worksheet from which to retrieve record data
- zh_Hans: 要获取记录数据的工作表 ID
- llm_description: This parameter specifies the ID of the worksheet where the records are stored.
- form: llm
-
- - name: field_ids
- type: string
- required: false
- label:
- en_US: Field IDs
- zh_Hans: 字段 ID 列表
- human_description:
- en_US: A comma-separated list of field IDs whose data to retrieve. If not provided, all fields' data will be fetched
- zh_Hans: 要获取记录数据的字段 ID,多个 ID 间用英文逗号隔开,不传此参数则将获取所有字段的数据
- llm_description: This optional parameter lets you specify a comma-separated list of field IDs. Unless the user explicitly requests to output the specified field in the question, this parameter should usually be omitted. If this parameter is omitted, the API will return data for all fields by default. When provided, only the data associated with these fields will be included in the response.
- form: llm
-
- - name: filters
- type: string
- required: false
- label:
- en_US: Filter Set
- zh_Hans: 筛选器组合
- human_description:
- en_US: A combination of filters applied to query records, formatted as a JSON array. See the application's API documentation for details on its structure and usage.
- zh_Hans: 查询记录的筛选条件组合,格式为 JSON 数组,可以从应用 API 文档中了解参数结构详情
- llm_description: |
- This parameter allows you to specify a set of conditions that records must meet to be included in the result set. It is formatted as a JSON array, with its structure defined as follows:
- ```
- type Filters = { // filter object array
- controlId: string; // fieldId
- dataType: number; // fieldTypeId
- spliceType: number; // condition concatenation method, 1: And, 2: Or
- filterType: number; // expression type, refer to the for enumerable values
- values?: string[]; // values in the condition, for option-type fields, multiple values can be passed
- value?: string; // value in the condition, a single value can be passed according to the field type
- dateRange?: number; // date range, mandatory when filterType is 17 or 18, refer to the for enumerable values
- minValue?: string; // minimum value for custom range
- maxValue?: string; // maximum value for custom range
- isAsc?: boolean; // ascending order, false: descending, true: ascending
- }[];
- ```
- For option-type fields, if this option field has `options`, then you need to get the corresponding `key` value from the `options` in the current field information via `value`, and pass it into `values` in array format. Do not use the `options` value of other fields as input conditions.
-
- ### FilterTypeEnum Reference
- ```
- Enum Value, Enum Character, Description
- 1, Like, Contains(Include)
- 2, Eq, Is (Equal)
- 3, Start, Starts With
- 4, End, Ends With
- 5, NotLike, Does Not Contain(Not Include)
- 6, Ne, Is Not (Not Equal)
- 7, IsEmpty, Empty
- 8, HasValue, Not Empty
- 11, Between, Within Range(Belong to)
- 12, NotBetween, Outside Range(Not belong to)
- 13, Gt, Greater Than
- 14, Gte, Greater Than or Equal To
- 15, Lt, Less Than
- 16, Lte, Less Than or Equal To
- 17, DateEnum, Date Is
- 18, NotDateEnum, Date Is Not
- 24, RCEq, Associated Field Is
- 25, RCNe, Associated Field Is Not
- 26, ArrEq, Array Equals
- 27, ArrNe, Array Does Not Equal
- 31, DateBetween, Date Within Range (can only be used with minValue and maxValue)
- 32, DateNotBetween, Date Not Within Range (can only be used with minValue and maxValue)
- 33, DateGt, Date Later Than
- 34, DateGte, Date Later Than or Equal To
- 35, DateLt, Date Earlier Than
- 36, DateLte, Date Earlier Than or Equal To
- ```
-
- ### DateRangeEnum Reference
- ```
- Enum Value, Enum Character, Description
- 1, Today, Today
- 2, Yesterday, Yesterday
- 3, Tomorrow, Tomorrow
- 4, ThisWeek, This Week
- 5, LastWeek, Last Week
- 6, NextWeek, Next Week
- 7, ThisMonth, This Month
- 8, LastMonth, Last Month
- 9, NextMonth, Next Month
- 12, ThisQuarter, This Quarter
- 13, LastQuarter, Last Quarter
- 14, NextQuarter, Next Quarter
- 15, ThisYear, This Year
- 16, LastYear, Last Year
- 17, NextYear, Next Year
- 18, Customize, Custom
- 21, Last7Day, Past 7 Days
- 22, Last14Day, Past 14 Days
- 23, Last30Day, Past 30 Days
- 31, Next7Day, Next 7 Days
- 32, Next14Day, Next 14 Days
- 33, Next33Day, Next 33 Days
- ```
- form: llm
-
- - name: sort_id
- type: string
- required: false
- label:
- en_US: Sort Field ID
- zh_Hans: 排序字段 ID
- human_description:
- en_US: The ID of the field used for sorting
- zh_Hans: 用以排序的字段 ID
- llm_description: This optional parameter specifies the unique identifier of the field that will be used to sort the results. It should be set to the ID of an existing field within your data structure.
- form: llm
-
- - name: sort_is_asc
- type: boolean
- required: false
- label:
- en_US: Ascending Order
- zh_Hans: 是否升序排列
- human_description:
- en_US: Determines whether the sorting is in ascending (true) or descending (false) order
- zh_Hans: 排序字段的排序方式:true-升序,false-降序
- llm_description: This optional parameter controls the direction of the sort. If set to true, the results will be sorted in ascending order; if false, they will be sorted in descending order.
- form: llm
-
- - name: limit
- type: number
- required: false
- label:
- en_US: Record Limit
- zh_Hans: 记录数量限制
- human_description:
- en_US: The maximum number of records to retrieve
- zh_Hans: 要获取的记录数量限制条数
- llm_description: This optional parameter allows you to specify the maximum number of records that should be returned in the result set. When retrieving paginated record data, this parameter indicates the number of rows to fetch per page, and must be used in conjunction with the `page_index` parameter.
- form: llm
-
- - name: page_index
- type: number
- required: false
- label:
- en_US: Page Index
- zh_Hans: 页码
- human_description:
- en_US: The page number when paginating through a list of records
- zh_Hans: 分页读取记录列表时的页码
- llm_description: This parameter is used when you need to paginate through a large set of records. The default value is 1, which refers to the first page. When it is used, the meaning of the `limit` parameter becomes the number of records per page.
- form: llm
-
- - name: host
- type: string
- required: false
- label:
- en_US: Host Address
- zh_Hans: 服务器地址
- human_description:
- en_US: The address for the privately deployed HAP server.
- zh_Hans: 私有部署 HAP 服务器地址,公有云无需填写
- llm_description: the address for the privately deployed HAP server.
- form: form
-
- - name: result_type
- type: select
- required: true
- options:
- - value: table
- label:
- en_US: table text
- zh_Hans: 表格文本
- - value: json
- label:
- en_US: json text
- zh_Hans: JSON文本
- default: table
- label:
- en_US: Result type
- zh_Hans: 结果类型
- human_description:
- en_US: used for selecting the result type, table styled text or json text
- zh_Hans: 用于选择结果类型,使用表格格式文本还是JSON格式文本
- form: form
diff --git a/api/core/tools/provider/builtin/hap/tools/list_worksheets.py b/api/core/tools/provider/builtin/hap/tools/list_worksheets.py
deleted file mode 100644
index 4e852c0028..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/list_worksheets.py
+++ /dev/null
@@ -1,83 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class ListWorksheetsTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- appkey = tool_parameters.get("appkey", "")
- if not appkey:
- return self.create_text_message("Invalid parameter App Key")
- sign = tool_parameters.get("sign", "")
- if not sign:
- return self.create_text_message("Invalid parameter Sign")
-
- host = tool_parameters.get("host", "")
- if not host:
- host = "https://api.mingdao.com"
- elif not (host.startswith("http://") or host.startswith("https://")):
- return self.create_text_message("Invalid parameter Host Address")
- else:
- host = f"{host.removesuffix('/')}/api"
- url = f"{host}/v1/open/app/get"
-
- result_type = tool_parameters.get("result_type", "")
- if not result_type:
- result_type = "table"
-
- headers = {"Content-Type": "application/json"}
- params = {
- "appKey": appkey,
- "sign": sign,
- }
- try:
- res = httpx.get(url, headers=headers, params=params, timeout=30)
- res_json = res.json()
- if res.is_success:
- if res_json["error_code"] != 1:
- return self.create_text_message(
- "Failed to access the application. {}".format(res_json["error_msg"])
- )
- else:
- if result_type == "json":
- worksheets = []
- for section in res_json["data"]["sections"]:
- worksheets.extend(self._extract_worksheets(section, result_type))
- return self.create_text_message(text=json.dumps(worksheets, ensure_ascii=False))
- else:
- worksheets = "|worksheetId|worksheetName|description|\n|---|---|---|"
- for section in res_json["data"]["sections"]:
- worksheets += self._extract_worksheets(section, result_type)
- return self.create_text_message(worksheets)
-
- else:
- return self.create_text_message(
- f"Failed to list worksheets, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to list worksheets, something went wrong: {}".format(e))
-
- def _extract_worksheets(self, section, type):
- items = []
- tables = ""
- for item in section.get("items", []):
- if item.get("type") == 0 and ("notes" not in item or item.get("notes") != "NO"):
- if type == "json":
- filtered_item = {"id": item["id"], "name": item["name"], "notes": item.get("notes", "")}
- items.append(filtered_item)
- else:
- tables += f"\n|{item['id']}|{item['name']}|{item.get('notes', '')}|"
-
- for child_section in section.get("childSections", []):
- if type == "json":
- items.extend(self._extract_worksheets(child_section, "json"))
- else:
- tables += self._extract_worksheets(child_section, "table")
-
- return items if type == "json" else tables
diff --git a/api/core/tools/provider/builtin/hap/tools/list_worksheets.yaml b/api/core/tools/provider/builtin/hap/tools/list_worksheets.yaml
deleted file mode 100644
index 935b72a895..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/list_worksheets.yaml
+++ /dev/null
@@ -1,68 +0,0 @@
-identity:
- name: list_worksheets
- author: Ryan Tian
- label:
- en_US: List Worksheets
- zh_Hans: 获取应用下所有工作表
-description:
- human:
- en_US: List worksheets within an application
- zh_Hans: 获取应用下的所有工作表和说明信息
- llm: A tool to list worksheets info within an application, imported parameter is AppKey and Sign of the application.
-parameters:
- - name: appkey
- type: secret-input
- required: true
- label:
- en_US: App Key
- zh_Hans: App Key
- human_description:
- en_US: The AppKey parameter for the HAP application, typically found in the application's API documentation.
- zh_Hans: HAP 应用的 AppKey 参数,可以从应用 API 文档中查找到
- llm_description: the AppKey parameter for the HAP application
- form: form
-
- - name: sign
- type: secret-input
- required: true
- label:
- en_US: Sign
- zh_Hans: Sign
- human_description:
- en_US: The Sign parameter for the HAP application
- zh_Hans: HAP 应用的 Sign 参数
- llm_description: the Sign parameter for the HAP application
- form: form
-
- - name: host
- type: string
- required: false
- label:
- en_US: Host Address
- zh_Hans: 服务器地址
- human_description:
- en_US: The address for the privately deployed HAP server.
- zh_Hans: 私有部署 HAP 服务器地址,公有云无需填写
- llm_description: the address for the privately deployed HAP server.
- form: form
-
- - name: result_type
- type: select
- required: true
- options:
- - value: table
- label:
- en_US: table text
- zh_Hans: 表格文本
- - value: json
- label:
- en_US: json text
- zh_Hans: JSON文本
- default: table
- label:
- en_US: Result type
- zh_Hans: 结果类型
- human_description:
- en_US: used for selecting the result type, table styled text or json text
- zh_Hans: 用于选择结果类型,使用表格格式文本还是JSON格式文本
- form: form
diff --git a/api/core/tools/provider/builtin/hap/tools/update_worksheet_record.py b/api/core/tools/provider/builtin/hap/tools/update_worksheet_record.py
deleted file mode 100644
index 971f3d37f6..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/update_worksheet_record.py
+++ /dev/null
@@ -1,55 +0,0 @@
-import json
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class UpdateWorksheetRecordTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- appkey = tool_parameters.get("appkey", "")
- if not appkey:
- return self.create_text_message("Invalid parameter App Key")
- sign = tool_parameters.get("sign", "")
- if not sign:
- return self.create_text_message("Invalid parameter Sign")
- worksheet_id = tool_parameters.get("worksheet_id", "")
- if not worksheet_id:
- return self.create_text_message("Invalid parameter Worksheet ID")
- row_id = tool_parameters.get("row_id", "")
- if not row_id:
- return self.create_text_message("Invalid parameter Record Row ID")
- record_data = tool_parameters.get("record_data", "")
- if not record_data:
- return self.create_text_message("Invalid parameter Record Row Data")
-
- host = tool_parameters.get("host", "")
- if not host:
- host = "https://api.mingdao.com"
- elif not host.startswith(("http://", "https://")):
- return self.create_text_message("Invalid parameter Host Address")
- else:
- host = f"{host.removesuffix('/')}/api"
-
- url = f"{host}/v2/open/worksheet/editRow"
- headers = {"Content-Type": "application/json"}
- payload = {"appKey": appkey, "sign": sign, "worksheetId": worksheet_id, "rowId": row_id}
-
- try:
- payload["controls"] = json.loads(record_data)
- res = httpx.post(url, headers=headers, json=payload, timeout=60)
- res.raise_for_status()
- res_json = res.json()
- if res_json.get("error_code") != 1:
- return self.create_text_message(f"Failed to update the record. {res_json['error_msg']}")
- return self.create_text_message("Record updated successfully.")
- except httpx.RequestError as e:
- return self.create_text_message(f"Failed to update the record, request error: {e}")
- except json.JSONDecodeError as e:
- return self.create_text_message(f"Failed to parse JSON response: {e}")
- except Exception as e:
- return self.create_text_message(f"Failed to update the record, unexpected error: {e}")
diff --git a/api/core/tools/provider/builtin/hap/tools/update_worksheet_record.yaml b/api/core/tools/provider/builtin/hap/tools/update_worksheet_record.yaml
deleted file mode 100644
index fe1f8f671a..0000000000
--- a/api/core/tools/provider/builtin/hap/tools/update_worksheet_record.yaml
+++ /dev/null
@@ -1,90 +0,0 @@
-identity:
- name: update_worksheet_record
- author: Ryan Tian
- label:
- en_US: Update Worksheet Record
- zh_Hans: 更新指定的一条工作表记录
-description:
- human:
- en_US: Updates a single record in a worksheet based on the specified record row ID
- zh_Hans: 根据指定的记录ID更新一条工作表记录数据
- llm: A tool to modify existing information within a particular record of a worksheet by referencing its unique identifier.
-parameters:
- - name: appkey
- type: secret-input
- required: true
- label:
- en_US: App Key
- zh_Hans: App Key
- human_description:
- en_US: The AppKey parameter for the HAP application, typically found in the application's API documentation.
- zh_Hans: HAP 应用的 AppKey 参数,可以从应用 API 文档中查找到
- llm_description: the AppKey parameter for the HAP application
- form: form
-
- - name: sign
- type: secret-input
- required: true
- label:
- en_US: Sign
- zh_Hans: Sign
- human_description:
- en_US: The Sign parameter for the HAP application
- zh_Hans: HAP 应用的 Sign 参数
- llm_description: the Sign parameter for the HAP application
- form: form
-
- - name: worksheet_id
- type: string
- required: true
- label:
- en_US: Worksheet ID
- zh_Hans: 工作表 ID
- human_description:
- en_US: The ID of the specified worksheet
- zh_Hans: 要获取字段信息的工作表 ID
- llm_description: The ID of the specified worksheet which to get the fields information.
- form: llm
-
- - name: row_id
- type: string
- required: true
- label:
- en_US: Record Row ID
- zh_Hans: 记录 ID
- human_description:
- en_US: The row ID of the specified record
- zh_Hans: 要更新的记录 ID
- llm_description: The row ID of the specified record which to be updated.
- form: llm
-
- - name: record_data
- type: string
- required: true
- label:
- en_US: Record Row Data
- zh_Hans: 记录数据
- human_description:
- en_US: The fields with data of the specified record
- zh_Hans: 要更新的记录数据,JSON 对象数组格式。数组元素属性:controlId-字段ID,value-字段值
- llm_description: |
- The fields with data of the specified record which to be updated. It is in the format of an array of JSON objects, and the structure is defined as follows:
- ```
- type RowData = {
- controlId: string; // Field ID to be updated
- value: string; // Field value to be updated
- }[];
- ```
- form: llm
-
- - name: host
- type: string
- required: false
- label:
- en_US: Host Address
- zh_Hans: 服务器地址
- human_description:
- en_US: The address for the privately deployed HAP server.
- zh_Hans: 私有部署 HAP 服务器地址,公有云无需填写
- llm_description: the address for the privately deployed HAP server.
- form: form
diff --git a/api/core/tools/provider/builtin/jina/_assets/icon.svg b/api/core/tools/provider/builtin/jina/_assets/icon.svg
deleted file mode 100644
index 2e1b00fa52..0000000000
--- a/api/core/tools/provider/builtin/jina/_assets/icon.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
diff --git a/api/core/tools/provider/builtin/jina/jina.py b/api/core/tools/provider/builtin/jina/jina.py
deleted file mode 100644
index 154e15db01..0000000000
--- a/api/core/tools/provider/builtin/jina/jina.py
+++ /dev/null
@@ -1,38 +0,0 @@
-import json
-from typing import Any
-
-from core.tools.entities.values import ToolLabelEnum
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.jina.tools.jina_reader import JinaReaderTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class GoogleProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- if credentials["api_key"] is None:
- credentials["api_key"] = ""
- else:
- result = (
- JinaReaderTool()
- .fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- )
- .invoke(
- user_id="",
- tool_parameters={
- "url": "https://example.com",
- },
- )[0]
- )
-
- message = json.loads(result.message)
- if message["code"] != 200:
- raise ToolProviderCredentialValidationError(message["message"])
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
-
- def _get_tool_labels(self) -> list[ToolLabelEnum]:
- return [ToolLabelEnum.SEARCH, ToolLabelEnum.PRODUCTIVITY]
diff --git a/api/core/tools/provider/builtin/jina/jina.yaml b/api/core/tools/provider/builtin/jina/jina.yaml
deleted file mode 100644
index 06f23382d9..0000000000
--- a/api/core/tools/provider/builtin/jina/jina.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-identity:
- author: Dify
- name: jina
- label:
- en_US: Jina
- zh_Hans: Jina
- pt_BR: Jina
- description:
- en_US: Convert any URL to an LLM-friendly input or perform searches on the web for grounding information. Experience improved output for your agent and RAG systems at no cost.
- zh_Hans: 将任何URL转换为LLM易读的输入或在网页上搜索引擎上搜索引擎。
- pt_BR: Converte qualquer URL em uma entrada LLm-fácil de ler ou realize pesquisas na web para obter informação de grounding. Tenha uma experiência melhor para seu agente e sistemas RAG sem custo.
- icon: icon.svg
- tags:
- - search
- - productivity
-credentials_for_provider:
- api_key:
- type: secret-input
- required: false
- label:
- en_US: API Key (leave empty if you don't have one)
- zh_Hans: API 密钥(可留空)
- pt_BR: Chave API (deixe vazio se você não tiver uma)
- placeholder:
- en_US: Please enter your Jina API key
- zh_Hans: 请输入你的 Jina API 密钥
- pt_BR: Por favor, insira sua chave de API do Jina
- help:
- en_US: Get your Jina API key from Jina (optional, but you can get a higher rate)
- zh_Hans: 从 Jina 获取您的 Jina API 密钥(非必须,能得到更高的速率)
- pt_BR: Obtenha sua chave de API do Jina na Jina (opcional, mas você pode obter uma taxa mais alta)
- url: https://jina.ai
diff --git a/api/core/tools/provider/builtin/jina/tools/jina_reader.py b/api/core/tools/provider/builtin/jina/tools/jina_reader.py
deleted file mode 100644
index 0dd55c6529..0000000000
--- a/api/core/tools/provider/builtin/jina/tools/jina_reader.py
+++ /dev/null
@@ -1,74 +0,0 @@
-import json
-from typing import Any, Union
-
-from yarl import URL
-
-from core.helper import ssrf_proxy
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class JinaReaderTool(BuiltinTool):
- _jina_reader_endpoint = "https://r.jina.ai/"
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- url = tool_parameters["url"]
-
- headers = {"Accept": "application/json"}
-
- if "api_key" in self.runtime.credentials and self.runtime.credentials.get("api_key"):
- headers["Authorization"] = "Bearer " + self.runtime.credentials.get("api_key")
-
- request_params = tool_parameters.get("request_params")
- if request_params is not None and request_params != "":
- try:
- request_params = json.loads(request_params)
- if not isinstance(request_params, dict):
- raise ValueError("request_params must be a JSON object")
- except (json.JSONDecodeError, ValueError) as e:
- raise ValueError(f"Invalid request_params: {e}")
-
- target_selector = tool_parameters.get("target_selector")
- if target_selector is not None and target_selector != "":
- headers["X-Target-Selector"] = target_selector
-
- wait_for_selector = tool_parameters.get("wait_for_selector")
- if wait_for_selector is not None and wait_for_selector != "":
- headers["X-Wait-For-Selector"] = wait_for_selector
-
- if tool_parameters.get("image_caption", False):
- headers["X-With-Generated-Alt"] = "true"
-
- if tool_parameters.get("gather_all_links_at_the_end", False):
- headers["X-With-Links-Summary"] = "true"
-
- if tool_parameters.get("gather_all_images_at_the_end", False):
- headers["X-With-Images-Summary"] = "true"
-
- proxy_server = tool_parameters.get("proxy_server")
- if proxy_server is not None and proxy_server != "":
- headers["X-Proxy-Url"] = proxy_server
-
- if tool_parameters.get("no_cache", False):
- headers["X-No-Cache"] = "true"
-
- max_retries = tool_parameters.get("max_retries", 3)
- response = ssrf_proxy.get(
- str(URL(self._jina_reader_endpoint + url)),
- headers=headers,
- params=request_params,
- timeout=(10, 60),
- max_retries=max_retries,
- )
-
- if tool_parameters.get("summary", False):
- return self.create_text_message(self.summary(user_id, response.text))
-
- return self.create_text_message(response.text)
diff --git a/api/core/tools/provider/builtin/jina/tools/jina_reader.yaml b/api/core/tools/provider/builtin/jina/tools/jina_reader.yaml
deleted file mode 100644
index 58ad6d8694..0000000000
--- a/api/core/tools/provider/builtin/jina/tools/jina_reader.yaml
+++ /dev/null
@@ -1,166 +0,0 @@
-identity:
- name: jina_reader
- author: Dify
- label:
- en_US: JinaReader
- zh_Hans: JinaReader
- pt_BR: JinaReader
-description:
- human:
- en_US: Convert any URL to an LLM-friendly input. Experience improved output for your agent and RAG systems at no cost.
- zh_Hans: 将任何 URL 转换为 LLM 友好的输入。无需付费即可体验为您的 Agent 和 RAG 系统提供的改进输出。
- pt_BR: Converta qualquer URL em uma entrada amigável ao LLM. Experimente uma saída aprimorada para seus sistemas de agente e RAG sem custo.
- llm: A tool for scraping webpages. Input should be a URL.
-parameters:
- - name: url
- type: string
- required: true
- label:
- en_US: URL
- zh_Hans: 网页链接
- pt_BR: URL
- human_description:
- en_US: used for linking to webpages
- zh_Hans: 用于链接到网页
- pt_BR: used for linking to webpages
- llm_description: url for scraping
- form: llm
- - name: request_params
- type: string
- required: false
- label:
- en_US: Request params
- zh_Hans: 请求参数
- pt_BR: Request params
- human_description:
- en_US: |
- request parameters, format: {"key1": "value1", "key2": "value2"}
- zh_Hans: |
- 请求参数,格式:{"key1": "value1", "key2": "value2"}
- pt_BR: |
- request parameters, format: {"key1": "value1", "key2": "value2"}
- llm_description: request parameters
- form: llm
- - name: target_selector
- type: string
- required: false
- label:
- en_US: Target selector
- zh_Hans: 目标选择器
- pt_BR: Seletor de destino
- human_description:
- en_US: css selector for scraping specific elements
- zh_Hans: css 选择器用于抓取特定元素
- pt_BR: css selector for scraping specific elements
- llm_description: css selector of the target element to scrape
- form: form
- - name: wait_for_selector
- type: string
- required: false
- label:
- en_US: Wait for selector
- zh_Hans: 等待选择器
- pt_BR: Aguardar por seletor
- human_description:
- en_US: css selector for waiting for specific elements
- zh_Hans: css 选择器用于等待特定元素
- pt_BR: css selector for waiting for specific elements
- llm_description: css selector of the target element to wait for
- form: form
- - name: image_caption
- type: boolean
- required: false
- default: false
- label:
- en_US: Image caption
- zh_Hans: 图片说明
- pt_BR: Legenda da imagem
- human_description:
- en_US: "Captions all images at the specified URL, adding 'Image [idx]: [caption]' as an alt tag for those without one. This allows downstream LLMs to interact with the images in activities such as reasoning and summarizing."
- zh_Hans: "为指定 URL 上的所有图像添加标题,为没有标题的图像添加“Image [idx]: [caption]”作为 alt 标签。这允许下游 LLM 在推理和总结等活动中与图像进行交互。"
- pt_BR: "Captions all images at the specified URL, adding 'Image [idx]: [caption]' as an alt tag for those without one. This allows downstream LLMs to interact with the images in activities such as reasoning and summarizing."
- llm_description: Captions all images at the specified URL
- form: form
- - name: gather_all_links_at_the_end
- type: boolean
- required: false
- default: false
- label:
- en_US: Gather all links at the end
- zh_Hans: 将所有链接集中到最后
- pt_BR: Coletar todos os links ao final
- human_description:
- en_US: A "Buttons & Links" section will be created at the end. This helps the downstream LLMs or web agents navigating the page or take further actions.
- zh_Hans: 最后会创建一个“按钮和链接”部分。这可以帮助下游 LLM 或 Web 代理浏览页面或采取进一步的行动。
- pt_BR: A "Buttons & Links" section will be created at the end. This helps the downstream LLMs or web agents navigating the page or take further actions.
- llm_description: Gather all links at the end
- form: form
- - name: gather_all_images_at_the_end
- type: boolean
- required: false
- default: false
- label:
- en_US: Gather all images at the end
- zh_Hans: 将所有图片集中到最后
- pt_BR: Coletar todas as imagens ao final
- human_description:
- en_US: An "Images" section will be created at the end. This gives the downstream LLMs an overview of all visuals on the page, which may improve reasoning.
- zh_Hans: 最后会创建一个“图像”部分。这可以让下游的 LLM 概览页面上的所有视觉效果,从而提高推理能力。
- pt_BR: An "Images" section will be created at the end. This gives the downstream LLMs an overview of all visuals on the page, which may improve reasoning.
- llm_description: Gather all images at the end
- form: form
- - name: proxy_server
- type: string
- required: false
- label:
- en_US: Proxy server
- zh_Hans: 代理服务器
- pt_BR: Servidor de proxy
- human_description:
- en_US: Use proxy to access URLs
- zh_Hans: 利用代理访问 URL
- pt_BR: Use proxy to access URLs
- llm_description: Use proxy to access URLs
- form: form
- - name: no_cache
- type: boolean
- required: false
- default: false
- label:
- en_US: Bypass the Cache
- zh_Hans: 绕过缓存
- pt_BR: Ignorar o cache
- human_description:
- en_US: Bypass the Cache
- zh_Hans: 是否绕过缓存
- pt_BR: Ignorar o cache
- llm_description: bypass the cache
- form: form
- - name: summary
- type: boolean
- required: false
- default: false
- label:
- en_US: Enable summary
- zh_Hans: 是否启用摘要
- pt_BR: Habilitar resumo
- human_description:
- en_US: Enable summary for the output
- zh_Hans: 为输出启用摘要
- pt_BR: Habilitar resumo para a saída
- llm_description: enable summary
- form: form
- - name: max_retries
- type: number
- required: false
- default: 3
- label:
- en_US: Retry
- zh_Hans: 重试
- pt_BR: Repetir
- human_description:
- en_US: Number of times to retry the request if it fails
- zh_Hans: 请求失败时重试的次数
- pt_BR: Número de vezes para repetir a solicitação se falhar
- llm_description: Number of times to retry the request if it fails
- form: form
diff --git a/api/core/tools/provider/builtin/jina/tools/jina_search.py b/api/core/tools/provider/builtin/jina/tools/jina_search.py
deleted file mode 100644
index 30af6de783..0000000000
--- a/api/core/tools/provider/builtin/jina/tools/jina_search.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from typing import Any, Union
-
-from yarl import URL
-
-from core.helper import ssrf_proxy
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class JinaSearchTool(BuiltinTool):
- _jina_search_endpoint = "https://s.jina.ai/"
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- query = tool_parameters["query"]
-
- headers = {"Accept": "application/json"}
-
- if "api_key" in self.runtime.credentials and self.runtime.credentials.get("api_key"):
- headers["Authorization"] = "Bearer " + self.runtime.credentials.get("api_key")
-
- if tool_parameters.get("image_caption", False):
- headers["X-With-Generated-Alt"] = "true"
-
- if tool_parameters.get("gather_all_links_at_the_end", False):
- headers["X-With-Links-Summary"] = "true"
-
- if tool_parameters.get("gather_all_images_at_the_end", False):
- headers["X-With-Images-Summary"] = "true"
-
- proxy_server = tool_parameters.get("proxy_server")
- if proxy_server is not None and proxy_server != "":
- headers["X-Proxy-Url"] = proxy_server
-
- if tool_parameters.get("no_cache", False):
- headers["X-No-Cache"] = "true"
-
- max_retries = tool_parameters.get("max_retries", 3)
- response = ssrf_proxy.get(
- str(URL(self._jina_search_endpoint + query)), headers=headers, timeout=(10, 60), max_retries=max_retries
- )
-
- return self.create_text_message(response.text)
diff --git a/api/core/tools/provider/builtin/jina/tools/jina_search.yaml b/api/core/tools/provider/builtin/jina/tools/jina_search.yaml
deleted file mode 100644
index 2bc70e1be1..0000000000
--- a/api/core/tools/provider/builtin/jina/tools/jina_search.yaml
+++ /dev/null
@@ -1,107 +0,0 @@
-identity:
- name: jina_search
- author: Dify
- label:
- en_US: JinaSearch
- zh_Hans: JinaSearch
- pt_BR: JinaSearch
-description:
- human:
- en_US: Search on the web and get the top 5 results. Useful for grounding using information from the web.
- zh_Hans: 在网络上搜索返回前 5 个结果。
- llm: A tool for searching results on the web for grounding. Input should be a simple question.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Question (Query)
- zh_Hans: 信息查询
- human_description:
- en_US: used to find information on the web
- zh_Hans: 在网络上搜索信息
- llm_description: simple question to ask on the web
- form: llm
- - name: image_caption
- type: boolean
- required: false
- default: false
- label:
- en_US: Image caption
- zh_Hans: 图片说明
- pt_BR: Legenda da imagem
- human_description:
- en_US: "Captions all images at the specified URL, adding 'Image [idx]: [caption]' as an alt tag for those without one. This allows downstream LLMs to interact with the images in activities such as reasoning and summarizing."
- zh_Hans: "为指定 URL 上的所有图像添加标题,为没有标题的图像添加“Image [idx]: [caption]”作为 alt 标签。这允许下游 LLM 在推理和总结等活动中与图像进行交互。"
- pt_BR: "Captions all images at the specified URL, adding 'Image [idx]: [caption]' as an alt tag for those without one. This allows downstream LLMs to interact with the images in activities such as reasoning and summarizing."
- llm_description: Captions all images at the specified URL
- form: form
- - name: gather_all_links_at_the_end
- type: boolean
- required: false
- default: false
- label:
- en_US: Gather all links at the end
- zh_Hans: 将所有链接集中到最后
- pt_BR: Coletar todos os links ao final
- human_description:
- en_US: A "Buttons & Links" section will be created at the end. This helps the downstream LLMs or web agents navigating the page or take further actions.
- zh_Hans: 最后会创建一个“按钮和链接”部分。这可以帮助下游 LLM 或 Web 代理浏览页面或采取进一步的行动。
- pt_BR: A "Buttons & Links" section will be created at the end. This helps the downstream LLMs or web agents navigating the page or take further actions.
- llm_description: Gather all links at the end
- form: form
- - name: gather_all_images_at_the_end
- type: boolean
- required: false
- default: false
- label:
- en_US: Gather all images at the end
- zh_Hans: 将所有图片集中到最后
- pt_BR: Coletar todas as imagens ao final
- human_description:
- en_US: An "Images" section will be created at the end. This gives the downstream LLMs an overview of all visuals on the page, which may improve reasoning.
- zh_Hans: 最后会创建一个“图像”部分。这可以让下游的 LLM 概览页面上的所有视觉效果,从而提高推理能力。
- pt_BR: An "Images" section will be created at the end. This gives the downstream LLMs an overview of all visuals on the page, which may improve reasoning.
- llm_description: Gather all images at the end
- form: form
- - name: proxy_server
- type: string
- required: false
- label:
- en_US: Proxy server
- zh_Hans: 代理服务器
- pt_BR: Servidor de proxy
- human_description:
- en_US: Use proxy to access URLs
- zh_Hans: 利用代理访问 URL
- pt_BR: Use proxy to access URLs
- llm_description: Use proxy to access URLs
- form: form
- - name: no_cache
- type: boolean
- required: false
- default: false
- label:
- en_US: Bypass the Cache
- zh_Hans: 绕过缓存
- pt_BR: Ignorar o cache
- human_description:
- en_US: Bypass the Cache
- zh_Hans: 是否绕过缓存
- pt_BR: Ignorar o cache
- llm_description: bypass the cache
- form: form
- - name: max_retries
- type: number
- required: false
- default: 3
- label:
- en_US: Retry
- zh_Hans: 重试
- pt_BR: Repetir
- human_description:
- en_US: Number of times to retry the request if it fails
- zh_Hans: 请求失败时重试的次数
- pt_BR: Número de vezes para repetir a solicitação se falhar
- llm_description: Number of times to retry the request if it fails
- form: form
diff --git a/api/core/tools/provider/builtin/jina/tools/jina_tokenizer.py b/api/core/tools/provider/builtin/jina/tools/jina_tokenizer.py
deleted file mode 100644
index 06dabcc9c2..0000000000
--- a/api/core/tools/provider/builtin/jina/tools/jina_tokenizer.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from typing import Any
-
-from core.helper import ssrf_proxy
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class JinaTokenizerTool(BuiltinTool):
- _jina_tokenizer_endpoint = "https://tokenize.jina.ai/"
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> ToolInvokeMessage:
- content = tool_parameters["content"]
- body = {"content": content}
-
- headers = {"Content-Type": "application/json"}
-
- if "api_key" in self.runtime.credentials and self.runtime.credentials.get("api_key"):
- headers["Authorization"] = "Bearer " + self.runtime.credentials.get("api_key")
-
- if tool_parameters.get("return_chunks", False):
- body["return_chunks"] = True
-
- if tool_parameters.get("return_tokens", False):
- body["return_tokens"] = True
-
- if tokenizer := tool_parameters.get("tokenizer"):
- body["tokenizer"] = tokenizer
-
- response = ssrf_proxy.post(
- self._jina_tokenizer_endpoint,
- headers=headers,
- json=body,
- )
-
- return self.create_json_message(response.json())
diff --git a/api/core/tools/provider/builtin/jina/tools/jina_tokenizer.yaml b/api/core/tools/provider/builtin/jina/tools/jina_tokenizer.yaml
deleted file mode 100644
index 62a5c7e7ba..0000000000
--- a/api/core/tools/provider/builtin/jina/tools/jina_tokenizer.yaml
+++ /dev/null
@@ -1,70 +0,0 @@
-identity:
- name: jina_tokenizer
- author: hjlarry
- label:
- en_US: JinaTokenizer
-description:
- human:
- en_US: Free API to tokenize text and segment long text into chunks.
- zh_Hans: 免费的API可以将文本tokenize,也可以将长文本分割成多个部分。
- llm: Free API to tokenize text and segment long text into chunks.
-parameters:
- - name: content
- type: string
- required: true
- label:
- en_US: Content
- zh_Hans: 内容
- llm_description: the content which need to tokenize or segment
- form: llm
- - name: return_tokens
- type: boolean
- required: false
- label:
- en_US: Return the tokens
- zh_Hans: 是否返回tokens
- human_description:
- en_US: Return the tokens and their corresponding ids in the response.
- zh_Hans: 返回tokens及其对应的ids。
- form: form
- - name: return_chunks
- type: boolean
- label:
- en_US: Return the chunks
- zh_Hans: 是否分块
- human_description:
- en_US: Chunking the input into semantically meaningful segments while handling a wide variety of text types and edge cases based on common structural cues.
- zh_Hans: 将输入分块为具有语义意义的片段,同时根据常见的结构线索处理各种文本类型和边缘情况。
- form: form
- - name: tokenizer
- type: select
- options:
- - value: cl100k_base
- label:
- en_US: cl100k_base
- - value: o200k_base
- label:
- en_US: o200k_base
- - value: p50k_base
- label:
- en_US: p50k_base
- - value: r50k_base
- label:
- en_US: r50k_base
- - value: p50k_edit
- label:
- en_US: p50k_edit
- - value: gpt2
- label:
- en_US: gpt2
- label:
- en_US: Tokenizer
- human_description:
- en_US: |
- · cl100k_base --- gpt-4, gpt-3.5-turbo, gpt-3.5
- · o200k_base --- gpt-4o, gpt-4o-mini
- · p50k_base --- text-davinci-003, text-davinci-002
- · r50k_base --- text-davinci-001, text-curie-001
- · p50k_edit --- text-davinci-edit-001, code-davinci-edit-001
- · gpt2 --- gpt-2
- form: form
diff --git a/api/core/tools/provider/builtin/json_process/_assets/icon.svg b/api/core/tools/provider/builtin/json_process/_assets/icon.svg
deleted file mode 100644
index b123983836..0000000000
--- a/api/core/tools/provider/builtin/json_process/_assets/icon.svg
+++ /dev/null
@@ -1,358 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/json_process/json_process.py b/api/core/tools/provider/builtin/json_process/json_process.py
deleted file mode 100644
index 10746210b5..0000000000
--- a/api/core/tools/provider/builtin/json_process/json_process.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.json_process.tools.parse import JSONParseTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class JsonExtractProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- JSONParseTool().invoke(
- user_id="",
- tool_parameters={"content": '{"name": "John", "age": 30, "city": "New York"}', "json_filter": "$.name"},
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/json_process/json_process.yaml b/api/core/tools/provider/builtin/json_process/json_process.yaml
deleted file mode 100644
index c7896bbea7..0000000000
--- a/api/core/tools/provider/builtin/json_process/json_process.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-identity:
- author: Mingwei Zhang
- name: json_process
- label:
- en_US: JSON Process
- zh_Hans: JSON 处理
- pt_BR: JSON Process
- description:
- en_US: Tools for processing JSON content using jsonpath_ng
- zh_Hans: 利用 jsonpath_ng 处理 JSON 内容的工具
- pt_BR: Tools for processing JSON content using jsonpath_ng
- icon: icon.svg
- tags:
- - utilities
diff --git a/api/core/tools/provider/builtin/json_process/tools/delete.py b/api/core/tools/provider/builtin/json_process/tools/delete.py
deleted file mode 100644
index fcab3d71a9..0000000000
--- a/api/core/tools/provider/builtin/json_process/tools/delete.py
+++ /dev/null
@@ -1,61 +0,0 @@
-import json
-from typing import Any, Union
-
-from jsonpath_ng import parse
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class JSONDeleteTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke the JSON delete tool
- """
- # Get content
- content = tool_parameters.get("content", "")
- if not content:
- return self.create_text_message("Invalid parameter content")
-
- # Get query
- query = tool_parameters.get("query", "")
- if not query:
- return self.create_text_message("Invalid parameter query")
-
- ensure_ascii = tool_parameters.get("ensure_ascii", True)
- try:
- result = self._delete(content, query, ensure_ascii)
- return self.create_text_message(str(result))
- except Exception as e:
- return self.create_text_message(f"Failed to delete JSON content: {str(e)}")
-
- def _delete(self, origin_json: str, query: str, ensure_ascii: bool) -> str:
- try:
- input_data = json.loads(origin_json)
- expr = parse("$." + query.lstrip("$.")) # Ensure query path starts with $
-
- matches = expr.find(input_data)
-
- if not matches:
- return json.dumps(input_data, ensure_ascii=ensure_ascii) # No changes if no matches found
-
- for match in matches:
- if isinstance(match.context.value, dict):
- # Delete key from dictionary
- del match.context.value[match.path.fields[-1]]
- elif isinstance(match.context.value, list):
- # Remove item from list
- match.context.value.remove(match.value)
- else:
- # For other cases, we might want to set to None or remove the parent key
- parent = match.context.parent
- if parent:
- del parent.value[match.path.fields[-1]]
-
- return json.dumps(input_data, ensure_ascii=ensure_ascii)
- except Exception as e:
- raise Exception(f"Delete operation failed: {str(e)}")
diff --git a/api/core/tools/provider/builtin/json_process/tools/delete.yaml b/api/core/tools/provider/builtin/json_process/tools/delete.yaml
deleted file mode 100644
index 4d390e40d1..0000000000
--- a/api/core/tools/provider/builtin/json_process/tools/delete.yaml
+++ /dev/null
@@ -1,52 +0,0 @@
-identity:
- name: json_delete
- author: Mingwei Zhang
- label:
- en_US: JSON Delete
- zh_Hans: JSON 删除
- pt_BR: JSON Delete
-description:
- human:
- en_US: A tool for deleting JSON content
- zh_Hans: 一个删除 JSON 内容的工具
- pt_BR: A tool for deleting JSON content
- llm: A tool for deleting JSON content
-parameters:
- - name: content
- type: string
- required: true
- label:
- en_US: JSON content
- zh_Hans: JSON 内容
- pt_BR: JSON content
- human_description:
- en_US: JSON content to be processed
- zh_Hans: 待处理的 JSON 内容
- pt_BR: JSON content to be processed
- llm_description: JSON content to be processed
- form: llm
- - name: query
- type: string
- required: true
- label:
- en_US: Query
- zh_Hans: 查询
- pt_BR: Query
- human_description:
- en_US: JSONPath query to locate the element to delete
- zh_Hans: 用于定位要删除元素的 JSONPath 查询
- pt_BR: JSONPath query to locate the element to delete
- llm_description: JSONPath query to locate the element to delete
- form: llm
- - name: ensure_ascii
- type: boolean
- default: true
- label:
- en_US: Ensure ASCII
- zh_Hans: 确保 ASCII
- pt_BR: Ensure ASCII
- human_description:
- en_US: Ensure the JSON output is ASCII encoded
- zh_Hans: 确保输出的 JSON 是 ASCII 编码
- pt_BR: Ensure the JSON output is ASCII encoded
- form: form
diff --git a/api/core/tools/provider/builtin/json_process/tools/insert.py b/api/core/tools/provider/builtin/json_process/tools/insert.py
deleted file mode 100644
index 793c74e5f9..0000000000
--- a/api/core/tools/provider/builtin/json_process/tools/insert.py
+++ /dev/null
@@ -1,105 +0,0 @@
-import json
-from typing import Any, Union
-
-from jsonpath_ng import parse
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class JSONParseTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- # get content
- content = tool_parameters.get("content", "")
- if not content:
- return self.create_text_message("Invalid parameter content")
-
- # get query
- query = tool_parameters.get("query", "")
- if not query:
- return self.create_text_message("Invalid parameter query")
-
- # get new value
- new_value = tool_parameters.get("new_value", "")
- if not new_value:
- return self.create_text_message("Invalid parameter new_value")
-
- # get insert position
- index = tool_parameters.get("index")
-
- # get create path
- create_path = tool_parameters.get("create_path", False)
-
- # get value decode.
- # if true, it will be decoded to an dict
- value_decode = tool_parameters.get("value_decode", False)
-
- ensure_ascii = tool_parameters.get("ensure_ascii", True)
- try:
- result = self._insert(content, query, new_value, ensure_ascii, value_decode, index, create_path)
- return self.create_text_message(str(result))
- except Exception:
- return self.create_text_message("Failed to insert JSON content")
-
- def _insert(
- self, origin_json, query, new_value, ensure_ascii: bool, value_decode: bool, index=None, create_path=False
- ):
- try:
- input_data = json.loads(origin_json)
- expr = parse(query)
- if value_decode is True:
- try:
- new_value = json.loads(new_value)
- except json.JSONDecodeError:
- return "Cannot decode new value to json object"
-
- matches = expr.find(input_data)
-
- if not matches and create_path:
- # create new path
- path_parts = query.strip("$").strip(".").split(".")
- current = input_data
- for i, part in enumerate(path_parts):
- if "[" in part and "]" in part:
- # process array index
- array_name, index = part.split("[")
- index = int(index.rstrip("]"))
- if array_name not in current:
- current[array_name] = []
- while len(current[array_name]) <= index:
- current[array_name].append({})
- current = current[array_name][index]
- else:
- if i == len(path_parts) - 1:
- current[part] = new_value
- elif part not in current:
- current[part] = {}
- current = current[part]
- else:
- for match in matches:
- if isinstance(match.value, dict):
- # insert new value into dict
- if isinstance(new_value, dict):
- match.value.update(new_value)
- else:
- raise ValueError("Cannot insert non-dict value into dict")
- elif isinstance(match.value, list):
- # insert new value into list
- if index is None:
- match.value.append(new_value)
- else:
- match.value.insert(int(index), new_value)
- else:
- # replace old value with new value
- match.full_path.update(input_data, new_value)
-
- return json.dumps(input_data, ensure_ascii=ensure_ascii)
- except Exception as e:
- return str(e)
diff --git a/api/core/tools/provider/builtin/json_process/tools/insert.yaml b/api/core/tools/provider/builtin/json_process/tools/insert.yaml
deleted file mode 100644
index 21b51312da..0000000000
--- a/api/core/tools/provider/builtin/json_process/tools/insert.yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-identity:
- name: json_insert
- author: Mingwei Zhang
- label:
- en_US: JSON Insert
- zh_Hans: JSON 插入
- pt_BR: JSON Insert
-description:
- human:
- en_US: A tool for inserting JSON content
- zh_Hans: 一个插入 JSON 内容的工具
- pt_BR: A tool for inserting JSON content
- llm: A tool for inserting JSON content
-parameters:
- - name: content
- type: string
- required: true
- label:
- en_US: JSON content
- zh_Hans: JSON 内容
- pt_BR: JSON content
- human_description:
- en_US: JSON content
- zh_Hans: JSON 内容
- pt_BR: JSON content
- llm_description: JSON content to be processed
- form: llm
- - name: query
- type: string
- required: true
- label:
- en_US: Query
- zh_Hans: 查询
- pt_BR: Query
- human_description:
- en_US: Object to insert
- zh_Hans: 待插入的对象
- pt_BR: Object to insert
- llm_description: JSONPath query to locate the element to insert
- form: llm
- - name: new_value
- type: string
- required: true
- label:
- en_US: New Value
- zh_Hans: 新值
- pt_BR: New Value
- human_description:
- en_US: New Value
- zh_Hans: 插入的新值
- pt_BR: New Value
- llm_description: New Value to insert
- form: llm
- - name: value_decode
- type: boolean
- default: false
- label:
- en_US: Decode Value
- zh_Hans: 解码值
- pt_BR: Decode Value
- human_description:
- en_US: Whether to decode the value to a JSON object
- zh_Hans: 是否将值解码为 JSON 对象
- pt_BR: Whether to decode the value to a JSON object
- form: form
- - name: create_path
- type: select
- required: true
- default: "False"
- label:
- en_US: Whether to create a path
- zh_Hans: 是否创建路径
- pt_BR: Whether to create a path
- human_description:
- en_US: Whether to create a path when the path does not exist
- zh_Hans: 查询路径不存在时是否创建路径
- pt_BR: Whether to create a path when the path does not exist
- options:
- - value: "True"
- label:
- en_US: "Yes"
- zh_Hans: 是
- pt_BR: "Yes"
- - value: "False"
- label:
- en_US: "No"
- zh_Hans: 否
- pt_BR: "No"
- form: form
- - name: ensure_ascii
- type: boolean
- default: true
- label:
- en_US: Ensure ASCII
- zh_Hans: 确保 ASCII
- pt_BR: Ensure ASCII
- human_description:
- en_US: Ensure the JSON output is ASCII encoded
- zh_Hans: 确保输出的 JSON 是 ASCII 编码
- pt_BR: Ensure the JSON output is ASCII encoded
- form: form
diff --git a/api/core/tools/provider/builtin/json_process/tools/parse.py b/api/core/tools/provider/builtin/json_process/tools/parse.py
deleted file mode 100644
index 37cae40153..0000000000
--- a/api/core/tools/provider/builtin/json_process/tools/parse.py
+++ /dev/null
@@ -1,53 +0,0 @@
-import json
-from typing import Any, Union
-
-from jsonpath_ng import parse
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class JSONParseTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- # get content
- content = tool_parameters.get("content", "")
- if not content:
- return self.create_text_message("Invalid parameter content")
-
- # get json filter
- json_filter = tool_parameters.get("json_filter", "")
- if not json_filter:
- return self.create_text_message("Invalid parameter json_filter")
-
- ensure_ascii = tool_parameters.get("ensure_ascii", True)
- try:
- result = self._extract(content, json_filter, ensure_ascii)
- return self.create_text_message(str(result))
- except Exception:
- return self.create_text_message("Failed to extract JSON content")
-
- # Extract data from JSON content
- def _extract(self, content: str, json_filter: str, ensure_ascii: bool) -> str:
- try:
- input_data = json.loads(content)
- expr = parse(json_filter)
- result = [match.value for match in expr.find(input_data)]
-
- if len(result) == 1:
- result = result[0]
-
- if isinstance(result, dict | list):
- return json.dumps(result, ensure_ascii=ensure_ascii)
- elif isinstance(result, str | int | float | bool) or result is None:
- return str(result)
- else:
- return repr(result)
- except Exception as e:
- return str(e)
diff --git a/api/core/tools/provider/builtin/json_process/tools/parse.yaml b/api/core/tools/provider/builtin/json_process/tools/parse.yaml
deleted file mode 100644
index c35f4eac07..0000000000
--- a/api/core/tools/provider/builtin/json_process/tools/parse.yaml
+++ /dev/null
@@ -1,52 +0,0 @@
-identity:
- name: parse
- author: Mingwei Zhang
- label:
- en_US: JSON Parse
- zh_Hans: JSON 解析
- pt_BR: JSON Parse
-description:
- human:
- en_US: A tool for extracting JSON objects
- zh_Hans: 一个解析JSON对象的工具
- pt_BR: A tool for extracting JSON objects
- llm: A tool for extracting JSON objects
-parameters:
- - name: content
- type: string
- required: true
- label:
- en_US: JSON data
- zh_Hans: JSON数据
- pt_BR: JSON data
- human_description:
- en_US: JSON data
- zh_Hans: JSON数据
- pt_BR: JSON数据
- llm_description: JSON data to be processed
- form: llm
- - name: json_filter
- type: string
- required: true
- label:
- en_US: JSON filter
- zh_Hans: JSON解析对象
- pt_BR: JSON filter
- human_description:
- en_US: JSON fields to be parsed
- zh_Hans: 需要解析的 JSON 字段
- pt_BR: JSON fields to be parsed
- llm_description: JSON fields to be parsed
- form: llm
- - name: ensure_ascii
- type: boolean
- default: true
- label:
- en_US: Ensure ASCII
- zh_Hans: 确保 ASCII
- pt_BR: Ensure ASCII
- human_description:
- en_US: Ensure the JSON output is ASCII encoded
- zh_Hans: 确保输出的 JSON 是 ASCII 编码
- pt_BR: Ensure the JSON output is ASCII encoded
- form: form
diff --git a/api/core/tools/provider/builtin/json_process/tools/replace.py b/api/core/tools/provider/builtin/json_process/tools/replace.py
deleted file mode 100644
index 383825c2d0..0000000000
--- a/api/core/tools/provider/builtin/json_process/tools/replace.py
+++ /dev/null
@@ -1,129 +0,0 @@
-import json
-from typing import Any, Union
-
-from jsonpath_ng import parse
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class JSONReplaceTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- # get content
- content = tool_parameters.get("content", "")
- if not content:
- return self.create_text_message("Invalid parameter content")
-
- # get query
- query = tool_parameters.get("query", "")
- if not query:
- return self.create_text_message("Invalid parameter query")
-
- # get replace value
- replace_value = tool_parameters.get("replace_value", "")
- if not replace_value:
- return self.create_text_message("Invalid parameter replace_value")
-
- # get replace model
- replace_model = tool_parameters.get("replace_model", "")
- if not replace_model:
- return self.create_text_message("Invalid parameter replace_model")
-
- # get value decode.
- # if true, it will be decoded to an dict
- value_decode = tool_parameters.get("value_decode", False)
-
- ensure_ascii = tool_parameters.get("ensure_ascii", True)
- try:
- if replace_model == "pattern":
- # get replace pattern
- replace_pattern = tool_parameters.get("replace_pattern", "")
- if not replace_pattern:
- return self.create_text_message("Invalid parameter replace_pattern")
- result = self._replace_pattern(
- content, query, replace_pattern, replace_value, ensure_ascii, value_decode
- )
- elif replace_model == "key":
- result = self._replace_key(content, query, replace_value, ensure_ascii)
- elif replace_model == "value":
- result = self._replace_value(content, query, replace_value, ensure_ascii, value_decode)
- return self.create_text_message(str(result))
- except Exception:
- return self.create_text_message("Failed to replace JSON content")
-
- # Replace pattern
- def _replace_pattern(
- self, content: str, query: str, replace_pattern: str, replace_value: str, ensure_ascii: bool, value_decode: bool
- ) -> str:
- try:
- input_data = json.loads(content)
- expr = parse(query)
-
- matches = expr.find(input_data)
-
- for match in matches:
- new_value = match.value.replace(replace_pattern, replace_value)
- if value_decode is True:
- try:
- new_value = json.loads(new_value)
- except json.JSONDecodeError:
- return "Cannot decode replace value to json object"
-
- match.full_path.update(input_data, new_value)
-
- return json.dumps(input_data, ensure_ascii=ensure_ascii)
- except Exception as e:
- return str(e)
-
- # Replace key
- def _replace_key(self, content: str, query: str, replace_value: str, ensure_ascii: bool) -> str:
- try:
- input_data = json.loads(content)
- expr = parse(query)
-
- matches = expr.find(input_data)
-
- for match in matches:
- parent = match.context.value
- if isinstance(parent, dict):
- old_key = match.path.fields[0]
- if old_key in parent:
- value = parent.pop(old_key)
- parent[replace_value] = value
- elif isinstance(parent, list):
- for item in parent:
- if isinstance(item, dict) and old_key in item:
- value = item.pop(old_key)
- item[replace_value] = value
- return json.dumps(input_data, ensure_ascii=ensure_ascii)
- except Exception as e:
- return str(e)
-
- # Replace value
- def _replace_value(
- self, content: str, query: str, replace_value: str, ensure_ascii: bool, value_decode: bool
- ) -> str:
- try:
- input_data = json.loads(content)
- expr = parse(query)
- if value_decode is True:
- try:
- replace_value = json.loads(replace_value)
- except json.JSONDecodeError:
- return "Cannot decode replace value to json object"
-
- matches = expr.find(input_data)
-
- for match in matches:
- match.full_path.update(input_data, replace_value)
-
- return json.dumps(input_data, ensure_ascii=ensure_ascii)
- except Exception as e:
- return str(e)
diff --git a/api/core/tools/provider/builtin/json_process/tools/replace.yaml b/api/core/tools/provider/builtin/json_process/tools/replace.yaml
deleted file mode 100644
index ae238b1fbc..0000000000
--- a/api/core/tools/provider/builtin/json_process/tools/replace.yaml
+++ /dev/null
@@ -1,119 +0,0 @@
-identity:
- name: json_replace
- author: Mingwei Zhang
- label:
- en_US: JSON Replace
- zh_Hans: JSON 替换
- pt_BR: JSON Replace
-description:
- human:
- en_US: A tool for replacing JSON content
- zh_Hans: 一个替换 JSON 内容的工具
- pt_BR: A tool for replacing JSON content
- llm: A tool for replacing JSON content
-parameters:
- - name: content
- type: string
- required: true
- label:
- en_US: JSON content
- zh_Hans: JSON 内容
- pt_BR: JSON content
- human_description:
- en_US: JSON content
- zh_Hans: JSON 内容
- pt_BR: JSON content
- llm_description: JSON content to be processed
- form: llm
- - name: query
- type: string
- required: true
- label:
- en_US: Query
- zh_Hans: 查询
- pt_BR: Query
- human_description:
- en_US: Query
- zh_Hans: 查询
- pt_BR: Query
- llm_description: JSONPath query to locate the element to replace
- form: llm
- - name: replace_pattern
- type: string
- required: false
- label:
- en_US: String to be replaced
- zh_Hans: 待替换字符串
- pt_BR: String to be replaced
- human_description:
- en_US: String to be replaced
- zh_Hans: 待替换字符串
- pt_BR: String to be replaced
- llm_description: String to be replaced
- form: llm
- - name: replace_value
- type: string
- required: true
- label:
- en_US: Replace Value
- zh_Hans: 替换值
- pt_BR: Replace Value
- human_description:
- en_US: New Value
- zh_Hans: 新值
- pt_BR: New Value
- llm_description: New Value to replace
- form: llm
- - name: value_decode
- type: boolean
- default: false
- label:
- en_US: Decode Value
- zh_Hans: 解码值
- pt_BR: Decode Value
- human_description:
- en_US: Whether to decode the value to a JSON object (Does not apply to replace key)
- zh_Hans: 是否将值解码为 JSON 对象 (不适用于键替换)
- pt_BR: Whether to decode the value to a JSON object (Does not apply to replace key)
- form: form
- - name: replace_model
- type: select
- required: true
- default: pattern
- label:
- en_US: Replace Model
- zh_Hans: 替换模式
- pt_BR: Replace Model
- human_description:
- en_US: Replace Model
- zh_Hans: 替换模式
- pt_BR: Replace Model
- options:
- - value: key
- label:
- en_US: replace key
- zh_Hans: 键替换
- pt_BR: replace key
- - value: value
- label:
- en_US: replace value
- zh_Hans: 值替换
- pt_BR: replace value
- - value: pattern
- label:
- en_US: replace string
- zh_Hans: 字符串替换
- pt_BR: replace string
- form: form
- - name: ensure_ascii
- type: boolean
- default: true
- label:
- en_US: Ensure ASCII
- zh_Hans: 确保 ASCII
- pt_BR: Ensure ASCII
- human_description:
- en_US: Ensure the JSON output is ASCII encoded
- zh_Hans: 确保输出的 JSON 是 ASCII 编码
- pt_BR: Ensure the JSON output is ASCII encoded
- form: form
diff --git a/api/core/tools/provider/builtin/judge0ce/_assets/icon.svg b/api/core/tools/provider/builtin/judge0ce/_assets/icon.svg
deleted file mode 100644
index 3e7e33da6e..0000000000
--- a/api/core/tools/provider/builtin/judge0ce/_assets/icon.svg
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
diff --git a/api/core/tools/provider/builtin/judge0ce/judge0ce.py b/api/core/tools/provider/builtin/judge0ce/judge0ce.py
deleted file mode 100644
index 50db74dd9e..0000000000
--- a/api/core/tools/provider/builtin/judge0ce/judge0ce.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.judge0ce.tools.executeCode import ExecuteCodeTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class Judge0CEProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- ExecuteCodeTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "source_code": "print('hello world')",
- "language_id": 71,
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/judge0ce/judge0ce.yaml b/api/core/tools/provider/builtin/judge0ce/judge0ce.yaml
deleted file mode 100644
index 9ff8aaac6d..0000000000
--- a/api/core/tools/provider/builtin/judge0ce/judge0ce.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-identity:
- author: Richards Tu
- name: judge0ce
- label:
- en_US: Judge0 CE
- zh_Hans: Judge0 CE
- pt_BR: Judge0 CE
- description:
- en_US: Judge0 CE is an open-source code execution system. Support various languages, including C, C++, Java, Python, Ruby, etc.
- zh_Hans: Judge0 CE 是一个开源的代码执行系统。支持多种语言,包括 C、C++、Java、Python、Ruby 等。
- pt_BR: Judge0 CE é um sistema de execução de código de código aberto. Suporta várias linguagens, incluindo C, C++, Java, Python, Ruby, etc.
- icon: icon.svg
- tags:
- - utilities
- - other
-credentials_for_provider:
- X-RapidAPI-Key:
- type: secret-input
- required: true
- label:
- en_US: RapidAPI Key
- zh_Hans: RapidAPI Key
- pt_BR: RapidAPI Key
- help:
- en_US: RapidAPI Key is required to access the Judge0 CE API.
- zh_Hans: RapidAPI Key 是访问 Judge0 CE API 所必需的。
- pt_BR: RapidAPI Key é necessário para acessar a API do Judge0 CE.
- placeholder:
- en_US: Enter your RapidAPI Key
- zh_Hans: 输入你的 RapidAPI Key
- pt_BR: Insira sua RapidAPI Key
- url: https://rapidapi.com/judge0-official/api/judge0-ce
diff --git a/api/core/tools/provider/builtin/judge0ce/tools/executeCode.py b/api/core/tools/provider/builtin/judge0ce/tools/executeCode.py
deleted file mode 100644
index b8d654ff63..0000000000
--- a/api/core/tools/provider/builtin/judge0ce/tools/executeCode.py
+++ /dev/null
@@ -1,61 +0,0 @@
-import json
-from typing import Any, Union
-
-import requests
-from httpx import post
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class ExecuteCodeTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- api_key = self.runtime.credentials["X-RapidAPI-Key"]
-
- url = "https://judge0-ce.p.rapidapi.com/submissions"
-
- querystring = {"base64_encoded": "false", "fields": "*"}
-
- headers = {
- "Content-Type": "application/json",
- "X-RapidAPI-Key": api_key,
- "X-RapidAPI-Host": "judge0-ce.p.rapidapi.com",
- }
-
- payload = {
- "language_id": tool_parameters["language_id"],
- "source_code": tool_parameters["source_code"],
- "stdin": tool_parameters.get("stdin", ""),
- "expected_output": tool_parameters.get("expected_output", ""),
- "additional_files": tool_parameters.get("additional_files", ""),
- }
-
- response = post(url, data=json.dumps(payload), headers=headers, params=querystring)
-
- if response.status_code != 201:
- raise Exception(response.text)
-
- token = response.json()["token"]
-
- url = f"https://judge0-ce.p.rapidapi.com/submissions/{token}"
- headers = {"X-RapidAPI-Key": api_key}
-
- response = requests.get(url, headers=headers)
- if response.status_code == 200:
- result = response.json()
- return self.create_text_message(
- text=f"stdout: {result.get('stdout', '')}\n"
- f"stderr: {result.get('stderr', '')}\n"
- f"compile_output: {result.get('compile_output', '')}\n"
- f"message: {result.get('message', '')}\n"
- f"status: {result['status']['description']}\n"
- f"time: {result.get('time', '')} seconds\n"
- f"memory: {result.get('memory', '')} bytes"
- )
- else:
- return self.create_text_message(text=f"Error retrieving submission details: {response.text}")
diff --git a/api/core/tools/provider/builtin/judge0ce/tools/executeCode.yaml b/api/core/tools/provider/builtin/judge0ce/tools/executeCode.yaml
deleted file mode 100644
index a8c0776f40..0000000000
--- a/api/core/tools/provider/builtin/judge0ce/tools/executeCode.yaml
+++ /dev/null
@@ -1,67 +0,0 @@
-identity:
- name: submitCodeExecutionTask
- author: Richards Tu
- label:
- en_US: Submit Code Execution Task to Judge0 CE and get execution result.
- zh_Hans: 提交代码执行任务到 Judge0 CE 并获取执行结果。
-description:
- human:
- en_US: A tool for executing code and getting the result.
- zh_Hans: 一个用于执行代码并获取结果的工具。
- llm: This tool is used for executing code and getting the result.
-parameters:
- - name: source_code
- type: string
- required: true
- label:
- en_US: Source Code
- zh_Hans: 源代码
- human_description:
- en_US: The source code to be executed.
- zh_Hans: 要执行的源代码。
- llm_description: The source code to be executed.
- form: llm
- - name: language_id
- type: number
- required: true
- label:
- en_US: Language ID
- zh_Hans: 语言 ID
- human_description:
- en_US: The ID of the language in which the source code is written.
- zh_Hans: 源代码所使用的语言的 ID。
- llm_description: The ID of the language in which the source code is written. For example, 50 for C++, 71 for Python, etc.
- form: llm
- - name: stdin
- type: string
- required: false
- label:
- en_US: Standard Input
- zh_Hans: 标准输入
- human_description:
- en_US: The standard input to be provided to the program.
- zh_Hans: 提供给程序的标准输入。
- llm_description: The standard input to be provided to the program. Optional.
- form: llm
- - name: expected_output
- type: string
- required: false
- label:
- en_US: Expected Output
- zh_Hans: 期望输出
- human_description:
- en_US: The expected output of the program. Used for comparison in some scenarios.
- zh_Hans: 程序的期望输出。在某些场景下用于比较。
- llm_description: The expected output of the program. Used for comparison in some scenarios. Optional.
- form: llm
- - name: additional_files
- type: string
- required: false
- label:
- en_US: Additional Files
- zh_Hans: 附加文件
- human_description:
- en_US: Base64 encoded additional files for the submission.
- zh_Hans: 提交的 Base64 编码的附加文件。
- llm_description: Base64 encoded additional files for the submission. Optional.
- form: llm
diff --git a/api/core/tools/provider/builtin/maths/_assets/icon.svg b/api/core/tools/provider/builtin/maths/_assets/icon.svg
deleted file mode 100644
index f94d115211..0000000000
--- a/api/core/tools/provider/builtin/maths/_assets/icon.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
diff --git a/api/core/tools/provider/builtin/maths/maths.py b/api/core/tools/provider/builtin/maths/maths.py
deleted file mode 100644
index d4b449ec87..0000000000
--- a/api/core/tools/provider/builtin/maths/maths.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.maths.tools.eval_expression import EvaluateExpressionTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class MathsProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- EvaluateExpressionTool().invoke(
- user_id="",
- tool_parameters={
- "expression": "1+(2+3)*4",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/maths/maths.yaml b/api/core/tools/provider/builtin/maths/maths.yaml
deleted file mode 100644
index 35c2380e29..0000000000
--- a/api/core/tools/provider/builtin/maths/maths.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-identity:
- author: Bowen Liang
- name: maths
- label:
- en_US: Maths
- zh_Hans: 数学工具
- pt_BR: Maths
- description:
- en_US: A tool for maths.
- zh_Hans: 一个用于数学计算的工具。
- pt_BR: A tool for maths.
- icon: icon.svg
- tags:
- - utilities
- - productivity
diff --git a/api/core/tools/provider/builtin/maths/tools/eval_expression.py b/api/core/tools/provider/builtin/maths/tools/eval_expression.py
deleted file mode 100644
index 0c5b5e41cb..0000000000
--- a/api/core/tools/provider/builtin/maths/tools/eval_expression.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import logging
-from typing import Any, Union
-
-import numexpr as ne
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class EvaluateExpressionTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- # get expression
- expression = tool_parameters.get("expression", "").strip()
- if not expression:
- return self.create_text_message("Invalid expression")
-
- try:
- result = ne.evaluate(expression)
- result_str = str(result)
- except Exception as e:
- logging.exception(f"Error evaluating expression: {expression}")
- return self.create_text_message(f"Invalid expression: {expression}, error: {str(e)}")
- return self.create_text_message(f'The result of the expression "{expression}" is {result_str}')
diff --git a/api/core/tools/provider/builtin/maths/tools/eval_expression.yaml b/api/core/tools/provider/builtin/maths/tools/eval_expression.yaml
deleted file mode 100644
index c936a4293f..0000000000
--- a/api/core/tools/provider/builtin/maths/tools/eval_expression.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-identity:
- name: eval_expression
- author: Bowen Liang
- label:
- en_US: Evaluate Math Expression
- zh_Hans: 计算数学表达式
- pt_BR: Evaluate Math Expression
-description:
- human:
- en_US: A tool for evaluating an math expression, calculated locally with NumExpr.
- zh_Hans: 一个用于计算数学表达式的工具,表达式将通过NumExpr本地执行。
- pt_BR: A tool for evaluating an math expression, calculated locally with NumExpr.
- llm: A tool for evaluating an math expression.
-parameters:
- - name: expression
- type: string
- required: true
- label:
- en_US: Math Expression
- zh_Hans: 数学计算表达式
- pt_BR: Math Expression
- human_description:
- en_US: Math Expression
- zh_Hans: 数学计算表达式
- pt_BR: Math Expression
- form: llm
diff --git a/api/core/tools/provider/builtin/nominatim/_assets/icon.svg b/api/core/tools/provider/builtin/nominatim/_assets/icon.svg
deleted file mode 100644
index db5a4eb868..0000000000
--- a/api/core/tools/provider/builtin/nominatim/_assets/icon.svg
+++ /dev/null
@@ -1,277 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/nominatim/nominatim.py b/api/core/tools/provider/builtin/nominatim/nominatim.py
deleted file mode 100644
index 5a24bed750..0000000000
--- a/api/core/tools/provider/builtin/nominatim/nominatim.py
+++ /dev/null
@@ -1,27 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.nominatim.tools.nominatim_search import NominatimSearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class NominatimProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- result = (
- NominatimSearchTool()
- .fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- )
- .invoke(
- user_id="",
- tool_parameters={
- "query": "London",
- "limit": 1,
- },
- )
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/nominatim/nominatim.yaml b/api/core/tools/provider/builtin/nominatim/nominatim.yaml
deleted file mode 100644
index 7d014bd78c..0000000000
--- a/api/core/tools/provider/builtin/nominatim/nominatim.yaml
+++ /dev/null
@@ -1,43 +0,0 @@
-identity:
- author: Charles Zhou
- name: nominatim
- label:
- en_US: Nominatim
- zh_Hans: Nominatim
- de_DE: Nominatim
- ja_JP: Nominatim
- description:
- en_US: Nominatim is a search engine for OpenStreetMap data
- zh_Hans: Nominatim是OpenStreetMap数据的搜索引擎
- de_DE: Nominatim ist eine Suchmaschine für OpenStreetMap-Daten
- ja_JP: NominatimはOpenStreetMapデータの検索エンジンです
- icon: icon.svg
- tags:
- - search
- - utilities
-credentials_for_provider:
- base_url:
- type: text-input
- required: false
- default: https://nominatim.openstreetmap.org
- label:
- en_US: Nominatim Base URL
- zh_Hans: Nominatim 基础 URL
- de_DE: Nominatim Basis-URL
- ja_JP: Nominatim ベースURL
- placeholder:
- en_US: "Enter your Nominatim instance URL (default:
- https://nominatim.openstreetmap.org)"
- zh_Hans: 输入您的Nominatim实例URL(默认:https://nominatim.openstreetmap.org)
- de_DE: "Geben Sie Ihre Nominatim-Instanz-URL ein (Standard:
- https://nominatim.openstreetmap.org)"
- ja_JP: NominatimインスタンスのURLを入力してください(デフォルト:https://nominatim.openstreetmap.org)
- help:
- en_US: The base URL for the Nominatim instance. Use the default for the public
- service or enter your self-hosted instance URL.
- zh_Hans: Nominatim实例的基础URL。使用默认值可访问公共服务,或输入您的自托管实例URL。
- de_DE: Die Basis-URL für die Nominatim-Instanz. Verwenden Sie den Standardwert
- für den öffentlichen Dienst oder geben Sie die URL Ihrer selbst
- gehosteten Instanz ein.
- ja_JP: NominatimインスタンスのベースURL。公共サービスにはデフォルトを使用するか、自己ホスティングインスタンスのURLを入力してください。
- url: https://nominatim.org/
diff --git a/api/core/tools/provider/builtin/nominatim/tools/nominatim_lookup.py b/api/core/tools/provider/builtin/nominatim/tools/nominatim_lookup.py
deleted file mode 100644
index ffa8ad0fcc..0000000000
--- a/api/core/tools/provider/builtin/nominatim/tools/nominatim_lookup.py
+++ /dev/null
@@ -1,40 +0,0 @@
-import json
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class NominatimLookupTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- osm_ids = tool_parameters.get("osm_ids", "")
-
- if not osm_ids:
- return self.create_text_message("Please provide OSM IDs")
-
- params = {"osm_ids": osm_ids, "format": "json", "addressdetails": 1}
-
- return self._make_request(user_id, "lookup", params)
-
- def _make_request(self, user_id: str, endpoint: str, params: dict) -> ToolInvokeMessage:
- base_url = self.runtime.credentials.get("base_url", "https://nominatim.openstreetmap.org")
-
- try:
- headers = {"User-Agent": "DifyNominatimTool/1.0"}
- s = requests.session()
- response = s.request(method="GET", headers=headers, url=f"{base_url}/{endpoint}", params=params)
- response_data = response.json()
-
- if response.status_code == 200:
- s.close()
- return self.create_text_message(
- self.summary(user_id=user_id, content=json.dumps(response_data, ensure_ascii=False))
- )
- else:
- return self.create_text_message(f"Error: {response.status_code} - {response.text}")
- except Exception as e:
- return self.create_text_message(f"An error occurred: {str(e)}")
diff --git a/api/core/tools/provider/builtin/nominatim/tools/nominatim_lookup.yaml b/api/core/tools/provider/builtin/nominatim/tools/nominatim_lookup.yaml
deleted file mode 100644
index 508c4dcd88..0000000000
--- a/api/core/tools/provider/builtin/nominatim/tools/nominatim_lookup.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-identity:
- name: nominatim_lookup
- author: Charles Zhou
- label:
- en_US: Nominatim OSM Lookup
- zh_Hans: Nominatim OSM 对象查找
- de_DE: Nominatim OSM-Objektsuche
- ja_JP: Nominatim OSM ルックアップ
-description:
- human:
- en_US: Look up OSM objects using their IDs with Nominatim
- zh_Hans: 使用Nominatim通过ID查找OSM对象
- de_DE: Suchen Sie OSM-Objekte anhand ihrer IDs mit Nominatim
- ja_JP: Nominatimを使用してIDでOSMオブジェクトを検索
- llm: A tool for looking up OpenStreetMap objects using their IDs with Nominatim.
-parameters:
- - name: osm_ids
- type: string
- required: true
- label:
- en_US: OSM IDs
- zh_Hans: OSM ID
- de_DE: OSM-IDs
- ja_JP: OSM ID
- human_description:
- en_US: Comma-separated list of OSM IDs to lookup (e.g., N123,W456,R789)
- zh_Hans: 要查找的OSM ID的逗号分隔列表(例如:N123,W456,R789)
- de_DE: Kommagetrennte Liste von OSM-IDs für die Suche (z.B. N123,W456,R789)
- ja_JP: 検索するOSM IDのカンマ区切りリスト(例:N123,W456,R789)
- llm_description: A comma-separated list of OSM IDs (prefixed with N, W, or R) for lookup.
- form: llm
diff --git a/api/core/tools/provider/builtin/nominatim/tools/nominatim_reverse.py b/api/core/tools/provider/builtin/nominatim/tools/nominatim_reverse.py
deleted file mode 100644
index f46691e1a3..0000000000
--- a/api/core/tools/provider/builtin/nominatim/tools/nominatim_reverse.py
+++ /dev/null
@@ -1,41 +0,0 @@
-import json
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class NominatimReverseTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- lat = tool_parameters.get("lat")
- lon = tool_parameters.get("lon")
-
- if lat is None or lon is None:
- return self.create_text_message("Please provide both latitude and longitude")
-
- params = {"lat": lat, "lon": lon, "format": "json", "addressdetails": 1}
-
- return self._make_request(user_id, "reverse", params)
-
- def _make_request(self, user_id: str, endpoint: str, params: dict) -> ToolInvokeMessage:
- base_url = self.runtime.credentials.get("base_url", "https://nominatim.openstreetmap.org")
-
- try:
- headers = {"User-Agent": "DifyNominatimTool/1.0"}
- s = requests.session()
- response = s.request(method="GET", headers=headers, url=f"{base_url}/{endpoint}", params=params)
- response_data = response.json()
-
- if response.status_code == 200:
- s.close()
- return self.create_text_message(
- self.summary(user_id=user_id, content=json.dumps(response_data, ensure_ascii=False))
- )
- else:
- return self.create_text_message(f"Error: {response.status_code} - {response.text}")
- except Exception as e:
- return self.create_text_message(f"An error occurred: {str(e)}")
diff --git a/api/core/tools/provider/builtin/nominatim/tools/nominatim_reverse.yaml b/api/core/tools/provider/builtin/nominatim/tools/nominatim_reverse.yaml
deleted file mode 100644
index f1a2dd09fb..0000000000
--- a/api/core/tools/provider/builtin/nominatim/tools/nominatim_reverse.yaml
+++ /dev/null
@@ -1,47 +0,0 @@
-identity:
- name: nominatim_reverse
- author: Charles Zhou
- label:
- en_US: Nominatim Reverse Geocoding
- zh_Hans: Nominatim 反向地理编码
- de_DE: Nominatim Rückwärts-Geocodierung
- ja_JP: Nominatim リバースジオコーディング
-description:
- human:
- en_US: Convert coordinates to addresses using Nominatim
- zh_Hans: 使用Nominatim将坐标转换为地址
- de_DE: Konvertieren Sie Koordinaten in Adressen mit Nominatim
- ja_JP: Nominatimを使用して座標を住所に変換
- llm: A tool for reverse geocoding using Nominatim, which can convert latitude
- and longitude coordinates to an address.
-parameters:
- - name: lat
- type: number
- required: true
- label:
- en_US: Latitude
- zh_Hans: 纬度
- de_DE: Breitengrad
- ja_JP: 緯度
- human_description:
- en_US: Latitude coordinate for reverse geocoding
- zh_Hans: 用于反向地理编码的纬度坐标
- de_DE: Breitengrad-Koordinate für die Rückwärts-Geocodierung
- ja_JP: リバースジオコーディングの緯度座標
- llm_description: The latitude coordinate for reverse geocoding.
- form: llm
- - name: lon
- type: number
- required: true
- label:
- en_US: Longitude
- zh_Hans: 经度
- de_DE: Längengrad
- ja_JP: 経度
- human_description:
- en_US: Longitude coordinate for reverse geocoding
- zh_Hans: 用于反向地理编码的经度坐标
- de_DE: Längengrad-Koordinate für die Rückwärts-Geocodierung
- ja_JP: リバースジオコーディングの経度座標
- llm_description: The longitude coordinate for reverse geocoding.
- form: llm
diff --git a/api/core/tools/provider/builtin/nominatim/tools/nominatim_search.py b/api/core/tools/provider/builtin/nominatim/tools/nominatim_search.py
deleted file mode 100644
index 34851d86dc..0000000000
--- a/api/core/tools/provider/builtin/nominatim/tools/nominatim_search.py
+++ /dev/null
@@ -1,41 +0,0 @@
-import json
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class NominatimSearchTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- query = tool_parameters.get("query", "")
- limit = tool_parameters.get("limit", 10)
-
- if not query:
- return self.create_text_message("Please input a search query")
-
- params = {"q": query, "format": "json", "limit": limit, "addressdetails": 1}
-
- return self._make_request(user_id, "search", params)
-
- def _make_request(self, user_id: str, endpoint: str, params: dict) -> ToolInvokeMessage:
- base_url = self.runtime.credentials.get("base_url", "https://nominatim.openstreetmap.org")
-
- try:
- headers = {"User-Agent": "DifyNominatimTool/1.0"}
- s = requests.session()
- response = s.request(method="GET", headers=headers, url=f"{base_url}/{endpoint}", params=params)
- response_data = response.json()
-
- if response.status_code == 200:
- s.close()
- return self.create_text_message(
- self.summary(user_id=user_id, content=json.dumps(response_data, ensure_ascii=False))
- )
- else:
- return self.create_text_message(f"Error: {response.status_code} - {response.text}")
- except Exception as e:
- return self.create_text_message(f"An error occurred: {str(e)}")
diff --git a/api/core/tools/provider/builtin/nominatim/tools/nominatim_search.yaml b/api/core/tools/provider/builtin/nominatim/tools/nominatim_search.yaml
deleted file mode 100644
index e0c53c046a..0000000000
--- a/api/core/tools/provider/builtin/nominatim/tools/nominatim_search.yaml
+++ /dev/null
@@ -1,51 +0,0 @@
-identity:
- name: nominatim_search
- author: Charles Zhou
- label:
- en_US: Nominatim Search
- zh_Hans: Nominatim 搜索
- de_DE: Nominatim Suche
- ja_JP: Nominatim 検索
-description:
- human:
- en_US: Search for locations using Nominatim
- zh_Hans: 使用Nominatim搜索位置
- de_DE: Suche nach Orten mit Nominatim
- ja_JP: Nominatimを使用して場所を検索
- llm: A tool for geocoding using Nominatim, which can search for locations based
- on addresses or place names.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Search Query
- zh_Hans: 搜索查询
- de_DE: Suchanfrage
- ja_JP: 検索クエリ
- human_description:
- en_US: Enter an address or place name to search for
- zh_Hans: 输入要搜索的地址或地名
- de_DE: Geben Sie eine Adresse oder einen Ortsnamen für die Suche ein
- ja_JP: 検索する住所または場所の名前を入力してください
- llm_description: The search query for Nominatim, which can be an address or place name.
- form: llm
- - name: limit
- type: number
- default: 10
- min: 1
- max: 40
- required: false
- label:
- en_US: Result Limit
- zh_Hans: 结果限制
- de_DE: Ergebnislimit
- ja_JP: 結果の制限
- human_description:
- en_US: "Maximum number of results to return (default: 10, max: 40)"
- zh_Hans: 要返回的最大结果数(默认:10,最大:40)
- de_DE: "Maximale Anzahl der zurückzugebenden Ergebnisse (Standard: 10, max: 40)"
- ja_JP: 返す結果の最大数(デフォルト:10、最大:40)
- llm_description: Limit the number of returned results. The default is 10, and
- the maximum is 40.
- form: form
diff --git a/api/core/tools/provider/builtin/novitaai/_assets/icon.ico b/api/core/tools/provider/builtin/novitaai/_assets/icon.ico
deleted file mode 100644
index e353ecf711..0000000000
Binary files a/api/core/tools/provider/builtin/novitaai/_assets/icon.ico and /dev/null differ
diff --git a/api/core/tools/provider/builtin/novitaai/_novita_tool_base.py b/api/core/tools/provider/builtin/novitaai/_novita_tool_base.py
deleted file mode 100644
index 762e158459..0000000000
--- a/api/core/tools/provider/builtin/novitaai/_novita_tool_base.py
+++ /dev/null
@@ -1,69 +0,0 @@
-from novita_client import (
- Txt2ImgV3Embedding,
- Txt2ImgV3HiresFix,
- Txt2ImgV3LoRA,
- Txt2ImgV3Refiner,
- V3TaskImage,
-)
-
-
-class NovitaAiToolBase:
- def _extract_loras(self, loras_str: str):
- if not loras_str:
- return []
-
- loras_ori_list = lora_str.strip().split(";")
- result_list = []
- for lora_str in loras_ori_list:
- lora_info = lora_str.strip().split(",")
- lora = Txt2ImgV3LoRA(
- model_name=lora_info[0].strip(),
- strength=float(lora_info[1]),
- )
- result_list.append(lora)
-
- return result_list
-
- def _extract_embeddings(self, embeddings_str: str):
- if not embeddings_str:
- return []
-
- embeddings_ori_list = embeddings_str.strip().split(";")
- result_list = []
- for embedding_str in embeddings_ori_list:
- embedding = Txt2ImgV3Embedding(model_name=embedding_str.strip())
- result_list.append(embedding)
-
- return result_list
-
- def _extract_hires_fix(self, hires_fix_str: str):
- hires_fix_info = hires_fix_str.strip().split(",")
- if "upscaler" in hires_fix_info:
- hires_fix = Txt2ImgV3HiresFix(
- target_width=int(hires_fix_info[0]),
- target_height=int(hires_fix_info[1]),
- strength=float(hires_fix_info[2]),
- upscaler=hires_fix_info[3].strip(),
- )
- else:
- hires_fix = Txt2ImgV3HiresFix(
- target_width=int(hires_fix_info[0]),
- target_height=int(hires_fix_info[1]),
- strength=float(hires_fix_info[2]),
- )
-
- return hires_fix
-
- def _extract_refiner(self, switch_at: str):
- refiner = Txt2ImgV3Refiner(switch_at=float(switch_at))
- return refiner
-
- def _is_hit_nsfw_detection(self, image: V3TaskImage, confidence_threshold: float) -> bool:
- """
- is hit nsfw
- """
- if image.nsfw_detection_result is None:
- return False
- if image.nsfw_detection_result.valid and image.nsfw_detection_result.confidence >= confidence_threshold:
- return True
- return False
diff --git a/api/core/tools/provider/builtin/novitaai/novitaai.py b/api/core/tools/provider/builtin/novitaai/novitaai.py
deleted file mode 100644
index d5e32eff29..0000000000
--- a/api/core/tools/provider/builtin/novitaai/novitaai.py
+++ /dev/null
@@ -1,34 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.novitaai.tools.novitaai_txt2img import NovitaAiTxt2ImgTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class NovitaAIProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- result = (
- NovitaAiTxt2ImgTool()
- .fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- )
- .invoke(
- user_id="",
- tool_parameters={
- "model_name": "cinenautXLATRUE_cinenautV10_392434.safetensors",
- "prompt": "a futuristic city with flying cars",
- "negative_prompt": "",
- "width": 128,
- "height": 128,
- "image_num": 1,
- "guidance_scale": 7.5,
- "seed": -1,
- "steps": 1,
- },
- )
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/novitaai/novitaai.yaml b/api/core/tools/provider/builtin/novitaai/novitaai.yaml
deleted file mode 100644
index 3eed8a889c..0000000000
--- a/api/core/tools/provider/builtin/novitaai/novitaai.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-identity:
- author: Xiao Ley
- name: novitaai
- label:
- en_US: Novita AI
- zh_Hans: Novita AI
- pt_BR: Novita AI
- description:
- en_US: Innovative AI for Image Generation
- zh_Hans: 用于图像生成的创新人工智能。
- pt_BR: Innovative AI for Image Generation
- icon: icon.ico
- tags:
- - image
- - productivity
-credentials_for_provider:
- api_key:
- type: secret-input
- required: true
- label:
- en_US: API Key
- zh_Hans: API 密钥
- pt_BR: Chave API
- placeholder:
- en_US: Please enter your Novita AI API key
- zh_Hans: 请输入你的 Novita AI API 密钥
- pt_BR: Por favor, insira sua chave de API do Novita AI
- help:
- en_US: Get your Novita AI API key from Novita AI
- zh_Hans: 从 Novita AI 获取您的 Novita AI API 密钥
- pt_BR: Obtenha sua chave de API do Novita AI na Novita AI
- url: https://novita.ai
diff --git a/api/core/tools/provider/builtin/novitaai/tools/novitaai_createtile.py b/api/core/tools/provider/builtin/novitaai/tools/novitaai_createtile.py
deleted file mode 100644
index 0b4f2edff3..0000000000
--- a/api/core/tools/provider/builtin/novitaai/tools/novitaai_createtile.py
+++ /dev/null
@@ -1,54 +0,0 @@
-from base64 import b64decode
-from copy import deepcopy
-from typing import Any, Union
-
-from novita_client import (
- NovitaClient,
-)
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class NovitaAiCreateTileTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- if "api_key" not in self.runtime.credentials or not self.runtime.credentials.get("api_key"):
- raise ToolProviderCredentialValidationError("Novita AI API Key is required.")
-
- api_key = self.runtime.credentials.get("api_key")
-
- client = NovitaClient(api_key=api_key)
- param = self._process_parameters(tool_parameters)
- client_result = client.create_tile(**param)
-
- results = []
- results.append(
- self.create_blob_message(
- blob=b64decode(client_result.image_file),
- meta={"mime_type": f"image/{client_result.image_type}"},
- save_as=self.VariableKey.IMAGE.value,
- )
- )
-
- return results
-
- def _process_parameters(self, parameters: dict[str, Any]) -> dict[str, Any]:
- """
- process parameters
- """
- res_parameters = deepcopy(parameters)
-
- # delete none and empty
- keys_to_delete = [k for k, v in res_parameters.items() if v is None or v == ""]
- for k in keys_to_delete:
- del res_parameters[k]
-
- return res_parameters
diff --git a/api/core/tools/provider/builtin/novitaai/tools/novitaai_createtile.yaml b/api/core/tools/provider/builtin/novitaai/tools/novitaai_createtile.yaml
deleted file mode 100644
index 8e5df50429..0000000000
--- a/api/core/tools/provider/builtin/novitaai/tools/novitaai_createtile.yaml
+++ /dev/null
@@ -1,80 +0,0 @@
-identity:
- name: novitaai_createtile
- author: Xiao Ley
- label:
- en_US: Novita AI Create Tile
- zh_Hans: Novita AI 创建平铺图案
-description:
- human:
- en_US: This feature produces images designed for seamless tiling, ideal for creating continuous patterns in fabrics, wallpapers, and various textures.
- zh_Hans: 该功能生成设计用于无缝平铺的图像,非常适合用于制作连续图案的织物、壁纸和各种纹理。
- llm: A tool for create images designed for seamless tiling, ideal for creating continuous patterns in fabrics, wallpapers, and various textures.
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: prompt
- zh_Hans: 提示
- human_description:
- en_US: Positive prompt word of the created tile, divided by `,`, Range [1, 512]. Only English input is allowed.
- zh_Hans: 生成平铺图案的正向提示,用 `,` 分隔,范围 [1, 512]。仅允许输入英文。
- llm_description: Image prompt of Novita AI, you should describe the image you want to generate as a list of words as possible as detailed, divided by `,`, Range [1, 512]. Only English input is allowed.
- form: llm
- - name: negative_prompt
- type: string
- required: false
- label:
- en_US: negative prompt
- zh_Hans: 负向提示
- human_description:
- en_US: Negtive prompt word of the created tile, divided by `,`, Range [1, 512]. Only English input is allowed.
- zh_Hans: 生成平铺图案的负向提示,用 `,` 分隔,范围 [1, 512]。仅允许输入英文。
- llm_description: Image negative prompt of Novita AI, divided by `,`, Range [1, 512]. Only English input is allowed.
- form: llm
- - name: width
- type: number
- default: 256
- min: 128
- max: 1024
- required: true
- label:
- en_US: width
- zh_Hans: 宽
- human_description:
- en_US: Image width, Range [128, 1024].
- zh_Hans: 图像宽度,范围 [128, 1024]
- form: form
- - name: height
- type: number
- default: 256
- min: 128
- max: 1024
- required: true
- label:
- en_US: height
- zh_Hans: 高
- human_description:
- en_US: Image height, Range [128, 1024].
- zh_Hans: 图像高度,范围 [128, 1024]
- form: form
- - name: response_image_type
- type: select
- default: jpeg
- required: false
- label:
- en_US: response image type
- zh_Hans: 响应图像类型
- human_description:
- en_US: Response image type, png or jpeg
- zh_Hans: 响应图像类型,png 或 jpeg
- form: form
- options:
- - value: jpeg
- label:
- en_US: jpeg
- zh_Hans: jpeg
- - value: png
- label:
- en_US: png
- zh_Hans: png
diff --git a/api/core/tools/provider/builtin/novitaai/tools/novitaai_modelquery.py b/api/core/tools/provider/builtin/novitaai/tools/novitaai_modelquery.py
deleted file mode 100644
index a200ee8123..0000000000
--- a/api/core/tools/provider/builtin/novitaai/tools/novitaai_modelquery.py
+++ /dev/null
@@ -1,148 +0,0 @@
-import json
-from copy import deepcopy
-from typing import Any, Union
-
-from pandas import DataFrame
-from yarl import URL
-
-from core.helper import ssrf_proxy
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class NovitaAiModelQueryTool(BuiltinTool):
- _model_query_endpoint = "https://api.novita.ai/v3/model"
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- if "api_key" not in self.runtime.credentials or not self.runtime.credentials.get("api_key"):
- raise ToolProviderCredentialValidationError("Novita AI API Key is required.")
-
- api_key = self.runtime.credentials.get("api_key")
- headers = {"Content-Type": "application/json", "Authorization": "Bearer " + api_key}
- params = self._process_parameters(tool_parameters)
- result_type = params.get("result_type")
- del params["result_type"]
-
- models_data = self._query_models(
- models_data=[],
- headers=headers,
- params=params,
- recursive=result_type not in {"first sd_name", "first name sd_name pair"},
- )
-
- result_str = ""
- if result_type == "first sd_name":
- result_str = models_data[0]["sd_name_in_api"] if len(models_data) > 0 else ""
- elif result_type == "first name sd_name pair":
- result_str = (
- json.dumps({"name": models_data[0]["name"], "sd_name": models_data[0]["sd_name_in_api"]})
- if len(models_data) > 0
- else ""
- )
- elif result_type == "sd_name array":
- sd_name_array = [model["sd_name_in_api"] for model in models_data] if len(models_data) > 0 else []
- result_str = json.dumps(sd_name_array)
- elif result_type == "name array":
- name_array = [model["name"] for model in models_data] if len(models_data) > 0 else []
- result_str = json.dumps(name_array)
- elif result_type == "name sd_name pair array":
- name_sd_name_pair_array = (
- [{"name": model["name"], "sd_name": model["sd_name_in_api"]} for model in models_data]
- if len(models_data) > 0
- else []
- )
- result_str = json.dumps(name_sd_name_pair_array)
- elif result_type == "whole info array":
- result_str = json.dumps(models_data)
- else:
- raise NotImplementedError
-
- return self.create_text_message(result_str)
-
- def _query_models(
- self,
- models_data: list,
- headers: dict[str, Any],
- params: dict[str, Any],
- pagination_cursor: str = "",
- recursive: bool = True,
- ) -> list:
- """
- query models
- """
- inside_params = deepcopy(params)
-
- if pagination_cursor != "":
- inside_params["pagination.cursor"] = pagination_cursor
-
- response = ssrf_proxy.get(
- url=str(URL(self._model_query_endpoint)), headers=headers, params=params, timeout=(10, 60)
- )
-
- res_data = response.json()
-
- models_data.extend(res_data["models"])
-
- res_data_len = len(res_data["models"])
- if res_data_len == 0 or res_data_len < int(params["pagination.limit"]) or recursive is False:
- # deduplicate
- df = DataFrame.from_dict(models_data)
- df_unique = df.drop_duplicates(subset=["id"])
- models_data = df_unique.to_dict("records")
- return models_data
-
- return self._query_models(
- models_data=models_data,
- headers=headers,
- params=inside_params,
- pagination_cursor=res_data["pagination"]["next_cursor"],
- )
-
- def _process_parameters(self, parameters: dict[str, Any]) -> dict[str, Any]:
- """
- process parameters
- """
- process_parameters = deepcopy(parameters)
- res_parameters = {}
-
- # delete none or empty
- keys_to_delete = [k for k, v in process_parameters.items() if v is None or v == ""]
- for k in keys_to_delete:
- del process_parameters[k]
-
- if "query" in process_parameters and process_parameters.get("query") != "unspecified":
- res_parameters["filter.query"] = process_parameters["query"]
-
- if "visibility" in process_parameters and process_parameters.get("visibility") != "unspecified":
- res_parameters["filter.visibility"] = process_parameters["visibility"]
-
- if "source" in process_parameters and process_parameters.get("source") != "unspecified":
- res_parameters["filter.source"] = process_parameters["source"]
-
- if "type" in process_parameters and process_parameters.get("type") != "unspecified":
- res_parameters["filter.types"] = process_parameters["type"]
-
- if "is_sdxl" in process_parameters:
- if process_parameters["is_sdxl"] == "true":
- res_parameters["filter.is_sdxl"] = True
- elif process_parameters["is_sdxl"] == "false":
- res_parameters["filter.is_sdxl"] = False
-
- res_parameters["result_type"] = process_parameters.get("result_type", "first sd_name")
-
- res_parameters["pagination.limit"] = (
- 1
- if res_parameters.get("result_type") == "first sd_name"
- or res_parameters.get("result_type") == "first name sd_name pair"
- else 100
- )
-
- return res_parameters
diff --git a/api/core/tools/provider/builtin/novitaai/tools/novitaai_modelquery.yaml b/api/core/tools/provider/builtin/novitaai/tools/novitaai_modelquery.yaml
deleted file mode 100644
index a14795e45e..0000000000
--- a/api/core/tools/provider/builtin/novitaai/tools/novitaai_modelquery.yaml
+++ /dev/null
@@ -1,175 +0,0 @@
-identity:
- name: novitaai_modelquery
- author: Xiao Ley
- label:
- en_US: Novita AI Model Query
- zh_Hans: Novita AI 模型查询
-description:
- human:
- en_US: Retrieve information on both public and private models. It allows users to access details such as model specifications, status, and usage guidelines, ensuring comprehensive insight into the available modeling resources.
- zh_Hans: 检索公开和私有模型信息。它允许用户访问模型规范、状态和使用指南等详细信息,确保了解可用的建模资源。
- llm: A tool for retrieve information on both public and private Novita AI models.
-parameters:
- - name: query
- type: string
- required: false
- label:
- en_US: query
- zh_Hans: 查询
- human_description:
- en_US: Seaching the content of sd_name, name, tags.
- zh_Hans: 搜索 sd_name、name、tags 中的内容
- llm_description: Enter the content to search
- form: llm
- - name: result_type
- type: select
- default: "first sd_name"
- required: true
- label:
- en_US: result format
- zh_Hans: 结果格式
- human_description:
- en_US: The format of result
- zh_Hans: 请求结果的格式
- form: form
- options:
- - value: "first sd_name"
- label:
- en_US: "first sd_name"
- zh_Hans: "第一个 sd_name"
- - value: "first name sd_name pair"
- label:
- en_US: "first name and sd_name pair: {name, sd_name}"
- zh_Hans: "第一个 name sd_name 组合:{name, sd_name}"
- - value: "sd_name array"
- label:
- en_US: "sd_name array: [sd_name]"
- zh_Hans: "sd_name 数组:[sd_name]"
- - value: "name array"
- label:
- en_US: "name array: [name]"
- zh_Hans: "name 数组:[name]"
- - value: "name sd_name pair array"
- label:
- en_US: "name and sd_name pair array: [{name, sd_name}]"
- zh_Hans: "name sd_name 组合数组:[{name, sd_name}]"
- - value: "whole info array"
- label:
- en_US: whole info array
- zh_Hans: 完整信息数组
- - name: visibility
- type: select
- default: unspecified
- required: false
- label:
- en_US: visibility
- zh_Hans: 可见性
- human_description:
- en_US: Whether the model is public or private
- zh_Hans: 模型是否公开或私有
- form: form
- options:
- - value: unspecified
- label:
- en_US: Unspecified
- zh_Hans: 未指定
- - value: public
- label:
- en_US: Public
- zh_Hans: 公开
- - value: private
- label:
- en_US: Private
- zh_Hans: 私有
- - name: source
- type: select
- default: unspecified
- required: false
- label:
- en_US: source
- zh_Hans: 来源
- human_description:
- en_US: Source of the model
- zh_Hans: 模型来源
- form: form
- options:
- - value: unspecified
- label:
- en_US: Unspecified
- zh_Hans: 未指定
- - value: civitai
- label:
- en_US: Civitai
- zh_Hans: Civitai
- - value: training
- label:
- en_US: Training
- zh_Hans: 训练
- - value: uploading
- label:
- en_US: Uploading
- zh_Hans: 上传
- - name: type
- type: select
- default: unspecified
- required: false
- label:
- en_US: type
- zh_Hans: 类型
- human_description:
- en_US: Specifies the type of models to include in the query.
- zh_Hans: 指定要查询的模型类型
- form: form
- options:
- - value: unspecified
- label:
- en_US: Unspecified
- zh_Hans: 未指定
- - value: checkpoint
- label:
- en_US: Checkpoint
- zh_Hans: Checkpoint
- - value: lora
- label:
- en_US: LoRA
- zh_Hans: LoRA
- - value: vae
- label:
- en_US: VAE
- zh_Hans: VAE
- - value: controlnet
- label:
- en_US: ControlNet
- zh_Hans: ControlNet
- - value: upscaler
- label:
- en_US: Upscaler
- zh_Hans: Upscaler
- - value: textualinversion
- label:
- en_US: Textual inversion
- zh_Hans: Textual Inversion
- - name: is_sdxl
- type: select
- default: unspecified
- required: false
- label:
- en_US: is sdxl
- zh_Hans: 是否是 SDXL
- human_description:
- en_US: Whether sdxl model or not. Setting this parameter to `true` includes only sdxl models in the query results, which are typically large-scale, high-performance models designed for extensive data processing tasks. Conversely, setting it to `false` excludes these models from the results. If left unspecified, the filter will not discriminate based on the sdxl classification, including all model types in the search results.
- zh_Hans: 是否是 SDXL 模型。设置此参数为 `是`,只查询 SDXL 模型,并包含大规模,高性能的模型。相反,设置为 `否`,将排除这些模型。如果未指定,将不会根据 SDXL 分类进行区分,包括查询结果中的所有模型类型。
- form: form
- options:
- - value: unspecified
- label:
- en_US: Unspecified
- zh_Hans: 未指定
- - value: "true"
- label:
- en_US: "True"
- zh_Hans: 是
- - value: "false"
- label:
- en_US: "False"
- zh_Hans: 否
diff --git a/api/core/tools/provider/builtin/novitaai/tools/novitaai_txt2img.py b/api/core/tools/provider/builtin/novitaai/tools/novitaai_txt2img.py
deleted file mode 100644
index 9c61eab9f9..0000000000
--- a/api/core/tools/provider/builtin/novitaai/tools/novitaai_txt2img.py
+++ /dev/null
@@ -1,90 +0,0 @@
-from base64 import b64decode
-from copy import deepcopy
-from typing import Any, Union
-
-from novita_client import (
- NovitaClient,
-)
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.novitaai._novita_tool_base import NovitaAiToolBase
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class NovitaAiTxt2ImgTool(BuiltinTool, NovitaAiToolBase):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- if "api_key" not in self.runtime.credentials or not self.runtime.credentials.get("api_key"):
- raise ToolProviderCredentialValidationError("Novita AI API Key is required.")
-
- api_key = self.runtime.credentials.get("api_key")
-
- client = NovitaClient(api_key=api_key)
- param = self._process_parameters(tool_parameters)
- client_result = client.txt2img_v3(**param)
-
- results = []
- for image_encoded, image in zip(client_result.images_encoded, client_result.images):
- if self._is_hit_nsfw_detection(image, 0.8):
- results = self.create_text_message(text="NSFW detected!")
- break
-
- results.append(
- self.create_blob_message(
- blob=b64decode(image_encoded),
- meta={"mime_type": f"image/{image.image_type}"},
- save_as=self.VariableKey.IMAGE.value,
- )
- )
-
- return results
-
- def _process_parameters(self, parameters: dict[str, Any]) -> dict[str, Any]:
- """
- process parameters
- """
- res_parameters = deepcopy(parameters)
-
- # delete none and empty
- keys_to_delete = [k for k, v in res_parameters.items() if v is None or v == ""]
- for k in keys_to_delete:
- del res_parameters[k]
-
- if "clip_skip" in res_parameters and res_parameters.get("clip_skip") == 0:
- del res_parameters["clip_skip"]
-
- if "refiner_switch_at" in res_parameters and res_parameters.get("refiner_switch_at") == 0:
- del res_parameters["refiner_switch_at"]
-
- if "enabled_enterprise_plan" in res_parameters:
- res_parameters["enterprise_plan"] = {"enabled": res_parameters["enabled_enterprise_plan"]}
- del res_parameters["enabled_enterprise_plan"]
-
- if "nsfw_detection_level" in res_parameters:
- res_parameters["nsfw_detection_level"] = int(res_parameters["nsfw_detection_level"])
-
- # process loras
- if "loras" in res_parameters:
- res_parameters["loras"] = self._extract_loras(res_parameters.get("loras"))
-
- # process embeddings
- if "embeddings" in res_parameters:
- res_parameters["embeddings"] = self._extract_embeddings(res_parameters.get("embeddings"))
-
- # process hires_fix
- if "hires_fix" in res_parameters:
- res_parameters["hires_fix"] = self._extract_hires_fix(res_parameters.get("hires_fix"))
-
- # process refiner
- if "refiner_switch_at" in res_parameters:
- res_parameters["refiner"] = self._extract_refiner(res_parameters.get("refiner_switch_at"))
- del res_parameters["refiner_switch_at"]
-
- return res_parameters
diff --git a/api/core/tools/provider/builtin/novitaai/tools/novitaai_txt2img.yaml b/api/core/tools/provider/builtin/novitaai/tools/novitaai_txt2img.yaml
deleted file mode 100644
index d625a643f9..0000000000
--- a/api/core/tools/provider/builtin/novitaai/tools/novitaai_txt2img.yaml
+++ /dev/null
@@ -1,341 +0,0 @@
-identity:
- name: novitaai_txt2img
- author: Xiao Ley
- label:
- en_US: Novita AI Text to Image
- zh_Hans: Novita AI 文字转图像
-description:
- human:
- en_US: Generate images from text prompts using Stable Diffusion models
- zh_Hans: 通过 Stable Diffusion 模型根据文字提示生成图像
- llm: A tool for generate images from English text prompts.
-parameters:
- - name: model_name
- type: string
- required: true
- label:
- en_US: model name
- zh_Hans: 模块名字
- human_description:
- en_US: Specify the name of the model checkpoint. You can use the "Novita AI Model Query" tool to query the corresponding "sd_name" value (type select "Checkpoint").
- zh_Hans: 指定 Model Checkpoint 名称。可通过“Novita AI 模型请求”工具查询对应的“sd_name”值(类型选择“Checkpoint”)。
- form: form
- - name: prompt
- type: string
- required: true
- label:
- en_US: prompt
- zh_Hans: 提示
- human_description:
- en_US: Text input required to guide the image generation, divided by `,`, Range [1, 1024]. Only English input is allowed.
- zh_Hans: 生成图像的正向提示,用 `,` 分隔,范围 [1, 1024]。仅允许输入英文。
- llm_description: Image prompt of Novita AI, you should describe the image you want to generate as a list of words as possible as detailed, divided by `,`, Range [1, 1024]. Only English input is allowed.
- form: llm
- - name: negative_prompt
- type: string
- required: false
- label:
- en_US: negative prompt
- zh_Hans: 负向提示
- human_description:
- en_US: Text input that will not guide the image generation, divided by `,`, Range [1, 1024]. Only English input is allowed.
- zh_Hans: 生成图像的负向提示,用 `,` 分隔,范围 [1, 1024]。仅允许输入英文。
- llm_description: Image negative prompt of Novita AI, divided by `,`, Range [1, 1024]. Only English input is allowed.
- form: llm
- - name: width
- type: number
- default: 512
- min: 128
- max: 2048
- required: true
- label:
- en_US: width
- zh_Hans: 宽
- human_description:
- en_US: Image width, Range [128, 2048].
- zh_Hans: 图像宽度,范围 [128, 2048]
- form: form
- - name: height
- type: number
- default: 512
- min: 128
- max: 2048
- required: true
- label:
- en_US: height
- zh_Hans: 高
- human_description:
- en_US: Image height, Range [128, 2048].
- zh_Hans: 图像高度,范围 [128, 2048]
- form: form
- - name: image_num
- type: number
- default: 1
- min: 1
- max: 8
- required: true
- label:
- en_US: image num
- zh_Hans: 图片数
- human_description:
- en_US: Image num, Range [1, 8].
- zh_Hans: 图片数,范围 [1, 8]
- form: form
- - name: steps
- type: number
- default: 20
- min: 1
- max: 100
- required: true
- label:
- en_US: steps
- zh_Hans: 步数
- human_description:
- en_US: The number of denoising steps. More steps usually can produce higher quality images, but take more time to generate, Range [1, 100].
- zh_Hans: 生成步数。更多步数可能会产生更好的图像,但生成时间更长,范围 [1, 100]
- form: form
- - name: seed
- type: number
- default: -1
- required: true
- label:
- en_US: seed
- zh_Hans: 种子
- human_description:
- en_US: A seed is a number from which Stable Diffusion generates noise, which, makes generation deterministic. Using the same seed and set of parameters will produce identical image each time, minimum -1.
- zh_Hans: 种子是 Stable Diffusion 生成噪声的数字,它使生成具有确定性。使用相同的种子和参数设置将生成每次生成相同的图像,最小值 -1。
- form: form
- - name: clip_skip
- type: number
- min: 1
- max: 12
- required: false
- label:
- en_US: clip skip
- zh_Hans: 层跳过数
- human_description:
- en_US: This parameter indicates the number of layers to stop from the bottom during optimization, so clip_skip on 2 would mean, that in SD1.x model where the CLIP has 12 layers, you would stop at 10th layer, Range [1, 12], get reference at https://novita.ai/get-started/Misc.html#what-s-clip-skip.
- zh_Hans: 此参数表示优化过程中从底部停止的层数,因此 clip_skip 的值为 2,表示在 SD1.x 模型中,CLIP 有 12 层,你将停止在 10 层,范围 [1, 12],参考 https://novita.ai/get-started/Misc.html#what-s-clip-skip。
- form: form
- - name: guidance_scale
- type: number
- default: "7.5"
- min: 1.0
- max: 30.0
- required: true
- label:
- en_US: guidance scale
- zh_Hans: 提示词遵守程度
- human_description:
- en_US: This setting says how close the Stable Diffusion will listen to your prompt, higer guidance forces the model to better follow the prompt, but result in lower quality output.Range [1, 30].
- zh_Hans: 此设置表明 Stable Diffusion 如何听从您的提示,较高的 guidance_scale 会强制模型更好跟随提示,但结果会更低质量输出。范围 [1.0, 30.0]。
- form: form
- - name: sampler_name
- type: select
- required: true
- label:
- en_US: sampler name
- zh_Hans: 采样器名称
- human_description:
- en_US: This parameter determines the denoising algorithm employed during the sampling phase of Stable Diffusion. Get reference at https://novita.ai/get-started/Misc.htmll#what-is-samplers.
- zh_Hans: 此参数决定了在稳定扩散采样阶段使用的去噪算法。参考 https://novita.ai/get-started/Misc.htmll#what-is-samplers。
- form: form
- options:
- - value: "Euler a"
- label:
- en_US: Euler a
- zh_Hans: Euler a
- - value: "Euler"
- label:
- en_US: Euler
- zh_Hans: Euler
- - value: "LMS"
- label:
- en_US: LMS
- zh_Hans: LMS
- - value: "Heun"
- label:
- en_US: Heun
- zh_Hans: Heun
- - value: "DPM2"
- label:
- en_US: DPM2
- zh_Hans: DPM2
- - value: "DPM2 a"
- label:
- en_US: DPM2 a
- zh_Hans: DPM2 a
- - value: "DPM++ 2S a"
- label:
- en_US: DPM++ 2S a
- zh_Hans: DPM++ 2S a
- - value: "DPM++ 2M"
- label:
- en_US: DPM++ 2M
- zh_Hans: DPM++ 2M
- - value: "DPM++ SDE"
- label:
- en_US: DPM++ SDE
- zh_Hans: DPM++ SDE
- - value: "DPM fast"
- label:
- en_US: DPM fast
- zh_Hans: DPM fast
- - value: "DPM adaptive"
- label:
- en_US: DPM adaptive
- zh_Hans: DPM adaptive
- - value: "LMS Karras"
- label:
- en_US: LMS Karras
- zh_Hans: LMS Karras
- - value: "DPM2 Karras"
- label:
- en_US: DPM2 Karras
- zh_Hans: DPM2 Karras
- - value: "DPM2 a Karras"
- label:
- en_US: DPM2 a Karras
- zh_Hans: DPM2 a Karras
- - value: "DPM++ 2S a Karras"
- label:
- en_US: DPM++ 2S a Karras
- zh_Hans: DPM++ 2S a Karras
- - value: "DPM++ 2M Karras"
- label:
- en_US: DPM++ 2M Karras
- zh_Hans: DPM++ 2M Karras
- - value: "DPM++ SDE Karras"
- label:
- en_US: DPM++ SDE Karras
- zh_Hans: DPM++ SDE Karras
- - value: "DDIM"
- label:
- en_US: DDIM
- zh_Hans: DDIM
- - value: "PLMS"
- label:
- en_US: PLMS
- zh_Hans: PLMS
- - value: "UniPC"
- label:
- en_US: UniPC
- zh_Hans: UniPC
- - name: sd_vae
- type: string
- required: false
- label:
- en_US: sd vae
- zh_Hans: sd vae
- human_description:
- en_US: VAE(Variational Autoencoder), get reference at https://novita.ai/get-started/Misc.html#what-s-variational-autoencoders-vae. You can use the "Novita AI Model Query" tool to query the corresponding "sd_name" value (type select "VAE").
- zh_Hans: VAE(变分自编码器),参考 https://novita.ai/get-started/Misc.html#what-s-variational-autoencoders-vae。可通过“Novita AI 模型请求”工具查询对应的“sd_name”值(类型选择“VAE”)。
- form: form
- - name: loras
- type: string
- required: false
- label:
- en_US: loRAs
- zh_Hans: loRAs
- human_description:
- en_US: LoRA models. Currenlty supports up to 5 LoRAs. You can use the "Novita AI Model Query" tool to query the corresponding "sd_name" value (type select "LoRA"). Input template is ",;,;...". Such as"Film Grain style_331903,0.5;DoggystylePOV_9600,0.5"
- zh_Hans: LoRA 模型。目前仅支持 5 个 LoRA。可通过“Novita AI 模型请求”工具查询对应的“sd_name”值(类型选择“LoRA”)。输入模板:“,;,;...”,例如:“Film Grain style_331903,0.5;DoggystylePOV_9600,0.5”
- form: form
- - name: embeddings
- type: string
- required: false
- label:
- en_US: text embeddings
- zh_Hans: 文本嵌入
- human_description:
- en_US: Textual Inversion is a training method for personalizing models by learning new text embeddings from a few example images, currenlty supports up to 5 embeddings. You can use the "Novita AI Model Query" tool to query the corresponding "sd_name" value (type select "Text Inversion"). Input template is ";;...". Such as "EasyNegativeV2_75525;AS-YoungerV2"
- zh_Hans: 文本反转是一种通过从一些示例图像中学习新的文本嵌入来个性化模型的训练方法,目前仅支持 5 个嵌入。可通过“Novita AI 模型请求”工具查询对应的“sd_name”值(类型选择“Text Inversion”)。输入模板:“;;...”,例如:“EasyNegativeV2_75525;AS-YoungerV2”
- form: form
- - name: hires_fix
- type: string
- required: false
- label:
- en_US: hires fix
- zh_Hans: 高分辨率修复
- human_description:
- en_US: Use high resolution image fix. Input template is ",,,". Such as "1024,1024,0.8", "1024,1024,0.8,RealESRGAN_x4plus_anime_6B"
- zh_Hans: 使用高分辨率修复。输入模板 “,,,”。例如 “1024,1024,0.8”、“1024,1024,0.8,RealESRGAN_x4plus_anime_6B”
- form: form
- - name: refiner_switch_at
- type: number
- min: 0.0
- max: 1.0
- required: false
- label:
- en_US: refiner switch at
- zh_Hans: 重采样参与时刻
- human_description:
- en_US: This parameter in the context of a refiner allows you to set the extent to which the refiner alters the output of a model. When set to 0, the refiner has no effect; at 1, it's fully active. Intermediate values like 0.5 provide a balanced effect, where the refiner is moderately engaged, enhancing or adjusting the output without dominating the original model's characteristics. This setting is particularly useful for fine-tuning the output to achieve a desired balance between refinement and the original generative features, Range [0, 1.0]. Is not all models support refiners!
- zh_Hans: 此参数允许您设置重采样更改模型输出的程度。当设置为0时,重采样不起作用;1时,它处于完全活动状态。像0.5这样的中间值提供了一种平衡效果,其中重采样适度参与,增强或调整输出,而不会主导原始模型的特性。此设置对于微调输出特别有用,范围 [0, 1.0]。不是所有模型都支持重采样!
- form: form
- - name: response_image_type
- type: select
- default: jpeg
- required: false
- label:
- en_US: response image type
- zh_Hans: 响应图像类型
- human_description:
- en_US: Response image type, png or jpeg
- zh_Hans: 响应图像类型,png 或 jpeg
- form: form
- options:
- - value: jpeg
- label:
- en_US: jpeg
- zh_Hans: jpeg
- - value: png
- label:
- en_US: png
- zh_Hans: png
- - name: enabled_enterprise_plan
- type: boolean
- default: false
- required: false
- label:
- en_US: enterprise plan enabled
- zh_Hans: 企业版计划启用
- human_description:
- en_US: Enable enterprise plan
- zh_Hans: 启用企业版计划
- form: form
- - name: enable_nsfw_detection
- type: boolean
- default: false
- required: false
- label:
- en_US: enable nsfw detection
- zh_Hans: 启用 NSFW 检测
- human_description:
- en_US: Enable nsfw detection
- zh_Hans: 启用 NSFW 检测
- form: form
- - name: nsfw_detection_level
- type: select
- default: "2"
- required: false
- label:
- en_US: nsfw detection level
- zh_Hans: NSFW 检测级别
- human_description:
- en_US: Nsfw detection level, from low to high
- zh_Hans: NSFW 检测级别,越高越严格
- form: form
- options:
- - value: "0"
- label:
- en_US: low
- zh_Hans: 低
- - value: "1"
- label:
- en_US: middle
- zh_Hans: 中
- - value: "2"
- label:
- en_US: high
- zh_Hans: 高
diff --git a/api/core/tools/provider/builtin/onebot/_assets/icon.ico b/api/core/tools/provider/builtin/onebot/_assets/icon.ico
deleted file mode 100644
index 1b07e965b9..0000000000
Binary files a/api/core/tools/provider/builtin/onebot/_assets/icon.ico and /dev/null differ
diff --git a/api/core/tools/provider/builtin/onebot/onebot.py b/api/core/tools/provider/builtin/onebot/onebot.py
deleted file mode 100644
index b8e5ed24d6..0000000000
--- a/api/core/tools/provider/builtin/onebot/onebot.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class OneBotProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- if not credentials.get("ob11_http_url"):
- raise ToolProviderCredentialValidationError("OneBot HTTP URL is required.")
diff --git a/api/core/tools/provider/builtin/onebot/onebot.yaml b/api/core/tools/provider/builtin/onebot/onebot.yaml
deleted file mode 100644
index 1922adc4de..0000000000
--- a/api/core/tools/provider/builtin/onebot/onebot.yaml
+++ /dev/null
@@ -1,35 +0,0 @@
-identity:
- author: RockChinQ
- name: onebot
- label:
- en_US: OneBot v11 Protocol
- zh_Hans: OneBot v11 协议
- description:
- en_US: Unofficial OneBot v11 Protocol Tool
- zh_Hans: 非官方 OneBot v11 协议工具
- icon: icon.ico
-credentials_for_provider:
- ob11_http_url:
- type: text-input
- required: true
- label:
- en_US: HTTP URL
- zh_Hans: HTTP URL
- description:
- en_US: Forward HTTP URL of OneBot v11
- zh_Hans: OneBot v11 正向 HTTP URL
- help:
- en_US: Fill this with the HTTP URL of your OneBot server
- zh_Hans: 请在你的 OneBot 协议端开启 正向 HTTP 并填写其 URL
- access_token:
- type: secret-input
- required: false
- label:
- en_US: Access Token
- zh_Hans: 访问令牌
- description:
- en_US: Access Token for OneBot v11 Protocol
- zh_Hans: OneBot 协议访问令牌
- help:
- en_US: Fill this if you set a access token in your OneBot server
- zh_Hans: 如果你在 OneBot 服务器中设置了 access token,请填写此项
diff --git a/api/core/tools/provider/builtin/onebot/tools/__init__.py b/api/core/tools/provider/builtin/onebot/tools/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/api/core/tools/provider/builtin/onebot/tools/send_group_msg.py b/api/core/tools/provider/builtin/onebot/tools/send_group_msg.py
deleted file mode 100644
index 9c95bbc2ae..0000000000
--- a/api/core/tools/provider/builtin/onebot/tools/send_group_msg.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from typing import Any, Union
-
-import requests
-from yarl import URL
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class SendGroupMsg(BuiltinTool):
- """OneBot v11 Tool: Send Group Message"""
-
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- # Get parameters
- send_group_id = tool_parameters.get("group_id", "")
-
- message = tool_parameters.get("message", "")
- if not message:
- return self.create_json_message({"error": "Message is empty."})
-
- auto_escape = tool_parameters.get("auto_escape", False)
-
- try:
- url = URL(self.runtime.credentials["ob11_http_url"]) / "send_group_msg"
-
- resp = requests.post(
- url,
- json={"group_id": send_group_id, "message": message, "auto_escape": auto_escape},
- headers={"Authorization": "Bearer " + self.runtime.credentials["access_token"]},
- )
-
- if resp.status_code != 200:
- return self.create_json_message({"error": f"Failed to send group message: {resp.text}"})
-
- return self.create_json_message({"response": resp.json()})
- except Exception as e:
- return self.create_json_message({"error": f"Failed to send group message: {e}"})
diff --git a/api/core/tools/provider/builtin/onebot/tools/send_group_msg.yaml b/api/core/tools/provider/builtin/onebot/tools/send_group_msg.yaml
deleted file mode 100644
index 64beaa8545..0000000000
--- a/api/core/tools/provider/builtin/onebot/tools/send_group_msg.yaml
+++ /dev/null
@@ -1,46 +0,0 @@
-identity:
- name: send_group_msg
- author: RockChinQ
- label:
- en_US: Send Group Message
- zh_Hans: 发送群消息
-description:
- human:
- en_US: Send a message to a group
- zh_Hans: 发送消息到群聊
- llm: A tool for sending a message segment to a group
-parameters:
- - name: group_id
- type: number
- required: true
- label:
- en_US: Target Group ID
- zh_Hans: 目标群 ID
- human_description:
- en_US: The group ID of the target group
- zh_Hans: 目标群的群 ID
- llm_description: The group ID of the target group
- form: llm
- - name: message
- type: string
- required: true
- label:
- en_US: Message
- zh_Hans: 消息
- human_description:
- en_US: The message to send
- zh_Hans: 要发送的消息。支持 CQ码(需要同时设置 auto_escape 为 true)
- llm_description: The message to send
- form: llm
- - name: auto_escape
- type: boolean
- required: false
- default: false
- label:
- en_US: Auto Escape
- zh_Hans: 自动转义
- human_description:
- en_US: If true, the message will be treated as a CQ code for parsing, otherwise it will be treated as plain text for direct sending. Since Dify currently does not support passing Object-format message chains, developers can send complex message components through CQ codes.
- zh_Hans: 若为 true 则会把 message 视为 CQ 码解析,否则视为 纯文本 直接发送。由于 Dify 目前不支持传入 Object格式 的消息,故开发者可以通过 CQ 码来发送复杂消息组件。
- llm_description: If true, the message will be treated as a CQ code for parsing, otherwise it will be treated as plain text for direct sending.
- form: form
diff --git a/api/core/tools/provider/builtin/onebot/tools/send_private_msg.py b/api/core/tools/provider/builtin/onebot/tools/send_private_msg.py
deleted file mode 100644
index 1174c7f07d..0000000000
--- a/api/core/tools/provider/builtin/onebot/tools/send_private_msg.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from typing import Any, Union
-
-import requests
-from yarl import URL
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class SendPrivateMsg(BuiltinTool):
- """OneBot v11 Tool: Send Private Message"""
-
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- # Get parameters
- send_user_id = tool_parameters.get("user_id", "")
-
- message = tool_parameters.get("message", "")
- if not message:
- return self.create_json_message({"error": "Message is empty."})
-
- auto_escape = tool_parameters.get("auto_escape", False)
-
- try:
- url = URL(self.runtime.credentials["ob11_http_url"]) / "send_private_msg"
-
- resp = requests.post(
- url,
- json={"user_id": send_user_id, "message": message, "auto_escape": auto_escape},
- headers={"Authorization": "Bearer " + self.runtime.credentials["access_token"]},
- )
-
- if resp.status_code != 200:
- return self.create_json_message({"error": f"Failed to send private message: {resp.text}"})
-
- return self.create_json_message({"response": resp.json()})
- except Exception as e:
- return self.create_json_message({"error": f"Failed to send private message: {e}"})
diff --git a/api/core/tools/provider/builtin/onebot/tools/send_private_msg.yaml b/api/core/tools/provider/builtin/onebot/tools/send_private_msg.yaml
deleted file mode 100644
index 8200ce4a83..0000000000
--- a/api/core/tools/provider/builtin/onebot/tools/send_private_msg.yaml
+++ /dev/null
@@ -1,46 +0,0 @@
-identity:
- name: send_private_msg
- author: RockChinQ
- label:
- en_US: Send Private Message
- zh_Hans: 发送私聊消息
-description:
- human:
- en_US: Send a private message to a user
- zh_Hans: 发送私聊消息给用户
- llm: A tool for sending a message segment to a user in private chat
-parameters:
- - name: user_id
- type: number
- required: true
- label:
- en_US: Target User ID
- zh_Hans: 目标用户 ID
- human_description:
- en_US: The user ID of the target user
- zh_Hans: 目标用户的用户 ID
- llm_description: The user ID of the target user
- form: llm
- - name: message
- type: string
- required: true
- label:
- en_US: Message
- zh_Hans: 消息
- human_description:
- en_US: The message to send
- zh_Hans: 要发送的消息。支持 CQ码(需要同时设置 auto_escape 为 true)
- llm_description: The message to send
- form: llm
- - name: auto_escape
- type: boolean
- required: false
- default: false
- label:
- en_US: Auto Escape
- zh_Hans: 自动转义
- human_description:
- en_US: If true, the message will be treated as a CQ code for parsing, otherwise it will be treated as plain text for direct sending. Since Dify currently does not support passing Object-format message chains, developers can send complex message components through CQ codes.
- zh_Hans: 若为 true 则会把 message 视为 CQ 码解析,否则视为 纯文本 直接发送。由于 Dify 目前不支持传入 Object格式 的消息,故开发者可以通过 CQ 码来发送复杂消息组件。
- llm_description: If true, the message will be treated as a CQ code for parsing, otherwise it will be treated as plain text for direct sending.
- form: form
diff --git a/api/core/tools/provider/builtin/openweather/_assets/icon.svg b/api/core/tools/provider/builtin/openweather/_assets/icon.svg
deleted file mode 100644
index f06cd87e64..0000000000
--- a/api/core/tools/provider/builtin/openweather/_assets/icon.svg
+++ /dev/null
@@ -1,12 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/openweather/openweather.py b/api/core/tools/provider/builtin/openweather/openweather.py
deleted file mode 100644
index 9e40249aba..0000000000
--- a/api/core/tools/provider/builtin/openweather/openweather.py
+++ /dev/null
@@ -1,29 +0,0 @@
-import requests
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-def query_weather(city="Beijing", units="metric", language="zh_cn", api_key=None):
- url = "https://api.openweathermap.org/data/2.5/weather"
- params = {"q": city, "appid": api_key, "units": units, "lang": language}
-
- return requests.get(url, params=params)
-
-
-class OpenweatherProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- if "api_key" not in credentials or not credentials.get("api_key"):
- raise ToolProviderCredentialValidationError("Open weather API key is required.")
- apikey = credentials.get("api_key")
- try:
- response = query_weather(api_key=apikey)
- if response.status_code == 200:
- pass
- else:
- raise ToolProviderCredentialValidationError((response.json()).get("info"))
- except Exception as e:
- raise ToolProviderCredentialValidationError("Open weather API Key is invalid. {}".format(e))
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/openweather/openweather.yaml b/api/core/tools/provider/builtin/openweather/openweather.yaml
deleted file mode 100644
index d4b66f87f9..0000000000
--- a/api/core/tools/provider/builtin/openweather/openweather.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-identity:
- author: Onelevenvy
- name: openweather
- label:
- en_US: Open weather query
- zh_Hans: Open Weather
- pt_BR: Consulta de clima open weather
- description:
- en_US: Weather query toolkit based on Open Weather
- zh_Hans: 基于open weather的天气查询工具包
- pt_BR: Kit de consulta de clima baseado no Open Weather
- icon: icon.svg
- tags:
- - weather
-credentials_for_provider:
- api_key:
- type: secret-input
- required: true
- label:
- en_US: API Key
- zh_Hans: API Key
- pt_BR: Fogo a chave
- placeholder:
- en_US: Please enter your open weather API Key
- zh_Hans: 请输入你的open weather API Key
- pt_BR: Insira sua chave de API open weather
- help:
- en_US: Get your API Key from open weather
- zh_Hans: 从open weather获取您的 API Key
- pt_BR: Obtenha sua chave de API do open weather
- url: https://openweathermap.org
diff --git a/api/core/tools/provider/builtin/openweather/tools/weather.py b/api/core/tools/provider/builtin/openweather/tools/weather.py
deleted file mode 100644
index ed4ec487fa..0000000000
--- a/api/core/tools/provider/builtin/openweather/tools/weather.py
+++ /dev/null
@@ -1,52 +0,0 @@
-import json
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class OpenweatherTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- city = tool_parameters.get("city", "")
- if not city:
- return self.create_text_message("Please tell me your city")
- if "api_key" not in self.runtime.credentials or not self.runtime.credentials.get("api_key"):
- return self.create_text_message("OpenWeather API key is required.")
-
- units = tool_parameters.get("units", "metric")
- lang = tool_parameters.get("lang", "zh_cn")
- try:
- # request URL
- url = "https://api.openweathermap.org/data/2.5/weather"
-
- # request params
- params = {
- "q": city,
- "appid": self.runtime.credentials.get("api_key"),
- "units": units,
- "lang": lang,
- }
- response = requests.get(url, params=params)
-
- if response.status_code == 200:
- data = response.json()
- return self.create_text_message(
- self.summary(user_id=user_id, content=json.dumps(data, ensure_ascii=False))
- )
- else:
- error_message = {
- "error": f"failed:{response.status_code}",
- "data": response.text,
- }
- # return error
- return json.dumps(error_message)
-
- except Exception as e:
- return self.create_text_message("Openweather API Key is invalid. {}".format(e))
diff --git a/api/core/tools/provider/builtin/openweather/tools/weather.yaml b/api/core/tools/provider/builtin/openweather/tools/weather.yaml
deleted file mode 100644
index f2dae5c2df..0000000000
--- a/api/core/tools/provider/builtin/openweather/tools/weather.yaml
+++ /dev/null
@@ -1,80 +0,0 @@
-identity:
- name: weather
- author: Onelevenvy
- label:
- en_US: Open Weather Query
- zh_Hans: 天气查询
- pt_BR: Previsão do tempo
- icon: icon.svg
-description:
- human:
- en_US: Weather forecast inquiry
- zh_Hans: 天气查询
- pt_BR: Inquérito sobre previsão meteorológica
- llm: A tool when you want to ask about the weather or weather-related question
-parameters:
- - name: city
- type: string
- required: true
- label:
- en_US: city
- zh_Hans: 城市
- pt_BR: cidade
- human_description:
- en_US: Target city for weather forecast query
- zh_Hans: 天气预报查询的目标城市
- pt_BR: Cidade de destino para consulta de previsão do tempo
- llm_description: If you don't know you can extract the city name from the
- question or you can reply:Please tell me your city. You have to extract
- the Chinese city name from the question.If the input region is in Chinese
- characters for China, it should be replaced with the corresponding English
- name, such as '北京' for correct input is 'Beijing'
- form: llm
- - name: lang
- type: select
- required: true
- human_description:
- en_US: language
- zh_Hans: 语言
- pt_BR: language
- label:
- en_US: language
- zh_Hans: 语言
- pt_BR: language
- form: form
- options:
- - value: zh_cn
- label:
- en_US: cn
- zh_Hans: 中国
- pt_BR: cn
- - value: en_us
- label:
- en_US: usa
- zh_Hans: 美国
- pt_BR: usa
- default: zh_cn
- - name: units
- type: select
- required: true
- human_description:
- en_US: units for temperature
- zh_Hans: 温度单位
- pt_BR: units for temperature
- label:
- en_US: units
- zh_Hans: 单位
- pt_BR: units
- form: form
- options:
- - value: metric
- label:
- en_US: metric
- zh_Hans: ℃
- pt_BR: metric
- - value: imperial
- label:
- en_US: imperial
- zh_Hans: ℉
- pt_BR: imperial
- default: metric
diff --git a/api/core/tools/provider/builtin/perplexity/_assets/icon.svg b/api/core/tools/provider/builtin/perplexity/_assets/icon.svg
deleted file mode 100644
index c2974c142f..0000000000
--- a/api/core/tools/provider/builtin/perplexity/_assets/icon.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/api/core/tools/provider/builtin/perplexity/perplexity.py b/api/core/tools/provider/builtin/perplexity/perplexity.py
deleted file mode 100644
index 80518853fb..0000000000
--- a/api/core/tools/provider/builtin/perplexity/perplexity.py
+++ /dev/null
@@ -1,38 +0,0 @@
-from typing import Any
-
-import requests
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.perplexity.tools.perplexity_search import PERPLEXITY_API_URL
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class PerplexityProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- headers = {
- "Authorization": f"Bearer {credentials.get('perplexity_api_key')}",
- "Content-Type": "application/json",
- }
-
- payload = {
- "model": "llama-3.1-sonar-small-128k-online",
- "messages": [
- {"role": "system", "content": "You are a helpful assistant."},
- {"role": "user", "content": "Hello"},
- ],
- "max_tokens": 5,
- "temperature": 0.1,
- "top_p": 0.9,
- "stream": False,
- }
-
- try:
- response = requests.post(PERPLEXITY_API_URL, json=payload, headers=headers)
- response.raise_for_status()
- except requests.RequestException as e:
- raise ToolProviderCredentialValidationError(f"Failed to validate Perplexity API key: {str(e)}")
-
- if response.status_code != 200:
- raise ToolProviderCredentialValidationError(
- f"Perplexity API key is invalid. Status code: {response.status_code}"
- )
diff --git a/api/core/tools/provider/builtin/perplexity/perplexity.yaml b/api/core/tools/provider/builtin/perplexity/perplexity.yaml
deleted file mode 100644
index c0b504f300..0000000000
--- a/api/core/tools/provider/builtin/perplexity/perplexity.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-identity:
- author: Dify
- name: perplexity
- label:
- en_US: Perplexity
- zh_Hans: Perplexity
- description:
- en_US: Perplexity.AI
- zh_Hans: Perplexity.AI
- icon: icon.svg
- tags:
- - search
-credentials_for_provider:
- perplexity_api_key:
- type: secret-input
- required: true
- label:
- en_US: Perplexity API key
- zh_Hans: Perplexity API key
- placeholder:
- en_US: Please input your Perplexity API key
- zh_Hans: 请输入你的 Perplexity API key
- help:
- en_US: Get your Perplexity API key from Perplexity
- zh_Hans: 从 Perplexity 获取您的 Perplexity API key
- url: https://www.perplexity.ai/settings/api
diff --git a/api/core/tools/provider/builtin/perplexity/tools/perplexity_search.py b/api/core/tools/provider/builtin/perplexity/tools/perplexity_search.py
deleted file mode 100644
index 5ed4b9ca99..0000000000
--- a/api/core/tools/provider/builtin/perplexity/tools/perplexity_search.py
+++ /dev/null
@@ -1,67 +0,0 @@
-import json
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-PERPLEXITY_API_URL = "https://api.perplexity.ai/chat/completions"
-
-
-class PerplexityAITool(BuiltinTool):
- def _parse_response(self, response: dict) -> dict:
- """Parse the response from Perplexity AI API"""
- if "choices" in response and len(response["choices"]) > 0:
- message = response["choices"][0]["message"]
- return {
- "content": message.get("content", ""),
- "role": message.get("role", ""),
- "citations": response.get("citations", []),
- }
- else:
- return {"content": "Unable to get a valid response", "role": "assistant", "citations": []}
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- headers = {
- "Authorization": f"Bearer {self.runtime.credentials['perplexity_api_key']}",
- "Content-Type": "application/json",
- }
-
- payload = {
- "model": tool_parameters.get("model", "llama-3.1-sonar-small-128k-online"),
- "messages": [
- {"role": "system", "content": "Be precise and concise."},
- {"role": "user", "content": tool_parameters["query"]},
- ],
- "max_tokens": tool_parameters.get("max_tokens", 4096),
- "temperature": tool_parameters.get("temperature", 0.7),
- "top_p": tool_parameters.get("top_p", 1),
- "top_k": tool_parameters.get("top_k", 5),
- "presence_penalty": tool_parameters.get("presence_penalty", 0),
- "frequency_penalty": tool_parameters.get("frequency_penalty", 1),
- "stream": False,
- }
-
- if "search_recency_filter" in tool_parameters:
- payload["search_recency_filter"] = tool_parameters["search_recency_filter"]
- if "return_citations" in tool_parameters:
- payload["return_citations"] = tool_parameters["return_citations"]
- if "search_domain_filter" in tool_parameters:
- if isinstance(tool_parameters["search_domain_filter"], str):
- payload["search_domain_filter"] = [tool_parameters["search_domain_filter"]]
- elif isinstance(tool_parameters["search_domain_filter"], list):
- payload["search_domain_filter"] = tool_parameters["search_domain_filter"]
-
- response = requests.post(url=PERPLEXITY_API_URL, json=payload, headers=headers)
- response.raise_for_status()
- valuable_res = self._parse_response(response.json())
-
- return [
- self.create_json_message(valuable_res),
- self.create_text_message(json.dumps(valuable_res, ensure_ascii=False, indent=2)),
- ]
diff --git a/api/core/tools/provider/builtin/perplexity/tools/perplexity_search.yaml b/api/core/tools/provider/builtin/perplexity/tools/perplexity_search.yaml
deleted file mode 100644
index 02a645df33..0000000000
--- a/api/core/tools/provider/builtin/perplexity/tools/perplexity_search.yaml
+++ /dev/null
@@ -1,178 +0,0 @@
-identity:
- name: perplexity
- author: Dify
- label:
- en_US: Perplexity Search
-description:
- human:
- en_US: Search information using Perplexity AI's language models.
- llm: This tool is used to search information using Perplexity AI's language models.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query
- zh_Hans: 查询
- human_description:
- en_US: The text query to be processed by the AI model.
- zh_Hans: 要由 AI 模型处理的文本查询。
- form: llm
- - name: model
- type: select
- required: false
- label:
- en_US: Model Name
- zh_Hans: 模型名称
- human_description:
- en_US: The Perplexity AI model to use for generating the response.
- zh_Hans: 用于生成响应的 Perplexity AI 模型。
- form: form
- default: "llama-3.1-sonar-small-128k-online"
- options:
- - value: llama-3.1-sonar-small-128k-online
- label:
- en_US: llama-3.1-sonar-small-128k-online
- zh_Hans: llama-3.1-sonar-small-128k-online
- - value: llama-3.1-sonar-large-128k-online
- label:
- en_US: llama-3.1-sonar-large-128k-online
- zh_Hans: llama-3.1-sonar-large-128k-online
- - value: llama-3.1-sonar-huge-128k-online
- label:
- en_US: llama-3.1-sonar-huge-128k-online
- zh_Hans: llama-3.1-sonar-huge-128k-online
- - name: max_tokens
- type: number
- required: false
- label:
- en_US: Max Tokens
- zh_Hans: 最大令牌数
- pt_BR: Máximo de Tokens
- human_description:
- en_US: The maximum number of tokens to generate in the response.
- zh_Hans: 在响应中生成的最大令牌数。
- pt_BR: O número máximo de tokens a serem gerados na resposta.
- form: form
- default: 4096
- min: 1
- max: 4096
- - name: temperature
- type: number
- required: false
- label:
- en_US: Temperature
- zh_Hans: 温度
- pt_BR: Temperatura
- human_description:
- en_US: Controls randomness in the output. Lower values make the output more focused and deterministic.
- zh_Hans: 控制输出的随机性。较低的值使输出更加集中和确定。
- form: form
- default: 0.7
- min: 0
- max: 1
- - name: top_k
- type: number
- required: false
- label:
- en_US: Top K
- zh_Hans: 取样数量
- human_description:
- en_US: The number of top results to consider for response generation.
- zh_Hans: 用于生成响应的顶部结果数量。
- form: form
- default: 5
- min: 1
- max: 100
- - name: top_p
- type: number
- required: false
- label:
- en_US: Top P
- zh_Hans: Top P
- human_description:
- en_US: Controls diversity via nucleus sampling.
- zh_Hans: 通过核心采样控制多样性。
- form: form
- default: 1
- min: 0.1
- max: 1
- step: 0.1
- - name: presence_penalty
- type: number
- required: false
- label:
- en_US: Presence Penalty
- zh_Hans: 存在惩罚
- human_description:
- en_US: Positive values penalize new tokens based on whether they appear in the text so far.
- zh_Hans: 正值会根据新词元是否已经出现在文本中来对其进行惩罚。
- form: form
- default: 0
- min: -1.0
- max: 1.0
- step: 0.1
- - name: frequency_penalty
- type: number
- required: false
- label:
- en_US: Frequency Penalty
- zh_Hans: 频率惩罚
- human_description:
- en_US: Positive values penalize new tokens based on their existing frequency in the text so far.
- zh_Hans: 正值会根据新词元在文本中已经出现的频率来对其进行惩罚。
- form: form
- default: 1
- min: 0.1
- max: 1.0
- step: 0.1
- - name: return_citations
- type: boolean
- required: false
- label:
- en_US: Return Citations
- zh_Hans: 返回引用
- human_description:
- en_US: Whether to return citations in the response.
- zh_Hans: 是否在响应中返回引用。
- form: form
- default: true
- - name: search_domain_filter
- type: string
- required: false
- label:
- en_US: Search Domain Filter
- zh_Hans: 搜索域过滤器
- human_description:
- en_US: Domain to filter the search results.
- zh_Hans: 用于过滤搜索结果的域名。
- form: form
- default: ""
- - name: search_recency_filter
- type: select
- required: false
- label:
- en_US: Search Recency Filter
- zh_Hans: 搜索时间过滤器
- human_description:
- en_US: Filter for search results based on recency.
- zh_Hans: 基于时间筛选搜索结果。
- form: form
- default: "month"
- options:
- - value: day
- label:
- en_US: Day
- zh_Hans: 天
- - value: week
- label:
- en_US: Week
- zh_Hans: 周
- - value: month
- label:
- en_US: Month
- zh_Hans: 月
- - value: year
- label:
- en_US: Year
- zh_Hans: 年
diff --git a/api/core/tools/provider/builtin/pubmed/_assets/icon.svg b/api/core/tools/provider/builtin/pubmed/_assets/icon.svg
deleted file mode 100644
index 6d6ff593f0..0000000000
--- a/api/core/tools/provider/builtin/pubmed/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/pubmed/pubmed.py b/api/core/tools/provider/builtin/pubmed/pubmed.py
deleted file mode 100644
index ea3a477c30..0000000000
--- a/api/core/tools/provider/builtin/pubmed/pubmed.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.pubmed.tools.pubmed_search import PubMedSearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class PubMedProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- PubMedSearchTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "query": "John Doe",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/pubmed/pubmed.yaml b/api/core/tools/provider/builtin/pubmed/pubmed.yaml
deleted file mode 100644
index 5f8303147c..0000000000
--- a/api/core/tools/provider/builtin/pubmed/pubmed.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-identity:
- author: Pink Banana
- name: pubmed
- label:
- en_US: PubMed
- zh_Hans: PubMed
- description:
- en_US: A search engine for biomedical literature.
- zh_Hans: 一款生物医学文献搜索引擎。
- icon: icon.svg
- tags:
- - medical
- - search
diff --git a/api/core/tools/provider/builtin/pubmed/tools/pubmed_search.py b/api/core/tools/provider/builtin/pubmed/tools/pubmed_search.py
deleted file mode 100644
index 3a4f374ea0..0000000000
--- a/api/core/tools/provider/builtin/pubmed/tools/pubmed_search.py
+++ /dev/null
@@ -1,191 +0,0 @@
-import json
-import time
-import urllib.error
-import urllib.parse
-import urllib.request
-from typing import Any
-
-from pydantic import BaseModel, Field
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class PubMedAPIWrapper(BaseModel):
- """
- Wrapper around PubMed API.
-
- This wrapper will use the PubMed API to conduct searches and fetch
- document summaries. By default, it will return the document summaries
- of the top-k results of an input search.
-
- Parameters:
- top_k_results: number of the top-scored document used for the PubMed tool
- load_max_docs: a limit to the number of loaded documents
- load_all_available_meta:
- if True: the `metadata` of the loaded Documents gets all available meta info
- (see https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ESearch)
- if False: the `metadata` gets only the most informative fields.
- """
-
- base_url_esearch: str = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?"
- base_url_efetch: str = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?"
- max_retry: int = 5
- sleep_time: float = 0.2
-
- # Default values for the parameters
- top_k_results: int = 3
- load_max_docs: int = 25
- ARXIV_MAX_QUERY_LENGTH: int = 300
- doc_content_chars_max: int = 2000
- load_all_available_meta: bool = False
- email: str = "your_email@example.com"
-
- def run(self, query: str) -> str:
- """
- Run PubMed search and get the article meta information.
- See https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ESearch
- It uses only the most informative fields of article meta information.
- """
-
- try:
- # Retrieve the top-k results for the query
- docs = [
- f"Published: {result['pub_date']}\nTitle: {result['title']}\nSummary: {result['summary']}"
- for result in self.load(query[: self.ARXIV_MAX_QUERY_LENGTH])
- ]
-
- # Join the results and limit the character count
- return "\n\n".join(docs)[: self.doc_content_chars_max] if docs else "No good PubMed Result was found"
- except Exception as ex:
- return f"PubMed exception: {ex}"
-
- def load(self, query: str) -> list[dict]:
- """
- Search PubMed for documents matching the query.
- Return a list of dictionaries containing the document metadata.
- """
-
- url = (
- self.base_url_esearch
- + "db=pubmed&term="
- + str({urllib.parse.quote(query)})
- + f"&retmode=json&retmax={self.top_k_results}&usehistory=y"
- )
- result = urllib.request.urlopen(url)
- text = result.read().decode("utf-8")
- json_text = json.loads(text)
-
- articles = []
- webenv = json_text["esearchresult"]["webenv"]
- for uid in json_text["esearchresult"]["idlist"]:
- article = self.retrieve_article(uid, webenv)
- articles.append(article)
-
- # Convert the list of articles to a JSON string
- return articles
-
- def retrieve_article(self, uid: str, webenv: str) -> dict:
- url = self.base_url_efetch + "db=pubmed&retmode=xml&id=" + uid + "&webenv=" + webenv
-
- retry = 0
- while True:
- try:
- result = urllib.request.urlopen(url)
- break
- except urllib.error.HTTPError as e:
- if e.code == 429 and retry < self.max_retry:
- # Too Many Requests error
- # wait for an exponentially increasing amount of time
- print(f"Too Many Requests, waiting for {self.sleep_time:.2f} seconds...")
- time.sleep(self.sleep_time)
- self.sleep_time *= 2
- retry += 1
- else:
- raise e
-
- xml_text = result.read().decode("utf-8")
-
- # Get title
- title = ""
- if "" in xml_text and "" in xml_text:
- start_tag = ""
- end_tag = ""
- title = xml_text[xml_text.index(start_tag) + len(start_tag) : xml_text.index(end_tag)]
-
- # Get abstract
- abstract = ""
- if "" in xml_text and "" in xml_text:
- start_tag = ""
- end_tag = ""
- abstract = xml_text[xml_text.index(start_tag) + len(start_tag) : xml_text.index(end_tag)]
-
- # Get publication date
- pub_date = ""
- if "" in xml_text and "" in xml_text:
- start_tag = ""
- end_tag = ""
- pub_date = xml_text[xml_text.index(start_tag) + len(start_tag) : xml_text.index(end_tag)]
-
- # Return article as dictionary
- article = {
- "uid": uid,
- "title": title,
- "summary": abstract,
- "pub_date": pub_date,
- }
- return article
-
-
-class PubmedQueryRun(BaseModel):
- """Tool that searches the PubMed API."""
-
- name: str = "PubMed"
- description: str = (
- "A wrapper around PubMed.org "
- "Useful for when you need to answer questions about Physics, Mathematics, "
- "Computer Science, Quantitative Biology, Quantitative Finance, Statistics, "
- "Electrical Engineering, and Economics "
- "from scientific articles on PubMed.org. "
- "Input should be a search query."
- )
- api_wrapper: PubMedAPIWrapper = Field(default_factory=PubMedAPIWrapper)
-
- def _run(
- self,
- query: str,
- ) -> str:
- """Use the Arxiv tool."""
- return self.api_wrapper.run(query)
-
-
-class PubMedInput(BaseModel):
- query: str = Field(..., description="Search query.")
-
-
-class PubMedSearchTool(BuiltinTool):
- """
- Tool for performing a search using PubMed search engine.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage | list[ToolInvokeMessage]:
- """
- Invoke the PubMed search tool.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Any]): The parameters for the tool invocation.
-
- Returns:
- ToolInvokeMessage | list[ToolInvokeMessage]: The result of the tool invocation.
- """
- query = tool_parameters.get("query", "")
-
- if not query:
- return self.create_text_message("Please input query")
-
- tool = PubmedQueryRun(args_schema=PubMedInput)
-
- result = tool._run(query)
-
- return self.create_text_message(self.summary(user_id=user_id, content=result))
diff --git a/api/core/tools/provider/builtin/pubmed/tools/pubmed_search.yaml b/api/core/tools/provider/builtin/pubmed/tools/pubmed_search.yaml
deleted file mode 100644
index 77ab809fbc..0000000000
--- a/api/core/tools/provider/builtin/pubmed/tools/pubmed_search.yaml
+++ /dev/null
@@ -1,23 +0,0 @@
-identity:
- name: pubmed_search
- author: Pink Banana
- label:
- en_US: PubMed Search
- zh_Hans: PubMed 搜索
-description:
- human:
- en_US: PubMed® comprises more than 35 million citations for biomedical literature from MEDLINE, life science journals, and online books. Citations may include links to full text content from PubMed Central and publisher web sites.
- zh_Hans: PubMed® 包含来自 MEDLINE、生命科学期刊和在线书籍的超过 3500 万篇生物医学文献引用。引用可能包括来自 PubMed Central 和出版商网站的全文内容链接。
- llm: Perform searches on PubMed and get results.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query string
- zh_Hans: 查询语句
- human_description:
- en_US: The search query.
- zh_Hans: 搜索查询语句。
- llm_description: Key words for searching
- form: llm
diff --git a/api/core/tools/provider/builtin/regex/_assets/icon.svg b/api/core/tools/provider/builtin/regex/_assets/icon.svg
deleted file mode 100644
index 0231a2b4aa..0000000000
--- a/api/core/tools/provider/builtin/regex/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/regex/regex.py b/api/core/tools/provider/builtin/regex/regex.py
deleted file mode 100644
index c498105979..0000000000
--- a/api/core/tools/provider/builtin/regex/regex.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.regex.tools.regex_extract import RegexExpressionTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class RegexProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- RegexExpressionTool().invoke(
- user_id="",
- tool_parameters={
- "content": "1+(2+3)*4",
- "expression": r"(\d+)",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/regex/regex.yaml b/api/core/tools/provider/builtin/regex/regex.yaml
deleted file mode 100644
index d05776f214..0000000000
--- a/api/core/tools/provider/builtin/regex/regex.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-identity:
- author: zhuhao
- name: regex
- label:
- en_US: Regex
- zh_Hans: 正则表达式提取
- pt_BR: Regex
- description:
- en_US: A tool for regex extraction.
- zh_Hans: 一个用于正则表达式内容提取的工具。
- pt_BR: A tool for regex extraction.
- icon: icon.svg
- tags:
- - utilities
- - productivity
diff --git a/api/core/tools/provider/builtin/regex/tools/regex_extract.py b/api/core/tools/provider/builtin/regex/tools/regex_extract.py
deleted file mode 100644
index 786b469404..0000000000
--- a/api/core/tools/provider/builtin/regex/tools/regex_extract.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import re
-from typing import Any, Union
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class RegexExpressionTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- # get expression
- content = tool_parameters.get("content", "").strip()
- if not content:
- return self.create_text_message("Invalid content")
- expression = tool_parameters.get("expression", "").strip()
- if not expression:
- return self.create_text_message("Invalid expression")
- try:
- result = re.findall(expression, content)
- return self.create_text_message(str(result))
- except Exception as e:
- return self.create_text_message(f"Failed to extract result, error: {str(e)}")
diff --git a/api/core/tools/provider/builtin/regex/tools/regex_extract.yaml b/api/core/tools/provider/builtin/regex/tools/regex_extract.yaml
deleted file mode 100644
index de4100def1..0000000000
--- a/api/core/tools/provider/builtin/regex/tools/regex_extract.yaml
+++ /dev/null
@@ -1,38 +0,0 @@
-identity:
- name: regex_extract
- author: zhuhao
- label:
- en_US: Regex Extract
- zh_Hans: 正则表达式内容提取
- pt_BR: Regex Extract
-description:
- human:
- en_US: A tool for extracting matching content using regular expressions.
- zh_Hans: 一个用于利用正则表达式提取匹配内容结果的工具。
- pt_BR: A tool for extracting matching content using regular expressions.
- llm: A tool for extracting matching content using regular expressions.
-parameters:
- - name: content
- type: string
- required: true
- label:
- en_US: Content to be extracted
- zh_Hans: 内容
- pt_BR: Content to be extracted
- human_description:
- en_US: Content to be extracted
- zh_Hans: 内容
- pt_BR: Content to be extracted
- form: llm
- - name: expression
- type: string
- required: true
- label:
- en_US: Regular expression
- zh_Hans: 正则表达式
- pt_BR: Regular expression
- human_description:
- en_US: Regular expression
- zh_Hans: 正则表达式
- pt_BR: Regular expression
- form: llm
diff --git a/api/core/tools/provider/builtin/searchapi/_assets/icon.svg b/api/core/tools/provider/builtin/searchapi/_assets/icon.svg
deleted file mode 100644
index 7660b2f351..0000000000
--- a/api/core/tools/provider/builtin/searchapi/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/searchapi/searchapi.py b/api/core/tools/provider/builtin/searchapi/searchapi.py
deleted file mode 100644
index 109bba8b2d..0000000000
--- a/api/core/tools/provider/builtin/searchapi/searchapi.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.searchapi.tools.google import GoogleTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class SearchAPIProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- GoogleTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={"query": "SearchApi dify", "result_type": "link"},
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/searchapi/searchapi.yaml b/api/core/tools/provider/builtin/searchapi/searchapi.yaml
deleted file mode 100644
index c2fa3f398e..0000000000
--- a/api/core/tools/provider/builtin/searchapi/searchapi.yaml
+++ /dev/null
@@ -1,34 +0,0 @@
-identity:
- author: SearchApi
- name: searchapi
- label:
- en_US: SearchApi
- zh_Hans: SearchApi
- pt_BR: SearchApi
- description:
- en_US: SearchApi is a robust real-time SERP API delivering structured data from a collection of search engines including Google Search, Google Jobs, YouTube, Google News, and many more.
- zh_Hans: SearchApi 是一个强大的实时 SERP API,可提供来自 Google 搜索、Google 招聘、YouTube、Google 新闻等搜索引擎集合的结构化数据。
- pt_BR: SearchApi is a robust real-time SERP API delivering structured data from a collection of search engines including Google Search, Google Jobs, YouTube, Google News, and many more.
- icon: icon.svg
- tags:
- - search
- - business
- - news
- - productivity
-credentials_for_provider:
- searchapi_api_key:
- type: secret-input
- required: true
- label:
- en_US: SearchApi API key
- zh_Hans: SearchApi API key
- pt_BR: SearchApi API key
- placeholder:
- en_US: Please input your SearchApi API key
- zh_Hans: 请输入你的 SearchApi API key
- pt_BR: Please input your SearchApi API key
- help:
- en_US: Get your SearchApi API key from SearchApi
- zh_Hans: 从 SearchApi 获取您的 SearchApi API key
- pt_BR: Get your SearchApi API key from SearchApi
- url: https://www.searchapi.io/
diff --git a/api/core/tools/provider/builtin/searchapi/tools/google.py b/api/core/tools/provider/builtin/searchapi/tools/google.py
deleted file mode 100644
index 17e2978194..0000000000
--- a/api/core/tools/provider/builtin/searchapi/tools/google.py
+++ /dev/null
@@ -1,112 +0,0 @@
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-SEARCH_API_URL = "https://www.searchapi.io/api/v1/search"
-
-
-class SearchAPI:
- """
- SearchAPI tool provider.
- """
-
- def __init__(self, api_key: str) -> None:
- """Initialize SearchAPI tool provider."""
- self.searchapi_api_key = api_key
-
- def run(self, query: str, **kwargs: Any) -> str:
- """Run query through SearchAPI and parse result."""
- type = kwargs.get("result_type", "text")
- return self._process_response(self.results(query, **kwargs), type=type)
-
- def results(self, query: str, **kwargs: Any) -> dict:
- """Run query through SearchAPI and return the raw result."""
- params = self.get_params(query, **kwargs)
- response = requests.get(
- url=SEARCH_API_URL,
- params=params,
- headers={"Authorization": f"Bearer {self.searchapi_api_key}"},
- )
- response.raise_for_status()
- return response.json()
-
- def get_params(self, query: str, **kwargs: Any) -> dict[str, str]:
- """Get parameters for SearchAPI."""
- return {
- "engine": "google",
- "q": query,
- **{key: value for key, value in kwargs.items() if value not in {None, ""}},
- }
-
- @staticmethod
- def _process_response(res: dict, type: str) -> str:
- """Process response from SearchAPI."""
- if "error" in res:
- raise ValueError(f"Got error from SearchApi: {res['error']}")
-
- toret = ""
- if type == "text":
- if "answer_box" in res and "answer" in res["answer_box"]:
- toret += res["answer_box"]["answer"] + "\n"
- if "answer_box" in res and "snippet" in res["answer_box"]:
- toret += res["answer_box"]["snippet"] + "\n"
- if "knowledge_graph" in res and "description" in res["knowledge_graph"]:
- toret += res["knowledge_graph"]["description"] + "\n"
- if "organic_results" in res and "snippet" in res["organic_results"][0]:
- for item in res["organic_results"]:
- toret += "content: " + item["snippet"] + "\n" + "link: " + item["link"] + "\n"
- if toret == "":
- toret = "No good search result found"
-
- elif type == "link":
- if "answer_box" in res and "organic_result" in res["answer_box"]:
- if "title" in res["answer_box"]["organic_result"]:
- toret = (
- f"[{res['answer_box']['organic_result']['title']}]"
- f"({res['answer_box']['organic_result']['link']})\n"
- )
- elif "organic_results" in res and "link" in res["organic_results"][0]:
- toret = ""
- for item in res["organic_results"]:
- toret += f"[{item['title']}]({item['link']})\n"
- elif "related_questions" in res and "link" in res["related_questions"][0]:
- toret = ""
- for item in res["related_questions"]:
- toret += f"[{item['title']}]({item['link']})\n"
- elif "related_searches" in res and "link" in res["related_searches"][0]:
- toret = ""
- for item in res["related_searches"]:
- toret += f"[{item['title']}]({item['link']})\n"
- else:
- toret = "No good search result found"
- return toret
-
-
-class GoogleTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke the SearchApi tool.
- """
- query = tool_parameters["query"]
- result_type = tool_parameters["result_type"]
- num = tool_parameters.get("num", 10)
- google_domain = tool_parameters.get("google_domain", "google.com")
- gl = tool_parameters.get("gl", "us")
- hl = tool_parameters.get("hl", "en")
- location = tool_parameters.get("location")
-
- api_key = self.runtime.credentials["searchapi_api_key"]
- result = SearchAPI(api_key).run(
- query, result_type=result_type, num=num, google_domain=google_domain, gl=gl, hl=hl, location=location
- )
-
- if result_type == "text":
- return self.create_text_message(text=result)
- return self.create_link_message(link=result)
diff --git a/api/core/tools/provider/builtin/searchapi/tools/google.yaml b/api/core/tools/provider/builtin/searchapi/tools/google.yaml
deleted file mode 100644
index b69a0e1d3e..0000000000
--- a/api/core/tools/provider/builtin/searchapi/tools/google.yaml
+++ /dev/null
@@ -1,481 +0,0 @@
-identity:
- name: google_search_api
- author: SearchApi
- label:
- en_US: Google Search API
- zh_Hans: Google Search API
-description:
- human:
- en_US: A tool to retrieve answer boxes, knowledge graphs, snippets, and webpages from Google Search engine.
- zh_Hans: 一种从 Google 搜索引擎检索答案框、知识图、片段和网页的工具。
- llm: A tool to retrieve answer boxes, knowledge graphs, snippets, and webpages from Google Search engine.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query
- zh_Hans: 询问
- human_description:
- en_US: Defines the query you want to search.
- zh_Hans: 定义您要搜索的查询。
- llm_description: Defines the search query you want to search.
- form: llm
- - name: result_type
- type: select
- required: true
- options:
- - value: text
- label:
- en_US: text
- zh_Hans: 文本
- - value: link
- label:
- en_US: link
- zh_Hans: 链接
- default: text
- label:
- en_US: Result type
- zh_Hans: 结果类型
- human_description:
- en_US: used for selecting the result type, text or link
- zh_Hans: 用于选择结果类型,使用文本还是链接进行展示
- form: form
- - name: location
- type: string
- required: false
- label:
- en_US: Location
- zh_Hans: 询问
- human_description:
- en_US: Defines from where you want the search to originate. (For example - New York)
- zh_Hans: 定义您想要搜索的起始位置。 (例如 - 纽约)
- llm_description: Defines from where you want the search to originate. (For example - New York)
- form: llm
- - name: gl
- type: select
- label:
- en_US: Country
- zh_Hans: 国家
- required: false
- human_description:
- en_US: Defines the country of the search. Default is "US".
- zh_Hans: 定义搜索的国家/地区。默认为“美国”。
- llm_description: Defines the gl parameter of the Google search.
- form: form
- default: US
- options:
- - value: AR
- label:
- en_US: Argentina
- zh_Hans: 阿根廷
- pt_BR: Argentina
- - value: AU
- label:
- en_US: Australia
- zh_Hans: 澳大利亚
- pt_BR: Australia
- - value: AT
- label:
- en_US: Austria
- zh_Hans: 奥地利
- pt_BR: Austria
- - value: BE
- label:
- en_US: Belgium
- zh_Hans: 比利时
- pt_BR: Belgium
- - value: BR
- label:
- en_US: Brazil
- zh_Hans: 巴西
- pt_BR: Brazil
- - value: CA
- label:
- en_US: Canada
- zh_Hans: 加拿大
- pt_BR: Canada
- - value: CL
- label:
- en_US: Chile
- zh_Hans: 智利
- pt_BR: Chile
- - value: CO
- label:
- en_US: Colombia
- zh_Hans: 哥伦比亚
- pt_BR: Colombia
- - value: CN
- label:
- en_US: China
- zh_Hans: 中国
- pt_BR: China
- - value: CZ
- label:
- en_US: Czech Republic
- zh_Hans: 捷克共和国
- pt_BR: Czech Republic
- - value: DK
- label:
- en_US: Denmark
- zh_Hans: 丹麦
- pt_BR: Denmark
- - value: FI
- label:
- en_US: Finland
- zh_Hans: 芬兰
- pt_BR: Finland
- - value: FR
- label:
- en_US: France
- zh_Hans: 法国
- pt_BR: France
- - value: DE
- label:
- en_US: Germany
- zh_Hans: 德国
- pt_BR: Germany
- - value: HK
- label:
- en_US: Hong Kong
- zh_Hans: 香港
- pt_BR: Hong Kong
- - value: IN
- label:
- en_US: India
- zh_Hans: 印度
- pt_BR: India
- - value: ID
- label:
- en_US: Indonesia
- zh_Hans: 印度尼西亚
- pt_BR: Indonesia
- - value: IT
- label:
- en_US: Italy
- zh_Hans: 意大利
- pt_BR: Italy
- - value: JP
- label:
- en_US: Japan
- zh_Hans: 日本
- pt_BR: Japan
- - value: KR
- label:
- en_US: Korea
- zh_Hans: 韩国
- pt_BR: Korea
- - value: MY
- label:
- en_US: Malaysia
- zh_Hans: 马来西亚
- pt_BR: Malaysia
- - value: MX
- label:
- en_US: Mexico
- zh_Hans: 墨西哥
- pt_BR: Mexico
- - value: NL
- label:
- en_US: Netherlands
- zh_Hans: 荷兰
- pt_BR: Netherlands
- - value: NZ
- label:
- en_US: New Zealand
- zh_Hans: 新西兰
- pt_BR: New Zealand
- - value: 'NO'
- label:
- en_US: Norway
- zh_Hans: 挪威
- pt_BR: Norway
- - value: PH
- label:
- en_US: Philippines
- zh_Hans: 菲律宾
- pt_BR: Philippines
- - value: PL
- label:
- en_US: Poland
- zh_Hans: 波兰
- pt_BR: Poland
- - value: PT
- label:
- en_US: Portugal
- zh_Hans: 葡萄牙
- pt_BR: Portugal
- - value: RU
- label:
- en_US: Russia
- zh_Hans: 俄罗斯
- pt_BR: Russia
- - value: SA
- label:
- en_US: Saudi Arabia
- zh_Hans: 沙特阿拉伯
- pt_BR: Saudi Arabia
- - value: SG
- label:
- en_US: Singapore
- zh_Hans: 新加坡
- pt_BR: Singapore
- - value: ZA
- label:
- en_US: South Africa
- zh_Hans: 南非
- pt_BR: South Africa
- - value: ES
- label:
- en_US: Spain
- zh_Hans: 西班牙
- pt_BR: Spain
- - value: SE
- label:
- en_US: Sweden
- zh_Hans: 瑞典
- pt_BR: Sweden
- - value: CH
- label:
- en_US: Switzerland
- zh_Hans: 瑞士
- pt_BR: Switzerland
- - value: TW
- label:
- en_US: Taiwan
- zh_Hans: 台湾
- pt_BR: Taiwan
- - value: TH
- label:
- en_US: Thailand
- zh_Hans: 泰国
- pt_BR: Thailand
- - value: TR
- label:
- en_US: Turkey
- zh_Hans: 土耳其
- pt_BR: Turkey
- - value: GB
- label:
- en_US: United Kingdom
- zh_Hans: 英国
- pt_BR: United Kingdom
- - value: US
- label:
- en_US: United States
- zh_Hans: 美国
- pt_BR: United States
- - name: hl
- type: select
- label:
- en_US: Language
- zh_Hans: 语言
- human_description:
- en_US: Defines the interface language of the search. Default is "en".
- zh_Hans: 定义搜索的界面语言。默认为“en”。
- required: false
- default: en
- form: form
- options:
- - value: ar
- label:
- en_US: Arabic
- zh_Hans: 阿拉伯语
- - value: bg
- label:
- en_US: Bulgarian
- zh_Hans: 保加利亚语
- - value: ca
- label:
- en_US: Catalan
- zh_Hans: 加泰罗尼亚语
- - value: zh-cn
- label:
- en_US: Chinese (Simplified)
- zh_Hans: 中文(简体)
- - value: zh-tw
- label:
- en_US: Chinese (Traditional)
- zh_Hans: 中文(繁体)
- - value: cs
- label:
- en_US: Czech
- zh_Hans: 捷克语
- - value: da
- label:
- en_US: Danish
- zh_Hans: 丹麦语
- - value: nl
- label:
- en_US: Dutch
- zh_Hans: 荷兰语
- - value: en
- label:
- en_US: English
- zh_Hans: 英语
- - value: et
- label:
- en_US: Estonian
- zh_Hans: 爱沙尼亚语
- - value: fi
- label:
- en_US: Finnish
- zh_Hans: 芬兰语
- - value: fr
- label:
- en_US: French
- zh_Hans: 法语
- - value: de
- label:
- en_US: German
- zh_Hans: 德语
- - value: el
- label:
- en_US: Greek
- zh_Hans: 希腊语
- - value: iw
- label:
- en_US: Hebrew
- zh_Hans: 希伯来语
- - value: hi
- label:
- en_US: Hindi
- zh_Hans: 印地语
- - value: hu
- label:
- en_US: Hungarian
- zh_Hans: 匈牙利语
- - value: id
- label:
- en_US: Indonesian
- zh_Hans: 印尼语
- - value: it
- label:
- en_US: Italian
- zh_Hans: 意大利语
- - value: ja
- label:
- en_US: Japanese
- zh_Hans: 日语
- - value: kn
- label:
- en_US: Kannada
- zh_Hans: 卡纳达语
- - value: ko
- label:
- en_US: Korean
- zh_Hans: 韩语
- - value: lv
- label:
- en_US: Latvian
- zh_Hans: 拉脱维亚语
- - value: lt
- label:
- en_US: Lithuanian
- zh_Hans: 立陶宛语
- - value: my
- label:
- en_US: Malay
- zh_Hans: 马来语
- - value: ml
- label:
- en_US: Malayalam
- zh_Hans: 马拉雅拉姆语
- - value: mr
- label:
- en_US: Marathi
- zh_Hans: 马拉地语
- - value: "no"
- label:
- en_US: Norwegian
- zh_Hans: 挪威语
- - value: pl
- label:
- en_US: Polish
- zh_Hans: 波兰语
- - value: pt-br
- label:
- en_US: Portuguese (Brazil)
- zh_Hans: 葡萄牙语(巴西)
- - value: pt-pt
- label:
- en_US: Portuguese (Portugal)
- zh_Hans: 葡萄牙语(葡萄牙)
- - value: pa
- label:
- en_US: Punjabi
- zh_Hans: 旁遮普语
- - value: ro
- label:
- en_US: Romanian
- zh_Hans: 罗马尼亚语
- - value: ru
- label:
- en_US: Russian
- zh_Hans: 俄语
- - value: sr
- label:
- en_US: Serbian
- zh_Hans: 塞尔维亚语
- - value: sk
- label:
- en_US: Slovak
- zh_Hans: 斯洛伐克语
- - value: sl
- label:
- en_US: Slovenian
- zh_Hans: 斯洛文尼亚语
- - value: es
- label:
- en_US: Spanish
- zh_Hans: 西班牙语
- - value: sv
- label:
- en_US: Swedish
- zh_Hans: 瑞典语
- - value: ta
- label:
- en_US: Tamil
- zh_Hans: 泰米尔语
- - value: te
- label:
- en_US: Telugu
- zh_Hans: 泰卢固语
- - value: th
- label:
- en_US: Thai
- zh_Hans: 泰语
- - value: tr
- label:
- en_US: Turkish
- zh_Hans: 土耳其语
- - value: uk
- label:
- en_US: Ukrainian
- zh_Hans: 乌克兰语
- - value: vi
- label:
- en_US: Vietnamese
- zh_Hans: 越南语
- - name: google_domain
- type: string
- required: false
- label:
- en_US: google_domain
- zh_Hans: google_domain
- human_description:
- en_US: Defines the Google domain of the search. Default is "google.com".
- zh_Hans: 定义搜索的 Google 域。默认为“google.com”。
- llm_description: Defines Google domain in which you want to search.
- form: llm
- - name: num
- type: number
- required: false
- label:
- en_US: num
- zh_Hans: num
- human_description:
- en_US: Specifies the number of results to display per page. Default is 10. Max number - 100, min - 1.
- zh_Hans: 指定每页显示的结果数。默认值为 10。最大数量 - 100,最小数量 - 1。
- llm_description: Specifies the num of results to display per page.
- form: llm
diff --git a/api/core/tools/provider/builtin/searchapi/tools/google_jobs.py b/api/core/tools/provider/builtin/searchapi/tools/google_jobs.py
deleted file mode 100644
index c478bc108b..0000000000
--- a/api/core/tools/provider/builtin/searchapi/tools/google_jobs.py
+++ /dev/null
@@ -1,102 +0,0 @@
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-SEARCH_API_URL = "https://www.searchapi.io/api/v1/search"
-
-
-class SearchAPI:
- """
- SearchAPI tool provider.
- """
-
- def __init__(self, api_key: str) -> None:
- """Initialize SearchAPI tool provider."""
- self.searchapi_api_key = api_key
-
- def run(self, query: str, **kwargs: Any) -> str:
- """Run query through SearchAPI and parse result."""
- type = kwargs.get("result_type", "text")
- return self._process_response(self.results(query, **kwargs), type=type)
-
- def results(self, query: str, **kwargs: Any) -> dict:
- """Run query through SearchAPI and return the raw result."""
- params = self.get_params(query, **kwargs)
- response = requests.get(
- url=SEARCH_API_URL,
- params=params,
- headers={"Authorization": f"Bearer {self.searchapi_api_key}"},
- )
- response.raise_for_status()
- return response.json()
-
- def get_params(self, query: str, **kwargs: Any) -> dict[str, str]:
- """Get parameters for SearchAPI."""
- return {
- "engine": "google_jobs",
- "q": query,
- **{key: value for key, value in kwargs.items() if value not in {None, ""}},
- }
-
- @staticmethod
- def _process_response(res: dict, type: str) -> str:
- """Process response from SearchAPI."""
- if "error" in res:
- raise ValueError(f"Got error from SearchApi: {res['error']}")
-
- toret = ""
- if type == "text":
- if "jobs" in res and "title" in res["jobs"][0]:
- for item in res["jobs"]:
- toret += (
- "title: "
- + item["title"]
- + "\n"
- + "company_name: "
- + item["company_name"]
- + "content: "
- + item["description"]
- + "\n"
- )
- if toret == "":
- toret = "No good search result found"
-
- elif type == "link":
- if "jobs" in res and "apply_link" in res["jobs"][0]:
- for item in res["jobs"]:
- toret += f"[{item['title']} - {item['company_name']}]({item['apply_link']})\n"
- else:
- toret = "No good search result found"
- return toret
-
-
-class GoogleJobsTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke the SearchApi tool.
- """
- query = tool_parameters["query"]
- result_type = tool_parameters["result_type"]
- is_remote = tool_parameters.get("is_remote")
- google_domain = tool_parameters.get("google_domain", "google.com")
- gl = tool_parameters.get("gl", "us")
- hl = tool_parameters.get("hl", "en")
- location = tool_parameters.get("location")
-
- ltype = 1 if is_remote else None
-
- api_key = self.runtime.credentials["searchapi_api_key"]
- result = SearchAPI(api_key).run(
- query, result_type=result_type, google_domain=google_domain, gl=gl, hl=hl, location=location, ltype=ltype
- )
-
- if result_type == "text":
- return self.create_text_message(text=result)
- return self.create_link_message(link=result)
diff --git a/api/core/tools/provider/builtin/searchapi/tools/google_jobs.yaml b/api/core/tools/provider/builtin/searchapi/tools/google_jobs.yaml
deleted file mode 100644
index 9033bc0f87..0000000000
--- a/api/core/tools/provider/builtin/searchapi/tools/google_jobs.yaml
+++ /dev/null
@@ -1,478 +0,0 @@
-identity:
- name: google_jobs_api
- author: SearchApi
- label:
- en_US: Google Jobs API
- zh_Hans: Google Jobs API
-description:
- human:
- en_US: A tool to retrieve job titles, company names and description from Google Jobs engine.
- zh_Hans: 一个从 Google 招聘引擎检索职位名称、公司名称和描述的工具。
- llm: A tool to retrieve job titles, company names and description from Google Jobs engine.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query
- zh_Hans: 询问
- human_description:
- en_US: Defines the query you want to search.
- zh_Hans: 定义您要搜索的查询。
- llm_description: Defines the search query you want to search.
- form: llm
- - name: result_type
- type: select
- required: true
- options:
- - value: text
- label:
- en_US: text
- zh_Hans: 文本
- - value: link
- label:
- en_US: link
- zh_Hans: 链接
- default: text
- label:
- en_US: Result type
- zh_Hans: 结果类型
- human_description:
- en_US: used for selecting the result type, text or link
- zh_Hans: 用于选择结果类型,使用文本还是链接进行展示
- form: form
- - name: location
- type: string
- required: false
- label:
- en_US: Location
- zh_Hans: 询问
- human_description:
- en_US: Defines from where you want the search to originate. (For example - New York)
- zh_Hans: 定义您想要搜索的起始位置。 (例如 - 纽约)
- llm_description: Defines from where you want the search to originate. (For example - New York)
- form: llm
- - name: gl
- type: select
- label:
- en_US: Country
- zh_Hans: 国家
- required: false
- human_description:
- en_US: Defines the country of the search. Default is "US".
- zh_Hans: 定义搜索的国家/地区。默认为“美国”。
- llm_description: Defines the gl parameter of the Google search.
- form: form
- default: US
- options:
- - value: AR
- label:
- en_US: Argentina
- zh_Hans: 阿根廷
- pt_BR: Argentina
- - value: AU
- label:
- en_US: Australia
- zh_Hans: 澳大利亚
- pt_BR: Australia
- - value: AT
- label:
- en_US: Austria
- zh_Hans: 奥地利
- pt_BR: Austria
- - value: BE
- label:
- en_US: Belgium
- zh_Hans: 比利时
- pt_BR: Belgium
- - value: BR
- label:
- en_US: Brazil
- zh_Hans: 巴西
- pt_BR: Brazil
- - value: CA
- label:
- en_US: Canada
- zh_Hans: 加拿大
- pt_BR: Canada
- - value: CL
- label:
- en_US: Chile
- zh_Hans: 智利
- pt_BR: Chile
- - value: CO
- label:
- en_US: Colombia
- zh_Hans: 哥伦比亚
- pt_BR: Colombia
- - value: CN
- label:
- en_US: China
- zh_Hans: 中国
- pt_BR: China
- - value: CZ
- label:
- en_US: Czech Republic
- zh_Hans: 捷克共和国
- pt_BR: Czech Republic
- - value: DK
- label:
- en_US: Denmark
- zh_Hans: 丹麦
- pt_BR: Denmark
- - value: FI
- label:
- en_US: Finland
- zh_Hans: 芬兰
- pt_BR: Finland
- - value: FR
- label:
- en_US: France
- zh_Hans: 法国
- pt_BR: France
- - value: DE
- label:
- en_US: Germany
- zh_Hans: 德国
- pt_BR: Germany
- - value: HK
- label:
- en_US: Hong Kong
- zh_Hans: 香港
- pt_BR: Hong Kong
- - value: IN
- label:
- en_US: India
- zh_Hans: 印度
- pt_BR: India
- - value: ID
- label:
- en_US: Indonesia
- zh_Hans: 印度尼西亚
- pt_BR: Indonesia
- - value: IT
- label:
- en_US: Italy
- zh_Hans: 意大利
- pt_BR: Italy
- - value: JP
- label:
- en_US: Japan
- zh_Hans: 日本
- pt_BR: Japan
- - value: KR
- label:
- en_US: Korea
- zh_Hans: 韩国
- pt_BR: Korea
- - value: MY
- label:
- en_US: Malaysia
- zh_Hans: 马来西亚
- pt_BR: Malaysia
- - value: MX
- label:
- en_US: Mexico
- zh_Hans: 墨西哥
- pt_BR: Mexico
- - value: NL
- label:
- en_US: Netherlands
- zh_Hans: 荷兰
- pt_BR: Netherlands
- - value: NZ
- label:
- en_US: New Zealand
- zh_Hans: 新西兰
- pt_BR: New Zealand
- - value: 'NO'
- label:
- en_US: Norway
- zh_Hans: 挪威
- pt_BR: Norway
- - value: PH
- label:
- en_US: Philippines
- zh_Hans: 菲律宾
- pt_BR: Philippines
- - value: PL
- label:
- en_US: Poland
- zh_Hans: 波兰
- pt_BR: Poland
- - value: PT
- label:
- en_US: Portugal
- zh_Hans: 葡萄牙
- pt_BR: Portugal
- - value: RU
- label:
- en_US: Russia
- zh_Hans: 俄罗斯
- pt_BR: Russia
- - value: SA
- label:
- en_US: Saudi Arabia
- zh_Hans: 沙特阿拉伯
- pt_BR: Saudi Arabia
- - value: SG
- label:
- en_US: Singapore
- zh_Hans: 新加坡
- pt_BR: Singapore
- - value: ZA
- label:
- en_US: South Africa
- zh_Hans: 南非
- pt_BR: South Africa
- - value: ES
- label:
- en_US: Spain
- zh_Hans: 西班牙
- pt_BR: Spain
- - value: SE
- label:
- en_US: Sweden
- zh_Hans: 瑞典
- pt_BR: Sweden
- - value: CH
- label:
- en_US: Switzerland
- zh_Hans: 瑞士
- pt_BR: Switzerland
- - value: TW
- label:
- en_US: Taiwan
- zh_Hans: 台湾
- pt_BR: Taiwan
- - value: TH
- label:
- en_US: Thailand
- zh_Hans: 泰国
- pt_BR: Thailand
- - value: TR
- label:
- en_US: Turkey
- zh_Hans: 土耳其
- pt_BR: Turkey
- - value: GB
- label:
- en_US: United Kingdom
- zh_Hans: 英国
- pt_BR: United Kingdom
- - value: US
- label:
- en_US: United States
- zh_Hans: 美国
- pt_BR: United States
- - name: hl
- type: select
- label:
- en_US: Language
- zh_Hans: 语言
- human_description:
- en_US: Defines the interface language of the search. Default is "en".
- zh_Hans: 定义搜索的界面语言。默认为“en”。
- required: false
- default: en
- form: form
- options:
- - value: ar
- label:
- en_US: Arabic
- zh_Hans: 阿拉伯语
- - value: bg
- label:
- en_US: Bulgarian
- zh_Hans: 保加利亚语
- - value: ca
- label:
- en_US: Catalan
- zh_Hans: 加泰罗尼亚语
- - value: zh-cn
- label:
- en_US: Chinese (Simplified)
- zh_Hans: 中文(简体)
- - value: zh-tw
- label:
- en_US: Chinese (Traditional)
- zh_Hans: 中文(繁体)
- - value: cs
- label:
- en_US: Czech
- zh_Hans: 捷克语
- - value: da
- label:
- en_US: Danish
- zh_Hans: 丹麦语
- - value: nl
- label:
- en_US: Dutch
- zh_Hans: 荷兰语
- - value: en
- label:
- en_US: English
- zh_Hans: 英语
- - value: et
- label:
- en_US: Estonian
- zh_Hans: 爱沙尼亚语
- - value: fi
- label:
- en_US: Finnish
- zh_Hans: 芬兰语
- - value: fr
- label:
- en_US: French
- zh_Hans: 法语
- - value: de
- label:
- en_US: German
- zh_Hans: 德语
- - value: el
- label:
- en_US: Greek
- zh_Hans: 希腊语
- - value: iw
- label:
- en_US: Hebrew
- zh_Hans: 希伯来语
- - value: hi
- label:
- en_US: Hindi
- zh_Hans: 印地语
- - value: hu
- label:
- en_US: Hungarian
- zh_Hans: 匈牙利语
- - value: id
- label:
- en_US: Indonesian
- zh_Hans: 印尼语
- - value: it
- label:
- en_US: Italian
- zh_Hans: 意大利语
- - value: ja
- label:
- en_US: Japanese
- zh_Hans: 日语
- - value: kn
- label:
- en_US: Kannada
- zh_Hans: 卡纳达语
- - value: ko
- label:
- en_US: Korean
- zh_Hans: 韩语
- - value: lv
- label:
- en_US: Latvian
- zh_Hans: 拉脱维亚语
- - value: lt
- label:
- en_US: Lithuanian
- zh_Hans: 立陶宛语
- - value: my
- label:
- en_US: Malay
- zh_Hans: 马来语
- - value: ml
- label:
- en_US: Malayalam
- zh_Hans: 马拉雅拉姆语
- - value: mr
- label:
- en_US: Marathi
- zh_Hans: 马拉地语
- - value: "no"
- label:
- en_US: Norwegian
- zh_Hans: 挪威语
- - value: pl
- label:
- en_US: Polish
- zh_Hans: 波兰语
- - value: pt-br
- label:
- en_US: Portuguese (Brazil)
- zh_Hans: 葡萄牙语(巴西)
- - value: pt-pt
- label:
- en_US: Portuguese (Portugal)
- zh_Hans: 葡萄牙语(葡萄牙)
- - value: pa
- label:
- en_US: Punjabi
- zh_Hans: 旁遮普语
- - value: ro
- label:
- en_US: Romanian
- zh_Hans: 罗马尼亚语
- - value: ru
- label:
- en_US: Russian
- zh_Hans: 俄语
- - value: sr
- label:
- en_US: Serbian
- zh_Hans: 塞尔维亚语
- - value: sk
- label:
- en_US: Slovak
- zh_Hans: 斯洛伐克语
- - value: sl
- label:
- en_US: Slovenian
- zh_Hans: 斯洛文尼亚语
- - value: es
- label:
- en_US: Spanish
- zh_Hans: 西班牙语
- - value: sv
- label:
- en_US: Swedish
- zh_Hans: 瑞典语
- - value: ta
- label:
- en_US: Tamil
- zh_Hans: 泰米尔语
- - value: te
- label:
- en_US: Telugu
- zh_Hans: 泰卢固语
- - value: th
- label:
- en_US: Thai
- zh_Hans: 泰语
- - value: tr
- label:
- en_US: Turkish
- zh_Hans: 土耳其语
- - value: uk
- label:
- en_US: Ukrainian
- zh_Hans: 乌克兰语
- - value: vi
- label:
- en_US: Vietnamese
- zh_Hans: 越南语
- - name: is_remote
- type: select
- label:
- en_US: is_remote
- zh_Hans: 很遥远
- human_description:
- en_US: Filter results based on the work arrangement. Set it to true to find jobs that offer work from home or remote work opportunities.
- zh_Hans: 根据工作安排过滤结果。将其设置为 true 可查找提供在家工作或远程工作机会的工作。
- required: false
- form: form
- options:
- - value: 'true'
- label:
- en_US: "true"
- zh_Hans: "true"
- - value: 'false'
- label:
- en_US: "false"
- zh_Hans: "false"
diff --git a/api/core/tools/provider/builtin/searchapi/tools/google_news.py b/api/core/tools/provider/builtin/searchapi/tools/google_news.py
deleted file mode 100644
index 562bc01964..0000000000
--- a/api/core/tools/provider/builtin/searchapi/tools/google_news.py
+++ /dev/null
@@ -1,97 +0,0 @@
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-SEARCH_API_URL = "https://www.searchapi.io/api/v1/search"
-
-
-class SearchAPI:
- """
- SearchAPI tool provider.
- """
-
- def __init__(self, api_key: str) -> None:
- """Initialize SearchAPI tool provider."""
- self.searchapi_api_key = api_key
-
- def run(self, query: str, **kwargs: Any) -> str:
- """Run query through SearchAPI and parse result."""
- type = kwargs.get("result_type", "text")
- return self._process_response(self.results(query, **kwargs), type=type)
-
- def results(self, query: str, **kwargs: Any) -> dict:
- """Run query through SearchAPI and return the raw result."""
- params = self.get_params(query, **kwargs)
- response = requests.get(
- url=SEARCH_API_URL,
- params=params,
- headers={"Authorization": f"Bearer {self.searchapi_api_key}"},
- )
- response.raise_for_status()
- return response.json()
-
- def get_params(self, query: str, **kwargs: Any) -> dict[str, str]:
- """Get parameters for SearchAPI."""
- return {
- "engine": "google_news",
- "q": query,
- **{key: value for key, value in kwargs.items() if value not in {None, ""}},
- }
-
- @staticmethod
- def _process_response(res: dict, type: str) -> str:
- """Process response from SearchAPI."""
- if "error" in res:
- raise ValueError(f"Got error from SearchApi: {res['error']}")
-
- toret = ""
- if type == "text":
- if "organic_results" in res and "snippet" in res["organic_results"][0]:
- for item in res["organic_results"]:
- toret += "content: " + item["snippet"] + "\n" + "link: " + item["link"] + "\n"
- if "top_stories" in res and "title" in res["top_stories"][0]:
- for item in res["top_stories"]:
- toret += "title: " + item["title"] + "\n" + "link: " + item["link"] + "\n"
- if toret == "":
- toret = "No good search result found"
-
- elif type == "link":
- if "organic_results" in res and "title" in res["organic_results"][0]:
- for item in res["organic_results"]:
- toret += f"[{item['title']}]({item['link']})\n"
- elif "top_stories" in res and "title" in res["top_stories"][0]:
- for item in res["top_stories"]:
- toret += f"[{item['title']}]({item['link']})\n"
- else:
- toret = "No good search result found"
- return toret
-
-
-class GoogleNewsTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke the SearchApi tool.
- """
- query = tool_parameters["query"]
- result_type = tool_parameters["result_type"]
- num = tool_parameters.get("num", 10)
- google_domain = tool_parameters.get("google_domain", "google.com")
- gl = tool_parameters.get("gl", "us")
- hl = tool_parameters.get("hl", "en")
- location = tool_parameters.get("location")
-
- api_key = self.runtime.credentials["searchapi_api_key"]
- result = SearchAPI(api_key).run(
- query, result_type=result_type, num=num, google_domain=google_domain, gl=gl, hl=hl, location=location
- )
-
- if result_type == "text":
- return self.create_text_message(text=result)
- return self.create_link_message(link=result)
diff --git a/api/core/tools/provider/builtin/searchapi/tools/google_news.yaml b/api/core/tools/provider/builtin/searchapi/tools/google_news.yaml
deleted file mode 100644
index cbb0edf982..0000000000
--- a/api/core/tools/provider/builtin/searchapi/tools/google_news.yaml
+++ /dev/null
@@ -1,482 +0,0 @@
-identity:
- name: google_news_api
- author: SearchApi
- label:
- en_US: Google News API
- zh_Hans: Google News API
-description:
- human:
- en_US: A tool to retrieve organic search results snippets and links from Google News engine.
- zh_Hans: 一种从 Google 新闻引擎检索有机搜索结果片段和链接的工具。
- llm: A tool to retrieve organic search results snippets and links from Google News engine.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query
- zh_Hans: 询问
- human_description:
- en_US: Defines the query you want to search.
- zh_Hans: 定义您要搜索的查询。
- llm_description: Defines the search query you want to search.
- form: llm
- - name: result_type
- type: select
- required: true
- options:
- - value: text
- label:
- en_US: text
- zh_Hans: 文本
- - value: link
- label:
- en_US: link
- zh_Hans: 链接
- default: text
- label:
- en_US: Result type
- zh_Hans: 结果类型
- human_description:
- en_US: used for selecting the result type, text or link.
- zh_Hans: 用于选择结果类型,使用文本还是链接进行展示。
- form: form
- - name: location
- type: string
- required: false
- label:
- en_US: Location
- zh_Hans: 询问
- human_description:
- en_US: Defines from where you want the search to originate. (For example - New York)
- zh_Hans: 定义您想要搜索的起始位置。 (例如 - 纽约)
- llm_description: Defines from where you want the search to originate. (For example - New York)
- form: llm
- - name: gl
- type: select
- label:
- en_US: Country
- zh_Hans: 国家
- required: false
- human_description:
- en_US: Defines the country of the search. Default is "US".
- zh_Hans: 定义搜索的国家/地区。默认为“美国”。
- llm_description: Defines the gl parameter of the Google search.
- form: form
- default: US
- options:
- - value: AR
- label:
- en_US: Argentina
- zh_Hans: 阿根廷
- pt_BR: Argentina
- - value: AU
- label:
- en_US: Australia
- zh_Hans: 澳大利亚
- pt_BR: Australia
- - value: AT
- label:
- en_US: Austria
- zh_Hans: 奥地利
- pt_BR: Austria
- - value: BE
- label:
- en_US: Belgium
- zh_Hans: 比利时
- pt_BR: Belgium
- - value: BR
- label:
- en_US: Brazil
- zh_Hans: 巴西
- pt_BR: Brazil
- - value: CA
- label:
- en_US: Canada
- zh_Hans: 加拿大
- pt_BR: Canada
- - value: CL
- label:
- en_US: Chile
- zh_Hans: 智利
- pt_BR: Chile
- - value: CO
- label:
- en_US: Colombia
- zh_Hans: 哥伦比亚
- pt_BR: Colombia
- - value: CN
- label:
- en_US: China
- zh_Hans: 中国
- pt_BR: China
- - value: CZ
- label:
- en_US: Czech Republic
- zh_Hans: 捷克共和国
- pt_BR: Czech Republic
- - value: DK
- label:
- en_US: Denmark
- zh_Hans: 丹麦
- pt_BR: Denmark
- - value: FI
- label:
- en_US: Finland
- zh_Hans: 芬兰
- pt_BR: Finland
- - value: FR
- label:
- en_US: France
- zh_Hans: 法国
- pt_BR: France
- - value: DE
- label:
- en_US: Germany
- zh_Hans: 德国
- pt_BR: Germany
- - value: HK
- label:
- en_US: Hong Kong
- zh_Hans: 香港
- pt_BR: Hong Kong
- - value: IN
- label:
- en_US: India
- zh_Hans: 印度
- pt_BR: India
- - value: ID
- label:
- en_US: Indonesia
- zh_Hans: 印度尼西亚
- pt_BR: Indonesia
- - value: IT
- label:
- en_US: Italy
- zh_Hans: 意大利
- pt_BR: Italy
- - value: JP
- label:
- en_US: Japan
- zh_Hans: 日本
- pt_BR: Japan
- - value: KR
- label:
- en_US: Korea
- zh_Hans: 韩国
- pt_BR: Korea
- - value: MY
- label:
- en_US: Malaysia
- zh_Hans: 马来西亚
- pt_BR: Malaysia
- - value: MX
- label:
- en_US: Mexico
- zh_Hans: 墨西哥
- pt_BR: Mexico
- - value: NL
- label:
- en_US: Netherlands
- zh_Hans: 荷兰
- pt_BR: Netherlands
- - value: NZ
- label:
- en_US: New Zealand
- zh_Hans: 新西兰
- pt_BR: New Zealand
- - value: 'NO'
- label:
- en_US: Norway
- zh_Hans: 挪威
- pt_BR: Norway
- - value: PH
- label:
- en_US: Philippines
- zh_Hans: 菲律宾
- pt_BR: Philippines
- - value: PL
- label:
- en_US: Poland
- zh_Hans: 波兰
- pt_BR: Poland
- - value: PT
- label:
- en_US: Portugal
- zh_Hans: 葡萄牙
- pt_BR: Portugal
- - value: RU
- label:
- en_US: Russia
- zh_Hans: 俄罗斯
- pt_BR: Russia
- - value: SA
- label:
- en_US: Saudi Arabia
- zh_Hans: 沙特阿拉伯
- pt_BR: Saudi Arabia
- - value: SG
- label:
- en_US: Singapore
- zh_Hans: 新加坡
- pt_BR: Singapore
- - value: ZA
- label:
- en_US: South Africa
- zh_Hans: 南非
- pt_BR: South Africa
- - value: ES
- label:
- en_US: Spain
- zh_Hans: 西班牙
- pt_BR: Spain
- - value: SE
- label:
- en_US: Sweden
- zh_Hans: 瑞典
- pt_BR: Sweden
- - value: CH
- label:
- en_US: Switzerland
- zh_Hans: 瑞士
- pt_BR: Switzerland
- - value: TW
- label:
- en_US: Taiwan
- zh_Hans: 台湾
- pt_BR: Taiwan
- - value: TH
- label:
- en_US: Thailand
- zh_Hans: 泰国
- pt_BR: Thailand
- - value: TR
- label:
- en_US: Turkey
- zh_Hans: 土耳其
- pt_BR: Turkey
- - value: GB
- label:
- en_US: United Kingdom
- zh_Hans: 英国
- pt_BR: United Kingdom
- - value: US
- label:
- en_US: United States
- zh_Hans: 美国
- pt_BR: United States
- - name: hl
- type: select
- label:
- en_US: Language
- zh_Hans: 语言
- human_description:
- en_US: Defines the interface language of the search. Default is "en".
- zh_Hans: 定义搜索的界面语言。默认为“en”。
- required: false
- default: en
- form: form
- options:
- - value: ar
- label:
- en_US: Arabic
- zh_Hans: 阿拉伯语
- - value: bg
- label:
- en_US: Bulgarian
- zh_Hans: 保加利亚语
- - value: ca
- label:
- en_US: Catalan
- zh_Hans: 加泰罗尼亚语
- - value: zh-cn
- label:
- en_US: Chinese (Simplified)
- zh_Hans: 中文(简体)
- - value: zh-tw
- label:
- en_US: Chinese (Traditional)
- zh_Hans: 中文(繁体)
- - value: cs
- label:
- en_US: Czech
- zh_Hans: 捷克语
- - value: da
- label:
- en_US: Danish
- zh_Hans: 丹麦语
- - value: nl
- label:
- en_US: Dutch
- zh_Hans: 荷兰语
- - value: en
- label:
- en_US: English
- zh_Hans: 英语
- - value: et
- label:
- en_US: Estonian
- zh_Hans: 爱沙尼亚语
- - value: fi
- label:
- en_US: Finnish
- zh_Hans: 芬兰语
- - value: fr
- label:
- en_US: French
- zh_Hans: 法语
- - value: de
- label:
- en_US: German
- zh_Hans: 德语
- - value: el
- label:
- en_US: Greek
- zh_Hans: 希腊语
- - value: iw
- label:
- en_US: Hebrew
- zh_Hans: 希伯来语
- - value: hi
- label:
- en_US: Hindi
- zh_Hans: 印地语
- - value: hu
- label:
- en_US: Hungarian
- zh_Hans: 匈牙利语
- - value: id
- label:
- en_US: Indonesian
- zh_Hans: 印尼语
- - value: it
- label:
- en_US: Italian
- zh_Hans: 意大利语
- - value: ja
- label:
- en_US: Japanese
- zh_Hans: 日语
- - value: kn
- label:
- en_US: Kannada
- zh_Hans: 卡纳达语
- - value: ko
- label:
- en_US: Korean
- zh_Hans: 韩语
- - value: lv
- label:
- en_US: Latvian
- zh_Hans: 拉脱维亚语
- - value: lt
- label:
- en_US: Lithuanian
- zh_Hans: 立陶宛语
- - value: my
- label:
- en_US: Malay
- zh_Hans: 马来语
- - value: ml
- label:
- en_US: Malayalam
- zh_Hans: 马拉雅拉姆语
- - value: mr
- label:
- en_US: Marathi
- zh_Hans: 马拉地语
- - value: "no"
- label:
- en_US: Norwegian
- zh_Hans: 挪威语
- - value: pl
- label:
- en_US: Polish
- zh_Hans: 波兰语
- - value: pt-br
- label:
- en_US: Portuguese (Brazil)
- zh_Hans: 葡萄牙语(巴西)
- - value: pt-pt
- label:
- en_US: Portuguese (Portugal)
- zh_Hans: 葡萄牙语(葡萄牙)
- - value: pa
- label:
- en_US: Punjabi
- zh_Hans: 旁遮普语
- - value: ro
- label:
- en_US: Romanian
- zh_Hans: 罗马尼亚语
- - value: ru
- label:
- en_US: Russian
- zh_Hans: 俄语
- - value: sr
- label:
- en_US: Serbian
- zh_Hans: 塞尔维亚语
- - value: sk
- label:
- en_US: Slovak
- zh_Hans: 斯洛伐克语
- - value: sl
- label:
- en_US: Slovenian
- zh_Hans: 斯洛文尼亚语
- - value: es
- label:
- en_US: Spanish
- zh_Hans: 西班牙语
- - value: sv
- label:
- en_US: Swedish
- zh_Hans: 瑞典语
- - value: ta
- label:
- en_US: Tamil
- zh_Hans: 泰米尔语
- - value: te
- label:
- en_US: Telugu
- zh_Hans: 泰卢固语
- - value: th
- label:
- en_US: Thai
- zh_Hans: 泰语
- - value: tr
- label:
- en_US: Turkish
- zh_Hans: 土耳其语
- - value: uk
- label:
- en_US: Ukrainian
- zh_Hans: 乌克兰语
- - value: vi
- label:
- en_US: Vietnamese
- zh_Hans: 越南语
- - name: google_domain
- type: string
- required: false
- label:
- en_US: google_domain
- zh_Hans: google_domain
- human_description:
- en_US: Defines the Google domain of the search. Default is "google.com".
- zh_Hans: 定义搜索的 Google 域。默认为“google.com”。
- llm_description: Defines Google domain in which you want to search.
- form: llm
- - name: num
- type: number
- required: false
- label:
- en_US: num
- zh_Hans: num
- human_description:
- en_US: Specifies the number of results to display per page. Default is 10. Max number - 100, min - 1.
- zh_Hans: 指定每页显示的结果数。默认值为 10。最大数量 - 100,最小数量 - 1。
- pt_BR: Specifies the number of results to display per page. Default is 10. Max number - 100, min - 1.
- llm_description: Specifies the num of results to display per page.
- form: llm
diff --git a/api/core/tools/provider/builtin/searchapi/tools/youtube_transcripts.py b/api/core/tools/provider/builtin/searchapi/tools/youtube_transcripts.py
deleted file mode 100644
index 1867cf7be7..0000000000
--- a/api/core/tools/provider/builtin/searchapi/tools/youtube_transcripts.py
+++ /dev/null
@@ -1,75 +0,0 @@
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-SEARCH_API_URL = "https://www.searchapi.io/api/v1/search"
-
-
-class SearchAPI:
- """
- SearchAPI tool provider.
- """
-
- def __init__(self, api_key: str) -> None:
- """Initialize SearchAPI tool provider."""
- self.searchapi_api_key = api_key
-
- def run(self, video_id: str, language: str, **kwargs: Any) -> str:
- """Run video_id through SearchAPI and parse result."""
- return self._process_response(self.results(video_id, language, **kwargs))
-
- def results(self, video_id: str, language: str, **kwargs: Any) -> dict:
- """Run video_id through SearchAPI and return the raw result."""
- params = self.get_params(video_id, language, **kwargs)
- response = requests.get(
- url=SEARCH_API_URL,
- params=params,
- headers={"Authorization": f"Bearer {self.searchapi_api_key}"},
- )
- response.raise_for_status()
- return response.json()
-
- def get_params(self, video_id: str, language: str, **kwargs: Any) -> dict[str, str]:
- """Get parameters for SearchAPI."""
- return {
- "engine": "youtube_transcripts",
- "video_id": video_id,
- "lang": language or "en",
- **{key: value for key, value in kwargs.items() if value not in {None, ""}},
- }
-
- @staticmethod
- def _process_response(res: dict) -> str:
- """Process response from SearchAPI."""
- if "error" in res:
- raise ValueError(f"Got error from SearchApi: {res['error']}")
-
- toret = ""
- if "transcripts" in res and "text" in res["transcripts"][0]:
- for item in res["transcripts"]:
- toret += item["text"] + " "
- if toret == "":
- toret = "No good search result found"
-
- return toret
-
-
-class YoutubeTranscriptsTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke the SearchApi tool.
- """
- video_id = tool_parameters["video_id"]
- language = tool_parameters.get("language", "en")
-
- api_key = self.runtime.credentials["searchapi_api_key"]
- result = SearchAPI(api_key).run(video_id, language=language)
-
- return self.create_text_message(text=result)
diff --git a/api/core/tools/provider/builtin/searchapi/tools/youtube_transcripts.yaml b/api/core/tools/provider/builtin/searchapi/tools/youtube_transcripts.yaml
deleted file mode 100644
index 8bdcd6bb93..0000000000
--- a/api/core/tools/provider/builtin/searchapi/tools/youtube_transcripts.yaml
+++ /dev/null
@@ -1,34 +0,0 @@
-identity:
- name: youtube_transcripts_api
- author: SearchApi
- label:
- en_US: YouTube Transcripts API
- zh_Hans: YouTube 脚本 API
-description:
- human:
- en_US: A tool to retrieve transcripts from the specific YouTube video.
- zh_Hans: 一种从特定 YouTube 视频检索文字记录的工具。
- llm: A tool to retrieve transcripts from the specific YouTube video.
-parameters:
- - name: video_id
- type: string
- required: true
- label:
- en_US: video_id
- zh_Hans: 视频ID
- human_description:
- en_US: Used to define the video you want to search. You can find the video id's in YouTube page that appears in URL. For example - https://www.youtube.com/watch?v=video_id.
- zh_Hans: 用于定义要搜索的视频。您可以在 URL 中显示的 YouTube 页面中找到视频 ID。例如 - https://www.youtube.com/watch?v=video_id。
- llm_description: Used to define the video you want to search.
- form: llm
- - name: language
- type: string
- required: false
- label:
- en_US: language
- zh_Hans: 语言
- human_description:
- en_US: Used to set the language for transcripts. The default value is "en". You can find all supported languages in SearchApi documentation.
- zh_Hans: 用于设置成绩单的语言。默认值为“en”。您可以在 SearchApi 文档中找到所有支持的语言。
- llm_description: Used to set the language for transcripts.
- form: llm
diff --git a/api/core/tools/provider/builtin/searxng/_assets/icon.svg b/api/core/tools/provider/builtin/searxng/_assets/icon.svg
deleted file mode 100644
index b94fe3728a..0000000000
--- a/api/core/tools/provider/builtin/searxng/_assets/icon.svg
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
diff --git a/api/core/tools/provider/builtin/searxng/docker/settings.yml b/api/core/tools/provider/builtin/searxng/docker/settings.yml
deleted file mode 100644
index 18e1868800..0000000000
--- a/api/core/tools/provider/builtin/searxng/docker/settings.yml
+++ /dev/null
@@ -1,2501 +0,0 @@
-general:
- # Debug mode, only for development. Is overwritten by ${SEARXNG_DEBUG}
- debug: false
- # displayed name
- instance_name: "searxng"
- # For example: https://example.com/privacy
- privacypolicy_url: false
- # use true to use your own donation page written in searx/info/en/donate.md
- # use false to disable the donation link
- donation_url: false
- # mailto:contact@example.com
- contact_url: false
- # record stats
- enable_metrics: true
-
-brand:
- new_issue_url: https://github.com/searxng/searxng/issues/new
- docs_url: https://docs.searxng.org/
- public_instances: https://searx.space
- wiki_url: https://github.com/searxng/searxng/wiki
- issue_url: https://github.com/searxng/searxng/issues
- # custom:
- # maintainer: "Jon Doe"
- # # Custom entries in the footer: [title]: [link]
- # links:
- # Uptime: https://uptime.searxng.org/history/darmarit-org
- # About: "https://searxng.org"
-
-search:
- # Filter results. 0: None, 1: Moderate, 2: Strict
- safe_search: 0
- # Existing autocomplete backends: "dbpedia", "duckduckgo", "google", "yandex", "mwmbl",
- # "seznam", "startpage", "stract", "swisscows", "qwant", "wikipedia" - leave blank to turn it off
- # by default.
- autocomplete: ""
- # minimun characters to type before autocompleter starts
- autocomplete_min: 4
- # Default search language - leave blank to detect from browser information or
- # use codes from 'languages.py'
- default_lang: "auto"
- # max_page: 0 # if engine supports paging, 0 means unlimited numbers of pages
- # Available languages
- # languages:
- # - all
- # - en
- # - en-US
- # - de
- # - it-IT
- # - fr
- # - fr-BE
- # ban time in seconds after engine errors
- ban_time_on_fail: 5
- # max ban time in seconds after engine errors
- max_ban_time_on_fail: 120
- suspended_times:
- # Engine suspension time after error (in seconds; set to 0 to disable)
- # For error "Access denied" and "HTTP error [402, 403]"
- SearxEngineAccessDenied: 86400
- # For error "CAPTCHA"
- SearxEngineCaptcha: 86400
- # For error "Too many request" and "HTTP error 429"
- SearxEngineTooManyRequests: 3600
- # Cloudflare CAPTCHA
- cf_SearxEngineCaptcha: 1296000
- cf_SearxEngineAccessDenied: 86400
- # ReCAPTCHA
- recaptcha_SearxEngineCaptcha: 604800
-
- # remove format to deny access, use lower case.
- # formats: [html, csv, json, rss]
- formats:
- - html
- - json
-
-server:
- # Is overwritten by ${SEARXNG_PORT} and ${SEARXNG_BIND_ADDRESS}
- port: 8888
- bind_address: "127.0.0.1"
- # public URL of the instance, to ensure correct inbound links. Is overwritten
- # by ${SEARXNG_URL}.
- base_url: http://0.0.0.0:8081/ # "http://example.com/location"
- # rate limit the number of request on the instance, block some bots.
- # Is overwritten by ${SEARXNG_LIMITER}
- limiter: false
- # enable features designed only for public instances.
- # Is overwritten by ${SEARXNG_PUBLIC_INSTANCE}
- public_instance: false
-
- # If your instance owns a /etc/searxng/settings.yml file, then set the following
- # values there.
-
- secret_key: "772ba36386fb56d0f8fe818941552dabbe69220d4c0eb4a385a5729cdbc20c2d" # Is overwritten by ${SEARXNG_SECRET}
- # Proxy image results through SearXNG. Is overwritten by ${SEARXNG_IMAGE_PROXY}
- image_proxy: false
- # 1.0 and 1.1 are supported
- http_protocol_version: "1.0"
- # POST queries are more secure as they don't show up in history but may cause
- # problems when using Firefox containers
- method: "POST"
- default_http_headers:
- X-Content-Type-Options: nosniff
- X-Download-Options: noopen
- X-Robots-Tag: noindex, nofollow
- Referrer-Policy: no-referrer
-
-redis:
- # URL to connect redis database. Is overwritten by ${SEARXNG_REDIS_URL}.
- # https://docs.searxng.org/admin/settings/settings_redis.html#settings-redis
- url: false
-
-ui:
- # Custom static path - leave it blank if you didn't change
- static_path: ""
- # Is overwritten by ${SEARXNG_STATIC_USE_HASH}.
- static_use_hash: false
- # Custom templates path - leave it blank if you didn't change
- templates_path: ""
- # query_in_title: When true, the result page's titles contains the query
- # it decreases the privacy, since the browser can records the page titles.
- query_in_title: false
- # infinite_scroll: When true, automatically loads the next page when scrolling to bottom of the current page.
- infinite_scroll: false
- # ui theme
- default_theme: simple
- # center the results ?
- center_alignment: false
- # URL prefix of the internet archive, don't forget trailing slash (if needed).
- # cache_url: "https://webcache.googleusercontent.com/search?q=cache:"
- # Default interface locale - leave blank to detect from browser information or
- # use codes from the 'locales' config section
- default_locale: ""
- # Open result links in a new tab by default
- # results_on_new_tab: false
- theme_args:
- # style of simple theme: auto, light, dark
- simple_style: auto
- # Perform search immediately if a category selected.
- # Disable to select multiple categories at once and start the search manually.
- search_on_category_select: true
- # Hotkeys: default or vim
- hotkeys: default
-
-# Lock arbitrary settings on the preferences page. To find the ID of the user
-# setting you want to lock, check the ID of the form on the page "preferences".
-#
-# preferences:
-# lock:
-# - language
-# - autocomplete
-# - method
-# - query_in_title
-
-# searx supports result proxification using an external service:
-# https://github.com/asciimoo/morty uncomment below section if you have running
-# morty proxy the key is base64 encoded (keep the !!binary notation)
-# Note: since commit af77ec3, morty accepts a base64 encoded key.
-#
-# result_proxy:
-# url: http://127.0.0.1:3000/
-# # the key is a base64 encoded string, the YAML !!binary prefix is optional
-# key: !!binary "your_morty_proxy_key"
-# # [true|false] enable the "proxy" button next to each result
-# proxify_results: true
-
-# communication with search engines
-#
-outgoing:
- # default timeout in seconds, can be override by engine
- request_timeout: 3.0
- # the maximum timeout in seconds
- # max_request_timeout: 10.0
- # suffix of searx_useragent, could contain information like an email address
- # to the administrator
- useragent_suffix: ""
- # The maximum number of concurrent connections that may be established.
- pool_connections: 100
- # Allow the connection pool to maintain keep-alive connections below this
- # point.
- pool_maxsize: 20
- # See https://www.python-httpx.org/http2/
- enable_http2: true
- # uncomment below section if you want to use a custom server certificate
- # see https://www.python-httpx.org/advanced/#changing-the-verification-defaults
- # and https://www.python-httpx.org/compatibility/#ssl-configuration
- # verify: ~/.mitmproxy/mitmproxy-ca-cert.cer
- #
- # uncomment below section if you want to use a proxyq see: SOCKS proxies
- # https://2.python-requests.org/en/latest/user/advanced/#proxies
- # are also supported: see
- # https://2.python-requests.org/en/latest/user/advanced/#socks
- #
- # proxies:
- # all://:
- # - http://host.docker.internal:1080
- #
- # using_tor_proxy: true
- #
- # Extra seconds to add in order to account for the time taken by the proxy
- #
- # extra_proxy_timeout: 10
- #
- # uncomment below section only if you have more than one network interface
- # which can be the source of outgoing search requests
- #
- # source_ips:
- # - 1.1.1.1
- # - 1.1.1.2
- # - fe80::/126
-
-# External plugin configuration, for more details see
-# https://docs.searxng.org/dev/plugins.html
-#
-# plugins:
-# - plugin1
-# - plugin2
-# - ...
-
-# Comment or un-comment plugin to activate / deactivate by default.
-#
-# enabled_plugins:
-# # these plugins are enabled if nothing is configured ..
-# - 'Hash plugin'
-# - 'Self Information'
-# - 'Tracker URL remover'
-# - 'Ahmia blacklist' # activation depends on outgoing.using_tor_proxy
-# # these plugins are disabled if nothing is configured ..
-# - 'Hostnames plugin' # see 'hostnames' configuration below
-# - 'Basic Calculator'
-# - 'Open Access DOI rewrite'
-# - 'Tor check plugin'
-# # Read the docs before activate: auto-detection of the language could be
-# # detrimental to users expectations / users can activate the plugin in the
-# # preferences if they want.
-# - 'Autodetect search language'
-
-# Configuration of the "Hostnames plugin":
-#
-# hostnames:
-# replace:
-# '(.*\.)?youtube\.com$': 'invidious.example.com'
-# '(.*\.)?youtu\.be$': 'invidious.example.com'
-# '(.*\.)?reddit\.com$': 'teddit.example.com'
-# '(.*\.)?redd\.it$': 'teddit.example.com'
-# '(www\.)?twitter\.com$': 'nitter.example.com'
-# remove:
-# - '(.*\.)?facebook.com$'
-# low_priority:
-# - '(.*\.)?google(\..*)?$'
-# high_priority:
-# - '(.*\.)?wikipedia.org$'
-#
-# Alternatively you can use external files for configuring the "Hostnames plugin":
-#
-# hostnames:
-# replace: 'rewrite-hosts.yml'
-#
-# Content of 'rewrite-hosts.yml' (place the file in the same directory as 'settings.yml'):
-# '(.*\.)?youtube\.com$': 'invidious.example.com'
-# '(.*\.)?youtu\.be$': 'invidious.example.com'
-#
-
-checker:
- # disable checker when in debug mode
- off_when_debug: true
-
- # use "scheduling: false" to disable scheduling
- # scheduling: interval or int
-
- # to activate the scheduler:
- # * uncomment "scheduling" section
- # * add "cache2 = name=searxngcache,items=2000,blocks=2000,blocksize=4096,bitmap=1"
- # to your uwsgi.ini
-
- # scheduling:
- # start_after: [300, 1800] # delay to start the first run of the checker
- # every: [86400, 90000] # how often the checker runs
-
- # additional tests: only for the YAML anchors (see the engines section)
- #
- additional_tests:
- rosebud: &test_rosebud
- matrix:
- query: rosebud
- lang: en
- result_container:
- - not_empty
- - ['one_title_contains', 'citizen kane']
- test:
- - unique_results
-
- android: &test_android
- matrix:
- query: ['android']
- lang: ['en', 'de', 'fr', 'zh-CN']
- result_container:
- - not_empty
- - ['one_title_contains', 'google']
- test:
- - unique_results
-
- # tests: only for the YAML anchors (see the engines section)
- tests:
- infobox: &tests_infobox
- infobox:
- matrix:
- query: ["linux", "new york", "bbc"]
- result_container:
- - has_infobox
-
-categories_as_tabs:
- general:
- images:
- videos:
- news:
- map:
- music:
- it:
- science:
- files:
- social media:
-
-engines:
- - name: 9gag
- engine: 9gag
- shortcut: 9g
- disabled: true
-
- - name: alpine linux packages
- engine: alpinelinux
- disabled: true
- shortcut: alp
-
- - name: annas archive
- engine: annas_archive
- disabled: true
- shortcut: aa
-
- # - name: annas articles
- # engine: annas_archive
- # shortcut: aaa
- # # https://docs.searxng.org/dev/engines/online/annas_archive.html
- # aa_content: 'magazine' # book_fiction, book_unknown, book_nonfiction, book_comic
- # aa_ext: 'pdf' # pdf, epub, ..
- # aa_sort: oldest' # newest, oldest, largest, smallest
-
- - name: apk mirror
- engine: apkmirror
- timeout: 4.0
- shortcut: apkm
- disabled: true
-
- - name: apple app store
- engine: apple_app_store
- shortcut: aps
- disabled: true
-
- # Requires Tor
- - name: ahmia
- engine: ahmia
- categories: onions
- enable_http: true
- shortcut: ah
-
- - name: anaconda
- engine: xpath
- paging: true
- first_page_num: 0
- search_url: https://anaconda.org/search?q={query}&page={pageno}
- results_xpath: //tbody/tr
- url_xpath: ./td/h5/a[last()]/@href
- title_xpath: ./td/h5
- content_xpath: ./td[h5]/text()
- categories: it
- timeout: 6.0
- shortcut: conda
- disabled: true
-
- - name: arch linux wiki
- engine: archlinux
- shortcut: al
-
- - name: artic
- engine: artic
- shortcut: arc
- timeout: 4.0
-
- - name: arxiv
- engine: arxiv
- shortcut: arx
- timeout: 4.0
-
- - name: ask
- engine: ask
- shortcut: ask
- disabled: true
-
- # tmp suspended: dh key too small
- # - name: base
- # engine: base
- # shortcut: bs
-
- - name: bandcamp
- engine: bandcamp
- shortcut: bc
- categories: music
-
- - name: wikipedia
- engine: wikipedia
- shortcut: wp
- # add "list" to the array to get results in the results list
- display_type: ["infobox"]
- base_url: 'https://{language}.wikipedia.org/'
- categories: [general]
-
- - name: bilibili
- engine: bilibili
- shortcut: bil
- disabled: true
-
- - name: bing
- engine: bing
- shortcut: bi
- disabled: false
-
- - name: bing images
- engine: bing_images
- shortcut: bii
-
- - name: bing news
- engine: bing_news
- shortcut: bin
-
- - name: bing videos
- engine: bing_videos
- shortcut: biv
-
- - name: bitbucket
- engine: xpath
- paging: true
- search_url: https://bitbucket.org/repo/all/{pageno}?name={query}
- url_xpath: //article[@class="repo-summary"]//a[@class="repo-link"]/@href
- title_xpath: //article[@class="repo-summary"]//a[@class="repo-link"]
- content_xpath: //article[@class="repo-summary"]/p
- categories: [it, repos]
- timeout: 4.0
- disabled: true
- shortcut: bb
- about:
- website: https://bitbucket.org/
- wikidata_id: Q2493781
- official_api_documentation: https://developer.atlassian.com/bitbucket
- use_official_api: false
- require_api_key: false
- results: HTML
-
- - name: bpb
- engine: bpb
- shortcut: bpb
- disabled: true
-
- - name: btdigg
- engine: btdigg
- shortcut: bt
- disabled: true
-
- - name: openverse
- engine: openverse
- categories: images
- shortcut: opv
-
- - name: media.ccc.de
- engine: ccc_media
- shortcut: c3tv
- # We don't set language: de here because media.ccc.de is not just
- # for a German audience. It contains many English videos and many
- # German videos have English subtitles.
- disabled: true
-
- - name: chefkoch
- engine: chefkoch
- shortcut: chef
- # to show premium or plus results too:
- # skip_premium: false
-
- # - name: core.ac.uk
- # engine: core
- # categories: science
- # shortcut: cor
- # # get your API key from: https://core.ac.uk/api-keys/register/
- # api_key: 'unset'
-
- - name: cppreference
- engine: cppreference
- shortcut: cpp
- paging: false
- disabled: true
-
- - name: crossref
- engine: crossref
- shortcut: cr
- timeout: 30
- disabled: true
-
- - name: crowdview
- engine: json_engine
- shortcut: cv
- categories: general
- paging: false
- search_url: https://crowdview-next-js.onrender.com/api/search-v3?query={query}
- results_query: results
- url_query: link
- title_query: title
- content_query: snippet
- disabled: true
- about:
- website: https://crowdview.ai/
-
- - name: yep
- engine: yep
- shortcut: yep
- categories: general
- search_type: web
- timeout: 5
- disabled: true
-
- - name: yep images
- engine: yep
- shortcut: yepi
- categories: images
- search_type: images
- disabled: true
-
- - name: yep news
- engine: yep
- shortcut: yepn
- categories: news
- search_type: news
- disabled: true
-
- - name: curlie
- engine: xpath
- shortcut: cl
- categories: general
- disabled: true
- paging: true
- lang_all: ''
- search_url: https://curlie.org/search?q={query}&lang={lang}&start={pageno}&stime=92452189
- page_size: 20
- results_xpath: //div[@id="site-list-content"]/div[@class="site-item"]
- url_xpath: ./div[@class="title-and-desc"]/a/@href
- title_xpath: ./div[@class="title-and-desc"]/a/div
- content_xpath: ./div[@class="title-and-desc"]/div[@class="site-descr"]
- about:
- website: https://curlie.org/
- wikidata_id: Q60715723
- use_official_api: false
- require_api_key: false
- results: HTML
-
- - name: currency
- engine: currency_convert
- categories: general
- shortcut: cc
-
- - name: bahnhof
- engine: json_engine
- search_url: https://www.bahnhof.de/api/stations/search/{query}
- url_prefix: https://www.bahnhof.de/
- url_query: slug
- title_query: name
- content_query: state
- shortcut: bf
- disabled: true
- about:
- website: https://www.bahn.de
- wikidata_id: Q22811603
- use_official_api: false
- require_api_key: false
- results: JSON
- language: de
- tests:
- bahnhof:
- matrix:
- query: berlin
- lang: en
- result_container:
- - not_empty
- - ['one_title_contains', 'Berlin Hauptbahnhof']
- test:
- - unique_results
-
- - name: deezer
- engine: deezer
- shortcut: dz
- disabled: true
-
- - name: destatis
- engine: destatis
- shortcut: destat
- disabled: true
-
- - name: deviantart
- engine: deviantart
- shortcut: da
- timeout: 3.0
-
- - name: ddg definitions
- engine: duckduckgo_definitions
- shortcut: ddd
- weight: 2
- disabled: true
- tests: *tests_infobox
-
- # cloudflare protected
- # - name: digbt
- # engine: digbt
- # shortcut: dbt
- # timeout: 6.0
- # disabled: true
-
- - name: docker hub
- engine: docker_hub
- shortcut: dh
- categories: [it, packages]
-
- - name: encyclosearch
- engine: json_engine
- shortcut: es
- categories: general
- paging: true
- search_url: https://encyclosearch.org/encyclosphere/search?q={query}&page={pageno}&resultsPerPage=15
- results_query: Results
- url_query: SourceURL
- title_query: Title
- content_query: Description
- disabled: true
- about:
- website: https://encyclosearch.org
- official_api_documentation: https://encyclosearch.org/docs/#/rest-api
- use_official_api: true
- require_api_key: false
- results: JSON
-
- - name: erowid
- engine: xpath
- paging: true
- first_page_num: 0
- page_size: 30
- search_url: https://www.erowid.org/search.php?q={query}&s={pageno}
- url_xpath: //dl[@class="results-list"]/dt[@class="result-title"]/a/@href
- title_xpath: //dl[@class="results-list"]/dt[@class="result-title"]/a/text()
- content_xpath: //dl[@class="results-list"]/dd[@class="result-details"]
- categories: []
- shortcut: ew
- disabled: true
- about:
- website: https://www.erowid.org/
- wikidata_id: Q1430691
- official_api_documentation:
- use_official_api: false
- require_api_key: false
- results: HTML
-
- # - name: elasticsearch
- # shortcut: es
- # engine: elasticsearch
- # base_url: http://localhost:9200
- # username: elastic
- # password: changeme
- # index: my-index
- # # available options: match, simple_query_string, term, terms, custom
- # query_type: match
- # # if query_type is set to custom, provide your query here
- # #custom_query_json: {"query":{"match_all": {}}}
- # #show_metadata: false
- # disabled: true
-
- - name: wikidata
- engine: wikidata
- shortcut: wd
- timeout: 3.0
- weight: 2
- # add "list" to the array to get results in the results list
- display_type: ["infobox"]
- tests: *tests_infobox
- categories: [general]
-
- - name: duckduckgo
- engine: duckduckgo
- shortcut: ddg
-
- - name: duckduckgo images
- engine: duckduckgo_extra
- categories: [images, web]
- ddg_category: images
- shortcut: ddi
- disabled: true
-
- - name: duckduckgo videos
- engine: duckduckgo_extra
- categories: [videos, web]
- ddg_category: videos
- shortcut: ddv
- disabled: true
-
- - name: duckduckgo news
- engine: duckduckgo_extra
- categories: [news, web]
- ddg_category: news
- shortcut: ddn
- disabled: true
-
- - name: duckduckgo weather
- engine: duckduckgo_weather
- shortcut: ddw
- disabled: true
-
- - name: apple maps
- engine: apple_maps
- shortcut: apm
- disabled: true
- timeout: 5.0
-
- - name: emojipedia
- engine: emojipedia
- timeout: 4.0
- shortcut: em
- disabled: true
-
- - name: tineye
- engine: tineye
- shortcut: tin
- timeout: 9.0
- disabled: true
-
- - name: etymonline
- engine: xpath
- paging: true
- search_url: https://etymonline.com/search?page={pageno}&q={query}
- url_xpath: //a[contains(@class, "word__name--")]/@href
- title_xpath: //a[contains(@class, "word__name--")]
- content_xpath: //section[contains(@class, "word__defination")]
- first_page_num: 1
- shortcut: et
- categories: [dictionaries]
- about:
- website: https://www.etymonline.com/
- wikidata_id: Q1188617
- official_api_documentation:
- use_official_api: false
- require_api_key: false
- results: HTML
-
- # - name: ebay
- # engine: ebay
- # shortcut: eb
- # base_url: 'https://www.ebay.com'
- # disabled: true
- # timeout: 5
-
- - name: 1x
- engine: www1x
- shortcut: 1x
- timeout: 3.0
- disabled: true
-
- - name: fdroid
- engine: fdroid
- shortcut: fd
- disabled: true
-
- - name: findthatmeme
- engine: findthatmeme
- shortcut: ftm
- disabled: true
-
- - name: flickr
- categories: images
- shortcut: fl
- # You can use the engine using the official stable API, but you need an API
- # key, see: https://www.flickr.com/services/apps/create/
- # engine: flickr
- # api_key: 'apikey' # required!
- # Or you can use the html non-stable engine, activated by default
- engine: flickr_noapi
-
- - name: free software directory
- engine: mediawiki
- shortcut: fsd
- categories: [it, software wikis]
- base_url: https://directory.fsf.org/
- search_type: title
- timeout: 5.0
- disabled: true
- about:
- website: https://directory.fsf.org/
- wikidata_id: Q2470288
-
- # - name: freesound
- # engine: freesound
- # shortcut: fnd
- # disabled: true
- # timeout: 15.0
- # API key required, see: https://freesound.org/docs/api/overview.html
- # api_key: MyAPIkey
-
- - name: frinkiac
- engine: frinkiac
- shortcut: frk
- disabled: true
-
- - name: fyyd
- engine: fyyd
- shortcut: fy
- timeout: 8.0
- disabled: true
-
- - name: geizhals
- engine: geizhals
- shortcut: geiz
- disabled: true
-
- - name: genius
- engine: genius
- shortcut: gen
-
- - name: gentoo
- engine: mediawiki
- shortcut: ge
- categories: ["it", "software wikis"]
- base_url: "https://wiki.gentoo.org/"
- api_path: "api.php"
- search_type: text
- timeout: 10
-
- - name: gitlab
- engine: json_engine
- paging: true
- search_url: https://gitlab.com/api/v4/projects?search={query}&page={pageno}
- url_query: web_url
- title_query: name_with_namespace
- content_query: description
- page_size: 20
- categories: [it, repos]
- shortcut: gl
- timeout: 10.0
- disabled: true
- about:
- website: https://about.gitlab.com/
- wikidata_id: Q16639197
- official_api_documentation: https://docs.gitlab.com/ee/api/
- use_official_api: false
- require_api_key: false
- results: JSON
-
- - name: github
- engine: github
- shortcut: gh
-
- - name: codeberg
- # https://docs.searxng.org/dev/engines/online/gitea.html
- engine: gitea
- base_url: https://codeberg.org
- shortcut: cb
- disabled: true
-
- - name: gitea.com
- engine: gitea
- base_url: https://gitea.com
- shortcut: gitea
- disabled: true
-
- - name: goodreads
- engine: goodreads
- shortcut: good
- timeout: 4.0
- disabled: true
-
- - name: google
- engine: google
- shortcut: go
- # additional_tests:
- # android: *test_android
-
- - name: google images
- engine: google_images
- shortcut: goi
- # additional_tests:
- # android: *test_android
- # dali:
- # matrix:
- # query: ['Dali Christ']
- # lang: ['en', 'de', 'fr', 'zh-CN']
- # result_container:
- # - ['one_title_contains', 'Salvador']
-
- - name: google news
- engine: google_news
- shortcut: gon
- # additional_tests:
- # android: *test_android
-
- - name: google videos
- engine: google_videos
- shortcut: gov
- # additional_tests:
- # android: *test_android
-
- - name: google scholar
- engine: google_scholar
- shortcut: gos
-
- - name: google play apps
- engine: google_play
- categories: [files, apps]
- shortcut: gpa
- play_categ: apps
- disabled: true
-
- - name: google play movies
- engine: google_play
- categories: videos
- shortcut: gpm
- play_categ: movies
- disabled: true
-
- - name: material icons
- engine: material_icons
- categories: images
- shortcut: mi
- disabled: true
-
- - name: gpodder
- engine: json_engine
- shortcut: gpod
- timeout: 4.0
- paging: false
- search_url: https://gpodder.net/search.json?q={query}
- url_query: url
- title_query: title
- content_query: description
- page_size: 19
- categories: music
- disabled: true
- about:
- website: https://gpodder.net
- wikidata_id: Q3093354
- official_api_documentation: https://gpoddernet.readthedocs.io/en/latest/api/
- use_official_api: false
- requires_api_key: false
- results: JSON
-
- - name: habrahabr
- engine: xpath
- paging: true
- search_url: https://habr.com/en/search/page{pageno}/?q={query}
- results_xpath: //article[contains(@class, "tm-articles-list__item")]
- url_xpath: .//a[@class="tm-title__link"]/@href
- title_xpath: .//a[@class="tm-title__link"]
- content_xpath: .//div[contains(@class, "article-formatted-body")]
- categories: it
- timeout: 4.0
- disabled: true
- shortcut: habr
- about:
- website: https://habr.com/
- wikidata_id: Q4494434
- official_api_documentation: https://habr.com/en/docs/help/api/
- use_official_api: false
- require_api_key: false
- results: HTML
-
- - name: hackernews
- engine: hackernews
- shortcut: hn
- disabled: true
-
- - name: hex
- engine: hex
- shortcut: hex
- disabled: true
- # Valid values: name inserted_at updated_at total_downloads recent_downloads
- sort_criteria: "recent_downloads"
- page_size: 10
-
- - name: crates.io
- engine: crates
- shortcut: crates
- disabled: true
- timeout: 6.0
-
- - name: hoogle
- engine: xpath
- search_url: https://hoogle.haskell.org/?hoogle={query}
- results_xpath: '//div[@class="result"]'
- title_xpath: './/div[@class="ans"]//a'
- url_xpath: './/div[@class="ans"]//a/@href'
- content_xpath: './/div[@class="from"]'
- page_size: 20
- categories: [it, packages]
- shortcut: ho
- about:
- website: https://hoogle.haskell.org/
- wikidata_id: Q34010
- official_api_documentation: https://hackage.haskell.org/api
- use_official_api: false
- require_api_key: false
- results: JSON
-
- - name: imdb
- engine: imdb
- shortcut: imdb
- timeout: 6.0
- disabled: true
-
- - name: imgur
- engine: imgur
- shortcut: img
- disabled: true
-
- - name: ina
- engine: ina
- shortcut: in
- timeout: 6.0
- disabled: true
-
- - name: invidious
- engine: invidious
- # Instanes will be selected randomly, see https://api.invidious.io/ for
- # instances that are stable (good uptime) and close to you.
- base_url:
- - https://invidious.io.lol
- - https://invidious.fdn.fr
- - https://yt.artemislena.eu
- - https://invidious.tiekoetter.com
- - https://invidious.flokinet.to
- - https://vid.puffyan.us
- - https://invidious.privacydev.net
- - https://inv.tux.pizza
- shortcut: iv
- timeout: 3.0
- disabled: true
-
- - name: jisho
- engine: jisho
- shortcut: js
- timeout: 3.0
- disabled: true
-
- - name: kickass
- engine: kickass
- base_url:
- - https://kickasstorrents.to
- - https://kickasstorrents.cr
- - https://kickasstorrent.cr
- - https://kickass.sx
- - https://kat.am
- shortcut: kc
- timeout: 4.0
- disabled: true
-
- - name: lemmy communities
- engine: lemmy
- lemmy_type: Communities
- shortcut: leco
-
- - name: lemmy users
- engine: lemmy
- network: lemmy communities
- lemmy_type: Users
- shortcut: leus
-
- - name: lemmy posts
- engine: lemmy
- network: lemmy communities
- lemmy_type: Posts
- shortcut: lepo
-
- - name: lemmy comments
- engine: lemmy
- network: lemmy communities
- lemmy_type: Comments
- shortcut: lecom
-
- - name: library genesis
- engine: xpath
- # search_url: https://libgen.is/search.php?req={query}
- search_url: https://libgen.rs/search.php?req={query}
- url_xpath: //a[contains(@href,"book/index.php?md5")]/@href
- title_xpath: //a[contains(@href,"book/")]/text()[1]
- content_xpath: //td/a[1][contains(@href,"=author")]/text()
- categories: files
- timeout: 7.0
- disabled: true
- shortcut: lg
- about:
- website: https://libgen.fun/
- wikidata_id: Q22017206
- official_api_documentation:
- use_official_api: false
- require_api_key: false
- results: HTML
-
- - name: z-library
- engine: zlibrary
- shortcut: zlib
- categories: files
- timeout: 7.0
- disabled: true
-
- - name: library of congress
- engine: loc
- shortcut: loc
- categories: images
-
- - name: libretranslate
- engine: libretranslate
- # https://github.com/LibreTranslate/LibreTranslate?tab=readme-ov-file#mirrors
- base_url:
- - https://translate.terraprint.co
- - https://trans.zillyhuhn.com
- # api_key: abc123
- shortcut: lt
- disabled: true
-
- - name: lingva
- engine: lingva
- shortcut: lv
- # set lingva instance in url, by default it will use the official instance
- # url: https://lingva.thedaviddelta.com
-
- - name: lobste.rs
- engine: xpath
- search_url: https://lobste.rs/search?q={query}&what=stories&order=relevance
- results_xpath: //li[contains(@class, "story")]
- url_xpath: .//a[@class="u-url"]/@href
- title_xpath: .//a[@class="u-url"]
- content_xpath: .//a[@class="domain"]
- categories: it
- shortcut: lo
- timeout: 5.0
- disabled: true
- about:
- website: https://lobste.rs/
- wikidata_id: Q60762874
- official_api_documentation:
- use_official_api: false
- require_api_key: false
- results: HTML
-
- - name: mastodon users
- engine: mastodon
- mastodon_type: accounts
- base_url: https://mastodon.social
- shortcut: mau
-
- - name: mastodon hashtags
- engine: mastodon
- mastodon_type: hashtags
- base_url: https://mastodon.social
- shortcut: mah
-
- # - name: matrixrooms
- # engine: mrs
- # # https://docs.searxng.org/dev/engines/online/mrs.html
- # # base_url: https://mrs-api-host
- # shortcut: mtrx
- # disabled: true
-
- - name: mdn
- shortcut: mdn
- engine: json_engine
- categories: [it]
- paging: true
- search_url: https://developer.mozilla.org/api/v1/search?q={query}&page={pageno}
- results_query: documents
- url_query: mdn_url
- url_prefix: https://developer.mozilla.org
- title_query: title
- content_query: summary
- about:
- website: https://developer.mozilla.org
- wikidata_id: Q3273508
- official_api_documentation: null
- use_official_api: false
- require_api_key: false
- results: JSON
-
- - name: metacpan
- engine: metacpan
- shortcut: cpan
- disabled: true
- number_of_results: 20
-
- # - name: meilisearch
- # engine: meilisearch
- # shortcut: mes
- # enable_http: true
- # base_url: http://localhost:7700
- # index: my-index
-
- - name: mixcloud
- engine: mixcloud
- shortcut: mc
-
- # MongoDB engine
- # Required dependency: pymongo
- # - name: mymongo
- # engine: mongodb
- # shortcut: md
- # exact_match_only: false
- # host: '127.0.0.1'
- # port: 27017
- # enable_http: true
- # results_per_page: 20
- # database: 'business'
- # collection: 'reviews' # name of the db collection
- # key: 'name' # key in the collection to search for
-
- - name: mozhi
- engine: mozhi
- base_url:
- - https://mozhi.aryak.me
- - https://translate.bus-hit.me
- - https://nyc1.mz.ggtyler.dev
- # mozhi_engine: google - see https://mozhi.aryak.me for supported engines
- timeout: 4.0
- shortcut: mz
- disabled: true
-
- - name: mwmbl
- engine: mwmbl
- # api_url: https://api.mwmbl.org
- shortcut: mwm
- disabled: true
-
- - name: npm
- engine: npm
- shortcut: npm
- timeout: 5.0
- disabled: true
-
- - name: nyaa
- engine: nyaa
- shortcut: nt
- disabled: true
-
- - name: mankier
- engine: json_engine
- search_url: https://www.mankier.com/api/v2/mans/?q={query}
- results_query: results
- url_query: url
- title_query: name
- content_query: description
- categories: it
- shortcut: man
- about:
- website: https://www.mankier.com/
- official_api_documentation: https://www.mankier.com/api
- use_official_api: true
- require_api_key: false
- results: JSON
-
- # read https://docs.searxng.org/dev/engines/online/mullvad_leta.html
- # - name: mullvadleta
- # engine: mullvad_leta
- # leta_engine: google # choose one of the following: google, brave
- # use_cache: true # Only 100 non-cache searches per day, suggested only for private instances
- # search_url: https://leta.mullvad.net
- # categories: [general, web]
- # shortcut: ml
-
- - name: odysee
- engine: odysee
- shortcut: od
- disabled: true
-
- - name: openairedatasets
- engine: json_engine
- paging: true
- search_url: https://api.openaire.eu/search/datasets?format=json&page={pageno}&size=10&title={query}
- results_query: response/results/result
- url_query: metadata/oaf:entity/oaf:result/children/instance/webresource/url/$
- title_query: metadata/oaf:entity/oaf:result/title/$
- content_query: metadata/oaf:entity/oaf:result/description/$
- content_html_to_text: true
- categories: "science"
- shortcut: oad
- timeout: 5.0
- about:
- website: https://www.openaire.eu/
- wikidata_id: Q25106053
- official_api_documentation: https://api.openaire.eu/
- use_official_api: false
- require_api_key: false
- results: JSON
-
- - name: openairepublications
- engine: json_engine
- paging: true
- search_url: https://api.openaire.eu/search/publications?format=json&page={pageno}&size=10&title={query}
- results_query: response/results/result
- url_query: metadata/oaf:entity/oaf:result/children/instance/webresource/url/$
- title_query: metadata/oaf:entity/oaf:result/title/$
- content_query: metadata/oaf:entity/oaf:result/description/$
- content_html_to_text: true
- categories: science
- shortcut: oap
- timeout: 5.0
- about:
- website: https://www.openaire.eu/
- wikidata_id: Q25106053
- official_api_documentation: https://api.openaire.eu/
- use_official_api: false
- require_api_key: false
- results: JSON
-
- - name: openmeteo
- engine: open_meteo
- shortcut: om
- disabled: true
-
- # - name: opensemanticsearch
- # engine: opensemantic
- # shortcut: oss
- # base_url: 'http://localhost:8983/solr/opensemanticsearch/'
-
- - name: openstreetmap
- engine: openstreetmap
- shortcut: osm
-
- - name: openrepos
- engine: xpath
- paging: true
- search_url: https://openrepos.net/search/node/{query}?page={pageno}
- url_xpath: //li[@class="search-result"]//h3[@class="title"]/a/@href
- title_xpath: //li[@class="search-result"]//h3[@class="title"]/a
- content_xpath: //li[@class="search-result"]//div[@class="search-snippet-info"]//p[@class="search-snippet"]
- categories: files
- timeout: 4.0
- disabled: true
- shortcut: or
- about:
- website: https://openrepos.net/
- wikidata_id:
- official_api_documentation:
- use_official_api: false
- require_api_key: false
- results: HTML
-
- - name: packagist
- engine: json_engine
- paging: true
- search_url: https://packagist.org/search.json?q={query}&page={pageno}
- results_query: results
- url_query: url
- title_query: name
- content_query: description
- categories: [it, packages]
- disabled: true
- timeout: 5.0
- shortcut: pack
- about:
- website: https://packagist.org
- wikidata_id: Q108311377
- official_api_documentation: https://packagist.org/apidoc
- use_official_api: true
- require_api_key: false
- results: JSON
-
- - name: pdbe
- engine: pdbe
- shortcut: pdb
- # Hide obsolete PDB entries. Default is not to hide obsolete structures
- # hide_obsolete: false
-
- - name: photon
- engine: photon
- shortcut: ph
-
- - name: pinterest
- engine: pinterest
- shortcut: pin
-
- - name: piped
- engine: piped
- shortcut: ppd
- categories: videos
- piped_filter: videos
- timeout: 3.0
-
- # URL to use as link and for embeds
- frontend_url: https://srv.piped.video
- # Instance will be selected randomly, for more see https://piped-instances.kavin.rocks/
- backend_url:
- - https://pipedapi.kavin.rocks
- - https://pipedapi-libre.kavin.rocks
- - https://pipedapi.adminforge.de
-
- - name: piped.music
- engine: piped
- network: piped
- shortcut: ppdm
- categories: music
- piped_filter: music_songs
- timeout: 3.0
-
- - name: piratebay
- engine: piratebay
- shortcut: tpb
- # You may need to change this URL to a proxy if piratebay is blocked in your
- # country
- url: https://thepiratebay.org/
- timeout: 3.0
-
- - name: pixiv
- shortcut: pv
- engine: pixiv
- disabled: true
- inactive: true
- pixiv_image_proxies:
- - https://pximg.example.org
- # A proxy is required to load the images. Hosting an image proxy server
- # for Pixiv:
- # --> https://pixivfe.pages.dev/hosting-image-proxy-server/
- # Proxies from public instances. Ask the public instances owners if they
- # agree to receive traffic from SearXNG!
- # --> https://codeberg.org/VnPower/PixivFE#instances
- # --> https://github.com/searxng/searxng/pull/3192#issuecomment-1941095047
- # image proxy of https://pixiv.cat
- # - https://i.pixiv.cat
- # image proxy of https://www.pixiv.pics
- # - https://pximg.cocomi.eu.org
- # image proxy of https://pixivfe.exozy.me
- # - https://pximg.exozy.me
- # image proxy of https://pixivfe.ducks.party
- # - https://pixiv.ducks.party
- # image proxy of https://pixiv.perennialte.ch
- # - https://pximg.perennialte.ch
-
- - name: podcastindex
- engine: podcastindex
- shortcut: podcast
-
- # Required dependency: psychopg2
- # - name: postgresql
- # engine: postgresql
- # database: postgres
- # username: postgres
- # password: postgres
- # limit: 10
- # query_str: 'SELECT * from my_table WHERE my_column = %(query)s'
- # shortcut : psql
-
- - name: presearch
- engine: presearch
- search_type: search
- categories: [general, web]
- shortcut: ps
- timeout: 4.0
- disabled: true
-
- - name: presearch images
- engine: presearch
- network: presearch
- search_type: images
- categories: [images, web]
- timeout: 4.0
- shortcut: psimg
- disabled: true
-
- - name: presearch videos
- engine: presearch
- network: presearch
- search_type: videos
- categories: [general, web]
- timeout: 4.0
- shortcut: psvid
- disabled: true
-
- - name: presearch news
- engine: presearch
- network: presearch
- search_type: news
- categories: [news, web]
- timeout: 4.0
- shortcut: psnews
- disabled: true
-
- - name: pub.dev
- engine: xpath
- shortcut: pd
- search_url: https://pub.dev/packages?q={query}&page={pageno}
- paging: true
- results_xpath: //div[contains(@class,"packages-item")]
- url_xpath: ./div/h3/a/@href
- title_xpath: ./div/h3/a
- content_xpath: ./div/div/div[contains(@class,"packages-description")]/span
- categories: [packages, it]
- timeout: 3.0
- disabled: true
- first_page_num: 1
- about:
- website: https://pub.dev/
- official_api_documentation: https://pub.dev/help/api
- use_official_api: false
- require_api_key: false
- results: HTML
-
- - name: pubmed
- engine: pubmed
- shortcut: pub
- timeout: 3.0
-
- - name: pypi
- shortcut: pypi
- engine: pypi
-
- - name: qwant
- qwant_categ: web
- engine: qwant
- disabled: true
- shortcut: qw
- categories: [general, web]
- additional_tests:
- rosebud: *test_rosebud
-
- - name: qwant news
- qwant_categ: news
- engine: qwant
- shortcut: qwn
- categories: news
- network: qwant
-
- - name: qwant images
- qwant_categ: images
- engine: qwant
- shortcut: qwi
- categories: [images, web]
- network: qwant
-
- - name: qwant videos
- qwant_categ: videos
- engine: qwant
- shortcut: qwv
- categories: [videos, web]
- network: qwant
-
- # - name: library
- # engine: recoll
- # shortcut: lib
- # base_url: 'https://recoll.example.org/'
- # search_dir: ''
- # mount_prefix: /export
- # dl_prefix: 'https://download.example.org'
- # timeout: 30.0
- # categories: files
- # disabled: true
-
- # - name: recoll library reference
- # engine: recoll
- # base_url: 'https://recoll.example.org/'
- # search_dir: reference
- # mount_prefix: /export
- # dl_prefix: 'https://download.example.org'
- # shortcut: libr
- # timeout: 30.0
- # categories: files
- # disabled: true
-
- - name: radio browser
- engine: radio_browser
- shortcut: rb
-
- - name: reddit
- engine: reddit
- shortcut: re
- page_size: 25
- disabled: true
-
- - name: rottentomatoes
- engine: rottentomatoes
- shortcut: rt
- disabled: true
-
- # Required dependency: redis
- # - name: myredis
- # shortcut : rds
- # engine: redis_server
- # exact_match_only: false
- # host: '127.0.0.1'
- # port: 6379
- # enable_http: true
- # password: ''
- # db: 0
-
- # tmp suspended: bad certificate
- # - name: scanr structures
- # shortcut: scs
- # engine: scanr_structures
- # disabled: true
-
- - name: searchmysite
- engine: xpath
- shortcut: sms
- categories: general
- paging: true
- search_url: https://searchmysite.net/search/?q={query}&page={pageno}
- results_xpath: //div[contains(@class,'search-result')]
- url_xpath: .//a[contains(@class,'result-link')]/@href
- title_xpath: .//span[contains(@class,'result-title-txt')]/text()
- content_xpath: ./p[@id='result-hightlight']
- disabled: true
- about:
- website: https://searchmysite.net
-
- - name: sepiasearch
- engine: sepiasearch
- shortcut: sep
-
- - name: soundcloud
- engine: soundcloud
- shortcut: sc
-
- - name: stackoverflow
- engine: stackexchange
- shortcut: st
- api_site: 'stackoverflow'
- categories: [it, q&a]
-
- - name: askubuntu
- engine: stackexchange
- shortcut: ubuntu
- api_site: 'askubuntu'
- categories: [it, q&a]
-
- - name: internetarchivescholar
- engine: internet_archive_scholar
- shortcut: ias
- timeout: 15.0
-
- - name: superuser
- engine: stackexchange
- shortcut: su
- api_site: 'superuser'
- categories: [it, q&a]
-
- - name: discuss.python
- engine: discourse
- shortcut: dpy
- base_url: 'https://discuss.python.org'
- categories: [it, q&a]
- disabled: true
-
- - name: caddy.community
- engine: discourse
- shortcut: caddy
- base_url: 'https://caddy.community'
- categories: [it, q&a]
- disabled: true
-
- - name: pi-hole.community
- engine: discourse
- shortcut: pi
- categories: [it, q&a]
- base_url: 'https://discourse.pi-hole.net'
- disabled: true
-
- - name: searchcode code
- engine: searchcode_code
- shortcut: scc
- disabled: true
-
- # - name: searx
- # engine: searx_engine
- # shortcut: se
- # instance_urls :
- # - http://127.0.0.1:8888/
- # - ...
- # disabled: true
-
- - name: semantic scholar
- engine: semantic_scholar
- disabled: true
- shortcut: se
-
- # Spotify needs API credentials
- # - name: spotify
- # engine: spotify
- # shortcut: stf
- # api_client_id: *******
- # api_client_secret: *******
-
- # - name: solr
- # engine: solr
- # shortcut: slr
- # base_url: http://localhost:8983
- # collection: collection_name
- # sort: '' # sorting: asc or desc
- # field_list: '' # comma separated list of field names to display on the UI
- # default_fields: '' # default field to query
- # query_fields: '' # query fields
- # enable_http: true
-
- # - name: springer nature
- # engine: springer
- # # get your API key from: https://dev.springernature.com/signup
- # # working API key, for test & debug: "a69685087d07eca9f13db62f65b8f601"
- # api_key: 'unset'
- # shortcut: springer
- # timeout: 15.0
-
- - name: startpage
- engine: startpage
- shortcut: sp
- timeout: 6.0
- disabled: true
- additional_tests:
- rosebud: *test_rosebud
-
- - name: tokyotoshokan
- engine: tokyotoshokan
- shortcut: tt
- timeout: 6.0
- disabled: true
-
- - name: solidtorrents
- engine: solidtorrents
- shortcut: solid
- timeout: 4.0
- base_url:
- - https://solidtorrents.to
- - https://bitsearch.to
-
- # For this demo of the sqlite engine download:
- # https://liste.mediathekview.de/filmliste-v2.db.bz2
- # and unpack into searx/data/filmliste-v2.db
- # Query to test: "!demo concert"
- #
- # - name: demo
- # engine: sqlite
- # shortcut: demo
- # categories: general
- # result_template: default.html
- # database: searx/data/filmliste-v2.db
- # query_str: >-
- # SELECT title || ' (' || time(duration, 'unixepoch') || ')' AS title,
- # COALESCE( NULLIF(url_video_hd,''), NULLIF(url_video_sd,''), url_video) AS url,
- # description AS content
- # FROM film
- # WHERE title LIKE :wildcard OR description LIKE :wildcard
- # ORDER BY duration DESC
-
- - name: tagesschau
- engine: tagesschau
- # when set to false, display URLs from Tagesschau, and not the actual source
- # (e.g. NDR, WDR, SWR, HR, ...)
- use_source_url: true
- shortcut: ts
- disabled: true
-
- - name: tmdb
- engine: xpath
- paging: true
- categories: movies
- search_url: https://www.themoviedb.org/search?page={pageno}&query={query}
- results_xpath: //div[contains(@class,"movie") or contains(@class,"tv")]//div[contains(@class,"card")]
- url_xpath: .//div[contains(@class,"poster")]/a/@href
- thumbnail_xpath: .//img/@src
- title_xpath: .//div[contains(@class,"title")]//h2
- content_xpath: .//div[contains(@class,"overview")]
- shortcut: tm
- disabled: true
-
- # Requires Tor
- - name: torch
- engine: xpath
- paging: true
- search_url:
- http://xmh57jrknzkhv6y3ls3ubitzfqnkrwxhopf5aygthi7d6rplyvk3noyd.onion/cgi-bin/omega/omega?P={query}&DEFAULTOP=and
- results_xpath: //table//tr
- url_xpath: ./td[2]/a
- title_xpath: ./td[2]/b
- content_xpath: ./td[2]/small
- categories: onions
- enable_http: true
- shortcut: tch
-
- # torznab engine lets you query any torznab compatible indexer. Using this
- # engine in combination with Jackett opens the possibility to query a lot of
- # public and private indexers directly from SearXNG. More details at:
- # https://docs.searxng.org/dev/engines/online/torznab.html
- #
- # - name: Torznab EZTV
- # engine: torznab
- # shortcut: eztv
- # base_url: http://localhost:9117/api/v2.0/indexers/eztv/results/torznab
- # enable_http: true # if using localhost
- # api_key: xxxxxxxxxxxxxxx
- # show_magnet_links: true
- # show_torrent_files: false
- # # https://github.com/Jackett/Jackett/wiki/Jackett-Categories
- # torznab_categories: # optional
- # - 2000
- # - 5000
-
- # tmp suspended - too slow, too many errors
- # - name: urbandictionary
- # engine : xpath
- # search_url : https://www.urbandictionary.com/define.php?term={query}
- # url_xpath : //*[@class="word"]/@href
- # title_xpath : //*[@class="def-header"]
- # content_xpath: //*[@class="meaning"]
- # shortcut: ud
-
- - name: unsplash
- engine: unsplash
- shortcut: us
-
- - name: yandex music
- engine: yandex_music
- shortcut: ydm
- disabled: true
- # https://yandex.com/support/music/access.html
- inactive: true
-
- - name: yahoo
- engine: yahoo
- shortcut: yh
- disabled: true
-
- - name: yahoo news
- engine: yahoo_news
- shortcut: yhn
-
- - name: youtube
- shortcut: yt
- # You can use the engine using the official stable API, but you need an API
- # key See: https://console.developers.google.com/project
- #
- # engine: youtube_api
- # api_key: 'apikey' # required!
- #
- # Or you can use the html non-stable engine, activated by default
- engine: youtube_noapi
-
- - name: dailymotion
- engine: dailymotion
- shortcut: dm
-
- - name: vimeo
- engine: vimeo
- shortcut: vm
- disabled: true
-
- - name: wiby
- engine: json_engine
- paging: true
- search_url: https://wiby.me/json/?q={query}&p={pageno}
- url_query: URL
- title_query: Title
- content_query: Snippet
- categories: [general, web]
- shortcut: wib
- disabled: true
- about:
- website: https://wiby.me/
-
- - name: alexandria
- engine: json_engine
- shortcut: alx
- categories: general
- paging: true
- search_url: https://api.alexandria.org/?a=1&q={query}&p={pageno}
- results_query: results
- title_query: title
- url_query: url
- content_query: snippet
- timeout: 1.5
- disabled: true
- about:
- website: https://alexandria.org/
- official_api_documentation: https://github.com/alexandria-org/alexandria-api/raw/master/README.md
- use_official_api: true
- require_api_key: false
- results: JSON
-
- - name: wikibooks
- engine: mediawiki
- weight: 0.5
- shortcut: wb
- categories: [general, wikimedia]
- base_url: "https://{language}.wikibooks.org/"
- search_type: text
- disabled: true
- about:
- website: https://www.wikibooks.org/
- wikidata_id: Q367
-
- - name: wikinews
- engine: mediawiki
- shortcut: wn
- categories: [news, wikimedia]
- base_url: "https://{language}.wikinews.org/"
- search_type: text
- srsort: create_timestamp_desc
- about:
- website: https://www.wikinews.org/
- wikidata_id: Q964
-
- - name: wikiquote
- engine: mediawiki
- weight: 0.5
- shortcut: wq
- categories: [general, wikimedia]
- base_url: "https://{language}.wikiquote.org/"
- search_type: text
- disabled: true
- additional_tests:
- rosebud: *test_rosebud
- about:
- website: https://www.wikiquote.org/
- wikidata_id: Q369
-
- - name: wikisource
- engine: mediawiki
- weight: 0.5
- shortcut: ws
- categories: [general, wikimedia]
- base_url: "https://{language}.wikisource.org/"
- search_type: text
- disabled: true
- about:
- website: https://www.wikisource.org/
- wikidata_id: Q263
-
- - name: wikispecies
- engine: mediawiki
- shortcut: wsp
- categories: [general, science, wikimedia]
- base_url: "https://species.wikimedia.org/"
- search_type: text
- disabled: true
- about:
- website: https://species.wikimedia.org/
- wikidata_id: Q13679
- tests:
- wikispecies:
- matrix:
- query: "Campbell, L.I. et al. 2011: MicroRNAs"
- lang: en
- result_container:
- - not_empty
- - ['one_title_contains', 'Tardigrada']
- test:
- - unique_results
-
- - name: wiktionary
- engine: mediawiki
- shortcut: wt
- categories: [dictionaries, wikimedia]
- base_url: "https://{language}.wiktionary.org/"
- search_type: text
- about:
- website: https://www.wiktionary.org/
- wikidata_id: Q151
-
- - name: wikiversity
- engine: mediawiki
- weight: 0.5
- shortcut: wv
- categories: [general, wikimedia]
- base_url: "https://{language}.wikiversity.org/"
- search_type: text
- disabled: true
- about:
- website: https://www.wikiversity.org/
- wikidata_id: Q370
-
- - name: wikivoyage
- engine: mediawiki
- weight: 0.5
- shortcut: wy
- categories: [general, wikimedia]
- base_url: "https://{language}.wikivoyage.org/"
- search_type: text
- disabled: true
- about:
- website: https://www.wikivoyage.org/
- wikidata_id: Q373
-
- - name: wikicommons.images
- engine: wikicommons
- shortcut: wc
- categories: images
- search_type: images
- number_of_results: 10
-
- - name: wikicommons.videos
- engine: wikicommons
- shortcut: wcv
- categories: videos
- search_type: videos
- number_of_results: 10
-
- - name: wikicommons.audio
- engine: wikicommons
- shortcut: wca
- categories: music
- search_type: audio
- number_of_results: 10
-
- - name: wikicommons.files
- engine: wikicommons
- shortcut: wcf
- categories: files
- search_type: files
- number_of_results: 10
-
- - name: wolframalpha
- shortcut: wa
- # You can use the engine using the official stable API, but you need an API
- # key. See: https://products.wolframalpha.com/api/
- #
- # engine: wolframalpha_api
- # api_key: ''
- #
- # Or you can use the html non-stable engine, activated by default
- engine: wolframalpha_noapi
- timeout: 6.0
- categories: general
- disabled: true
-
- - name: dictzone
- engine: dictzone
- shortcut: dc
-
- - name: mymemory translated
- engine: translated
- shortcut: tl
- timeout: 5.0
- # You can use without an API key, but you are limited to 1000 words/day
- # See: https://mymemory.translated.net/doc/usagelimits.php
- # api_key: ''
-
- # Required dependency: mysql-connector-python
- # - name: mysql
- # engine: mysql_server
- # database: mydatabase
- # username: user
- # password: pass
- # limit: 10
- # query_str: 'SELECT * from mytable WHERE fieldname=%(query)s'
- # shortcut: mysql
-
- - name: 1337x
- engine: 1337x
- shortcut: 1337x
- disabled: true
-
- - name: duden
- engine: duden
- shortcut: du
- disabled: true
-
- - name: seznam
- shortcut: szn
- engine: seznam
- disabled: true
-
- # - name: deepl
- # engine: deepl
- # shortcut: dpl
- # # You can use the engine using the official stable API, but you need an API key
- # # See: https://www.deepl.com/pro-api?cta=header-pro-api
- # api_key: '' # required!
- # timeout: 5.0
- # disabled: true
-
- - name: mojeek
- shortcut: mjk
- engine: mojeek
- categories: [general, web]
- disabled: true
-
- - name: mojeek images
- shortcut: mjkimg
- engine: mojeek
- categories: [images, web]
- search_type: images
- paging: false
- disabled: true
-
- - name: mojeek news
- shortcut: mjknews
- engine: mojeek
- categories: [news, web]
- search_type: news
- paging: false
- disabled: true
-
- - name: moviepilot
- engine: moviepilot
- shortcut: mp
- disabled: true
-
- - name: naver
- shortcut: nvr
- categories: [general, web]
- engine: xpath
- paging: true
- search_url: https://search.naver.com/search.naver?where=webkr&sm=osp_hty&ie=UTF-8&query={query}&start={pageno}
- url_xpath: //a[@class="link_tit"]/@href
- title_xpath: //a[@class="link_tit"]
- content_xpath: //div[@class="total_dsc_wrap"]/a
- first_page_num: 1
- page_size: 10
- disabled: true
- about:
- website: https://www.naver.com/
- wikidata_id: Q485639
- official_api_documentation: https://developers.naver.com/docs/nmt/examples/
- use_official_api: false
- require_api_key: false
- results: HTML
- language: ko
-
- - name: rubygems
- shortcut: rbg
- engine: xpath
- paging: true
- search_url: https://rubygems.org/search?page={pageno}&query={query}
- results_xpath: /html/body/main/div/a[@class="gems__gem"]
- url_xpath: ./@href
- title_xpath: ./span/h2
- content_xpath: ./span/p
- suggestion_xpath: /html/body/main/div/div[@class="search__suggestions"]/p/a
- first_page_num: 1
- categories: [it, packages]
- disabled: true
- about:
- website: https://rubygems.org/
- wikidata_id: Q1853420
- official_api_documentation: https://guides.rubygems.org/rubygems-org-api/
- use_official_api: false
- require_api_key: false
- results: HTML
-
- - name: peertube
- engine: peertube
- shortcut: ptb
- paging: true
- # alternatives see: https://instances.joinpeertube.org/instances
- # base_url: https://tube.4aem.com
- categories: videos
- disabled: true
- timeout: 6.0
-
- - name: mediathekviewweb
- engine: mediathekviewweb
- shortcut: mvw
- disabled: true
-
- - name: yacy
- # https://docs.searxng.org/dev/engines/online/yacy.html
- engine: yacy
- categories: general
- search_type: text
- base_url:
- - https://yacy.searchlab.eu
- # see https://github.com/searxng/searxng/pull/3631#issuecomment-2240903027
- # - https://search.kyun.li
- # - https://yacy.securecomcorp.eu
- # - https://yacy.myserv.ca
- # - https://yacy.nsupdate.info
- # - https://yacy.electroncash.de
- shortcut: ya
- disabled: true
- # if you aren't using HTTPS for your local yacy instance disable https
- # enable_http: false
- search_mode: 'global'
- # timeout can be reduced in 'local' search mode
- timeout: 5.0
-
- - name: yacy images
- engine: yacy
- network: yacy
- categories: images
- search_type: image
- shortcut: yai
- disabled: true
- # timeout can be reduced in 'local' search mode
- timeout: 5.0
-
- - name: rumble
- engine: rumble
- shortcut: ru
- base_url: https://rumble.com/
- paging: true
- categories: videos
- disabled: true
-
- - name: livespace
- engine: livespace
- shortcut: ls
- categories: videos
- disabled: true
- timeout: 5.0
-
- - name: wordnik
- engine: wordnik
- shortcut: def
- base_url: https://www.wordnik.com/
- categories: [dictionaries]
- timeout: 5.0
-
- - name: woxikon.de synonyme
- engine: xpath
- shortcut: woxi
- categories: [dictionaries]
- timeout: 5.0
- disabled: true
- search_url: https://synonyme.woxikon.de/synonyme/{query}.php
- url_xpath: //div[@class="upper-synonyms"]/a/@href
- content_xpath: //div[@class="synonyms-list-group"]
- title_xpath: //div[@class="upper-synonyms"]/a
- no_result_for_http_status: [404]
- about:
- website: https://www.woxikon.de/
- wikidata_id: # No Wikidata ID
- use_official_api: false
- require_api_key: false
- results: HTML
- language: de
-
- - name: seekr news
- engine: seekr
- shortcut: senews
- categories: news
- seekr_category: news
- disabled: true
-
- - name: seekr images
- engine: seekr
- network: seekr news
- shortcut: seimg
- categories: images
- seekr_category: images
- disabled: true
-
- - name: seekr videos
- engine: seekr
- network: seekr news
- shortcut: sevid
- categories: videos
- seekr_category: videos
- disabled: true
-
- - name: sjp.pwn
- engine: sjp
- shortcut: sjp
- base_url: https://sjp.pwn.pl/
- timeout: 5.0
- disabled: true
-
- - name: stract
- engine: stract
- shortcut: str
- disabled: true
-
- - name: svgrepo
- engine: svgrepo
- shortcut: svg
- timeout: 10.0
- disabled: true
-
- - name: tootfinder
- engine: tootfinder
- shortcut: toot
-
- - name: voidlinux
- engine: voidlinux
- shortcut: void
- disabled: true
-
- - name: wallhaven
- engine: wallhaven
- # api_key: abcdefghijklmnopqrstuvwxyz
- shortcut: wh
-
- # wikimini: online encyclopedia for children
- # The fulltext and title parameter is necessary for Wikimini because
- # sometimes it will not show the results and redirect instead
- - name: wikimini
- engine: xpath
- shortcut: wkmn
- search_url: https://fr.wikimini.org/w/index.php?search={query}&title=Sp%C3%A9cial%3ASearch&fulltext=Search
- url_xpath: //li/div[@class="mw-search-result-heading"]/a/@href
- title_xpath: //li//div[@class="mw-search-result-heading"]/a
- content_xpath: //li/div[@class="searchresult"]
- categories: general
- disabled: true
- about:
- website: https://wikimini.org/
- wikidata_id: Q3568032
- use_official_api: false
- require_api_key: false
- results: HTML
- language: fr
-
- - name: wttr.in
- engine: wttr
- shortcut: wttr
- timeout: 9.0
-
- - name: yummly
- engine: yummly
- shortcut: yum
- disabled: true
-
- - name: brave
- engine: brave
- shortcut: br
- time_range_support: true
- paging: true
- categories: [general, web]
- brave_category: search
- # brave_spellcheck: true
-
- - name: brave.images
- engine: brave
- network: brave
- shortcut: brimg
- categories: [images, web]
- brave_category: images
-
- - name: brave.videos
- engine: brave
- network: brave
- shortcut: brvid
- categories: [videos, web]
- brave_category: videos
-
- - name: brave.news
- engine: brave
- network: brave
- shortcut: brnews
- categories: news
- brave_category: news
-
- # - name: brave.goggles
- # engine: brave
- # network: brave
- # shortcut: brgog
- # time_range_support: true
- # paging: true
- # categories: [general, web]
- # brave_category: goggles
- # Goggles: # required! This should be a URL ending in .goggle
-
- - name: lib.rs
- shortcut: lrs
- engine: lib_rs
- disabled: true
-
- - name: sourcehut
- shortcut: srht
- engine: xpath
- paging: true
- search_url: https://sr.ht/projects?page={pageno}&search={query}
- results_xpath: (//div[@class="event-list"])[1]/div[@class="event"]
- url_xpath: ./h4/a[2]/@href
- title_xpath: ./h4/a[2]
- content_xpath: ./p
- first_page_num: 1
- categories: [it, repos]
- disabled: true
- about:
- website: https://sr.ht
- wikidata_id: Q78514485
- official_api_documentation: https://man.sr.ht/
- use_official_api: false
- require_api_key: false
- results: HTML
-
- - name: goo
- shortcut: goo
- engine: xpath
- paging: true
- search_url: https://search.goo.ne.jp/web.jsp?MT={query}&FR={pageno}0
- url_xpath: //div[@class="result"]/p[@class='title fsL1']/a/@href
- title_xpath: //div[@class="result"]/p[@class='title fsL1']/a
- content_xpath: //p[contains(@class,'url fsM')]/following-sibling::p
- first_page_num: 0
- categories: [general, web]
- disabled: true
- timeout: 4.0
- about:
- website: https://search.goo.ne.jp
- wikidata_id: Q249044
- use_official_api: false
- require_api_key: false
- results: HTML
- language: ja
-
- - name: bt4g
- engine: bt4g
- shortcut: bt4g
-
- - name: pkg.go.dev
- engine: pkg_go_dev
- shortcut: pgo
- disabled: true
-
-# Doku engine lets you access to any Doku wiki instance:
-# A public one or a privete/corporate one.
-# - name: ubuntuwiki
-# engine: doku
-# shortcut: uw
-# base_url: 'https://doc.ubuntu-fr.org'
-
-# Be careful when enabling this engine if you are
-# running a public instance. Do not expose any sensitive
-# information. You can restrict access by configuring a list
-# of access tokens under tokens.
-# - name: git grep
-# engine: command
-# command: ['git', 'grep', '{{QUERY}}']
-# shortcut: gg
-# tokens: []
-# disabled: true
-# delimiter:
-# chars: ':'
-# keys: ['filepath', 'code']
-
-# Be careful when enabling this engine if you are
-# running a public instance. Do not expose any sensitive
-# information. You can restrict access by configuring a list
-# of access tokens under tokens.
-# - name: locate
-# engine: command
-# command: ['locate', '{{QUERY}}']
-# shortcut: loc
-# tokens: []
-# disabled: true
-# delimiter:
-# chars: ' '
-# keys: ['line']
-
-# Be careful when enabling this engine if you are
-# running a public instance. Do not expose any sensitive
-# information. You can restrict access by configuring a list
-# of access tokens under tokens.
-# - name: find
-# engine: command
-# command: ['find', '.', '-name', '{{QUERY}}']
-# query_type: path
-# shortcut: fnd
-# tokens: []
-# disabled: true
-# delimiter:
-# chars: ' '
-# keys: ['line']
-
-# Be careful when enabling this engine if you are
-# running a public instance. Do not expose any sensitive
-# information. You can restrict access by configuring a list
-# of access tokens under tokens.
-# - name: pattern search in files
-# engine: command
-# command: ['fgrep', '{{QUERY}}']
-# shortcut: fgr
-# tokens: []
-# disabled: true
-# delimiter:
-# chars: ' '
-# keys: ['line']
-
-# Be careful when enabling this engine if you are
-# running a public instance. Do not expose any sensitive
-# information. You can restrict access by configuring a list
-# of access tokens under tokens.
-# - name: regex search in files
-# engine: command
-# command: ['grep', '{{QUERY}}']
-# shortcut: gr
-# tokens: []
-# disabled: true
-# delimiter:
-# chars: ' '
-# keys: ['line']
-
-doi_resolvers:
- oadoi.org: 'https://oadoi.org/'
- doi.org: 'https://doi.org/'
- doai.io: 'https://dissem.in/'
- sci-hub.se: 'https://sci-hub.se/'
- sci-hub.st: 'https://sci-hub.st/'
- sci-hub.ru: 'https://sci-hub.ru/'
-
-default_doi_resolver: 'oadoi.org'
diff --git a/api/core/tools/provider/builtin/searxng/docker/uwsgi.ini b/api/core/tools/provider/builtin/searxng/docker/uwsgi.ini
deleted file mode 100644
index 9db3d76264..0000000000
--- a/api/core/tools/provider/builtin/searxng/docker/uwsgi.ini
+++ /dev/null
@@ -1,54 +0,0 @@
-[uwsgi]
-# Who will run the code
-uid = searxng
-gid = searxng
-
-# Number of workers (usually CPU count)
-# default value: %k (= number of CPU core, see Dockerfile)
-workers = %k
-
-# Number of threads per worker
-# default value: 4 (see Dockerfile)
-threads = 4
-
-# The right granted on the created socket
-chmod-socket = 666
-
-# Plugin to use and interpreter config
-single-interpreter = true
-master = true
-plugin = python3
-lazy-apps = true
-enable-threads = 4
-
-# Module to import
-module = searx.webapp
-
-# Virtualenv and python path
-pythonpath = /usr/local/searxng/
-chdir = /usr/local/searxng/searx/
-
-# automatically set processes name to something meaningful
-auto-procname = true
-
-# Disable request logging for privacy
-disable-logging = true
-log-5xx = true
-
-# Set the max size of a request (request-body excluded)
-buffer-size = 8192
-
-# No keep alive
-# See https://github.com/searx/searx-docker/issues/24
-add-header = Connection: close
-
-# Follow SIGTERM convention
-# See https://github.com/searxng/searxng/issues/3427
-die-on-term
-
-# uwsgi serves the static files
-static-map = /static=/usr/local/searxng/searx/static
-# expires set to one day
-static-expires = /* 86400
-static-gzip-all = True
-offload-threads = 4
diff --git a/api/core/tools/provider/builtin/searxng/searxng.py b/api/core/tools/provider/builtin/searxng/searxng.py
deleted file mode 100644
index b7bbcc60b1..0000000000
--- a/api/core/tools/provider/builtin/searxng/searxng.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.searxng.tools.searxng_search import SearXNGSearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class SearXNGProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- SearXNGSearchTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={"query": "SearXNG", "limit": 1, "search_type": "general"},
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/searxng/searxng.yaml b/api/core/tools/provider/builtin/searxng/searxng.yaml
deleted file mode 100644
index 9554c93d5a..0000000000
--- a/api/core/tools/provider/builtin/searxng/searxng.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-identity:
- author: Junytang
- name: searxng
- label:
- en_US: SearXNG
- zh_Hans: SearXNG
- description:
- en_US: A free internet metasearch engine.
- zh_Hans: 开源免费的互联网元搜索引擎
- icon: icon.svg
- tags:
- - search
- - productivity
-credentials_for_provider:
- searxng_base_url:
- type: text-input
- required: true
- label:
- en_US: SearXNG base URL
- zh_Hans: SearXNG base URL
- placeholder:
- en_US: Please input your SearXNG base URL
- zh_Hans: 请输入您的 SearXNG base URL
- url: https://docs.dify.ai/tutorials/tool-configuration/searxng
diff --git a/api/core/tools/provider/builtin/searxng/tools/searxng_search.py b/api/core/tools/provider/builtin/searxng/tools/searxng_search.py
deleted file mode 100644
index c5e339a108..0000000000
--- a/api/core/tools/provider/builtin/searxng/tools/searxng_search.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from typing import Any
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class SearXNGSearchTool(BuiltinTool):
- """
- Tool for performing a search using SearXNG engine.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage | list[ToolInvokeMessage]:
- """
- Invoke the SearXNG search tool.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Any]): The parameters for the tool invocation.
-
- Returns:
- ToolInvokeMessage | list[ToolInvokeMessage]: The result of the tool invocation.
- """
-
- host = self.runtime.credentials.get("searxng_base_url")
- if not host:
- raise Exception("SearXNG api is required")
-
- response = requests.get(
- host,
- params={
- "q": tool_parameters.get("query"),
- "format": "json",
- "categories": tool_parameters.get("search_type", "general"),
- },
- )
-
- if response.status_code != 200:
- raise Exception(f"Error {response.status_code}: {response.text}")
-
- res = response.json().get("results", [])
- if not res:
- return self.create_text_message(f"No results found, get response: {response.content}")
-
- return [self.create_json_message(item) for item in res]
diff --git a/api/core/tools/provider/builtin/searxng/tools/searxng_search.yaml b/api/core/tools/provider/builtin/searxng/tools/searxng_search.yaml
deleted file mode 100644
index a5e448a303..0000000000
--- a/api/core/tools/provider/builtin/searxng/tools/searxng_search.yaml
+++ /dev/null
@@ -1,69 +0,0 @@
-identity:
- name: searxng_search
- author: Junytang
- label:
- en_US: SearXNG Search
- zh_Hans: SearXNG 搜索
-description:
- human:
- en_US: SearXNG is a free internet metasearch engine which aggregates results from more than 70 search services.
- zh_Hans: SearXNG 是一个免费的互联网元搜索引擎,它从70多个不同的搜索服务中聚合搜索结果。
- llm: Perform searches on SearXNG and get results.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query string
- zh_Hans: 查询语句
- llm_description: Key words for searching
- form: llm
- - name: search_type
- type: select
- required: true
- label:
- en_US: search type
- zh_Hans: 搜索类型
- default: general
- options:
- - value: general
- label:
- en_US: General
- zh_Hans: 综合
- - value: images
- label:
- en_US: Images
- zh_Hans: 图片
- - value: videos
- label:
- en_US: Videos
- zh_Hans: 视频
- - value: news
- label:
- en_US: News
- zh_Hans: 新闻
- - value: map
- label:
- en_US: Map
- zh_Hans: 地图
- - value: music
- label:
- en_US: Music
- zh_Hans: 音乐
- - value: it
- label:
- en_US: It
- zh_Hans: 信息技术
- - value: science
- label:
- en_US: Science
- zh_Hans: 科学
- - value: files
- label:
- en_US: Files
- zh_Hans: 文件
- - value: social_media
- label:
- en_US: Social Media
- zh_Hans: 社交媒体
- form: form
diff --git a/api/core/tools/provider/builtin/serper/_assets/icon.svg b/api/core/tools/provider/builtin/serper/_assets/icon.svg
deleted file mode 100644
index 3f973a552e..0000000000
--- a/api/core/tools/provider/builtin/serper/_assets/icon.svg
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/serper/serper.py b/api/core/tools/provider/builtin/serper/serper.py
deleted file mode 100644
index cb1d090a9d..0000000000
--- a/api/core/tools/provider/builtin/serper/serper.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.serper.tools.serper_search import SerperSearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class SerperProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- SerperSearchTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={"query": "test", "result_type": "link"},
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/serper/serper.yaml b/api/core/tools/provider/builtin/serper/serper.yaml
deleted file mode 100644
index b3b2d76c4b..0000000000
--- a/api/core/tools/provider/builtin/serper/serper.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-identity:
- author: zhuhao
- name: serper
- label:
- en_US: Serper
- zh_Hans: Serper
- pt_BR: Serper
- description:
- en_US: Serper is a powerful real-time search engine tool API that provides structured data from Google Search.
- zh_Hans: Serper 是一个强大的实时搜索引擎工具API,可提供来自 Google 搜索引擎搜索的结构化数据。
- pt_BR: Serper is a powerful real-time search engine tool API that provides structured data from Google Search.
- icon: icon.svg
- tags:
- - search
-credentials_for_provider:
- serperapi_api_key:
- type: secret-input
- required: true
- label:
- en_US: Serper API key
- zh_Hans: Serper API key
- pt_BR: Serper API key
- placeholder:
- en_US: Please input your Serper API key
- zh_Hans: 请输入你的 Serper API key
- pt_BR: Please input your Serper API key
- help:
- en_US: Get your Serper API key from Serper
- zh_Hans: 从 Serper 获取您的 Serper API key
- pt_BR: Get your Serper API key from Serper
- url: https://serper.dev/api-key
diff --git a/api/core/tools/provider/builtin/serper/tools/serper_search.py b/api/core/tools/provider/builtin/serper/tools/serper_search.py
deleted file mode 100644
index 7baebbf958..0000000000
--- a/api/core/tools/provider/builtin/serper/tools/serper_search.py
+++ /dev/null
@@ -1,34 +0,0 @@
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-SERPER_API_URL = "https://google.serper.dev/search"
-
-
-class SerperSearchTool(BuiltinTool):
- def _parse_response(self, response: dict) -> dict:
- result = {}
- if "knowledgeGraph" in response:
- result["title"] = response["knowledgeGraph"].get("title", "")
- result["description"] = response["knowledgeGraph"].get("description", "")
- if "organic" in response:
- result["organic"] = [
- {"title": item.get("title", ""), "link": item.get("link", ""), "snippet": item.get("snippet", "")}
- for item in response["organic"]
- ]
- return result
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- params = {"q": tool_parameters["query"], "gl": "us", "hl": "en"}
- headers = {"X-API-KEY": self.runtime.credentials["serperapi_api_key"], "Content-Type": "application/json"}
- response = requests.get(url=SERPER_API_URL, params=params, headers=headers)
- response.raise_for_status()
- valuable_res = self._parse_response(response.json())
- return self.create_json_message(valuable_res)
diff --git a/api/core/tools/provider/builtin/serper/tools/serper_search.yaml b/api/core/tools/provider/builtin/serper/tools/serper_search.yaml
deleted file mode 100644
index e1c0a056e6..0000000000
--- a/api/core/tools/provider/builtin/serper/tools/serper_search.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-identity:
- name: serper
- author: zhuhao
- label:
- en_US: Serper
- zh_Hans: Serper
- pt_BR: Serper
-description:
- human:
- en_US: A tool for performing a Google search and extracting snippets and webpages.Input should be a search query.
- zh_Hans: 一个用于执行 Google 搜索并提取片段和网页的工具。输入应该是一个搜索查询。
- pt_BR: A tool for performing a Google search and extracting snippets and webpages.Input should be a search query.
- llm: A tool for performing a Google search and extracting snippets and webpages.Input should be a search query.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query string
- zh_Hans: 查询语句
- pt_BR: Query string
- human_description:
- en_US: used for searching
- zh_Hans: 用于搜索网页内容
- pt_BR: used for searching
- llm_description: key words for searching
- form: llm
diff --git a/api/core/tools/provider/builtin/siliconflow/_assets/icon.svg b/api/core/tools/provider/builtin/siliconflow/_assets/icon.svg
deleted file mode 100644
index ad6b384f7a..0000000000
--- a/api/core/tools/provider/builtin/siliconflow/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/siliconflow/siliconflow.py b/api/core/tools/provider/builtin/siliconflow/siliconflow.py
deleted file mode 100644
index 37a0b0755b..0000000000
--- a/api/core/tools/provider/builtin/siliconflow/siliconflow.py
+++ /dev/null
@@ -1,17 +0,0 @@
-import requests
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class SiliconflowProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- url = "https://api.siliconflow.cn/v1/models"
- headers = {
- "accept": "application/json",
- "authorization": f"Bearer {credentials.get('siliconFlow_api_key')}",
- }
-
- response = requests.get(url, headers=headers)
- if response.status_code != 200:
- raise ToolProviderCredentialValidationError("SiliconFlow API key is invalid")
diff --git a/api/core/tools/provider/builtin/siliconflow/siliconflow.yaml b/api/core/tools/provider/builtin/siliconflow/siliconflow.yaml
deleted file mode 100644
index 46be99f262..0000000000
--- a/api/core/tools/provider/builtin/siliconflow/siliconflow.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-identity:
- author: hjlarry
- name: siliconflow
- label:
- en_US: SiliconFlow
- zh_CN: 硅基流动
- description:
- en_US: The image generation API provided by SiliconFlow includes Flux and Stable Diffusion models.
- zh_CN: 硅基流动提供的图片生成 API,包含 Flux 和 Stable Diffusion 模型。
- icon: icon.svg
- tags:
- - image
-credentials_for_provider:
- siliconFlow_api_key:
- type: secret-input
- required: true
- label:
- en_US: SiliconFlow API Key
- placeholder:
- en_US: Please input your SiliconFlow API key
- url: https://cloud.siliconflow.cn/account/ak
diff --git a/api/core/tools/provider/builtin/siliconflow/tools/flux.py b/api/core/tools/provider/builtin/siliconflow/tools/flux.py
deleted file mode 100644
index 0d16ff385e..0000000000
--- a/api/core/tools/provider/builtin/siliconflow/tools/flux.py
+++ /dev/null
@@ -1,43 +0,0 @@
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-FLUX_URL = {
- "schnell": "https://api.siliconflow.cn/v1/black-forest-labs/FLUX.1-schnell/text-to-image",
- "dev": "https://api.siliconflow.cn/v1/image/generations",
-}
-
-
-class FluxTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- headers = {
- "accept": "application/json",
- "content-type": "application/json",
- "authorization": f"Bearer {self.runtime.credentials['siliconFlow_api_key']}",
- }
-
- payload = {
- "prompt": tool_parameters.get("prompt"),
- "image_size": tool_parameters.get("image_size", "1024x1024"),
- "seed": tool_parameters.get("seed"),
- "num_inference_steps": tool_parameters.get("num_inference_steps", 20),
- }
- model = tool_parameters.get("model", "schnell")
- url = FLUX_URL.get(model)
- if model == "dev":
- payload["model"] = "black-forest-labs/FLUX.1-dev"
-
- response = requests.post(url, json=payload, headers=headers)
- if response.status_code != 200:
- return self.create_text_message(f"Got Error Response:{response.text}")
-
- res = response.json()
- result = [self.create_json_message(res)]
- for image in res.get("images", []):
- result.append(self.create_image_message(image=image.get("url"), save_as=self.VariableKey.IMAGE.value))
- return result
diff --git a/api/core/tools/provider/builtin/siliconflow/tools/flux.yaml b/api/core/tools/provider/builtin/siliconflow/tools/flux.yaml
deleted file mode 100644
index d06b9bf3e1..0000000000
--- a/api/core/tools/provider/builtin/siliconflow/tools/flux.yaml
+++ /dev/null
@@ -1,88 +0,0 @@
-identity:
- name: flux
- author: hjlarry
- label:
- en_US: Flux
- icon: icon.svg
-description:
- human:
- en_US: Generate image via SiliconFlow's flux model.
- llm: This tool is used to generate image from prompt via SiliconFlow's flux model.
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: prompt
- zh_Hans: 提示词
- human_description:
- en_US: The text prompt used to generate the image.
- zh_Hans: 建议用英文的生成图片提示词以获得更好的生成效果。
- llm_description: this prompt text will be used to generate image.
- form: llm
- - name: model
- type: select
- required: true
- options:
- - value: schnell
- label:
- en_US: Flux.1-schnell
- - value: dev
- label:
- en_US: Flux.1-dev
- default: schnell
- label:
- en_US: Choose Image Model
- zh_Hans: 选择生成图片的模型
- form: form
- - name: image_size
- type: select
- required: true
- options:
- - value: 1024x1024
- label:
- en_US: 1024x1024
- - value: 768x1024
- label:
- en_US: 768x1024
- - value: 576x1024
- label:
- en_US: 576x1024
- - value: 512x1024
- label:
- en_US: 512x1024
- - value: 1024x576
- label:
- en_US: 1024x576
- - value: 768x512
- label:
- en_US: 768x512
- default: 1024x1024
- label:
- en_US: Choose Image Size
- zh_Hans: 选择生成的图片大小
- form: form
- - name: num_inference_steps
- type: number
- required: true
- default: 20
- min: 1
- max: 100
- label:
- en_US: Num Inference Steps
- zh_Hans: 生成图片的步数
- form: form
- human_description:
- en_US: The number of inference steps to perform. More steps produce higher quality but take longer.
- zh_Hans: 执行的推理步骤数量。更多的步骤可以产生更高质量的结果,但需要更长的时间。
- - name: seed
- type: number
- min: 0
- max: 9999999999
- label:
- en_US: Seed
- zh_Hans: 种子
- human_description:
- en_US: The same seed and prompt can produce similar images.
- zh_Hans: 相同的种子和提示可以产生相似的图像。
- form: form
diff --git a/api/core/tools/provider/builtin/siliconflow/tools/stable_diffusion.py b/api/core/tools/provider/builtin/siliconflow/tools/stable_diffusion.py
deleted file mode 100644
index d6a0b03d1b..0000000000
--- a/api/core/tools/provider/builtin/siliconflow/tools/stable_diffusion.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-SDURL = {
- "sd_3": "https://api.siliconflow.cn/v1/stabilityai/stable-diffusion-3-medium/text-to-image",
- "sd_xl": "https://api.siliconflow.cn/v1/stabilityai/stable-diffusion-xl-base-1.0/text-to-image",
-}
-
-
-class StableDiffusionTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- headers = {
- "accept": "application/json",
- "content-type": "application/json",
- "authorization": f"Bearer {self.runtime.credentials['siliconFlow_api_key']}",
- }
-
- model = tool_parameters.get("model", "sd_3")
- url = SDURL.get(model)
-
- payload = {
- "prompt": tool_parameters.get("prompt"),
- "negative_prompt": tool_parameters.get("negative_prompt", ""),
- "image_size": tool_parameters.get("image_size", "1024x1024"),
- "batch_size": tool_parameters.get("batch_size", 1),
- "seed": tool_parameters.get("seed"),
- "guidance_scale": tool_parameters.get("guidance_scale", 7.5),
- "num_inference_steps": tool_parameters.get("num_inference_steps", 20),
- }
-
- response = requests.post(url, json=payload, headers=headers)
- if response.status_code != 200:
- return self.create_text_message(f"Got Error Response:{response.text}")
-
- res = response.json()
- result = [self.create_json_message(res)]
- for image in res.get("images", []):
- result.append(self.create_image_message(image=image.get("url"), save_as=self.VariableKey.IMAGE.value))
- return result
diff --git a/api/core/tools/provider/builtin/siliconflow/tools/stable_diffusion.yaml b/api/core/tools/provider/builtin/siliconflow/tools/stable_diffusion.yaml
deleted file mode 100644
index dce10adc87..0000000000
--- a/api/core/tools/provider/builtin/siliconflow/tools/stable_diffusion.yaml
+++ /dev/null
@@ -1,121 +0,0 @@
-identity:
- name: stable_diffusion
- author: hjlarry
- label:
- en_US: Stable Diffusion
- icon: icon.svg
-description:
- human:
- en_US: Generate image via SiliconFlow's stable diffusion model.
- llm: This tool is used to generate image from prompt via SiliconFlow's stable diffusion model.
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: prompt
- zh_Hans: 提示词
- human_description:
- en_US: The text prompt used to generate the image.
- zh_Hans: 用于生成图片的文字提示词
- llm_description: this prompt text will be used to generate image.
- form: llm
- - name: negative_prompt
- type: string
- label:
- en_US: negative prompt
- zh_Hans: 负面提示词
- human_description:
- en_US: Describe what you don't want included in the image.
- zh_Hans: 描述您不希望包含在图片中的内容。
- llm_description: Describe what you don't want included in the image.
- form: llm
- - name: model
- type: select
- required: true
- options:
- - value: sd_3
- label:
- en_US: Stable Diffusion 3
- - value: sd_xl
- label:
- en_US: Stable Diffusion XL
- default: sd_3
- label:
- en_US: Choose Image Model
- zh_Hans: 选择生成图片的模型
- form: form
- - name: image_size
- type: select
- required: true
- options:
- - value: 1024x1024
- label:
- en_US: 1024x1024
- - value: 1024x2048
- label:
- en_US: 1024x2048
- - value: 1152x2048
- label:
- en_US: 1152x2048
- - value: 1536x1024
- label:
- en_US: 1536x1024
- - value: 1536x2048
- label:
- en_US: 1536x2048
- - value: 2048x1152
- label:
- en_US: 2048x1152
- default: 1024x1024
- label:
- en_US: Choose Image Size
- zh_Hans: 选择生成图片的大小
- form: form
- - name: batch_size
- type: number
- required: true
- default: 1
- min: 1
- max: 4
- label:
- en_US: Number Images
- zh_Hans: 生成图片的数量
- form: form
- - name: guidance_scale
- type: number
- required: true
- default: 7.5
- min: 0
- max: 100
- label:
- en_US: Guidance Scale
- zh_Hans: 与提示词紧密性
- human_description:
- en_US: Classifier Free Guidance. How close you want the model to stick to your prompt when looking for a related image to show you.
- zh_Hans: 无分类器引导。您希望模型在寻找相关图片向您展示时,与您的提示保持多紧密的关联度。
- form: form
- - name: num_inference_steps
- type: number
- required: true
- default: 20
- min: 1
- max: 100
- label:
- en_US: Num Inference Steps
- zh_Hans: 生成图片的步数
- human_description:
- en_US: The number of inference steps to perform. More steps produce higher quality but take longer.
- zh_Hans: 执行的推理步骤数量。更多的步骤可以产生更高质量的结果,但需要更长的时间。
- form: form
- - name: seed
- type: number
- min: 0
- max: 9999999999
- label:
- en_US: Seed
- zh_Hans: 种子
- human_description:
- en_US: The same seed and prompt can produce similar images.
- zh_Hans: 相同的种子和提示可以产生相似的图像。
- form: form
diff --git a/api/core/tools/provider/builtin/slack/_assets/icon.svg b/api/core/tools/provider/builtin/slack/_assets/icon.svg
deleted file mode 100644
index e43c2c47dc..0000000000
--- a/api/core/tools/provider/builtin/slack/_assets/icon.svg
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
diff --git a/api/core/tools/provider/builtin/slack/slack.py b/api/core/tools/provider/builtin/slack/slack.py
deleted file mode 100644
index 2de7911f63..0000000000
--- a/api/core/tools/provider/builtin/slack/slack.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from core.tools.provider.builtin.slack.tools.slack_webhook import SlackWebhookTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class SlackProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- SlackWebhookTool()
- pass
diff --git a/api/core/tools/provider/builtin/slack/slack.yaml b/api/core/tools/provider/builtin/slack/slack.yaml
deleted file mode 100644
index 1070ffbf03..0000000000
--- a/api/core/tools/provider/builtin/slack/slack.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-identity:
- author: Pan YANG
- name: slack
- label:
- en_US: Slack
- zh_Hans: Slack
- pt_BR: Slack
- description:
- en_US: Slack Webhook
- zh_Hans: Slack Webhook
- pt_BR: Slack Webhook
- icon: icon.svg
- tags:
- - social
- - productivity
-credentials_for_provider:
diff --git a/api/core/tools/provider/builtin/slack/tools/slack_webhook.py b/api/core/tools/provider/builtin/slack/tools/slack_webhook.py
deleted file mode 100644
index 85e0de7675..0000000000
--- a/api/core/tools/provider/builtin/slack/tools/slack_webhook.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class SlackWebhookTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Incoming Webhooks
- API Document: https://api.slack.com/messaging/webhooks
- """
-
- content = tool_parameters.get("content", "")
- if not content:
- return self.create_text_message("Invalid parameter content")
-
- webhook_url = tool_parameters.get("webhook_url", "")
-
- if not webhook_url.startswith("https://hooks.slack.com/"):
- return self.create_text_message(
- f"Invalid parameter webhook_url ${webhook_url}, not a valid Slack webhook URL"
- )
-
- headers = {
- "Content-Type": "application/json",
- }
- params = {}
- payload = {
- "text": content,
- }
-
- try:
- res = httpx.post(webhook_url, headers=headers, params=params, json=payload)
- if res.is_success:
- return self.create_text_message("Text message was sent successfully")
- else:
- return self.create_text_message(
- f"Failed to send the text message, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to send message through webhook. {}".format(e))
diff --git a/api/core/tools/provider/builtin/slack/tools/slack_webhook.yaml b/api/core/tools/provider/builtin/slack/tools/slack_webhook.yaml
deleted file mode 100644
index b838d74373..0000000000
--- a/api/core/tools/provider/builtin/slack/tools/slack_webhook.yaml
+++ /dev/null
@@ -1,40 +0,0 @@
-identity:
- name: slack_webhook
- author: Pan YANG
- label:
- en_US: Incoming Webhook to send message
- zh_Hans: 通过入站 Webhook 发送消息
- pt_BR: Incoming Webhook to send message
- icon: icon.svg
-description:
- human:
- en_US: Sending a message on Slack via the Incoming Webhook
- zh_Hans: 通过入站 Webhook 在 Slack 上发送消息
- pt_BR: Sending a message on Slack via the Incoming Webhook
- llm: A tool for sending messages to a chat on Slack.
-parameters:
- - name: webhook_url
- type: string
- required: true
- label:
- en_US: Slack Incoming Webhook url
- zh_Hans: Slack 入站 Webhook 的 url
- pt_BR: Slack Incoming Webhook url
- human_description:
- en_US: Slack Incoming Webhook url
- zh_Hans: Slack 入站 Webhook 的 url
- pt_BR: Slack Incoming Webhook url
- form: form
- - name: content
- type: string
- required: true
- label:
- en_US: content
- zh_Hans: 消息内容
- pt_BR: content
- human_description:
- en_US: Content to sent to the channel or person.
- zh_Hans: 消息内容文本
- pt_BR: Content to sent to the channel or person.
- llm_description: Content of the message
- form: llm
diff --git a/api/core/tools/provider/builtin/spark/__init__.py b/api/core/tools/provider/builtin/spark/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/api/core/tools/provider/builtin/spark/_assets/icon.svg b/api/core/tools/provider/builtin/spark/_assets/icon.svg
deleted file mode 100644
index ef0a9131a4..0000000000
--- a/api/core/tools/provider/builtin/spark/_assets/icon.svg
+++ /dev/null
@@ -1,5 +0,0 @@
-
diff --git a/api/core/tools/provider/builtin/spark/spark.py b/api/core/tools/provider/builtin/spark/spark.py
deleted file mode 100644
index e0b1a58a3f..0000000000
--- a/api/core/tools/provider/builtin/spark/spark.py
+++ /dev/null
@@ -1,36 +0,0 @@
-import json
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.spark.tools.spark_img_generation import spark_response
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class SparkProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- if "APPID" not in credentials or not credentials.get("APPID"):
- raise ToolProviderCredentialValidationError("APPID is required.")
- if "APISecret" not in credentials or not credentials.get("APISecret"):
- raise ToolProviderCredentialValidationError("APISecret is required.")
- if "APIKey" not in credentials or not credentials.get("APIKey"):
- raise ToolProviderCredentialValidationError("APIKey is required.")
-
- appid = credentials.get("APPID")
- apisecret = credentials.get("APISecret")
- apikey = credentials.get("APIKey")
- prompt = "a cute black dog"
-
- try:
- response = spark_response(prompt, appid, apikey, apisecret)
- data = json.loads(response)
- code = data["header"]["code"]
-
- if code == 0:
- # 0 success,
- pass
- else:
- raise ToolProviderCredentialValidationError("image generate error, code:{}".format(code))
- except Exception as e:
- raise ToolProviderCredentialValidationError("APPID APISecret APIKey is invalid. {}".format(e))
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/spark/spark.yaml b/api/core/tools/provider/builtin/spark/spark.yaml
deleted file mode 100644
index fa1543443a..0000000000
--- a/api/core/tools/provider/builtin/spark/spark.yaml
+++ /dev/null
@@ -1,61 +0,0 @@
-identity:
- author: Onelevenvy
- name: spark
- label:
- en_US: Spark
- zh_Hans: 讯飞星火
- pt_BR: Spark
- description:
- en_US: Spark Platform Toolkit
- zh_Hans: 讯飞星火平台工具
- pt_BR: Pacote de Ferramentas da Plataforma Spark
- icon: icon.svg
- tags:
- - image
-credentials_for_provider:
- APPID:
- type: secret-input
- required: true
- label:
- en_US: Spark APPID
- zh_Hans: APPID
- pt_BR: Spark APPID
- help:
- en_US: Please input your APPID
- zh_Hans: 请输入你的 APPID
- pt_BR: Please input your APPID
- placeholder:
- en_US: Please input your APPID
- zh_Hans: 请输入你的 APPID
- pt_BR: Please input your APPID
- APISecret:
- type: secret-input
- required: true
- label:
- en_US: Spark APISecret
- zh_Hans: APISecret
- pt_BR: Spark APISecret
- help:
- en_US: Please input your Spark APISecret
- zh_Hans: 请输入你的 APISecret
- pt_BR: Please input your Spark APISecret
- placeholder:
- en_US: Please input your Spark APISecret
- zh_Hans: 请输入你的 APISecret
- pt_BR: Please input your Spark APISecret
- APIKey:
- type: secret-input
- required: true
- label:
- en_US: Spark APIKey
- zh_Hans: APIKey
- pt_BR: Spark APIKey
- help:
- en_US: Please input your Spark APIKey
- zh_Hans: 请输入你的 APIKey
- pt_BR: Please input your Spark APIKey
- placeholder:
- en_US: Please input your Spark APIKey
- zh_Hans: 请输入你的 APIKey
- pt_BR: Please input Spark APIKey
- url: https://console.xfyun.cn/services
diff --git a/api/core/tools/provider/builtin/spark/tools/spark_img_generation.py b/api/core/tools/provider/builtin/spark/tools/spark_img_generation.py
deleted file mode 100644
index 81d9e8d941..0000000000
--- a/api/core/tools/provider/builtin/spark/tools/spark_img_generation.py
+++ /dev/null
@@ -1,139 +0,0 @@
-import base64
-import hashlib
-import hmac
-import json
-from base64 import b64decode
-from datetime import datetime
-from time import mktime
-from typing import Any, Union
-from urllib.parse import urlencode
-from wsgiref.handlers import format_date_time
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class AssembleHeaderError(Exception):
- def __init__(self, msg):
- self.message = msg
-
-
-class Url:
- def __init__(self, host, path, schema):
- self.host = host
- self.path = path
- self.schema = schema
-
-
-# calculate sha256 and encode to base64
-def sha256base64(data):
- sha256 = hashlib.sha256()
- sha256.update(data)
- digest = base64.b64encode(sha256.digest()).decode(encoding="utf-8")
- return digest
-
-
-def parse_url(request_url):
- stidx = request_url.index("://")
- host = request_url[stidx + 3 :]
- schema = request_url[: stidx + 3]
- edidx = host.index("/")
- if edidx <= 0:
- raise AssembleHeaderError("invalid request url:" + request_url)
- path = host[edidx:]
- host = host[:edidx]
- u = Url(host, path, schema)
- return u
-
-
-def assemble_ws_auth_url(request_url, method="GET", api_key="", api_secret=""):
- u = parse_url(request_url)
- host = u.host
- path = u.path
- now = datetime.now()
- date = format_date_time(mktime(now.timetuple()))
- signature_origin = "host: {}\ndate: {}\n{} {} HTTP/1.1".format(host, date, method, path)
- signature_sha = hmac.new(
- api_secret.encode("utf-8"),
- signature_origin.encode("utf-8"),
- digestmod=hashlib.sha256,
- ).digest()
- signature_sha = base64.b64encode(signature_sha).decode(encoding="utf-8")
- authorization_origin = (
- f'api_key="{api_key}", algorithm="hmac-sha256", headers="host date request-line", signature="{signature_sha}"'
- )
-
- authorization = base64.b64encode(authorization_origin.encode("utf-8")).decode(encoding="utf-8")
- values = {"host": host, "date": date, "authorization": authorization}
-
- return request_url + "?" + urlencode(values)
-
-
-def get_body(appid, text):
- body = {
- "header": {"app_id": appid, "uid": "123456789"},
- "parameter": {"chat": {"domain": "general", "temperature": 0.5, "max_tokens": 4096}},
- "payload": {"message": {"text": [{"role": "user", "content": text}]}},
- }
- return body
-
-
-def spark_response(text, appid, apikey, apisecret):
- host = "http://spark-api.cn-huabei-1.xf-yun.com/v2.1/tti"
- url = assemble_ws_auth_url(host, method="POST", api_key=apikey, api_secret=apisecret)
- content = get_body(appid, text)
- response = requests.post(url, json=content, headers={"content-type": "application/json"}).text
- return response
-
-
-class SparkImgGeneratorTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
-
- if "APPID" not in self.runtime.credentials or not self.runtime.credentials.get("APPID"):
- return self.create_text_message("APPID is required.")
- if "APISecret" not in self.runtime.credentials or not self.runtime.credentials.get("APISecret"):
- return self.create_text_message("APISecret is required.")
- if "APIKey" not in self.runtime.credentials or not self.runtime.credentials.get("APIKey"):
- return self.create_text_message("APIKey is required.")
-
- prompt = tool_parameters.get("prompt", "")
- if not prompt:
- return self.create_text_message("Please input prompt")
- res = self.img_generation(prompt)
- result = []
- for image in res:
- result.append(
- self.create_blob_message(
- blob=b64decode(image["base64_image"]),
- meta={"mime_type": "image/png"},
- save_as=self.VariableKey.IMAGE.value,
- )
- )
- return result
-
- def img_generation(self, prompt):
- response = spark_response(
- text=prompt,
- appid=self.runtime.credentials.get("APPID"),
- apikey=self.runtime.credentials.get("APIKey"),
- apisecret=self.runtime.credentials.get("APISecret"),
- )
- data = json.loads(response)
- code = data["header"]["code"]
- if code != 0:
- return self.create_text_message(f"error: {code}, {data}")
- else:
- text = data["payload"]["choices"]["text"]
- image_content = text[0]
- image_base = image_content["content"]
- json_data = {"base64_image": image_base}
- return [json_data]
diff --git a/api/core/tools/provider/builtin/spark/tools/spark_img_generation.yaml b/api/core/tools/provider/builtin/spark/tools/spark_img_generation.yaml
deleted file mode 100644
index d44bbc9564..0000000000
--- a/api/core/tools/provider/builtin/spark/tools/spark_img_generation.yaml
+++ /dev/null
@@ -1,36 +0,0 @@
-identity:
- name: spark_img_generation
- author: Onelevenvy
- label:
- en_US: Spark Image Generation
- zh_Hans: 图片生成
- pt_BR: Geração de imagens Spark
- icon: icon.svg
- description:
- en_US: Spark Image Generation
- zh_Hans: 图片生成
- pt_BR: Geração de imagens Spark
-description:
- human:
- en_US: Generate images based on user input, with image generation API
- provided by Spark
- zh_Hans: 根据用户的输入生成图片,由讯飞星火提供图片生成api
- pt_BR: Gerar imagens com base na entrada do usuário, com API de geração
- de imagem fornecida pela Spark
- llm: spark_img_generation is a tool used to generate images from text
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: Prompt
- zh_Hans: 提示词
- pt_BR: Prompt
- human_description:
- en_US: Image prompt
- zh_Hans: 图像提示词
- pt_BR: Image prompt
- llm_description: Image prompt of spark_img_generation tooll, you should
- describe the image you want to generate as a list of words as possible
- as detailed
- form: llm
diff --git a/api/core/tools/provider/builtin/spider/_assets/icon.svg b/api/core/tools/provider/builtin/spider/_assets/icon.svg
deleted file mode 100644
index 604a09d01d..0000000000
--- a/api/core/tools/provider/builtin/spider/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/api/core/tools/provider/builtin/spider/spider.py b/api/core/tools/provider/builtin/spider/spider.py
deleted file mode 100644
index 5959555318..0000000000
--- a/api/core/tools/provider/builtin/spider/spider.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.spider.spiderApp import Spider
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class SpiderProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- app = Spider(api_key=credentials["spider_api_key"])
- app.scrape_url(url="https://spider.cloud")
- except AttributeError as e:
- # Handle cases where NoneType is not iterable, which might indicate API issues
- if "NoneType" in str(e) and "not iterable" in str(e):
- raise ToolProviderCredentialValidationError("API is currently down, try again in 15 minutes", str(e))
- else:
- raise ToolProviderCredentialValidationError("An unexpected error occurred.", str(e))
- except Exception as e:
- raise ToolProviderCredentialValidationError("An unexpected error occurred.", str(e))
diff --git a/api/core/tools/provider/builtin/spider/spider.yaml b/api/core/tools/provider/builtin/spider/spider.yaml
deleted file mode 100644
index 45702c85dd..0000000000
--- a/api/core/tools/provider/builtin/spider/spider.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-identity:
- author: William Espegren
- name: spider
- label:
- en_US: Spider
- zh_CN: Spider
- description:
- en_US: Spider API integration, returning LLM-ready data by scraping & crawling websites.
- zh_CN: Spider API 集成,通过爬取和抓取网站返回 LLM-ready 数据。
- icon: icon.svg
- tags:
- - search
- - utilities
-credentials_for_provider:
- spider_api_key:
- type: secret-input
- required: true
- label:
- en_US: Spider API Key
- zh_CN: Spider API 密钥
- placeholder:
- en_US: Please input your Spider API key
- zh_CN: 请输入您的 Spider API 密钥
- help:
- en_US: Get your Spider API key from your Spider dashboard
- zh_CN: 从您的 Spider 仪表板中获取 Spider API 密钥。
- url: https://spider.cloud/
diff --git a/api/core/tools/provider/builtin/spider/spiderApp.py b/api/core/tools/provider/builtin/spider/spiderApp.py
deleted file mode 100644
index 4bc446a1a0..0000000000
--- a/api/core/tools/provider/builtin/spider/spiderApp.py
+++ /dev/null
@@ -1,221 +0,0 @@
-import os
-from typing import Literal, Optional, TypedDict
-
-import requests
-
-
-class RequestParamsDict(TypedDict, total=False):
- url: Optional[str]
- request: Optional[Literal["http", "chrome", "smart"]]
- limit: Optional[int]
- return_format: Optional[Literal["raw", "markdown", "html2text", "text", "bytes"]]
- tld: Optional[bool]
- depth: Optional[int]
- cache: Optional[bool]
- budget: Optional[dict[str, int]]
- locale: Optional[str]
- cookies: Optional[str]
- stealth: Optional[bool]
- headers: Optional[dict[str, str]]
- anti_bot: Optional[bool]
- metadata: Optional[bool]
- viewport: Optional[dict[str, int]]
- encoding: Optional[str]
- subdomains: Optional[bool]
- user_agent: Optional[str]
- store_data: Optional[bool]
- gpt_config: Optional[list[str]]
- fingerprint: Optional[bool]
- storageless: Optional[bool]
- readability: Optional[bool]
- proxy_enabled: Optional[bool]
- respect_robots: Optional[bool]
- query_selector: Optional[str]
- full_resources: Optional[bool]
- request_timeout: Optional[int]
- run_in_background: Optional[bool]
- skip_config_checks: Optional[bool]
-
-
-class Spider:
- def __init__(self, api_key: Optional[str] = None):
- """
- Initialize the Spider with an API key.
-
- :param api_key: A string of the API key for Spider. Defaults to the SPIDER_API_KEY environment variable.
- :raises ValueError: If no API key is provided.
- """
- self.api_key = api_key or os.getenv("SPIDER_API_KEY")
- if self.api_key is None:
- raise ValueError("No API key provided")
-
- def api_post(
- self,
- endpoint: str,
- data: dict,
- stream: bool,
- content_type: str = "application/json",
- ):
- """
- Send a POST request to the specified API endpoint.
-
- :param endpoint: The API endpoint to which the POST request is sent.
- :param data: The data (dictionary) to be sent in the POST request.
- :param stream: Boolean indicating if the response should be streamed.
- :return: The JSON response or the raw response stream if stream is True.
- """
- headers = self._prepare_headers(content_type)
- response = self._post_request(f"https://api.spider.cloud/v1/{endpoint}", data, headers, stream)
-
- if stream:
- return response
- elif response.status_code == 200:
- return response.json()
- else:
- self._handle_error(response, f"post to {endpoint}")
-
- def api_get(self, endpoint: str, stream: bool, content_type: str = "application/json"):
- """
- Send a GET request to the specified endpoint.
-
- :param endpoint: The API endpoint from which to retrieve data.
- :return: The JSON decoded response.
- """
- headers = self._prepare_headers(content_type)
- response = self._get_request(f"https://api.spider.cloud/v1/{endpoint}", headers, stream)
- if response.status_code == 200:
- return response.json()
- else:
- self._handle_error(response, f"get from {endpoint}")
-
- def get_credits(self):
- """
- Retrieve the account's remaining credits.
-
- :return: JSON response containing the number of credits left.
- """
- return self.api_get("credits", stream=False)
-
- def scrape_url(
- self,
- url: str,
- params: Optional[RequestParamsDict] = None,
- stream: bool = False,
- content_type: str = "application/json",
- ):
- """
- Scrape data from the specified URL.
-
- :param url: The URL from which to scrape data.
- :param params: Optional dictionary of additional parameters for the scrape request.
- :return: JSON response containing the scraping results.
- """
- params = params or {}
-
- # Add { "return_format": "markdown" } to the params if not already present
- if "return_format" not in params:
- params["return_format"] = "markdown"
-
- # Set limit to 1
- params["limit"] = 1
-
- return self.api_post("crawl", {"url": url, **(params or {})}, stream, content_type)
-
- def crawl_url(
- self,
- url: str,
- params: Optional[RequestParamsDict] = None,
- stream: bool = False,
- content_type: str = "application/json",
- ):
- """
- Start crawling at the specified URL.
-
- :param url: The URL to begin crawling.
- :param params: Optional dictionary with additional parameters to customize the crawl.
- :param stream: Boolean indicating if the response should be streamed. Defaults to False.
- :return: JSON response or the raw response stream if streaming enabled.
- """
- params = params or {}
-
- # Add { "return_format": "markdown" } to the params if not already present
- if "return_format" not in params:
- params["return_format"] = "markdown"
-
- return self.api_post("crawl", {"url": url, **(params or {})}, stream, content_type)
-
- def links(
- self,
- url: str,
- params: Optional[RequestParamsDict] = None,
- stream: bool = False,
- content_type: str = "application/json",
- ):
- """
- Retrieve links from the specified URL.
-
- :param url: The URL from which to extract links.
- :param params: Optional parameters for the link retrieval request.
- :return: JSON response containing the links.
- """
- return self.api_post("links", {"url": url, **(params or {})}, stream, content_type)
-
- def extract_contacts(
- self,
- url: str,
- params: Optional[RequestParamsDict] = None,
- stream: bool = False,
- content_type: str = "application/json",
- ):
- """
- Extract contact information from the specified URL.
-
- :param url: The URL from which to extract contact information.
- :param params: Optional parameters for the contact extraction.
- :return: JSON response containing extracted contact details.
- """
- return self.api_post(
- "pipeline/extract-contacts",
- {"url": url, **(params or {})},
- stream,
- content_type,
- )
-
- def label(
- self,
- url: str,
- params: Optional[RequestParamsDict] = None,
- stream: bool = False,
- content_type: str = "application/json",
- ):
- """
- Apply labeling to data extracted from the specified URL.
-
- :param url: The URL to label data from.
- :param params: Optional parameters to guide the labeling process.
- :return: JSON response with labeled data.
- """
- return self.api_post("pipeline/label", {"url": url, **(params or {})}, stream, content_type)
-
- def _prepare_headers(self, content_type: str = "application/json"):
- return {
- "Content-Type": content_type,
- "Authorization": f"Bearer {self.api_key}",
- "User-Agent": "Spider-Client/0.0.27",
- }
-
- def _post_request(self, url: str, data, headers, stream=False):
- return requests.post(url, headers=headers, json=data, stream=stream)
-
- def _get_request(self, url: str, headers, stream=False):
- return requests.get(url, headers=headers, stream=stream)
-
- def _delete_request(self, url: str, headers, stream=False):
- return requests.delete(url, headers=headers, stream=stream)
-
- def _handle_error(self, response, action):
- if response.status_code in {402, 409, 500}:
- error_message = response.json().get("error", "Unknown error occurred")
- raise Exception(f"Failed to {action}. Status code: {response.status_code}. Error: {error_message}")
- else:
- raise Exception(f"Unexpected error occurred while trying to {action}. Status code: {response.status_code}")
diff --git a/api/core/tools/provider/builtin/spider/tools/scraper_crawler.py b/api/core/tools/provider/builtin/spider/tools/scraper_crawler.py
deleted file mode 100644
index 20d2daef55..0000000000
--- a/api/core/tools/provider/builtin/spider/tools/scraper_crawler.py
+++ /dev/null
@@ -1,49 +0,0 @@
-from typing import Any, Union
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.provider.builtin.spider.spiderApp import Spider
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class ScrapeTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- # initialize the app object with the api key
- app = Spider(api_key=self.runtime.credentials["spider_api_key"])
-
- url = tool_parameters["url"]
- mode = tool_parameters["mode"]
-
- options = {
- "limit": tool_parameters.get("limit", 0),
- "depth": tool_parameters.get("depth", 0),
- "blacklist": tool_parameters.get("blacklist", "").split(",") if tool_parameters.get("blacklist") else [],
- "whitelist": tool_parameters.get("whitelist", "").split(",") if tool_parameters.get("whitelist") else [],
- "readability": tool_parameters.get("readability", False),
- }
-
- result = ""
-
- try:
- if mode == "scrape":
- scrape_result = app.scrape_url(
- url=url,
- params=options,
- )
-
- for i in scrape_result:
- result += "URL: " + i.get("url", "") + "\n"
- result += "CONTENT: " + i.get("content", "") + "\n\n"
- elif mode == "crawl":
- crawl_result = app.crawl_url(
- url=tool_parameters["url"],
- params=options,
- )
- for i in crawl_result:
- result += "URL: " + i.get("url", "") + "\n"
- result += "CONTENT: " + i.get("content", "") + "\n\n"
- except Exception as e:
- return self.create_text_message("An error occurred", str(e))
-
- return self.create_text_message(result)
diff --git a/api/core/tools/provider/builtin/spider/tools/scraper_crawler.yaml b/api/core/tools/provider/builtin/spider/tools/scraper_crawler.yaml
deleted file mode 100644
index 5b20c2fc2f..0000000000
--- a/api/core/tools/provider/builtin/spider/tools/scraper_crawler.yaml
+++ /dev/null
@@ -1,102 +0,0 @@
-identity:
- name: scraper_crawler
- author: William Espegren
- label:
- en_US: Web Scraper & Crawler
- zh_Hans: 网页抓取与爬虫
-description:
- human:
- en_US: A tool for scraping & crawling webpages. Input should be a url.
- zh_Hans: 用于抓取和爬取网页的工具。输入应该是一个网址。
- llm: A tool for scraping & crawling webpages. Input should be a url.
-parameters:
- - name: url
- type: string
- required: true
- label:
- en_US: URL
- zh_Hans: 网址
- human_description:
- en_US: url to be scraped or crawled
- zh_Hans: 要抓取或爬取的网址
- llm_description: url to either be scraped or crawled
- form: llm
- - name: mode
- type: select
- required: true
- options:
- - value: scrape
- label:
- en_US: scrape
- zh_Hans: 抓取
- - value: crawl
- label:
- en_US: crawl
- zh_Hans: 爬取
- default: crawl
- label:
- en_US: Mode
- zh_Hans: 模式
- human_description:
- en_US: used for selecting to either scrape the website or crawl the entire website following subpages
- zh_Hans: 用于选择抓取网站或爬取整个网站及其子页面
- form: form
- - name: limit
- type: number
- required: false
- label:
- en_US: maximum number of pages to crawl
- zh_Hans: 最大爬取页面数
- human_description:
- en_US: specify the maximum number of pages to crawl per website. the crawler will stop after reaching this limit.
- zh_Hans: 指定每个网站要爬取的最大页面数。爬虫将在达到此限制后停止。
- form: form
- min: 0
- default: 0
- - name: depth
- type: number
- required: false
- label:
- en_US: maximum depth of pages to crawl
- zh_Hans: 最大爬取深度
- human_description:
- en_US: the crawl limit for maximum depth.
- zh_Hans: 最大爬取深度的限制。
- form: form
- min: 0
- default: 0
- - name: blacklist
- type: string
- required: false
- label:
- en_US: url patterns to exclude
- zh_Hans: 要排除的URL模式
- human_description:
- en_US: blacklist a set of paths that you do not want to crawl. you can use regex patterns to help with the list.
- zh_Hans: 指定一组不想爬取的路径。您可以使用正则表达式模式来帮助定义列表。
- placeholder:
- en_US: /blog/*, /about
- form: form
- - name: whitelist
- type: string
- required: false
- label:
- en_US: URL patterns to include
- zh_Hans: 要包含的URL模式
- human_description:
- en_US: Whitelist a set of paths that you want to crawl, ignoring all other routes that do not match the patterns. You can use regex patterns to help with the list.
- zh_Hans: 指定一组要爬取的路径,忽略所有不匹配模式的其他路由。您可以使用正则表达式模式来帮助定义列表。
- placeholder:
- en_US: /blog/*, /about
- form: form
- - name: readability
- type: boolean
- required: false
- label:
- en_US: Pre-process the content for LLM usage
- zh_Hans: 仅返回页面的主要内容
- human_description:
- en_US: Use Mozilla's readability to pre-process the content for reading. This may drastically improve the content for LLM usage.
- zh_Hans: 如果启用,爬虫将仅返回页面的主要内容,不包括标题、导航、页脚等。
- form: form
- default: false
diff --git a/api/core/tools/provider/builtin/stability/_assets/icon.svg b/api/core/tools/provider/builtin/stability/_assets/icon.svg
deleted file mode 100644
index 56357a3555..0000000000
--- a/api/core/tools/provider/builtin/stability/_assets/icon.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/stability/stability.py b/api/core/tools/provider/builtin/stability/stability.py
deleted file mode 100644
index f09d81ac27..0000000000
--- a/api/core/tools/provider/builtin/stability/stability.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from typing import Any
-
-from core.tools.provider.builtin.stability.tools.base import BaseStabilityAuthorization
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class StabilityToolProvider(BuiltinToolProviderController, BaseStabilityAuthorization):
- """
- This class is responsible for providing the stability tool.
- """
-
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- """
- This method is responsible for validating the credentials.
- """
- self.sd_validate_credentials(credentials)
diff --git a/api/core/tools/provider/builtin/stability/stability.yaml b/api/core/tools/provider/builtin/stability/stability.yaml
deleted file mode 100644
index c3e01c1e31..0000000000
--- a/api/core/tools/provider/builtin/stability/stability.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-identity:
- author: Dify
- name: stability
- label:
- en_US: Stability
- zh_Hans: Stability
- pt_BR: Stability
- description:
- en_US: Activating humanity's potential through generative AI
- zh_Hans: 通过生成式 AI 激活人类的潜力
- pt_BR: Activating humanity's potential through generative AI
- icon: icon.svg
- tags:
- - image
-credentials_for_provider:
- api_key:
- type: secret-input
- required: true
- label:
- en_US: API key
- zh_Hans: API key
- pt_BR: API key
- placeholder:
- en_US: Please input your API key
- zh_Hans: 请输入你的 API key
- pt_BR: Please input your API key
- help:
- en_US: Get your API key from Stability
- zh_Hans: 从 Stability 获取你的 API key
- pt_BR: Get your API key from Stability
- url: https://platform.stability.ai/account/keys
diff --git a/api/core/tools/provider/builtin/stability/tools/base.py b/api/core/tools/provider/builtin/stability/tools/base.py
deleted file mode 100644
index c3b7edbefa..0000000000
--- a/api/core/tools/provider/builtin/stability/tools/base.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import requests
-from yarl import URL
-
-from core.tools.errors import ToolProviderCredentialValidationError
-
-
-class BaseStabilityAuthorization:
- def sd_validate_credentials(self, credentials: dict):
- """
- This method is responsible for validating the credentials.
- """
- api_key = credentials.get("api_key", "")
- if not api_key:
- raise ToolProviderCredentialValidationError("API key is required.")
-
- response = requests.get(
- URL("https://api.stability.ai") / "v1" / "user" / "account",
- headers=self.generate_authorization_headers(credentials),
- timeout=(5, 30),
- )
-
- if not response.ok:
- raise ToolProviderCredentialValidationError("Invalid API key.")
-
- return True
-
- def generate_authorization_headers(self, credentials: dict) -> dict[str, str]:
- """
- This method is responsible for generating the authorization headers.
- """
- return {"Authorization": f'Bearer {credentials.get("api_key", "")}'}
diff --git a/api/core/tools/provider/builtin/stability/tools/text2image.py b/api/core/tools/provider/builtin/stability/tools/text2image.py
deleted file mode 100644
index 6bcf315484..0000000000
--- a/api/core/tools/provider/builtin/stability/tools/text2image.py
+++ /dev/null
@@ -1,56 +0,0 @@
-from typing import Any
-
-from httpx import post
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.provider.builtin.stability.tools.base import BaseStabilityAuthorization
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class StableDiffusionTool(BuiltinTool, BaseStabilityAuthorization):
- """
- This class is responsible for providing the stable diffusion tool.
- """
-
- model_endpoint_map: dict[str, str] = {
- "sd3": "https://api.stability.ai/v2beta/stable-image/generate/sd3",
- "sd3-turbo": "https://api.stability.ai/v2beta/stable-image/generate/sd3",
- "core": "https://api.stability.ai/v2beta/stable-image/generate/core",
- }
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage | list[ToolInvokeMessage]:
- """
- Invoke the tool.
- """
- payload = {
- "prompt": tool_parameters.get("prompt", ""),
- "aspect_ratio": tool_parameters.get("aspect_ratio", "16:9") or tool_parameters.get("aspect_radio", "16:9"),
- "mode": "text-to-image",
- "seed": tool_parameters.get("seed", 0),
- "output_format": "png",
- }
-
- model = tool_parameters.get("model", "core")
-
- if model in {"sd3", "sd3-turbo"}:
- payload["model"] = tool_parameters.get("model")
-
- if model != "sd3-turbo":
- payload["negative_prompt"] = tool_parameters.get("negative_prompt", "")
-
- response = post(
- self.model_endpoint_map[tool_parameters.get("model", "core")],
- headers={
- "accept": "image/*",
- **self.generate_authorization_headers(self.runtime.credentials),
- },
- files={key: (None, str(value)) for key, value in payload.items()},
- timeout=(5, 30),
- )
-
- if not response.status_code == 200:
- raise Exception(response.text)
-
- return self.create_blob_message(
- blob=response.content, meta={"mime_type": "image/png"}, save_as=self.VariableKey.IMAGE.value
- )
diff --git a/api/core/tools/provider/builtin/stability/tools/text2image.yaml b/api/core/tools/provider/builtin/stability/tools/text2image.yaml
deleted file mode 100644
index 21345f9f18..0000000000
--- a/api/core/tools/provider/builtin/stability/tools/text2image.yaml
+++ /dev/null
@@ -1,142 +0,0 @@
-identity:
- name: stability_text2image
- author: Dify
- label:
- en_US: StableDiffusion
- zh_Hans: 稳定扩散
- pt_BR: StableDiffusion
-description:
- human:
- en_US: A tool for generate images based on the text input
- zh_Hans: 一个基于文本输入生成图像的工具
- pt_BR: A tool for generate images based on the text input
- llm: A tool for generate images based on the text input
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: Prompt
- zh_Hans: 提示词
- pt_BR: Prompt
- human_description:
- en_US: used for generating images
- zh_Hans: 用于生成图像
- pt_BR: used for generating images
- llm_description: key words for generating images
- form: llm
- - name: model
- type: select
- default: sd3-turbo
- required: true
- label:
- en_US: Model
- zh_Hans: 模型
- pt_BR: Model
- options:
- - value: core
- label:
- en_US: Core
- zh_Hans: Core
- pt_BR: Core
- - value: sd3
- label:
- en_US: Stable Diffusion 3
- zh_Hans: Stable Diffusion 3
- pt_BR: Stable Diffusion 3
- - value: sd3-turbo
- label:
- en_US: Stable Diffusion 3 Turbo
- zh_Hans: Stable Diffusion 3 Turbo
- pt_BR: Stable Diffusion 3 Turbo
- human_description:
- en_US: Model for generating images
- zh_Hans: 用于生成图像的模型
- pt_BR: Model for generating images
- llm_description: Model for generating images
- form: form
- - name: negative_prompt
- type: string
- default: bad art, ugly, deformed, watermark, duplicated, discontinuous lines
- required: false
- label:
- en_US: Negative Prompt
- zh_Hans: 负面提示
- pt_BR: Negative Prompt
- human_description:
- en_US: Negative Prompt
- zh_Hans: 负面提示
- pt_BR: Negative Prompt
- llm_description: Negative Prompt
- form: form
- - name: seeds
- type: number
- default: 0
- required: false
- label:
- en_US: Seeds
- zh_Hans: 种子
- pt_BR: Seeds
- human_description:
- en_US: Seeds
- zh_Hans: 种子
- pt_BR: Seeds
- llm_description: Seeds
- min: 0
- max: 4294967294
- form: form
- - name: aspect_ratio
- type: select
- default: '16:9'
- options:
- - value: '16:9'
- label:
- en_US: '16:9'
- zh_Hans: '16:9'
- pt_BR: '16:9'
- - value: '1:1'
- label:
- en_US: '1:1'
- zh_Hans: '1:1'
- pt_BR: '1:1'
- - value: '21:9'
- label:
- en_US: '21:9'
- zh_Hans: '21:9'
- pt_BR: '21:9'
- - value: '2:3'
- label:
- en_US: '2:3'
- zh_Hans: '2:3'
- pt_BR: '2:3'
- - value: '4:5'
- label:
- en_US: '4:5'
- zh_Hans: '4:5'
- pt_BR: '4:5'
- - value: '5:4'
- label:
- en_US: '5:4'
- zh_Hans: '5:4'
- pt_BR: '5:4'
- - value: '9:16'
- label:
- en_US: '9:16'
- zh_Hans: '9:16'
- pt_BR: '9:16'
- - value: '9:21'
- label:
- en_US: '9:21'
- zh_Hans: '9:21'
- pt_BR: '9:21'
- required: false
- label:
- en_US: Aspect Ratio
- zh_Hans: 长宽比
- pt_BR: Aspect Ratio
- human_description:
- en_US: Aspect Ratio
- zh_Hans: 长宽比
- pt_BR: Aspect Ratio
- llm_description: Aspect Ratio
- form: form
diff --git a/api/core/tools/provider/builtin/stablediffusion/_assets/icon.png b/api/core/tools/provider/builtin/stablediffusion/_assets/icon.png
deleted file mode 100644
index fc372b28f1..0000000000
Binary files a/api/core/tools/provider/builtin/stablediffusion/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/stablediffusion/stablediffusion.py b/api/core/tools/provider/builtin/stablediffusion/stablediffusion.py
deleted file mode 100644
index abaa297cf3..0000000000
--- a/api/core/tools/provider/builtin/stablediffusion/stablediffusion.py
+++ /dev/null
@@ -1,17 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.stablediffusion.tools.stable_diffusion import StableDiffusionTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class StableDiffusionProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- StableDiffusionTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).validate_models()
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/stablediffusion/stablediffusion.yaml b/api/core/tools/provider/builtin/stablediffusion/stablediffusion.yaml
deleted file mode 100644
index 9b3c804f72..0000000000
--- a/api/core/tools/provider/builtin/stablediffusion/stablediffusion.yaml
+++ /dev/null
@@ -1,42 +0,0 @@
-identity:
- author: Dify
- name: stablediffusion
- label:
- en_US: Stable Diffusion
- zh_Hans: Stable Diffusion
- pt_BR: Stable Diffusion
- description:
- en_US: Stable Diffusion is a tool for generating images which can be deployed locally.
- zh_Hans: Stable Diffusion 是一个可以在本地部署的图片生成的工具。
- pt_BR: Stable Diffusion is a tool for generating images which can be deployed locally.
- icon: icon.png
- tags:
- - image
-credentials_for_provider:
- base_url:
- type: secret-input
- required: true
- label:
- en_US: Base URL
- zh_Hans: StableDiffusion服务器的Base URL
- pt_BR: Base URL
- placeholder:
- en_US: Please input your StableDiffusion server's Base URL
- zh_Hans: 请输入你的 StableDiffusion 服务器的 Base URL
- pt_BR: Please input your StableDiffusion server's Base URL
- model:
- type: text-input
- required: true
- label:
- en_US: Model
- zh_Hans: 模型
- pt_BR: Model
- placeholder:
- en_US: Please input your model
- zh_Hans: 请输入你的模型名称
- pt_BR: Please input your model
- help:
- en_US: The model name of the StableDiffusion server
- zh_Hans: StableDiffusion服务器的模型名称
- pt_BR: The model name of the StableDiffusion server
- url: https://docs.dify.ai/tutorials/tool-configuration/stable-diffusion
diff --git a/api/core/tools/provider/builtin/stablediffusion/tools/stable_diffusion.py b/api/core/tools/provider/builtin/stablediffusion/tools/stable_diffusion.py
deleted file mode 100644
index 64fdc961b4..0000000000
--- a/api/core/tools/provider/builtin/stablediffusion/tools/stable_diffusion.py
+++ /dev/null
@@ -1,390 +0,0 @@
-import io
-import json
-from base64 import b64decode, b64encode
-from copy import deepcopy
-from typing import Any, Union
-
-from httpx import get, post
-from PIL import Image
-from yarl import URL
-
-from core.tools.entities.common_entities import I18nObject
-from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameter, ToolParameterOption
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.tool.builtin_tool import BuiltinTool
-
-# All commented out parameters default to null
-DRAW_TEXT_OPTIONS = {
- # Prompts
- "prompt": "",
- "negative_prompt": "",
- # "styles": [],
- # Seeds
- "seed": -1,
- "subseed": -1,
- "subseed_strength": 0,
- "seed_resize_from_h": -1,
- "seed_resize_from_w": -1,
- # Samplers
- "sampler_name": "DPM++ 2M",
- # "scheduler": "",
- # "sampler_index": "Automatic",
- # Latent Space Options
- "batch_size": 1,
- "n_iter": 1,
- "steps": 10,
- "cfg_scale": 7,
- "width": 512,
- "height": 512,
- # "restore_faces": True,
- # "tiling": True,
- "do_not_save_samples": False,
- "do_not_save_grid": False,
- # "eta": 0,
- # "denoising_strength": 0.75,
- # "s_min_uncond": 0,
- # "s_churn": 0,
- # "s_tmax": 0,
- # "s_tmin": 0,
- # "s_noise": 0,
- "override_settings": {},
- "override_settings_restore_afterwards": True,
- # Refinement Options
- "refiner_checkpoint": "",
- "refiner_switch_at": 0,
- "disable_extra_networks": False,
- # "firstpass_image": "",
- # "comments": "",
- # High-Resolution Options
- "enable_hr": False,
- "firstphase_width": 0,
- "firstphase_height": 0,
- "hr_scale": 2,
- # "hr_upscaler": "",
- "hr_second_pass_steps": 0,
- "hr_resize_x": 0,
- "hr_resize_y": 0,
- # "hr_checkpoint_name": "",
- # "hr_sampler_name": "",
- # "hr_scheduler": "",
- "hr_prompt": "",
- "hr_negative_prompt": "",
- # Task Options
- # "force_task_id": "",
- # Script Options
- # "script_name": "",
- "script_args": [],
- # Output Options
- "send_images": True,
- "save_images": False,
- "alwayson_scripts": {},
- # "infotext": "",
-}
-
-
-class StableDiffusionTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- # base url
- base_url = self.runtime.credentials.get("base_url", None)
- if not base_url:
- return self.create_text_message("Please input base_url")
-
- if tool_parameters.get("model"):
- self.runtime.credentials["model"] = tool_parameters["model"]
-
- model = self.runtime.credentials.get("model", None)
- if not model:
- return self.create_text_message("Please input model")
-
- # set model
- try:
- url = str(URL(base_url) / "sdapi" / "v1" / "options")
- response = post(url, data=json.dumps({"sd_model_checkpoint": model}))
- if response.status_code != 200:
- raise ToolProviderCredentialValidationError("Failed to set model, please tell user to set model")
- except Exception as e:
- raise ToolProviderCredentialValidationError("Failed to set model, please tell user to set model")
-
- # get image id and image variable
- image_id = tool_parameters.get("image_id", "")
- image_variable = self.get_default_image_variable()
- # Return text2img if there's no image ID or no image variable
- if not image_id or not image_variable:
- return self.text2img(base_url=base_url, tool_parameters=tool_parameters)
-
- # Proceed with image-to-image generation
- return self.img2img(base_url=base_url, tool_parameters=tool_parameters)
-
- def validate_models(self) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- validate models
- """
- try:
- base_url = self.runtime.credentials.get("base_url", None)
- if not base_url:
- raise ToolProviderCredentialValidationError("Please input base_url")
- model = self.runtime.credentials.get("model", None)
- if not model:
- raise ToolProviderCredentialValidationError("Please input model")
-
- api_url = str(URL(base_url) / "sdapi" / "v1" / "sd-models")
- response = get(url=api_url, timeout=10)
- if response.status_code == 404:
- # try draw a picture
- self._invoke(
- user_id="test",
- tool_parameters={
- "prompt": "a cat",
- "width": 1024,
- "height": 1024,
- "steps": 1,
- "lora": "",
- },
- )
- elif response.status_code != 200:
- raise ToolProviderCredentialValidationError("Failed to get models")
- else:
- models = [d["model_name"] for d in response.json()]
- if len([d for d in models if d == model]) > 0:
- return self.create_text_message(json.dumps(models))
- else:
- raise ToolProviderCredentialValidationError(f"model {model} does not exist")
- except Exception as e:
- raise ToolProviderCredentialValidationError(f"Failed to get models, {e}")
-
- def get_sd_models(self) -> list[str]:
- """
- get sd models
- """
- try:
- base_url = self.runtime.credentials.get("base_url", None)
- if not base_url:
- return []
- api_url = str(URL(base_url) / "sdapi" / "v1" / "sd-models")
- response = get(url=api_url, timeout=(2, 10))
- if response.status_code != 200:
- return []
- else:
- return [d["model_name"] for d in response.json()]
- except Exception as e:
- return []
-
- def get_sample_methods(self) -> list[str]:
- """
- get sample method
- """
- try:
- base_url = self.runtime.credentials.get("base_url", None)
- if not base_url:
- return []
- api_url = str(URL(base_url) / "sdapi" / "v1" / "samplers")
- response = get(url=api_url, timeout=(2, 10))
- if response.status_code != 200:
- return []
- else:
- return [d["name"] for d in response.json()]
- except Exception as e:
- return []
-
- def img2img(
- self, base_url: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- generate image
- """
-
- # Fetch the binary data of the image
- image_variable = self.get_default_image_variable()
- image_binary = self.get_variable_file(image_variable.name)
- if not image_binary:
- return self.create_text_message("Image not found, please request user to generate image firstly.")
-
- # Convert image to RGB and save as PNG
- try:
- with Image.open(io.BytesIO(image_binary)) as image, io.BytesIO() as buffer:
- image.convert("RGB").save(buffer, format="PNG")
- image_binary = buffer.getvalue()
- except Exception as e:
- return self.create_text_message(f"Failed to process the image: {str(e)}")
-
- # copy draw options
- draw_options = deepcopy(DRAW_TEXT_OPTIONS)
- # set image options
- model = tool_parameters.get("model", "")
- draw_options_image = {
- "init_images": [b64encode(image_binary).decode("utf-8")],
- "denoising_strength": 0.9,
- "restore_faces": False,
- "script_args": [],
- "override_settings": {"sd_model_checkpoint": model},
- "resize_mode": 0,
- "image_cfg_scale": 0,
- # "mask": None,
- "mask_blur_x": 4,
- "mask_blur_y": 4,
- "mask_blur": 0,
- "mask_round": True,
- "inpainting_fill": 0,
- "inpaint_full_res": True,
- "inpaint_full_res_padding": 0,
- "inpainting_mask_invert": 0,
- "initial_noise_multiplier": 0,
- # "latent_mask": None,
- "include_init_images": True,
- }
- # update key and values
- draw_options.update(draw_options_image)
- draw_options.update(tool_parameters)
-
- # get prompt lora model
- prompt = tool_parameters.get("prompt", "")
- lora = tool_parameters.get("lora", "")
- model = tool_parameters.get("model", "")
- if lora:
- draw_options["prompt"] = f"{lora},{prompt}"
- else:
- draw_options["prompt"] = prompt
-
- try:
- url = str(URL(base_url) / "sdapi" / "v1" / "img2img")
- response = post(url, data=json.dumps(draw_options), timeout=120)
- if response.status_code != 200:
- return self.create_text_message("Failed to generate image")
-
- image = response.json()["images"][0]
-
- return self.create_blob_message(
- blob=b64decode(image), meta={"mime_type": "image/png"}, save_as=self.VariableKey.IMAGE.value
- )
-
- except Exception as e:
- return self.create_text_message("Failed to generate image")
-
- def text2img(
- self, base_url: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- generate image
- """
- # copy draw options
- draw_options = deepcopy(DRAW_TEXT_OPTIONS)
- draw_options.update(tool_parameters)
- # get prompt lora model
- prompt = tool_parameters.get("prompt", "")
- lora = tool_parameters.get("lora", "")
- model = tool_parameters.get("model", "")
- if lora:
- draw_options["prompt"] = f"{lora},{prompt}"
- else:
- draw_options["prompt"] = prompt
- draw_options["override_settings"]["sd_model_checkpoint"] = model
-
- try:
- url = str(URL(base_url) / "sdapi" / "v1" / "txt2img")
- response = post(url, data=json.dumps(draw_options), timeout=120)
- if response.status_code != 200:
- return self.create_text_message("Failed to generate image")
-
- image = response.json()["images"][0]
-
- return self.create_blob_message(
- blob=b64decode(image), meta={"mime_type": "image/png"}, save_as=self.VariableKey.IMAGE.value
- )
-
- except Exception as e:
- return self.create_text_message("Failed to generate image")
-
- def get_runtime_parameters(self) -> list[ToolParameter]:
- parameters = [
- ToolParameter(
- name="prompt",
- label=I18nObject(en_US="Prompt", zh_Hans="Prompt"),
- human_description=I18nObject(
- en_US="Image prompt, you can check the official documentation of Stable Diffusion",
- zh_Hans="图像提示词,您可以查看 Stable Diffusion 的官方文档",
- ),
- type=ToolParameter.ToolParameterType.STRING,
- form=ToolParameter.ToolParameterForm.LLM,
- llm_description="Image prompt of Stable Diffusion, you should describe the image you want to generate"
- " as a list of words as possible as detailed, the prompt must be written in English.",
- required=True,
- ),
- ]
- if len(self.list_default_image_variables()) != 0:
- parameters.append(
- ToolParameter(
- name="image_id",
- label=I18nObject(en_US="image_id", zh_Hans="image_id"),
- human_description=I18nObject(
- en_US="Image id of the image you want to generate based on, if you want to generate image based"
- " on the default image, you can leave this field empty.",
- zh_Hans="您想要生成的图像的图像 ID,如果您想要基于默认图像生成图像,则可以将此字段留空。",
- ),
- type=ToolParameter.ToolParameterType.STRING,
- form=ToolParameter.ToolParameterForm.LLM,
- llm_description="Image id of the original image, you can leave this field empty if you want to"
- " generate a new image.",
- required=True,
- options=[
- ToolParameterOption(value=i.name, label=I18nObject(en_US=i.name, zh_Hans=i.name))
- for i in self.list_default_image_variables()
- ],
- )
- )
-
- if self.runtime.credentials:
- try:
- models = self.get_sd_models()
- if len(models) != 0:
- parameters.append(
- ToolParameter(
- name="model",
- label=I18nObject(en_US="Model", zh_Hans="Model"),
- human_description=I18nObject(
- en_US="Model of Stable Diffusion, you can check the official documentation"
- " of Stable Diffusion",
- zh_Hans="Stable Diffusion 的模型,您可以查看 Stable Diffusion 的官方文档",
- ),
- type=ToolParameter.ToolParameterType.SELECT,
- form=ToolParameter.ToolParameterForm.FORM,
- llm_description="Model of Stable Diffusion, you can check the official documentation"
- " of Stable Diffusion",
- required=True,
- default=models[0],
- options=[
- ToolParameterOption(value=i, label=I18nObject(en_US=i, zh_Hans=i)) for i in models
- ],
- )
- )
-
- except:
- pass
-
- sample_methods = self.get_sample_methods()
- if len(sample_methods) != 0:
- parameters.append(
- ToolParameter(
- name="sampler_name",
- label=I18nObject(en_US="Sampling method", zh_Hans="Sampling method"),
- human_description=I18nObject(
- en_US="Sampling method of Stable Diffusion, you can check the official documentation"
- " of Stable Diffusion",
- zh_Hans="Stable Diffusion 的Sampling method,您可以查看 Stable Diffusion 的官方文档",
- ),
- type=ToolParameter.ToolParameterType.SELECT,
- form=ToolParameter.ToolParameterForm.FORM,
- llm_description="Sampling method of Stable Diffusion, you can check the official documentation"
- " of Stable Diffusion",
- required=True,
- default=sample_methods[0],
- options=[
- ToolParameterOption(value=i, label=I18nObject(en_US=i, zh_Hans=i)) for i in sample_methods
- ],
- )
- )
- return parameters
diff --git a/api/core/tools/provider/builtin/stablediffusion/tools/stable_diffusion.yaml b/api/core/tools/provider/builtin/stablediffusion/tools/stable_diffusion.yaml
deleted file mode 100644
index bbbdb16caf..0000000000
--- a/api/core/tools/provider/builtin/stablediffusion/tools/stable_diffusion.yaml
+++ /dev/null
@@ -1,104 +0,0 @@
-identity:
- name: stable_diffusion
- author: Dify
- label:
- en_US: Stable Diffusion WebUI
- zh_Hans: Stable Diffusion WebUI
- pt_BR: Stable Diffusion WebUI
-description:
- human:
- en_US: A tool for generating images which can be deployed locally, you can use stable-diffusion-webui to deploy it.
- zh_Hans: 一个可以在本地部署的图片生成的工具,您可以使用 stable-diffusion-webui 来部署它。
- pt_BR: A tool for generating images which can be deployed locally, you can use stable-diffusion-webui to deploy it.
- llm: draw the image you want based on your prompt.
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: Prompt
- zh_Hans: 提示词
- pt_BR: Prompt
- human_description:
- en_US: Image prompt, you can check the official documentation of Stable Diffusion
- zh_Hans: 图像提示词,您可以查看 Stable Diffusion 的官方文档
- pt_BR: Image prompt, you can check the official documentation of Stable Diffusion
- llm_description: Image prompt of Stable Diffusion, you should describe the image you want to generate as a list of words as possible as detailed, the prompt must be written in English.
- form: llm
- - name: model
- type: string
- required: false
- label:
- en_US: Model Name
- zh_Hans: 模型名称
- pt_BR: Model Name
- human_description:
- en_US: Model Name
- zh_Hans: 模型名称
- pt_BR: Model Name
- form: form
- - name: lora
- type: string
- required: false
- label:
- en_US: Lora
- zh_Hans: Lora
- pt_BR: Lora
- human_description:
- en_US: Lora
- zh_Hans: Lora
- pt_BR: Lora
- form: form
- default: ""
- - name: steps
- type: number
- required: false
- label:
- en_US: Steps
- zh_Hans: Steps
- pt_BR: Steps
- human_description:
- en_US: Steps
- zh_Hans: Steps
- pt_BR: Steps
- form: form
- default: 10
- - name: width
- type: number
- required: false
- label:
- en_US: Width
- zh_Hans: Width
- pt_BR: Width
- human_description:
- en_US: Width
- zh_Hans: Width
- pt_BR: Width
- form: form
- default: 1024
- - name: height
- type: number
- required: false
- label:
- en_US: Height
- zh_Hans: Height
- pt_BR: Height
- human_description:
- en_US: Height
- zh_Hans: Height
- pt_BR: Height
- form: form
- default: 1024
- - name: negative_prompt
- type: string
- required: false
- label:
- en_US: Negative prompt
- zh_Hans: Negative prompt
- pt_BR: Negative prompt
- human_description:
- en_US: Negative prompt
- zh_Hans: Negative prompt
- pt_BR: Negative prompt
- form: form
- default: bad art, ugly, deformed, watermark, duplicated, discontinuous lines
diff --git a/api/core/tools/provider/builtin/stackexchange/_assets/icon.svg b/api/core/tools/provider/builtin/stackexchange/_assets/icon.svg
deleted file mode 100644
index 7042bc0e41..0000000000
--- a/api/core/tools/provider/builtin/stackexchange/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/stackexchange/stackexchange.py b/api/core/tools/provider/builtin/stackexchange/stackexchange.py
deleted file mode 100644
index 9680c633cc..0000000000
--- a/api/core/tools/provider/builtin/stackexchange/stackexchange.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.stackexchange.tools.searchStackExQuestions import SearchStackExQuestionsTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class StackExchangeProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- SearchStackExQuestionsTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "intitle": "Test",
- "sort": "relevance",
- "order": "desc",
- "site": "stackoverflow",
- "accepted": True,
- "pagesize": 1,
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/stackexchange/stackexchange.yaml b/api/core/tools/provider/builtin/stackexchange/stackexchange.yaml
deleted file mode 100644
index d382a3cca9..0000000000
--- a/api/core/tools/provider/builtin/stackexchange/stackexchange.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-identity:
- author: Richards Tu
- name: stackexchange
- label:
- en_US: Stack Exchange
- zh_Hans: Stack Exchange
- description:
- en_US: Access questions and answers from the Stack Exchange and its sub-sites.
- zh_Hans: 从 Stack Exchange 和其子论坛获取问题和答案。
- icon: icon.svg
- tags:
- - search
- - utilities
diff --git a/api/core/tools/provider/builtin/stackexchange/tools/fetchAnsByStackExQuesID.py b/api/core/tools/provider/builtin/stackexchange/tools/fetchAnsByStackExQuesID.py
deleted file mode 100644
index 5345320095..0000000000
--- a/api/core/tools/provider/builtin/stackexchange/tools/fetchAnsByStackExQuesID.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from typing import Any, Union
-
-import requests
-from pydantic import BaseModel, Field
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class FetchAnsByStackExQuesIDInput(BaseModel):
- id: int = Field(..., description="The question ID")
- site: str = Field(..., description="The Stack Exchange site")
- order: str = Field(..., description="asc or desc")
- sort: str = Field(..., description="activity, votes, creation")
- pagesize: int = Field(..., description="Number of answers per page")
- page: int = Field(..., description="Page number")
-
-
-class FetchAnsByStackExQuesIDTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- input = FetchAnsByStackExQuesIDInput(**tool_parameters)
-
- params = {
- "site": input.site,
- "filter": "!nNPvSNdWme",
- "order": input.order,
- "sort": input.sort,
- "pagesize": input.pagesize,
- "page": input.page,
- }
-
- response = requests.get(f"https://api.stackexchange.com/2.3/questions/{input.id}/answers", params=params)
-
- if response.status_code == 200:
- return self.create_text_message(self.summary(user_id=user_id, content=response.text))
- else:
- return self.create_text_message(f"API request failed with status code {response.status_code}")
diff --git a/api/core/tools/provider/builtin/stackexchange/tools/fetchAnsByStackExQuesID.yaml b/api/core/tools/provider/builtin/stackexchange/tools/fetchAnsByStackExQuesID.yaml
deleted file mode 100644
index d663bce609..0000000000
--- a/api/core/tools/provider/builtin/stackexchange/tools/fetchAnsByStackExQuesID.yaml
+++ /dev/null
@@ -1,107 +0,0 @@
-identity:
- name: fetchAnsByStackExQuesID
- author: Richards Tu
- label:
- en_US: Fetch Stack Exchange Answers
- zh_Hans: 获取 Stack Exchange 答案
-description:
- human:
- en_US: A tool for retrieving answers for a specific Stack Exchange question ID. Must be used with the searchStackExQuesID tool.
- zh_Hans: 用于检索特定Stack Exchange问题ID的答案的工具。必须与searchStackExQuesID工具一起使用。
- llm: A tool for retrieving answers for Stack Exchange question ID.
-parameters:
- - name: id
- type: string
- required: true
- label:
- en_US: Question ID
- zh_Hans: 问题ID
- human_description:
- en_US: The ID of the Stack Exchange question to fetch answers for.
- zh_Hans: 要获取答案的Stack Exchange问题的ID。
- llm_description: The ID of the Stack Exchange question.
- form: llm
- - name: site
- type: string
- required: true
- label:
- en_US: Stack Exchange site
- zh_Hans: Stack Exchange站点
- human_description:
- en_US: The Stack Exchange site the question is from, e.g. stackoverflow, unix, etc.
- zh_Hans: 问题所在的Stack Exchange站点,例如stackoverflow、unix等。
- llm_description: Stack Exchange site identifier - 'stackoverflow', 'serverfault', 'superuser', 'askubuntu', 'unix', 'cs', 'softwareengineering', 'codegolf', 'codereview', 'cstheory', 'security', 'cryptography', 'reverseengineering', 'datascience', 'devops', 'ux', 'dba', 'gis', 'webmasters', 'arduino', 'raspberrypi', 'networkengineering', 'iot', 'tor', 'sqa', 'mathoverflow', 'math', 'mathematica', 'dsp', 'gamedev', 'robotics', 'genai', 'computergraphics'.
- form: llm
- - name: filter
- type: string
- required: true
- label:
- en_US: Filter
- zh_Hans: 过滤器
- human_description:
- en_US: This is required in order to actually get the body of the answer.
- zh_Hans: 为了实际获取答案的正文是必需的。
- options:
- - value: "!nNPvSNdWme"
- label:
- en_US: Must Select
- zh_Hans: 必须选择
- form: form
- default: "!nNPvSNdWme"
- - name: order
- type: string
- required: true
- label:
- en_US: Sort direction
- zh_Hans: 排序方向
- human_description:
- en_US: The direction to sort the answers - ascending or descending.
- zh_Hans: 答案的排序方向 - 升序或降序。
- form: form
- options:
- - value: asc
- label:
- en_US: Ascending
- zh_Hans: 升序
- - value: desc
- label:
- en_US: Descending
- zh_Hans: 降序
- default: desc
- - name: sort
- type: string
- required: true
- label:
- en_US: Sort order
- zh_Hans: 排序
- human_description:
- en_US: The sort order for the answers - activity, votes, or creation date.
- zh_Hans: 答案的排序顺序 - 活动、投票或创建日期。
- llm_description: activity, votes, or creation.
- form: llm
- - name: pagesize
- type: number
- required: true
- label:
- en_US: Results per page
- zh_Hans: 每页结果数
- human_description:
- en_US: The number of answers to return per page.
- zh_Hans: 每页返回的答案数。
- form: form
- min: 1
- max: 5
- default: 1
- - name: page
- type: number
- required: true
- label:
- en_US: Page number
- zh_Hans: 页码
- human_description:
- en_US: The page number of answers to retrieve.
- zh_Hans: 要检索的答案的页码。
- form: form
- min: 1
- max: 5
- default: 3
diff --git a/api/core/tools/provider/builtin/stackexchange/tools/searchStackExQuestions.py b/api/core/tools/provider/builtin/stackexchange/tools/searchStackExQuestions.py
deleted file mode 100644
index 4a25a808ad..0000000000
--- a/api/core/tools/provider/builtin/stackexchange/tools/searchStackExQuestions.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from typing import Any, Union
-
-import requests
-from pydantic import BaseModel, Field
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class SearchStackExQuestionsInput(BaseModel):
- intitle: str = Field(..., description="The search query.")
- sort: str = Field(..., description="The sort order - relevance, activity, votes, creation.")
- order: str = Field(..., description="asc or desc")
- site: str = Field(..., description="The Stack Exchange site.")
- tagged: str = Field(None, description="Semicolon-separated tags to include.")
- nottagged: str = Field(None, description="Semicolon-separated tags to exclude.")
- accepted: bool = Field(..., description="true for only accepted answers, false otherwise")
- pagesize: int = Field(..., description="Number of results per page")
-
-
-class SearchStackExQuestionsTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- input = SearchStackExQuestionsInput(**tool_parameters)
-
- params = {
- "intitle": input.intitle,
- "sort": input.sort,
- "order": input.order,
- "site": input.site,
- "accepted": input.accepted,
- "pagesize": input.pagesize,
- }
- if input.tagged:
- params["tagged"] = input.tagged
- if input.nottagged:
- params["nottagged"] = input.nottagged
-
- response = requests.get("https://api.stackexchange.com/2.3/search", params=params)
-
- if response.status_code == 200:
- return self.create_text_message(self.summary(user_id=user_id, content=response.text))
- else:
- return self.create_text_message(f"API request failed with status code {response.status_code}")
diff --git a/api/core/tools/provider/builtin/stackexchange/tools/searchStackExQuestions.yaml b/api/core/tools/provider/builtin/stackexchange/tools/searchStackExQuestions.yaml
deleted file mode 100644
index bbfbae38b0..0000000000
--- a/api/core/tools/provider/builtin/stackexchange/tools/searchStackExQuestions.yaml
+++ /dev/null
@@ -1,121 +0,0 @@
-identity:
- name: searchStackExQuestions
- author: Richards Tu
- label:
- en_US: Search Stack Exchange Questions
- zh_Hans: 搜索Stack Exchange问题
-description:
- human:
- en_US: A tool for searching questions on a Stack Exchange site.
- zh_Hans: 在Stack Exchange站点上搜索问题的工具。
- llm: A tool for searching questions on Stack Exchange site.
-parameters:
- - name: intitle
- type: string
- required: true
- label:
- en_US: Search query
- zh_Hans: 搜索查询
- human_description:
- en_US: The search query to use for finding questions.
- zh_Hans: 用于查找问题的搜索查询。
- llm_description: The search query.
- form: llm
- - name: sort
- type: string
- required: true
- label:
- en_US: Sort order
- zh_Hans: 排序
- human_description:
- en_US: The sort order for the search results - relevance, activity, votes, or creation date.
- zh_Hans: 搜索结果的排序顺序 - 相关性、活动、投票或创建日期。
- llm_description: The sort order - 'relevance', 'activity', 'votes', or 'creation'.
- form: llm
- - name: order
- type: select
- required: true
- label:
- en_US: Sort direction
- zh_Hans: 排序方向
- human_description:
- en_US: The direction to sort - ascending or descending.
- zh_Hans: 排序方向 - 升序或降序。
- form: form
- options:
- - value: asc
- label:
- en_US: Ascending
- zh_Hans: 升序
- - value: desc
- label:
- en_US: Descending
- zh_Hans: 降序
- default: desc
- - name: site
- type: string
- required: true
- label:
- en_US: Stack Exchange site
- zh_Hans: Stack Exchange 站点
- human_description:
- en_US: The Stack Exchange site to search, e.g. stackoverflow, unix, etc.
- zh_Hans: 要搜索的Stack Exchange站点,例如stackoverflow、unix等。
- llm_description: Stack Exchange site identifier - 'stackoverflow', 'serverfault', 'superuser', 'askubuntu', 'unix', 'cs', 'softwareengineering', 'codegolf', 'codereview', 'cstheory', 'security', 'cryptography', 'reverseengineering', 'datascience', 'devops', 'ux', 'dba', 'gis', 'webmasters', 'arduino', 'raspberrypi', 'networkengineering', 'iot', 'tor', 'sqa', 'mathoverflow', 'math', 'mathematica', 'dsp', 'gamedev', 'robotics', 'genai', 'computergraphics'.
- form: llm
- - name: tagged
- type: string
- required: false
- label:
- en_US: Include tags
- zh_Hans: 包含标签
- human_description:
- en_US: A semicolon-separated list of tags that questions must have.
- zh_Hans: 问题必须具有的标签的分号分隔列表。
- llm_description: Semicolon-separated tags to include. Leave blank if not needed.
- form: llm
- - name: nottagged
- type: string
- required: false
- label:
- en_US: Exclude tags
- zh_Hans: 排除标签
- human_description:
- en_US: A semicolon-separated list of tags to exclude from the search.
- zh_Hans: 从搜索中排除的标签的分号分隔列表。
- llm_description: Semicolon-separated tags to exclude. Leave blank if not needed.
- form: llm
- - name: accepted
- type: boolean
- required: true
- label:
- en_US: Has accepted answer
- zh_Hans: 有已接受的答案
- human_description:
- en_US: Whether to limit to only questions that have an accepted answer.
- zh_Hans: 是否限制为只有已接受答案的问题。
- form: form
- options:
- - value: 'true'
- label:
- en_US: 'Yes'
- zh_Hans: 是
- - value: 'false'
- label:
- en_US: 'No'
- zh_Hans: 否
- default: 'true'
- - name: pagesize
- type: number
- required: true
- label:
- en_US: Results per page
- zh_Hans: 每页结果数
- human_description:
- en_US: The number of results to return per page.
- zh_Hans: 每页返回的结果数。
- llm_description: The number of results per page.
- form: form
- min: 1
- max: 50
- default: 10
diff --git a/api/core/tools/provider/builtin/stepfun/__init__.py b/api/core/tools/provider/builtin/stepfun/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/api/core/tools/provider/builtin/stepfun/_assets/icon.png b/api/core/tools/provider/builtin/stepfun/_assets/icon.png
deleted file mode 100644
index 85b96d0c74..0000000000
Binary files a/api/core/tools/provider/builtin/stepfun/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/stepfun/stepfun.py b/api/core/tools/provider/builtin/stepfun/stepfun.py
deleted file mode 100644
index b24f730c95..0000000000
--- a/api/core/tools/provider/builtin/stepfun/stepfun.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.stepfun.tools.image import StepfunTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class StepfunProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- StepfunTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "prompt": "cute girl, blue eyes, white hair, anime style",
- "size": "1024x1024",
- "n": 1,
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/stepfun/stepfun.yaml b/api/core/tools/provider/builtin/stepfun/stepfun.yaml
deleted file mode 100644
index 1f841ec369..0000000000
--- a/api/core/tools/provider/builtin/stepfun/stepfun.yaml
+++ /dev/null
@@ -1,46 +0,0 @@
-identity:
- author: Stepfun
- name: stepfun
- label:
- en_US: Image-1X
- zh_Hans: 阶跃星辰绘画
- pt_BR: Image-1X
- description:
- en_US: Image-1X
- zh_Hans: 阶跃星辰绘画
- pt_BR: Image-1X
- icon: icon.png
- tags:
- - image
- - productivity
-credentials_for_provider:
- stepfun_api_key:
- type: secret-input
- required: true
- label:
- en_US: Stepfun API key
- zh_Hans: 阶跃星辰API key
- pt_BR: Stepfun API key
- help:
- en_US: Please input your stepfun API key
- zh_Hans: 请输入你的阶跃星辰 API key
- pt_BR: Please input your stepfun API key
- placeholder:
- en_US: Please input your stepfun API key
- zh_Hans: 请输入你的阶跃星辰 API key
- pt_BR: Please input your stepfun API key
- stepfun_base_url:
- type: text-input
- required: false
- label:
- en_US: Stepfun base URL
- zh_Hans: 阶跃星辰 base URL
- pt_BR: Stepfun base URL
- help:
- en_US: Please input your Stepfun base URL
- zh_Hans: 请输入你的阶跃星辰 base URL
- pt_BR: Please input your Stepfun base URL
- placeholder:
- en_US: Please input your Stepfun base URL
- zh_Hans: 请输入你的阶跃星辰 base URL
- pt_BR: Please input your Stepfun base URL
diff --git a/api/core/tools/provider/builtin/stepfun/tools/image.py b/api/core/tools/provider/builtin/stepfun/tools/image.py
deleted file mode 100644
index 0b92b122bf..0000000000
--- a/api/core/tools/provider/builtin/stepfun/tools/image.py
+++ /dev/null
@@ -1,75 +0,0 @@
-import random
-from typing import Any, Union
-
-from openai import OpenAI
-from yarl import URL
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class StepfunTool(BuiltinTool):
- """Stepfun Image Generation Tool"""
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- base_url = self.runtime.credentials.get("stepfun_base_url", "https://api.stepfun.com")
- base_url = str(URL(base_url) / "v1")
-
- client = OpenAI(
- api_key=self.runtime.credentials["stepfun_api_key"],
- base_url=base_url,
- )
-
- extra_body = {}
- model = tool_parameters.get("model", "step-1x-medium")
- if not model:
- return self.create_text_message("Please input model name")
- # prompt
- prompt = tool_parameters.get("prompt", "")
- if not prompt:
- return self.create_text_message("Please input prompt")
-
- seed = tool_parameters.get("seed", 0)
- if seed > 0:
- extra_body["seed"] = seed
- steps = tool_parameters.get("steps", 0)
- if steps > 0:
- extra_body["steps"] = steps
- negative_prompt = tool_parameters.get("negative_prompt", "")
- if negative_prompt:
- extra_body["negative_prompt"] = negative_prompt
-
- # call openapi stepfun model
- response = client.images.generate(
- prompt=prompt,
- model=model,
- size=tool_parameters.get("size", "1024x1024"),
- n=tool_parameters.get("n", 1),
- extra_body=extra_body,
- )
- print(response)
-
- result = []
- for image in response.data:
- result.append(self.create_image_message(image=image.url))
- result.append(
- self.create_json_message(
- {
- "url": image.url,
- }
- )
- )
- return result
-
- @staticmethod
- def _generate_random_id(length=8):
- characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
- random_id = "".join(random.choices(characters, k=length))
- return random_id
diff --git a/api/core/tools/provider/builtin/stepfun/tools/image.yaml b/api/core/tools/provider/builtin/stepfun/tools/image.yaml
deleted file mode 100644
index dcc5bd2db2..0000000000
--- a/api/core/tools/provider/builtin/stepfun/tools/image.yaml
+++ /dev/null
@@ -1,158 +0,0 @@
-identity:
- name: stepfun
- author: Stepfun
- label:
- en_US: step-1x
- zh_Hans: 阶跃星辰绘画
- pt_BR: step-1x
- description:
- en_US: step-1x is a powerful drawing tool by stepfun, you can draw the image based on your prompt
- zh_Hans: step-1x 系列是阶跃星辰提供的强大的绘画工具,它可以根据您的提示词绘制出您想要的图像。
- pt_BR: step-1x is a powerful drawing tool by stepfun, you can draw the image based on your prompt
-description:
- human:
- en_US: step-1x is a text to image tool
- zh_Hans: step-1x 是一个文本/图像到图像的工具
- pt_BR: step-1x is a text to image tool
- llm: step-1x is a tool used to generate images from text or image
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: Prompt
- zh_Hans: 提示词
- pt_BR: Prompt
- human_description:
- en_US: Image prompt, you can check the official documentation of step-1x
- zh_Hans: 图像提示词,您可以查看 step-1x 的官方文档
- pt_BR: Image prompt, you can check the official documentation of step-1x
- llm_description: Image prompt of step-1x you should describe the image you want to generate as a list of words as possible as detailed
- form: llm
- - name: model
- type: select
- required: false
- human_description:
- en_US: used for selecting the model name
- zh_Hans: 用于选择模型的名字
- pt_BR: used for selecting the model name
- label:
- en_US: Model Name
- zh_Hans: 模型名字
- pt_BR: Model Name
- form: form
- options:
- - value: step-1x-turbo
- label:
- en_US: turbo
- zh_Hans: turbo
- pt_BR: turbo
- - value: step-1x-medium
- label:
- en_US: medium
- zh_Hans: medium
- pt_BR: medium
- - value: step-1x-large
- label:
- en_US: large
- zh_Hans: large
- pt_BR: large
- default: step-1x-medium
- - name: size
- type: select
- required: false
- human_description:
- en_US: used for selecting the image size
- zh_Hans: 用于选择图像大小
- pt_BR: used for selecting the image size
- label:
- en_US: Image size
- zh_Hans: 图像大小
- pt_BR: Image size
- form: form
- options:
- - value: 256x256
- label:
- en_US: 256x256
- zh_Hans: 256x256
- pt_BR: 256x256
- - value: 512x512
- label:
- en_US: 512x512
- zh_Hans: 512x512
- pt_BR: 512x512
- - value: 768x768
- label:
- en_US: 768x768
- zh_Hans: 768x768
- pt_BR: 768x768
- - value: 1024x1024
- label:
- en_US: 1024x1024
- zh_Hans: 1024x1024
- pt_BR: 1024x1024
- - value: 1280x800
- label:
- en_US: 1280x800
- zh_Hans: 1280x800
- pt_BR: 1280x800
- - value: 800x1280
- label:
- en_US: 800x1280
- zh_Hans: 800x1280
- pt_BR: 800x1280
- default: 1024x1024
- - name: n
- type: number
- required: true
- human_description:
- en_US: used for selecting the number of images
- zh_Hans: 用于选择图像数量
- pt_BR: used for selecting the number of images
- label:
- en_US: Number of images
- zh_Hans: 图像数量
- pt_BR: Number of images
- form: form
- default: 1
- min: 1
- max: 10
- - name: seed
- type: number
- required: false
- label:
- en_US: seed
- zh_Hans: seed
- pt_BR: seed
- human_description:
- en_US: seed
- zh_Hans: seed
- pt_BR: seed
- form: form
- default: 10
- - name: steps
- type: number
- required: false
- label:
- en_US: Steps
- zh_Hans: Steps
- pt_BR: Steps
- human_description:
- en_US: Steps
- zh_Hans: Steps
- pt_BR: Steps
- form: form
- default: 10
- - name: negative_prompt
- type: string
- required: false
- label:
- en_US: Negative prompt
- zh_Hans: Negative prompt
- pt_BR: Negative prompt
- human_description:
- en_US: Negative prompt
- zh_Hans: Negative prompt
- pt_BR: Negative prompt
- form: form
- default: (worst quality:1.3), (nsfw), low quality
diff --git a/api/core/tools/provider/builtin/tavily/_assets/icon.png b/api/core/tools/provider/builtin/tavily/_assets/icon.png
deleted file mode 100644
index fdb40ab568..0000000000
Binary files a/api/core/tools/provider/builtin/tavily/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/tavily/tavily.py b/api/core/tools/provider/builtin/tavily/tavily.py
deleted file mode 100644
index a702b0a74e..0000000000
--- a/api/core/tools/provider/builtin/tavily/tavily.py
+++ /dev/null
@@ -1,29 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.tavily.tools.tavily_search import TavilySearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class TavilyProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- TavilySearchTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "query": "Sachin Tendulkar",
- "search_depth": "basic",
- "include_answer": True,
- "include_images": False,
- "include_raw_content": False,
- "max_results": 5,
- "include_domains": "",
- "exclude_domains": "",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/tavily/tavily.yaml b/api/core/tools/provider/builtin/tavily/tavily.yaml
deleted file mode 100644
index 7b25a81848..0000000000
--- a/api/core/tools/provider/builtin/tavily/tavily.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-identity:
- author: Yash Parmar
- name: tavily
- label:
- en_US: Tavily
- zh_Hans: Tavily
- pt_BR: Tavily
- description:
- en_US: Tavily
- zh_Hans: Tavily
- pt_BR: Tavily
- icon: icon.png
- tags:
- - search
-credentials_for_provider:
- tavily_api_key:
- type: secret-input
- required: true
- label:
- en_US: Tavily API key
- zh_Hans: Tavily API key
- pt_BR: Tavily API key
- placeholder:
- en_US: Please input your Tavily API key
- zh_Hans: 请输入你的 Tavily API key
- pt_BR: Please input your Tavily API key
- help:
- en_US: Get your Tavily API key from Tavily
- zh_Hans: 从 TavilyApi 获取您的 Tavily API key
- pt_BR: Get your Tavily API key from Tavily
- url: https://docs.tavily.com/docs/tavily-api/introduction
diff --git a/api/core/tools/provider/builtin/tavily/tools/tavily_search.py b/api/core/tools/provider/builtin/tavily/tools/tavily_search.py
deleted file mode 100644
index ca6d8633e4..0000000000
--- a/api/core/tools/provider/builtin/tavily/tools/tavily_search.py
+++ /dev/null
@@ -1,124 +0,0 @@
-from typing import Any
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-TAVILY_API_URL = "https://api.tavily.com"
-
-
-class TavilySearch:
- """
- A class for performing search operations using the Tavily Search API.
-
- Args:
- api_key (str): The API key for accessing the Tavily Search API.
-
- Methods:
- raw_results: Retrieves raw search results from the Tavily Search API.
- results: Retrieves cleaned search results from the Tavily Search API.
- clean_results: Cleans the raw search results.
- """
-
- def __init__(self, api_key: str) -> None:
- self.api_key = api_key
-
- def raw_results(self, params: dict[str, Any]) -> dict:
- """
- Retrieves raw search results from the Tavily Search API.
-
- Args:
- params (Dict[str, Any]): The search parameters.
-
- Returns:
- dict: The raw search results.
-
- """
- params["api_key"] = self.api_key
- if (
- "exclude_domains" in params
- and isinstance(params["exclude_domains"], str)
- and params["exclude_domains"] != "None"
- ):
- params["exclude_domains"] = params["exclude_domains"].split()
- else:
- params["exclude_domains"] = []
- if (
- "include_domains" in params
- and isinstance(params["include_domains"], str)
- and params["include_domains"] != "None"
- ):
- params["include_domains"] = params["include_domains"].split()
- else:
- params["include_domains"] = []
-
- response = requests.post(f"{TAVILY_API_URL}/search", json=params)
- response.raise_for_status()
- return response.json()
-
- def results(self, params: dict[str, Any]) -> list[dict]:
- """
- Retrieves cleaned search results from the Tavily Search API.
-
- Args:
- params (Dict[str, Any]): The search parameters.
-
- Returns:
- list: The cleaned search results.
-
- """
- raw_search_results = self.raw_results(params)
- return self.clean_results(raw_search_results["results"])
-
- def clean_results(self, results: list[dict]) -> list[dict]:
- """
- Cleans the raw search results.
-
- Args:
- results (list): The raw search results.
-
- Returns:
- list: The cleaned search results.
-
- """
- clean_results = []
- for result in results:
- clean_results.append(
- {
- "url": result["url"],
- "content": result["content"],
- }
- )
- # return clean results as a string
- return "\n".join([f"{res['url']}\n{res['content']}" for res in clean_results])
-
-
-class TavilySearchTool(BuiltinTool):
- """
- A tool for searching Tavily using a given query.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage | list[ToolInvokeMessage]:
- """
- Invokes the Tavily search tool with the given user ID and tool parameters.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (Dict[str, Any]): The parameters for the Tavily search tool.
-
- Returns:
- ToolInvokeMessage | list[ToolInvokeMessage]: The result of the Tavily search tool invocation.
- """
- query = tool_parameters.get("query", "")
-
- api_key = self.runtime.credentials["tavily_api_key"]
- if not query:
- return self.create_text_message("Please input query")
- tavily_search = TavilySearch(api_key)
- results = tavily_search.results(tool_parameters)
- print(results)
- if not results:
- return self.create_text_message(f"No results found for '{query}' in Tavily")
- else:
- return self.create_text_message(text=results)
diff --git a/api/core/tools/provider/builtin/tavily/tools/tavily_search.yaml b/api/core/tools/provider/builtin/tavily/tools/tavily_search.yaml
deleted file mode 100644
index 88426056af..0000000000
--- a/api/core/tools/provider/builtin/tavily/tools/tavily_search.yaml
+++ /dev/null
@@ -1,162 +0,0 @@
-identity:
- name: tavily_search
- author: Yash Parmar
- label:
- en_US: TavilySearch
- zh_Hans: TavilySearch
- pt_BR: TavilySearch
-description:
- human:
- en_US: A tool for search engine built specifically for AI agents (LLMs), delivering real-time, accurate, and factual results at speed.
- zh_Hans: 专为人工智能代理 (LLM) 构建的搜索引擎工具,可快速提供实时、准确和真实的结果。
- pt_BR: A tool for search engine built specifically for AI agents (LLMs), delivering real-time, accurate, and factual results at speed.
- llm: A tool for search engine built specifically for AI agents (LLMs), delivering real-time, accurate, and factual results at speed.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query string
- zh_Hans: 查询语句
- pt_BR: Query string
- human_description:
- en_US: used for searching
- zh_Hans: 用于搜索网页内容
- pt_BR: used for searching
- llm_description: key words for searching
- form: llm
- - name: search_depth
- type: select
- required: false
- label:
- en_US: Search Depth
- zh_Hans: 搜索深度
- pt_BR: Search Depth
- human_description:
- en_US: The depth of search results
- zh_Hans: 搜索结果的深度
- pt_BR: The depth of search results
- form: form
- options:
- - value: basic
- label:
- en_US: Basic
- zh_Hans: 基本
- pt_BR: Basic
- - value: advanced
- label:
- en_US: Advanced
- zh_Hans: 高级
- pt_BR: Advanced
- default: basic
- - name: include_images
- type: boolean
- required: false
- label:
- en_US: Include Images
- zh_Hans: 包含图片
- pt_BR: Include Images
- human_description:
- en_US: Include images in the search results
- zh_Hans: 在搜索结果中包含图片
- pt_BR: Include images in the search results
- form: form
- options:
- - value: 'true'
- label:
- en_US: 'Yes'
- zh_Hans: 是
- pt_BR: 'Yes'
- - value: 'false'
- label:
- en_US: 'No'
- zh_Hans: 否
- pt_BR: 'No'
- default: 'false'
- - name: include_answer
- type: boolean
- required: false
- label:
- en_US: Include Answer
- zh_Hans: 包含答案
- pt_BR: Include Answer
- human_description:
- en_US: Include answers in the search results
- zh_Hans: 在搜索结果中包含答案
- pt_BR: Include answers in the search results
- form: form
- options:
- - value: 'true'
- label:
- en_US: 'Yes'
- zh_Hans: 是
- pt_BR: 'Yes'
- - value: 'false'
- label:
- en_US: 'No'
- zh_Hans: 否
- pt_BR: 'No'
- default: 'false'
- - name: include_raw_content
- type: boolean
- required: false
- label:
- en_US: Include Raw Content
- zh_Hans: 包含原始内容
- pt_BR: Include Raw Content
- human_description:
- en_US: Include raw content in the search results
- zh_Hans: 在搜索结果中包含原始内容
- pt_BR: Include raw content in the search results
- form: form
- options:
- - value: 'true'
- label:
- en_US: 'Yes'
- zh_Hans: 是
- pt_BR: 'Yes'
- - value: 'false'
- label:
- en_US: 'No'
- zh_Hans: 否
- pt_BR: 'No'
- default: 'false'
- - name: max_results
- type: number
- required: false
- label:
- en_US: Max Results
- zh_Hans: 最大结果
- pt_BR: Max Results
- human_description:
- en_US: The number of maximum search results to return
- zh_Hans: 返回的最大搜索结果数
- pt_BR: The number of maximum search results to return
- form: form
- min: 1
- max: 20
- default: 5
- - name: include_domains
- type: string
- required: false
- label:
- en_US: Include Domains
- zh_Hans: 包含域
- pt_BR: Include Domains
- human_description:
- en_US: A list of domains to specifically include in the search results
- zh_Hans: 在搜索结果中特别包含的域名列表
- pt_BR: A list of domains to specifically include in the search results
- form: form
- - name: exclude_domains
- type: string
- required: false
- label:
- en_US: Exclude Domains
- zh_Hans: 排除域
- pt_BR: Exclude Domains
- human_description:
- en_US: A list of domains to specifically exclude from the search results
- zh_Hans: 从搜索结果中特别排除的域名列表
- pt_BR: A list of domains to specifically exclude from the search results
- form: form
diff --git a/api/core/tools/provider/builtin/tianditu/_assets/icon.svg b/api/core/tools/provider/builtin/tianditu/_assets/icon.svg
deleted file mode 100644
index 749d4bda26..0000000000
--- a/api/core/tools/provider/builtin/tianditu/_assets/icon.svg
+++ /dev/null
@@ -1,21 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/tianditu/tianditu.py b/api/core/tools/provider/builtin/tianditu/tianditu.py
deleted file mode 100644
index cb7d7bd8bb..0000000000
--- a/api/core/tools/provider/builtin/tianditu/tianditu.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.tianditu.tools.poisearch import PoiSearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class TiandituProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- PoiSearchTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "content": "北京",
- "specify": "156110000",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/tianditu/tianditu.yaml b/api/core/tools/provider/builtin/tianditu/tianditu.yaml
deleted file mode 100644
index 77af834bdc..0000000000
--- a/api/core/tools/provider/builtin/tianditu/tianditu.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-identity:
- author: Listeng
- name: tianditu
- label:
- en_US: Tianditu
- zh_Hans: 天地图
- pt_BR: Tianditu
- description:
- en_US: The Tianditu tool provided the functions of place name search, geocoding, static maps generation, etc. in China region.
- zh_Hans: 天地图工具可以调用天地图的接口,实现中国区域内的地名搜索、地理编码、静态地图等功能。
- pt_BR: The Tianditu tool provided the functions of place name search, geocoding, static maps generation, etc. in China region.
- icon: icon.svg
- tags:
- - utilities
- - travel
-credentials_for_provider:
- tianditu_api_key:
- type: secret-input
- required: true
- label:
- en_US: Tianditu API Key
- zh_Hans: 天地图Key
- pt_BR: Tianditu API key
- placeholder:
- en_US: Please input your Tianditu API key
- zh_Hans: 请输入你的天地图Key
- pt_BR: Please input your Tianditu API key
- help:
- en_US: Get your Tianditu API key from Tianditu
- zh_Hans: 获取您的天地图Key
- pt_BR: Get your Tianditu API key from Tianditu
- url: http://lbs.tianditu.gov.cn/home.html
diff --git a/api/core/tools/provider/builtin/tianditu/tools/geocoder.py b/api/core/tools/provider/builtin/tianditu/tools/geocoder.py
deleted file mode 100644
index 690a0aed6f..0000000000
--- a/api/core/tools/provider/builtin/tianditu/tools/geocoder.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import json
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GeocoderTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- base_url = "http://api.tianditu.gov.cn/geocoder"
-
- keyword = tool_parameters.get("keyword", "")
- if not keyword:
- return self.create_text_message("Invalid parameter keyword")
-
- tk = self.runtime.credentials["tianditu_api_key"]
-
- params = {
- "keyWord": keyword,
- }
-
- result = requests.get(base_url + "?ds=" + json.dumps(params, ensure_ascii=False) + "&tk=" + tk).json()
-
- return self.create_json_message(result)
diff --git a/api/core/tools/provider/builtin/tianditu/tools/geocoder.yaml b/api/core/tools/provider/builtin/tianditu/tools/geocoder.yaml
deleted file mode 100644
index d6a168f950..0000000000
--- a/api/core/tools/provider/builtin/tianditu/tools/geocoder.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-identity:
- name: geocoder
- author: Listeng
- label:
- en_US: Get coords converted from address name
- zh_Hans: 地理编码
- pt_BR: Get coords converted from address name
-description:
- human:
- en_US: Geocoder
- zh_Hans: 中国区域地理编码查询
- pt_BR: Geocoder
- llm: A tool for geocoder in China
-parameters:
- - name: keyword
- type: string
- required: true
- label:
- en_US: keyword
- zh_Hans: 搜索的关键字
- pt_BR: keyword
- human_description:
- en_US: keyword
- zh_Hans: 搜索的关键字
- pt_BR: keyword
- form: llm
diff --git a/api/core/tools/provider/builtin/tianditu/tools/poisearch.py b/api/core/tools/provider/builtin/tianditu/tools/poisearch.py
deleted file mode 100644
index 798dd94d33..0000000000
--- a/api/core/tools/provider/builtin/tianditu/tools/poisearch.py
+++ /dev/null
@@ -1,58 +0,0 @@
-import json
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class PoiSearchTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- geocoder_base_url = "http://api.tianditu.gov.cn/geocoder"
- base_url = "http://api.tianditu.gov.cn/v2/search"
-
- keyword = tool_parameters.get("keyword", "")
- if not keyword:
- return self.create_text_message("Invalid parameter keyword")
-
- baseAddress = tool_parameters.get("baseAddress", "")
- if not baseAddress:
- return self.create_text_message("Invalid parameter baseAddress")
-
- tk = self.runtime.credentials["tianditu_api_key"]
-
- base_coords = requests.get(
- geocoder_base_url
- + "?ds="
- + json.dumps(
- {
- "keyWord": baseAddress,
- },
- ensure_ascii=False,
- )
- + "&tk="
- + tk
- ).json()
-
- params = {
- "keyWord": keyword,
- "queryRadius": 5000,
- "queryType": 3,
- "pointLonlat": base_coords["location"]["lon"] + "," + base_coords["location"]["lat"],
- "start": 0,
- "count": 100,
- }
-
- result = requests.get(
- base_url + "?postStr=" + json.dumps(params, ensure_ascii=False) + "&type=query&tk=" + tk
- ).json()
-
- return self.create_json_message(result)
diff --git a/api/core/tools/provider/builtin/tianditu/tools/poisearch.yaml b/api/core/tools/provider/builtin/tianditu/tools/poisearch.yaml
deleted file mode 100644
index 01289d24e3..0000000000
--- a/api/core/tools/provider/builtin/tianditu/tools/poisearch.yaml
+++ /dev/null
@@ -1,38 +0,0 @@
-identity:
- name: point_of_interest_search
- author: Listeng
- label:
- en_US: Point of Interest search
- zh_Hans: 兴趣点搜索
- pt_BR: Point of Interest search
-description:
- human:
- en_US: Search for certain types of points of interest around a location
- zh_Hans: 搜索某个位置周边的5公里内某种类型的兴趣点
- pt_BR: Search for certain types of points of interest around a location
- llm: A tool for searching for certain types of points of interest around a location
-parameters:
- - name: keyword
- type: string
- required: true
- label:
- en_US: poi keyword
- zh_Hans: 兴趣点的关键字
- pt_BR: poi keyword
- human_description:
- en_US: poi keyword
- zh_Hans: 兴趣点的关键字
- pt_BR: poi keyword
- form: llm
- - name: baseAddress
- type: string
- required: true
- label:
- en_US: base current point
- zh_Hans: 当前位置的关键字
- pt_BR: base current point
- human_description:
- en_US: base current point
- zh_Hans: 当前位置的关键字
- pt_BR: base current point
- form: llm
diff --git a/api/core/tools/provider/builtin/tianditu/tools/staticmap.py b/api/core/tools/provider/builtin/tianditu/tools/staticmap.py
deleted file mode 100644
index aeaef08805..0000000000
--- a/api/core/tools/provider/builtin/tianditu/tools/staticmap.py
+++ /dev/null
@@ -1,49 +0,0 @@
-import json
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class PoiSearchTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
-
- geocoder_base_url = "http://api.tianditu.gov.cn/geocoder"
- base_url = "http://api.tianditu.gov.cn/staticimage"
-
- keyword = tool_parameters.get("keyword", "")
- if not keyword:
- return self.create_text_message("Invalid parameter keyword")
-
- tk = self.runtime.credentials["tianditu_api_key"]
-
- keyword_coords = requests.get(
- geocoder_base_url
- + "?ds="
- + json.dumps(
- {
- "keyWord": keyword,
- },
- ensure_ascii=False,
- )
- + "&tk="
- + tk
- ).json()
- coords = keyword_coords["location"]["lon"] + "," + keyword_coords["location"]["lat"]
-
- result = requests.get(
- base_url + "?center=" + coords + "&markers=" + coords + "&width=400&height=300&zoom=14&tk=" + tk
- ).content
-
- return self.create_blob_message(
- blob=result, meta={"mime_type": "image/png"}, save_as=self.VariableKey.IMAGE.value
- )
diff --git a/api/core/tools/provider/builtin/tianditu/tools/staticmap.yaml b/api/core/tools/provider/builtin/tianditu/tools/staticmap.yaml
deleted file mode 100644
index fc54c42806..0000000000
--- a/api/core/tools/provider/builtin/tianditu/tools/staticmap.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-identity:
- name: generate_static_map
- author: Listeng
- label:
- en_US: Generate a static map
- zh_Hans: 生成静态地图
- pt_BR: Generate a static map
-description:
- human:
- en_US: Generate a static map
- zh_Hans: 生成静态地图
- pt_BR: Generate a static map
- llm: A tool for generate a static map
-parameters:
- - name: keyword
- type: string
- required: true
- label:
- en_US: keyword
- zh_Hans: 搜索的关键字
- pt_BR: keyword
- human_description:
- en_US: keyword
- zh_Hans: 搜索的关键字
- pt_BR: keyword
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/_assets/icon.svg b/api/core/tools/provider/builtin/trello/_assets/icon.svg
deleted file mode 100644
index f8e2bd47c0..0000000000
--- a/api/core/tools/provider/builtin/trello/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/trello/tools/create_board.py b/api/core/tools/provider/builtin/trello/tools/create_board.py
deleted file mode 100644
index 5a61d22157..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/create_board.py
+++ /dev/null
@@ -1,44 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class CreateBoardTool(BuiltinTool):
- """
- Tool for creating a new Trello board.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
- """
- Invoke the tool to create a new Trello board.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation.
-
- Returns:
- ToolInvokeMessage: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
- board_name = tool_parameters.get("name")
-
- if not (api_key and token and board_name):
- return self.create_text_message("Missing required parameters: API key, token, or board name.")
-
- url = "https://api.trello.com/1/boards/"
- query_params = {"name": board_name, "key": api_key, "token": token}
-
- try:
- response = requests.post(url, params=query_params)
- response.raise_for_status()
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to create board")
-
- board = response.json()
- return self.create_text_message(
- text=f"Board created successfully! Board name: {board['name']}, ID: {board['id']}"
- )
diff --git a/api/core/tools/provider/builtin/trello/tools/create_board.yaml b/api/core/tools/provider/builtin/trello/tools/create_board.yaml
deleted file mode 100644
index 60dbab61f5..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/create_board.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-identity:
- name: create_board
- author: Yash Parmar
- label:
- en_US: Create Board
- zh_Hans: 创建看板
- pt_BR: Criar Quadro
-description:
- human:
- en_US: Creates a new Trello board with a specified name. This tool allows users to quickly add new boards to their Trello account, facilitating project organization and management.
- zh_Hans: 使用指定的名称创建一个新的 Trello 看板。此工具允许用户快速向其 Trello 账户添加新的看板,促进项目组织和管理。
- pt_BR: Cria um novo quadro Trello com um nome especificado. Esta ferramenta permite que os usuários adicionem rapidamente novos quadros à sua conta Trello, facilitando a organização e gestão de projetos.
- llm: Create a new Trello board using the specified name. This functionality simplifies the addition of boards, enhancing project organization and management within Trello.
-parameters:
- - name: name
- type: string
- required: true
- label:
- en_US: Board Name
- zh_Hans: 看板名称
- pt_BR: Nome do Quadro
- human_description:
- en_US: The name for the new Trello board. This name helps in identifying and organizing your projects on Trello.
- zh_Hans: 新 Trello 看板的名称。这个名称有助于在 Trello 上识别和组织您的项目。
- pt_BR: O nome para o novo quadro Trello. Este nome ajuda a identificar e organizar seus projetos no Trello.
- llm_description: Specify the name for your new Trello board, aiding in project identification and organization within Trello.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/tools/create_list_on_board.py b/api/core/tools/provider/builtin/trello/tools/create_list_on_board.py
deleted file mode 100644
index b32b0124dd..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/create_list_on_board.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class CreateListOnBoardTool(BuiltinTool):
- """
- Tool for creating a list on a Trello board by its ID.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
- """
- Invoke the tool to create a list on a Trello board by its ID.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation,
- including the board ID and list name.
-
- Returns:
- ToolInvokeMessage: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
- board_id = tool_parameters.get("id")
- list_name = tool_parameters.get("name")
-
- if not (api_key and token and board_id and list_name):
- return self.create_text_message("Missing required parameters: API key, token, board ID, or list name.")
-
- url = f"https://api.trello.com/1/boards/{board_id}/lists"
- params = {"name": list_name, "key": api_key, "token": token}
-
- try:
- response = requests.post(url, params=params)
- response.raise_for_status()
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to create list")
-
- new_list = response.json()
- return self.create_text_message(
- text=f"List '{new_list['name']}' created successfully with Id {new_list['id']} on board {board_id}."
- )
diff --git a/api/core/tools/provider/builtin/trello/tools/create_list_on_board.yaml b/api/core/tools/provider/builtin/trello/tools/create_list_on_board.yaml
deleted file mode 100644
index 789b92437a..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/create_list_on_board.yaml
+++ /dev/null
@@ -1,40 +0,0 @@
-identity:
- name: create_list_on_board
- author: Yash Parmar
- label:
- en_US: Create List on Board
- zh_Hans: 在看板上创建列表
- pt_BR: Criar Lista no Quadro
-description:
- human:
- en_US: Creates a new list on a specified Trello board by providing the board's ID and the desired name for the list. Streamlines the process of organizing board content.
- zh_Hans: 通过提供看板的 ID 和列表的所需名称,在指定的 Trello 看板上创建一个新列表。简化了组织看板内容的过程。
- pt_BR: Cria uma nova lista em um quadro Trello especificado, fornecendo o ID do quadro e o nome desejado para a lista. Facilita o processo de organização do conteúdo do quadro.
- llm: Generate a new list within a Trello board by specifying the board's ID and a name for the list. Enhances board management by allowing quick additions of new lists.
-parameters:
- - name: id
- type: string
- required: true
- label:
- en_US: Board ID
- zh_Hans: 看板 ID
- pt_BR: ID do Quadro
- human_description:
- en_US: The unique identifier of the Trello board where the new list will be created.
- zh_Hans: 新列表将被创建在其上的 Trello 看板的唯一标识符。
- pt_BR: O identificador único do quadro Trello onde a nova lista será criada.
- llm_description: Input the ID of the Trello board to pinpoint where the new list should be added, ensuring correct placement.
- form: llm
- - name: name
- type: string
- required: true
- label:
- en_US: List Name
- zh_Hans: 列表名称
- pt_BR: Nome da Lista
- human_description:
- en_US: The name for the new list to be created on the Trello board.
- zh_Hans: 将在 Trello 看板上创建的新列表的名称。
- pt_BR: O nome para a nova lista que será criada no quadro Trello.
- llm_description: Provide a name for the new list, defining its purpose or content focus, to facilitate board organization.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/tools/create_new_card_on_board.py b/api/core/tools/provider/builtin/trello/tools/create_new_card_on_board.py
deleted file mode 100644
index e98efb81ca..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/create_new_card_on_board.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class CreateNewCardOnBoardTool(BuiltinTool):
- """
- Tool for creating a new card on a Trello board.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool, None]]) -> ToolInvokeMessage:
- """
- Invoke the tool to create a new card on a Trello board.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool, None]]): The parameters for the tool invocation,
- including details for the new card.
-
- Returns:
- ToolInvokeMessage: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
-
- # Ensure required parameters are present
- if "name" not in tool_parameters or "idList" not in tool_parameters:
- return self.create_text_message("Missing required parameters: name or idList.")
-
- url = "https://api.trello.com/1/cards"
- params = {**tool_parameters, "key": api_key, "token": token}
-
- try:
- response = requests.post(url, params=params)
- response.raise_for_status()
- new_card = response.json()
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to create card")
-
- return self.create_text_message(
- text=f"New card '{new_card['name']}' created successfully with ID {new_card['id']}."
- )
diff --git a/api/core/tools/provider/builtin/trello/tools/create_new_card_on_board.yaml b/api/core/tools/provider/builtin/trello/tools/create_new_card_on_board.yaml
deleted file mode 100644
index 9953af718d..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/create_new_card_on_board.yaml
+++ /dev/null
@@ -1,145 +0,0 @@
-identity:
- name: create_new_card_on_board
- author: Yash Parmar
- label:
- en_US: Create New Card on Board
- zh_Hans: 在看板上创建新卡片
- pt_BR: Criar Novo Cartão no Quadro
-description:
- human:
- en_US: Creates a new card on a Trello board with specified details like name, description, list ID, and other optional parameters. Facilitates task addition and project management within Trello.
- zh_Hans: 用指定的详情(如名称、描述、列表 ID 和其他可选参数)在 Trello 看板上创建一个新卡片。便于在 Trello 中添加任务和管理项目。
- pt_BR: Cria um novo cartão em um quadro Trello com detalhes especificados, como nome, descrição, ID da lista e outros parâmetros opcionais. Facilita a adição de tarefas e a gestão de projetos dentro do Trello.
- llm: Initiate a new card on a Trello board by specifying essential details such as the card's name, description, and the list it belongs to, among other settings. Streamlines project task additions and organizational workflows.
-parameters:
- - name: name
- type: string
- required: true
- label:
- en_US: Card Name
- zh_Hans: 卡片名称
- pt_BR: Nome do Cartão
- human_description:
- en_US: The name for the new card. Acts as the primary identifier and summary of the card's purpose.
- zh_Hans: 新卡片的名称。作为卡片目的的主要标识和总结。
- pt_BR: O nome para o novo cartão. Funciona como o identificador principal e resumo do propósito do cartão.
- llm_description: Provide a concise, descriptive name for the card, outlining its main focus or task.
- form: llm
- # Include additional parameters like desc, pos, due, idList, etc., following the same pattern.
- - name: desc
- type: string
- required: false
- label:
- en_US: Card Description
- zh_Hans: 卡片描述
- pt_BR: Descrição do Cartão
- human_description:
- en_US: Optional. A brief description of the card's purpose or contents.
- zh_Hans: 可选。卡片目的或内容的简要描述。
- pt_BR: Opcional. Uma breve descrição do propósito ou conteúdo do cartão.
- llm_description: Add a brief description to the card to provide context or additional information about its purpose.
- form: llm
- - name: pos
- type: string
- required: false
- label:
- en_US: Position
- zh_Hans: 位置
- pt_BR: Posição
- human_description:
- en_US: Optional. The position of the card in the list. Can be 'top', 'bottom', or a positive number.
- zh_Hans: 可选。卡片在列表中的位置。可以是“top”、“bottom” 或正数。
- pt_BR: Opcional. A posição do cartão na lista. Pode ser 'top', 'bottom' ou um número positivo.
- llm_description: Specify the position of the card within the list, either at the top, bottom, or a specific numerical index.
- form: llm
- - name: due
- type: string
- required: false
- label:
- en_US: Due Date
- zh_Hans: 截止日期
- pt_BR: Data de Vencimento
- human_description:
- en_US: Optional. The due date for the card in the format 'MM/DD/YYYY'.
- zh_Hans: 可选。卡片的截止日期,格式为“MM/DD/YYYY”。
- pt_BR: Opcional. A data de vencimento do cartão no formato 'MM/DD/YYYY'.
- llm_description: Set a due date for the card to establish a deadline for completion or action.
- form: llm
- - name: start
- type: string
- required: false
- label:
- en_US: Start Date
- zh_Hans: 开始日期
- pt_BR: Data de Início
- human_description:
- en_US: Optional. The start date for the card in the format 'MM/DD/YYYY'.
- zh_Hans: 可选。卡片的开始日期,格式为“MM/DD/YYYY”。
- pt_BR: Opcional. A data de início do cartão no formato 'MM/DD/YYYY'.
- llm_description: Specify a start date for the card to mark the beginning of a task or project phase.
- form: llm
- - name: dueComplete
- type: boolean
- required: false
- label:
- en_US: Due Complete
- zh_Hans: 截止日期已完成
- pt_BR: Vencimento Concluído
- human_description:
- en_US: Optional. Set to true if the due date has been completed, or false if it is pending.
- zh_Hans: 可选。如果截止日期已完成,则设置为 true;如果尚未完成,则设置为 false。
- pt_BR: Opcional. Defina como true se a data de vencimento foi concluída, ou como false se estiver pendente.
- llm_description: Indicate whether the due date for the card has been marked as complete or is still pending.
- form: llm
- - name: idList
- type: string
- required: true
- label:
- en_US: List ID
- zh_Hans: 列表 ID
- pt_BR: ID da Lista
- human_description:
- en_US: The unique identifier of the list where the card will be added.
- zh_Hans: 卡片将被添加到的列表的唯一标识符。
- pt_BR: O identificador único da lista onde o cartão será adicionado.
- llm_description: Input the ID of the list where the card should be placed, ensuring it is added to the correct list.
- form: llm
- - name: idMembers
- type: string
- required: false
- label:
- en_US: Member IDs
- zh_Hans: 成员 ID
- pt_BR: IDs de Membros
- human_description:
- en_US: Optional. The IDs of members to assign to the card.
- zh_Hans: 可选。要分配给卡片的成员的 ID。
- pt_BR: Opcional. Os IDs dos membros a serem atribuídos ao cartão.
- llm_description: Specify the IDs of members to assign to the card, allowing for task delegation or collaboration.
- form: llm
- - name: idLabels
- type: string
- required: false
- label:
- en_US: Label IDs
- zh_Hans: 标签 ID
- pt_BR: IDs de Etiquetas
- human_description:
- en_US: Optional. The IDs of labels to assign to the card.
- zh_Hans: 可选。要分配给卡片的标签的 ID。
- pt_BR: Opcional. Os IDs das etiquetas a serem atribuídos ao cartão.
- llm_description: Assign specific labels to the card by providing their IDs, aiding in visual categorization or prioritization.
- form: llm
- - name: urlSource
- type: string
- required: false
- label:
- en_US: Source URL
- zh_Hans: 来源 URL
- pt_BR: URL de Origem
- human_description:
- en_US: Optional. The URL to attach as the card's source.
- zh_Hans: 可选。要附加为卡片来源的 URL。
- pt_BR: Opcional. O URL a ser anexado como a fonte do cartão.
- llm_description: Provide a URL to serve as the source reference for the card, linking to external resources or documents.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/tools/delete_board.py b/api/core/tools/provider/builtin/trello/tools/delete_board.py
deleted file mode 100644
index 7fc9d1f13c..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/delete_board.py
+++ /dev/null
@@ -1,41 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class DeleteBoardTool(BuiltinTool):
- """
- Tool for deleting a Trello board by ID.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
- """
- Invoke the tool to delete a Trello board by its ID.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation,
- including the board ID.
-
- Returns:
- ToolInvokeMessage: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
- board_id = tool_parameters.get("boardId")
-
- if not (api_key and token and board_id):
- return self.create_text_message("Missing required parameters: API key, token, or board ID.")
-
- url = f"https://api.trello.com/1/boards/{board_id}?key={api_key}&token={token}"
-
- try:
- response = requests.delete(url)
- response.raise_for_status()
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to delete board")
-
- return self.create_text_message(text=f"Board with ID {board_id} deleted successfully.")
diff --git a/api/core/tools/provider/builtin/trello/tools/delete_board.yaml b/api/core/tools/provider/builtin/trello/tools/delete_board.yaml
deleted file mode 100644
index f043e78870..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/delete_board.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-identity:
- name: delete_board
- author: Yash Parmar
- label:
- en_US: Delete Board
- zh_Hans: 删除看板
- pt_BR: Excluir Quadro
-description:
- human:
- en_US: Deletes a Trello board using its unique ID. This tool allows for the removal of boards that are no longer needed, ensuring a tidy workspace.
- zh_Hans: 使用其唯一 ID 删除 Trello 看板。此工具允许删除不再需要的看板,确保工作区整洁。
- pt_BR: Exclui um quadro Trello usando seu ID único. Esta ferramenta permite a remoção de quadros que não são mais necessários, garantindo um espaço de trabalho organizado.
- llm: Remove a Trello board by specifying its ID. This functionality is helpful for cleaning up unnecessary boards from your Trello account.
-parameters:
- - name: boardId
- type: string
- required: true
- label:
- en_US: Board ID
- zh_Hans: 看板 ID
- pt_BR: ID do Quadro
- human_description:
- en_US: The unique identifier for the Trello board you wish to delete. This ensures the specific board is accurately targeted for deletion.
- zh_Hans: 您希望删除的 Trello 看板的唯一标识符。这确保了准确地针对特定看板进行删除。
- pt_BR: O identificador único para o quadro Trello que você deseja excluir. Isso garante que o quadro específico seja precisamente direcionado para exclusão.
- llm_description: Enter the ID of the Trello board you want to remove. This ID is essential to identify the board precisely and perform the deletion.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/tools/delete_card.py b/api/core/tools/provider/builtin/trello/tools/delete_card.py
deleted file mode 100644
index 1de98d639e..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/delete_card.py
+++ /dev/null
@@ -1,41 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class DeleteCardByIdTool(BuiltinTool):
- """
- Tool for deleting a Trello card by its ID.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
- """
- Invoke the tool to delete a Trello card by its ID.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation,
- including the card ID.
-
- Returns:
- ToolInvokeMessage: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
- card_id = tool_parameters.get("id")
-
- if not (api_key and token and card_id):
- return self.create_text_message("Missing required parameters: API key, token, or card ID.")
-
- url = f"https://api.trello.com/1/cards/{card_id}?key={api_key}&token={token}"
-
- try:
- response = requests.delete(url)
- response.raise_for_status()
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to delete card")
-
- return self.create_text_message(text=f"Card with ID {card_id} has been successfully deleted.")
diff --git a/api/core/tools/provider/builtin/trello/tools/delete_card.yaml b/api/core/tools/provider/builtin/trello/tools/delete_card.yaml
deleted file mode 100644
index 8898ef1bde..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/delete_card.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-identity:
- name: delete_card_by_id
- author: Yash Parmar
- label:
- en_US: Delete Card by ID
- zh_Hans: 通过 ID 删除卡片
- pt_BR: Deletar Cartão por ID
-description:
- human:
- en_US: Deletes a Trello card using its unique ID. This tool facilitates the removal of cards that are no longer needed, maintaining an organized board.
- zh_Hans: 使用其唯一 ID 删除 Trello 卡片。此工具便于删除不再需要的卡片,保持看板的有序。
- pt_BR: Exclui um cartão Trello usando seu ID único. Esta ferramenta facilita a remoção de cartões que não são mais necessários, mantendo um quadro organizado.
- llm: Remove a specific Trello card by providing its ID. Ideal for cleaning up and organizing your Trello boards by eliminating unwanted cards.
-parameters:
- - name: id
- type: string
- required: true
- label:
- en_US: Card ID
- zh_Hans: 卡片 ID
- pt_BR: ID do Cartão
- human_description:
- en_US: The unique identifier of the Trello card you wish to delete. This ensures the precise card is removed.
- zh_Hans: 您希望删除的 Trello 卡片的唯一标识符。这确保了精确移除特定卡片。
- pt_BR: O identificador único do cartão Trello que você deseja excluir. Isso garante que o cartão exato seja removido.
- llm_description: Input the ID of the Trello card targeted for deletion to ensure accurate and specific removal.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/tools/fetch_all_boards.py b/api/core/tools/provider/builtin/trello/tools/fetch_all_boards.py
deleted file mode 100644
index 0c5ed9ea85..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/fetch_all_boards.py
+++ /dev/null
@@ -1,50 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class FetchAllBoardsTool(BuiltinTool):
- """
- Tool for fetching all boards from Trello.
- """
-
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke the fetch all boards tool.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation.
-
- Returns:
- Union[ToolInvokeMessage, List[ToolInvokeMessage]]: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
-
- if not (api_key and token):
- return self.create_text_message("Missing Trello API key or token in credentials.")
-
- # Including board filter in the request if provided
- board_filter = tool_parameters.get("boards", "open")
- url = f"https://api.trello.com/1/members/me/boards?filter={board_filter}&key={api_key}&token={token}"
-
- try:
- response = requests.get(url)
- response.raise_for_status() # Raises stored HTTPError, if one occurred.
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to fetch boards")
-
- boards = response.json()
-
- if not boards:
- return self.create_text_message("No boards found in Trello.")
-
- # Creating a string with both board names and IDs
- boards_info = ", ".join([f"{board['name']} (ID: {board['id']})" for board in boards])
- return self.create_text_message(text=f"Boards: {boards_info}")
diff --git a/api/core/tools/provider/builtin/trello/tools/fetch_all_boards.yaml b/api/core/tools/provider/builtin/trello/tools/fetch_all_boards.yaml
deleted file mode 100644
index d0ac4beaaa..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/fetch_all_boards.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-identity:
- name: fetch_all_boards
- author: Yash Parmar
- label:
- en_US: Fetch All Boards
- zh_Hans: 获取所有看板
- pt_BR: Buscar Todos os Quadros
-description:
- human:
- en_US: Retrieves all the Trello boards associated with the user's account. This tool provides a quick overview of all open boards, aiding in efficient project management and organization.
- zh_Hans: 检索与用户账户关联的所有 Trello 看板。该工具提供了所有打开的看板的快速概览,有助于高效的项目管理和组织。
- pt_BR: Recupera todos os quadros do Trello associados à conta do usuário. Esta ferramenta oferece uma visão geral rápida de todos os quadros abertos, auxiliando na gestão e organização eficiente do projeto.
- llm: This tool fetches all Trello boards linked to the user's account, offering a swift snapshot of open boards to streamline project management and organization tasks.
-parameters:
- - name: boards
- type: string
- required: false
- default: open
- label:
- en_US: Boards filter
- zh_Hans: 看板过滤器
- pt_BR: Filtro de quadros
- human_description:
- en_US: Specifies the type of boards to retrieve. Default is 'open', fetching all open boards. Other options include 'closed', 'members', 'organization', etc.
- zh_Hans: 指定要检索的看板类型。默认为“open”,获取所有打开的看板。其他选项包括“closed”,“members”,“organization”等。
- pt_BR: Especifica o tipo de quadros a serem recuperados. O padrão é 'open', buscando todos os quadros abertos. Outras opções incluem 'closed', 'members', 'organization', etc.
- llm_description: Determines the category of boards to be displayed, with 'open' as the default setting to show all open boards. Variants like 'closed', 'members', and 'organization' are also selectable.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/tools/get_board_actions.py b/api/core/tools/provider/builtin/trello/tools/get_board_actions.py
deleted file mode 100644
index cabc7ce093..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/get_board_actions.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GetBoardActionsTool(BuiltinTool):
- """
- Tool for retrieving actions for a Trello board by its ID.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
- """
- Invoke the tool to retrieve actions for a Trello board by its ID.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation,
- including the board ID.
-
- Returns:
- ToolInvokeMessage: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
- board_id = tool_parameters.get("boardId")
-
- if not (api_key and token and board_id):
- return self.create_text_message("Missing required parameters: API key, token, or board ID.")
-
- url = f"https://api.trello.com/1/boards/{board_id}/actions?key={api_key}&token={token}"
-
- try:
- response = requests.get(url)
- response.raise_for_status()
- actions = response.json()
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to retrieve board actions")
-
- actions_summary = "\n".join(
- [f"{action['type']}: {action.get('data', {}).get('text', 'No details available')}" for action in actions]
- )
- return self.create_text_message(text=f"Actions for Board ID {board_id}:\n{actions_summary}")
diff --git a/api/core/tools/provider/builtin/trello/tools/get_board_actions.yaml b/api/core/tools/provider/builtin/trello/tools/get_board_actions.yaml
deleted file mode 100644
index 1ba89f9e44..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/get_board_actions.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-identity:
- name: get_board_actions
- author: Yash Parmar
- label:
- en_US: Get Board Actions
- zh_Hans: 获取看板操作
- pt_BR: Obter Ações do Quadro
-description:
- human:
- en_US: Retrieves a list of actions (such as updates, movements, and comments) for a Trello board by its ID. This tool provides insights into the board's activity history.
- zh_Hans: 通过其 ID 为 Trello 看板检索操作列表(如更新、移动和评论)。此工具提供了看板活动历史的见解。
- pt_BR: Recupera uma lista de ações (como atualizações, movimentos e comentários) para um quadro Trello pelo seu ID. Esta ferramenta oferece insights sobre o histórico de atividades do quadro.
- llm: Fetch the sequence of actions performed on a Trello board, such as card updates, movements, and comments, by providing the board's ID. Offers a historical view of board activities.
-parameters:
- - name: boardId
- type: string
- required: true
- label:
- en_US: Board ID
- zh_Hans: 看板 ID
- pt_BR: ID do Quadro
- human_description:
- en_US: The unique identifier of the Trello board for which you want to retrieve actions. It targets the specific board to fetch its activity log.
- zh_Hans: 您想要检索操作的 Trello 看板的唯一标识符。它定位特定的看板以获取其活动日志。
- pt_BR: O identificador único do quadro Trello para o qual você deseja recuperar ações. Direciona especificamente para o quadro para buscar seu registro de atividades.
- llm_description: Input the ID of the Trello board to access its detailed action history, including all updates, comments, and movements related to the board.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/tools/get_board_by_id.py b/api/core/tools/provider/builtin/trello/tools/get_board_by_id.py
deleted file mode 100644
index fe42cd9c5c..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/get_board_by_id.py
+++ /dev/null
@@ -1,66 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GetBoardByIdTool(BuiltinTool):
- """
- Tool for retrieving detailed information about a Trello board by its ID.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
- """
- Invoke the tool to retrieve a Trello board by its ID.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation,
- including the board ID.
-
- Returns:
- ToolInvokeMessage: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
- board_id = tool_parameters.get("boardId")
-
- if not (api_key and token and board_id):
- return self.create_text_message("Missing required parameters: API key, token, or board ID.")
-
- url = f"https://api.trello.com/1/boards/{board_id}?key={api_key}&token={token}"
-
- try:
- response = requests.get(url)
- response.raise_for_status()
- board = response.json()
- board_details = self.format_board_details(board)
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to retrieve board")
-
- return self.create_text_message(text=board_details)
-
- def format_board_details(self, board: dict) -> str:
- """
- Format the board details into a human-readable string.
-
- Args:
- board (dict): The board information as a dictionary.
-
- Returns:
- str: Formatted board details.
- """
- details = (
- f"Board Name: {board['name']}\n"
- f"Board ID: {board['id']}\n"
- f"Description: {board['desc'] or 'No description provided.'}\n"
- f"Status: {'Closed' if board['closed'] else 'Open'}\n"
- f"Organization ID: {board['idOrganization'] or 'Not part of an organization.'}\n"
- f"URL: {board['url']}\n"
- f"Short URL: {board['shortUrl']}\n"
- f"Permission Level: {board['prefs']['permissionLevel']}\n"
- f"Background Color: {board['prefs']['backgroundColor']}"
- )
- return details
diff --git a/api/core/tools/provider/builtin/trello/tools/get_board_by_id.yaml b/api/core/tools/provider/builtin/trello/tools/get_board_by_id.yaml
deleted file mode 100644
index 45c93006ba..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/get_board_by_id.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-identity:
- name: get_board_by_id
- author: Yash Parmar
- label:
- en_US: Get Board by ID
- zh_Hans: 通过 ID 获取看板
- pt_BR: Obter Quadro por ID
-description:
- human:
- en_US: Retrieves detailed information about a specific Trello board using its unique ID. This tool enables users to quickly access board details without navigating through the Trello interface.
- zh_Hans: 使用其唯一 ID 检索有关特定 Trello 看板的详细信息。此工具使用户能够快速访问看板详情,无需通过 Trello 界面导航。
- pt_BR: Recupera informações detalhadas sobre um quadro Trello específico usando seu ID único. Esta ferramenta permite que os usuários acessem rapidamente os detalhes do quadro sem navegar pela interface do Trello.
- llm: Access details of a Trello board by providing its ID. This tool offers a direct way to view board information, simplifying the process of managing and reviewing Trello boards.
-parameters:
- - name: boardId
- type: string
- required: true
- label:
- en_US: Board ID
- zh_Hans: 看板 ID
- pt_BR: ID do Quadro
- human_description:
- en_US: The unique identifier for the Trello board you wish to retrieve. This ID enables precise targeting and fetching of the board's details.
- zh_Hans: 您希望检索的 Trello 看板的唯一标识符。此 ID 使能够准确定位和获取看板的详细信息。
- pt_BR: O identificador único do quadro Trello que você deseja recuperar. Este ID permite o direcionamento preciso e a obtenção dos detalhes do quadro.
- llm_description: Input the ID of the Trello board to get its details. This unique ID ensures accurate retrieval of information about the specified board.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/tools/get_board_cards.py b/api/core/tools/provider/builtin/trello/tools/get_board_cards.py
deleted file mode 100644
index ff2b1221e7..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/get_board_cards.py
+++ /dev/null
@@ -1,43 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GetBoardCardsTool(BuiltinTool):
- """
- Tool for retrieving cards on a Trello board by its ID.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
- """
- Invoke the tool to retrieve cards on a Trello board by its ID.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation,
- including the board ID.
-
- Returns:
- ToolInvokeMessage: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
- board_id = tool_parameters.get("boardId")
-
- if not (api_key and token and board_id):
- return self.create_text_message("Missing required parameters: API key, token, or board ID.")
-
- url = f"https://api.trello.com/1/boards/{board_id}/cards?key={api_key}&token={token}"
-
- try:
- response = requests.get(url)
- response.raise_for_status()
- cards = response.json()
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to retrieve board cards")
-
- cards_summary = "\n".join([f"{card['name']} (ID: {card['id']})" for card in cards])
- return self.create_text_message(text=f"Cards for Board ID {board_id}:\n{cards_summary}")
diff --git a/api/core/tools/provider/builtin/trello/tools/get_board_cards.yaml b/api/core/tools/provider/builtin/trello/tools/get_board_cards.yaml
deleted file mode 100644
index 852ea278af..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/get_board_cards.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-identity:
- name: get_board_cards
- author: Yash Parmar
- label:
- en_US: Get Board Cards
- zh_Hans: 获取看板卡片
- pt_BR: Obter Cartões do Quadro
-description:
- human:
- en_US: Retrieves all cards present on a specific Trello board by its ID, providing a list of card names and their IDs. Useful for managing and organizing project tasks.
- zh_Hans: 通过其 ID 检索特定 Trello 看板上的所有卡片,提供卡片名称及其 ID 的列表。用于管理和组织项目任务。
- pt_BR: Recupera todos os cartões presentes em um quadro Trello específico pelo seu ID, fornecendo uma lista dos nomes dos cartões e seus IDs. Útil para gerenciar e organizar tarefas de projetos.
- llm: Obtain a list of all cards on a specific Trello board by entering the board's ID. This tool helps in quickly assessing the tasks or items associated with the board.
-parameters:
- - name: boardId
- type: string
- required: true
- label:
- en_US: Board ID
- zh_Hans: 看板 ID
- pt_BR: ID do Quadro
- human_description:
- en_US: The unique identifier of the Trello board from which you want to retrieve cards. It specifies the exact board to gather card details from.
- zh_Hans: 您想要从中检索卡片的 Trello 看板的唯一标识符。它指定了要从中收集卡片详细信息的确切看板。
- pt_BR: O identificador único do quadro Trello do qual você deseja recuperar os cartões. Especifica o quadro exato para obter detalhes dos cartões.
- llm_description: Input the ID of the Trello board to fetch its cards, allowing for a detailed overview of the board's contents.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/tools/get_filterd_board_cards.py b/api/core/tools/provider/builtin/trello/tools/get_filterd_board_cards.py
deleted file mode 100644
index 3d7f9f4ad1..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/get_filterd_board_cards.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GetFilteredBoardCardsTool(BuiltinTool):
- """
- Tool for retrieving filtered cards on a Trello board by its ID and a specified filter.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
- """
- Invoke the tool to retrieve filtered cards on a Trello board by its ID and filter.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation,
- including the board ID and filter.
-
- Returns:
- ToolInvokeMessage: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
- board_id = tool_parameters.get("boardId")
- filter = tool_parameters.get("filter")
-
- if not (api_key and token and board_id and filter):
- return self.create_text_message("Missing required parameters: API key, token, board ID, or filter.")
-
- url = f"https://api.trello.com/1/boards/{board_id}/cards/{filter}?key={api_key}&token={token}"
-
- try:
- response = requests.get(url)
- response.raise_for_status()
- filtered_cards = response.json()
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to retrieve filtered cards")
-
- card_details = "\n".join([f"{card['name']} (ID: {card['id']})" for card in filtered_cards])
- return self.create_text_message(
- text=f"Filtered Cards for Board ID {board_id} with Filter '{filter}':\n{card_details}"
- )
diff --git a/api/core/tools/provider/builtin/trello/tools/get_filterd_board_cards.yaml b/api/core/tools/provider/builtin/trello/tools/get_filterd_board_cards.yaml
deleted file mode 100644
index 3905956457..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/get_filterd_board_cards.yaml
+++ /dev/null
@@ -1,40 +0,0 @@
-identity:
- name: get_filtered_board_cards
- author: Yash Parmar
- label:
- en_US: Get Filtered Board Cards
- zh_Hans: 获取筛选的看板卡片
- pt_BR: Obter Cartões Filtrados do Quadro
-description:
- human:
- en_US: Retrieves cards from a Trello board using a specified filter and the board's ID. Filters include options like 'all', 'open', 'closed', 'none', and 'visible', allowing for tailored views of board content.
- zh_Hans: 使用指定的过滤器和看板的 ID 从 Trello 看板检索卡片。过滤器包括 'all', 'open', 'closed', 'none' 和 'visible' 等选项,允许对看板内容进行定制查看。
- pt_BR: Recupera cartões de um quadro Trello usando um filtro especificado e o ID do quadro. Os filtros incluem opções como 'all', 'open', 'closed', 'none' e 'visible', permitindo visualizações personalizadas do conteúdo do quadro.
- llm: Access cards on a Trello board through specific filters such as 'all', 'open', 'closed', 'none', and 'visible' by providing the board's ID. This feature enables focused examination of the board's cards.
-parameters:
- - name: boardId
- type: string
- required: true
- label:
- en_US: Board ID
- zh_Hans: 看板 ID
- pt_BR: ID do Quadro
- human_description:
- en_US: The unique identifier for the Trello board from which to retrieve the filtered cards.
- zh_Hans: 用于检索筛选卡片的 Trello 看板的唯一标识符。
- pt_BR: O identificador único do quadro Trello do qual os cartões filtrados serão recuperados.
- llm_description: Enter the Trello board's ID to specify from which board to fetch the cards using the filter.
- form: llm
- - name: filter
- type: string
- required: true
- label:
- en_US: Filter
- zh_Hans: 过滤器
- pt_BR: Filtro
- human_description:
- en_US: The filter to apply when retrieving cards. Valid values are 'all', 'open', 'closed', 'none', and 'visible'.
- zh_Hans: 检索卡片时应用的过滤器。有效值为 'all', 'open', 'closed', 'none', 和 'visible'。
- pt_BR: O filtro a ser aplicado ao recuperar cartões. Os valores válidos são 'all', 'open', 'closed', 'none' e 'visible'.
- llm_description: Specify the filter for card retrieval. Choose from 'all', 'open', 'closed', 'none', or 'visible' to control which cards are fetched.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/tools/get_lists_on_board.py b/api/core/tools/provider/builtin/trello/tools/get_lists_on_board.py
deleted file mode 100644
index ccf404068f..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/get_lists_on_board.py
+++ /dev/null
@@ -1,43 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class GetListsFromBoardTool(BuiltinTool):
- """
- Tool for retrieving all lists from a specified Trello board by its ID.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
- """
- Invoke the tool to get all lists from a specified Trello board.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation,
- including the board ID.
-
- Returns:
- ToolInvokeMessage: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
- board_id = tool_parameters.get("boardId")
-
- if not (api_key and token and board_id):
- return self.create_text_message("Missing required parameters: API key, token, or board ID.")
-
- url = f"https://api.trello.com/1/boards/{board_id}/lists?key={api_key}&token={token}"
-
- try:
- response = requests.get(url)
- response.raise_for_status()
- lists = response.json()
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to retrieve lists")
-
- lists_info = "\n".join([f"{list['name']} (ID: {list['id']})" for list in lists])
- return self.create_text_message(text=f"Lists on Board ID {board_id}:\n{lists_info}")
diff --git a/api/core/tools/provider/builtin/trello/tools/get_lists_on_board.yaml b/api/core/tools/provider/builtin/trello/tools/get_lists_on_board.yaml
deleted file mode 100644
index 31028a8040..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/get_lists_on_board.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-identity:
- name: get_lists_from_board
- author: Yash Parmar
- label:
- en_US: Get Lists from Board
- zh_Hans: 获取看板的列表
- pt_BR: Obter Listas do Quadro
-description:
- human:
- en_US: Retrieves all lists from a specified Trello board by its ID, providing an overview of the board's organization and current phases or categories.
- zh_Hans: 通过其 ID 从指定的 Trello 看板检索所有列表,提供看板组织和当前阶段或类别的概览。
- pt_BR: Recupera todas as listas de um quadro Trello especificado pelo seu ID, fornecendo uma visão geral da organização do quadro e das fases ou categorias atuais.
- llm: Fetch and display all lists from a specific Trello board by inputting the board's ID. This aids in understanding the board's structure and task categorization.
-parameters:
- - name: boardId
- type: string
- required: true
- label:
- en_US: Board ID
- zh_Hans: 看板 ID
- pt_BR: ID do Quadro
- human_description:
- en_US: The unique identifier of the Trello board from which to retrieve the lists.
- zh_Hans: 用于检索列表的 Trello 看板的唯一标识符。
- pt_BR: O identificador único do quadro Trello do qual as listas serão recuperadas.
- llm_description: Enter the ID of the Trello board to obtain a detailed list of all its lists, providing insight into the board's structure.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/tools/update_board.py b/api/core/tools/provider/builtin/trello/tools/update_board.py
deleted file mode 100644
index 1e358b00f4..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/update_board.py
+++ /dev/null
@@ -1,47 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class UpdateBoardByIdTool(BuiltinTool):
- """
- Tool for updating a Trello board by its ID with various parameters.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool, None]]) -> ToolInvokeMessage:
- """
- Invoke the tool to update a Trello board by its ID.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool, None]]): The parameters for the tool invocation,
- including board ID and updates.
-
- Returns:
- ToolInvokeMessage: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
- board_id = tool_parameters.pop("boardId", None)
-
- if not (api_key and token and board_id):
- return self.create_text_message("Missing required parameters: API key, token, or board ID.")
-
- url = f"https://api.trello.com/1/boards/{board_id}"
-
- # Removing parameters not intended for update action or with None value
- params = {k: v for k, v in tool_parameters.items() if v is not None}
- params["key"] = api_key
- params["token"] = token
-
- try:
- response = requests.put(url, params=params)
- response.raise_for_status()
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to update board")
-
- updated_board = response.json()
- return self.create_text_message(text=f"Board '{updated_board['name']}' updated successfully.")
diff --git a/api/core/tools/provider/builtin/trello/tools/update_board.yaml b/api/core/tools/provider/builtin/trello/tools/update_board.yaml
deleted file mode 100644
index 487919631a..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/update_board.yaml
+++ /dev/null
@@ -1,157 +0,0 @@
-identity:
- name: update_board_by_id
- author: Yash Parmar
- label:
- en_US: Update Board by ID
- zh_Hans: 通过 ID 更新看板
- pt_BR: Atualizar Quadro por ID
-description:
- human:
- en_US: Updates a Trello board's settings based on the provided ID and parameters. Allows for changing the board's name, description, status, and other preferences.
- zh_Hans: 根据提供的 ID 和参数更新 Trello 看板的设置。允许更改看板的名称、描述、状态和其他偏好设置。
- pt_BR: Atualiza as configurações de um quadro Trello com base no ID fornecido e nos parâmetros. Permite alterar o nome, descrição, status e outras preferências do quadro.
- llm: Modify a Trello board's attributes like its name, description, and visibility settings using the board's ID. This tool streamlines board customization and management.
-parameters:
- - name: boardId
- type: string
- required: true
- label:
- en_US: Board ID
- zh_Hans: 看板 ID
- pt_BR: ID do Quadro
- human_description:
- en_US: The unique identifier of the Trello board you want to update. Ensures targeted and precise updates.
- zh_Hans: 您要更新的 Trello 看板的唯一标识符。确保目标准确和更新精确。
- pt_BR: O identificador único do quadro Trello que você deseja atualizar. Garante atualizações direcionadas e precisas.
- llm_description: Provide the specific ID of the Trello board you aim to update to ensure accuracy in modification process.
- form: llm
- - name: name
- type: string
- required: false
- label:
- en_US: Board Name
- zh_Hans: 看板名称
- pt_BR: Nome do Quadro
- human_description:
- en_US: Optional. The new name for the board.
- zh_Hans: 可选。看板的新名称。
- pt_BR: Opcional. O novo nome para o quadro.
- llm_description: Enter a new name for the board if you wish to change it; this name identifies the board in Trello.
- form: llm
- - name: desc
- type: string
- required: false
- label:
- en_US: Board Description
- zh_Hans: 看板描述
- pt_BR: Descrição do Quadro
- human_description:
- en_US: Optional. The new description for the board.
- zh_Hans: 可选。看板的新描述。
- pt_BR: Opcional. A nova descrição para o quadro.
- llm_description: Provide a new description for the board if you wish to update it; this description provides additional context about the board.
- form: llm
- - name: closed
- type: boolean
- required: false
- label:
- en_US: Closed
- zh_Hans: 已关闭
- pt_BR: Fechado
- human_description:
- en_US: Optional. Set to true to close the board, or false to keep it open.
- zh_Hans: 可选。设置为 true 以关闭看板,或设置为 false 以保持打开。
- pt_BR: Opcional. Defina como true para fechar o quadro ou como false para mantê-lo aberto.
- llm_description: Specify whether the board should be closed or kept open by setting this parameter to true or false.
- form: llm
- - name: subscribed
- type: string
- required: false
- label:
- en_US: Subscribed
- zh_Hans: 订阅
- pt_BR: Inscrito
- human_description:
- en_US: Optional. Set to true to subscribe to the board, or false to unsubscribe.
- zh_Hans: 可选。设置为 true 以订阅看板,或设置为 false 以取消订阅。
- pt_BR: Opcional. Defina como true para se inscrever no quadro ou como false para cancelar a inscrição.
- llm_description: Choose to subscribe or unsubscribe from the board by setting this parameter to true or false.
- form: llm
- - name: idOrganization
- type: string
- required: false
- label:
- en_US: Organization ID
- zh_Hans: 组织 ID
- pt_BR: ID da Organização
- human_description:
- en_US: Optional. The ID of the organization to which the board belongs.
- zh_Hans: 可选。看板所属组织的 ID。
- pt_BR: Opcional. O ID da organização à qual o quadro pertence.
- llm_description: Input the ID of the organization to which the board is associated, if applicable.
- form: llm
- - name: prefs_permissionLevel
- type: string
- required: false
- label:
- en_US: Permission Level
- zh_Hans: 权限级别
- pt_BR: Nível de Permissão
- human_description:
- en_US: Optional. The permission level for the board. Valid values are 'private', 'org', or 'public'.
- zh_Hans: 可选。看板的权限级别。有效值为 'private'、'org' 或 'public'。
- pt_BR: Opcional. O nível de permissão para o quadro. Os valores válidos são 'private', 'org' ou 'public'.
- llm_description: Specify the permission level for the board by choosing from 'private', 'org', or 'public'.
- form: llm
- - name: prefs_selfJoin
- type: boolean
- required: false
- label:
- en_US: Allow Self-Join
- zh_Hans: 允许自行加入
- pt_BR: Permitir Auto-Inscrição
- human_description:
- en_US: Optional. Set to true to allow members to join the board without an invitation, or false to require an invitation.
- zh_Hans: 可选。设置为 true 以允许成员加入看板而无需邀请,或设置为 false 以要求邀请。
- pt_BR: Opcional. Defina como true para permitir que os membros se inscrevam no quadro sem um convite, ou como false para exigir um convite.
- llm_description: Choose whether to allow members to join the board without an invitation by setting this parameter to true or false.
- form: llm
- - name: prefs_cardCovers
- type: boolean
- required: false
- label:
- en_US: Card Covers
- zh_Hans: 卡片封面
- pt_BR: Capas de Cartão
- human_description:
- en_US: Optional. Set to true to enable card covers, or false to disable them.
- zh_Hans: 可选。设置为 true 以启用卡片封面,或设置为 false 以禁用卡片封面。
- pt_BR: Opcional. Defina como true para habilitar capas de cartão ou como false para desabilitá-las.
- llm_description: Enable or disable card covers by setting this parameter to true or false.
- form: llm
- - name: prefs_hideVotes
- type: boolean
- required: false
- label:
- en_US: Hide Votes
- zh_Hans: 隐藏投票
- pt_BR: Ocultar Votos
- human_description:
- en_US: Optional. Set to true to hide votes, or false to show them.
- zh_Hans: 可选。设置为 true 以隐藏投票,或设置为 false 以显示投票。
- pt_BR: Opcional. Defina como true para ocultar votos ou como false para mostrá-los.
- llm_description: Choose to hide or show votes by setting this parameter to true or false.
- form: llm
- - name: prefs_invitations
- type: string
- required: false
- label:
- en_US: Invitations
- zh_Hans: 邀请
- pt_BR: Convites
- human_description:
- en_US: Optional. Set to 'members' to allow only board members to send invitations, or 'admins' to allow admins to send invitations.
- zh_Hans: 可选。设置为 'members' 以仅允许看板成员发送邀请,或设置为 'admins' 以允许管理员发送邀请。
- pt_BR: Opcional. Defina como 'members' para permitir que apenas membros do quadro enviem convites, ou 'admins' para permitir que os administradores enviem convites.
- llm_description: Choose who can send invitations by setting this parameter to 'members' or 'admins'.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/tools/update_card.py b/api/core/tools/provider/builtin/trello/tools/update_card.py
deleted file mode 100644
index d25fcbafaa..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/update_card.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from typing import Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class UpdateCardByIdTool(BuiltinTool):
- """
- Tool for updating a Trello card by its ID.
- """
-
- def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool, None]]) -> ToolInvokeMessage:
- """
- Invoke the tool to update a Trello card by its ID.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (dict[str, Union[str, int, bool, None]]): The parameters for the tool invocation,
- including the card ID and updates.
-
- Returns:
- ToolInvokeMessage: The result of the tool invocation.
- """
- api_key = self.runtime.credentials.get("trello_api_key")
- token = self.runtime.credentials.get("trello_api_token")
- card_id = tool_parameters.get("id")
-
- if not (api_key and token and card_id):
- return self.create_text_message("Missing required parameters: API key, token, or card ID.")
-
- # Constructing the URL and the payload for the PUT request
- url = f"https://api.trello.com/1/cards/{card_id}"
- params = {k: v for k, v in tool_parameters.items() if v is not None and k != "id"}
- params.update({"key": api_key, "token": token})
-
- try:
- response = requests.put(url, params=params)
- response.raise_for_status()
- except requests.exceptions.RequestException as e:
- return self.create_text_message("Failed to update card")
-
- updated_card_info = f"Card '{card_id}' updated successfully."
- return self.create_text_message(text=updated_card_info)
diff --git a/api/core/tools/provider/builtin/trello/tools/update_card.yaml b/api/core/tools/provider/builtin/trello/tools/update_card.yaml
deleted file mode 100644
index 5240dfc3ed..0000000000
--- a/api/core/tools/provider/builtin/trello/tools/update_card.yaml
+++ /dev/null
@@ -1,81 +0,0 @@
-identity:
- name: update_card_by_id
- author: Yash Parmar
- label:
- en_US: Update Card by ID
- zh_Hans: 通过 ID 更新卡片
- pt_BR: Atualizar Cartão por ID
-description:
- human:
- en_US: Updates specified attributes of a Trello card, such as its name, description, list ID, and board ID, by providing the card's unique ID.
- zh_Hans: 通过提供卡片的唯一 ID,更新 Trello 卡片的特定属性,如其名称、描述、列表 ID 和看板 ID。
- pt_BR: Atualiza atributos específicos de um cartão Trello, como seu nome, descrição, ID da lista e ID do quadro, fornecendo o ID único do cartão.
- llm: Modify a Trello card's key details, including name, description, and its placement on the board, by using the card's ID. Enables precise and targeted updates to card information.
-parameters:
- - name: id
- type: string
- required: true
- label:
- en_US: Card ID
- zh_Hans: 卡片 ID
- pt_BR: ID do Cartão
- human_description:
- en_US: The unique identifier of the Trello card you intend to update.
- zh_Hans: 您打算更新的 Trello 卡片的唯一标识符。
- pt_BR: O identificador único do cartão Trello que você pretende atualizar.
- llm_description: Input the ID of the Trello card to be updated to ensure the correct card is targeted.
- form: llm
- # Include other parameters following the same pattern
- - name: name
- type: string
- required: false
- label:
- en_US: New Name
- zh_Hans: 新名称
- pt_BR: Novo Nome
- human_description:
- en_US: Optional. The new name to assign to the card.
- zh_Hans: 可选。要分配给卡片的新名称。
- pt_BR: Opcional. O novo nome a ser atribuído ao cartão.
- llm_description: Specify a new name for the card if changing it. This name is what will be displayed on the Trello board.
- form: llm
- # Add definitions for desc, idList and idBoard parameters
- - name: desc
- type: string
- required: false
- label:
- en_US: New Description
- zh_Hans: 新描述
- pt_BR: Nova Descrição
- human_description:
- en_US: Optional. The new description to assign to the card.
- zh_Hans: 可选。要分配给卡片的新描述。
- pt_BR: Opcional. A nova descrição a ser atribuída ao cartão.
- llm_description: Provide a new description for the card if you wish to update it; this description provides additional context about the card.
- form: llm
- - name: idList
- type: string
- required: false
- label:
- en_US: List ID
- zh_Hans: 列表 ID
- pt_BR: ID da Lista
- human_description:
- en_US: Optional. The ID of the list to which the card should be moved.
- zh_Hans: 可选。卡片应移动到的列表的 ID。
- pt_BR: Opcional. O ID da lista para a qual o cartão deve ser movido.
- llm_description: Enter the ID of the list where you want to move the card. This action relocates the card to the specified list.
- form: llm
- - name: idBoard
- type: string
- required: false
- label:
- en_US: Board ID
- zh_Hans: 看板 ID
- pt_BR: ID do Quadro
- human_description:
- en_US: Optional. The ID of the board to which the card should be moved.
- zh_Hans: 可选。卡片应移动到的看板的 ID。
- pt_BR: Opcional. O ID do quadro para o qual o cartão deve ser movido.
- llm_description: Provide the ID of the board where you want to move the card. This action relocates the card to the specified board.
- form: llm
diff --git a/api/core/tools/provider/builtin/trello/trello.py b/api/core/tools/provider/builtin/trello/trello.py
deleted file mode 100644
index e0dca50ec9..0000000000
--- a/api/core/tools/provider/builtin/trello/trello.py
+++ /dev/null
@@ -1,34 +0,0 @@
-from typing import Any
-
-import requests
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class TrelloProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- """Validate Trello API credentials by making a test API call.
-
- Args:
- credentials (dict[str, Any]): The Trello API credentials to validate.
-
- Raises:
- ToolProviderCredentialValidationError: If the credentials are invalid.
- """
- api_key = credentials.get("trello_api_key")
- token = credentials.get("trello_api_token")
- url = f"https://api.trello.com/1/members/me?key={api_key}&token={token}"
-
- try:
- response = requests.get(url)
- response.raise_for_status() # Raises an HTTPError for bad responses
- except requests.exceptions.HTTPError as e:
- if response.status_code == 401:
- # Unauthorized, indicating invalid credentials
- raise ToolProviderCredentialValidationError("Invalid Trello credentials: Unauthorized.")
- # Handle other potential HTTP errors
- raise ToolProviderCredentialValidationError("Error validating Trello credentials")
- except requests.exceptions.RequestException as e:
- # Handle other exceptions, such as connection errors
- raise ToolProviderCredentialValidationError("Error validating Trello credentials")
diff --git a/api/core/tools/provider/builtin/trello/trello.yaml b/api/core/tools/provider/builtin/trello/trello.yaml
deleted file mode 100644
index 49c9f4f9a1..0000000000
--- a/api/core/tools/provider/builtin/trello/trello.yaml
+++ /dev/null
@@ -1,47 +0,0 @@
-identity:
- author: Yash Parmar
- name: trello
- label:
- en_US: Trello
- zh_Hans: Trello
- pt_BR: Trello
- description:
- en_US: "Trello: A visual tool for organizing your work and life."
- zh_Hans: "Trello: 一个用于组织工作和生活的视觉工具。"
- pt_BR: "Trello: Uma ferramenta visual para organizar seu trabalho e vida."
- icon: icon.svg
- tags:
- - productivity
-credentials_for_provider:
- trello_api_key:
- type: secret-input
- required: true
- label:
- en_US: Trello API key
- zh_Hans: Trello API key
- pt_BR: Trello API key
- placeholder:
- en_US: Enter your Trello API key
- zh_Hans: 输入您的 Trello API key
- pt_BR: Insira sua chave API do Trello
- help:
- en_US: Obtain your API key from Trello's website.
- zh_Hans: 从 Trello 网站获取您的 API key。
- pt_BR: Obtenha sua chave API no site do Trello.
- url: https://developer.atlassian.com/cloud/trello/guides/rest-api/api-introduction/
- trello_api_token:
- type: secret-input
- required: true
- label:
- en_US: Trello API token
- zh_Hans: Trello API token
- pt_BR: Trello API token
- placeholder:
- en_US: Enter your Trello API token
- zh_Hans: 输入您的 Trello API token
- pt_BR: Insira seu token API do Trello
- help:
- en_US: Secure your API token from Trello's website.
- zh_Hans: 从 Trello 网站获取您的 API token。
- pt_BR: Garanta seu token API no site do Trello.
- url: https://developer.atlassian.com/cloud/trello/guides/rest-api/api-introduction/
diff --git a/api/core/tools/provider/builtin/twilio/_assets/icon.svg b/api/core/tools/provider/builtin/twilio/_assets/icon.svg
deleted file mode 100644
index a1e2bd12c2..0000000000
--- a/api/core/tools/provider/builtin/twilio/_assets/icon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/twilio/tools/send_message.py b/api/core/tools/provider/builtin/twilio/tools/send_message.py
deleted file mode 100644
index 5ee839baa5..0000000000
--- a/api/core/tools/provider/builtin/twilio/tools/send_message.py
+++ /dev/null
@@ -1,97 +0,0 @@
-from typing import Any, Optional, Union
-
-from pydantic import BaseModel, field_validator
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class TwilioAPIWrapper(BaseModel):
- """Messaging Client using Twilio.
-
- To use, you should have the ``twilio`` python package installed,
- and the environment variables ``TWILIO_ACCOUNT_SID``, ``TWILIO_AUTH_TOKEN``, and
- ``TWILIO_FROM_NUMBER``, or pass `account_sid`, `auth_token`, and `from_number` as
- named parameters to the constructor.
- """
-
- client: Any = None #: :meta private:
- account_sid: Optional[str] = None
- """Twilio account string identifier."""
- auth_token: Optional[str] = None
- """Twilio auth token."""
- from_number: Optional[str] = None
- """A Twilio phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164)
- format, an
- [alphanumeric sender ID](https://www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id),
- or a [Channel Endpoint address](https://www.twilio.com/docs/sms/channels#channel-addresses)
- that is enabled for the type of message you want to send. Phone numbers or
- [short codes](https://www.twilio.com/docs/sms/api/short-code) purchased from
- Twilio also work here. You cannot, for example, spoof messages from a private
- cell phone number. If you are using `messaging_service_sid`, this parameter
- must be empty.
- """
-
- @field_validator("client", mode="before")
- @classmethod
- def set_validator(cls, values: dict) -> dict:
- """Validate that api key and python package exists in environment."""
- try:
- from twilio.rest import Client
- except ImportError:
- raise ImportError("Could not import twilio python package. Please install it with `pip install twilio`.")
- account_sid = values.get("account_sid")
- auth_token = values.get("auth_token")
- values["from_number"] = values.get("from_number")
- values["client"] = Client(account_sid, auth_token)
-
- return values
-
- def run(self, body: str, to: str) -> str:
- """Run body through Twilio and respond with message sid.
-
- Args:
- body: The text of the message you want to send. Can be up to 1,600
- characters in length.
- to: The destination phone number in
- [E.164](https://www.twilio.com/docs/glossary/what-e164) format for
- SMS/MMS or
- [Channel user address](https://www.twilio.com/docs/sms/channels#channel-addresses)
- for other 3rd-party channels.
- """
- message = self.client.messages.create(to, from_=self.from_number, body=body)
- return message.sid
-
-
-class SendMessageTool(BuiltinTool):
- """
- A tool for sending messages using Twilio API.
-
- Args:
- user_id (str): The ID of the user invoking the tool.
- tool_parameters (Dict[str, Any]): The parameters required for sending the message.
-
- Returns:
- Union[ToolInvokeMessage, List[ToolInvokeMessage]]: The result of invoking the tool,
- which includes the status of the message sending operation.
- """
-
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- account_sid = self.runtime.credentials["account_sid"]
- auth_token = self.runtime.credentials["auth_token"]
- from_number = self.runtime.credentials["from_number"]
-
- message = tool_parameters["message"]
- to_number = tool_parameters["to_number"]
-
- if to_number.startswith("whatsapp:"):
- from_number = f"whatsapp: {from_number}"
-
- twilio = TwilioAPIWrapper(account_sid=account_sid, auth_token=auth_token, from_number=from_number)
-
- # Sending the message through Twilio
- result = twilio.run(message, to_number)
-
- return self.create_text_message(text="Message sent successfully.")
diff --git a/api/core/tools/provider/builtin/twilio/tools/send_message.yaml b/api/core/tools/provider/builtin/twilio/tools/send_message.yaml
deleted file mode 100644
index e129698c86..0000000000
--- a/api/core/tools/provider/builtin/twilio/tools/send_message.yaml
+++ /dev/null
@@ -1,40 +0,0 @@
-identity:
- name: send_message
- author: Yash Parmar
- label:
- en_US: SendMessage
- zh_Hans: 发送消息
- pt_BR: SendMessage
-description:
- human:
- en_US: Send SMS or Twilio Messaging Channels messages.
- zh_Hans: 发送SMS或Twilio消息通道消息。
- pt_BR: Send SMS or Twilio Messaging Channels messages.
- llm: Send SMS or Twilio Messaging Channels messages. Supports different channels including WhatsApp.
-parameters:
- - name: message
- type: string
- required: true
- label:
- en_US: Message
- zh_Hans: 消息内容
- pt_BR: Message
- human_description:
- en_US: The content of the message to be sent.
- zh_Hans: 要发送的消息内容。
- pt_BR: The content of the message to be sent.
- llm_description: The content of the message to be sent.
- form: llm
- - name: to_number
- type: string
- required: true
- label:
- en_US: To Number
- zh_Hans: 收信号码
- pt_BR: Para Número
- human_description:
- en_US: The recipient's phone number. Prefix with 'whatsapp:' for WhatsApp messages, e.g., "whatsapp:+1234567890".
- zh_Hans: 收件人的电话号码。WhatsApp消息前缀为'whatsapp:',例如,"whatsapp:+1234567890"。
- pt_BR: The recipient's phone number. Prefix with 'whatsapp:' for WhatsApp messages, e.g., "whatsapp:+1234567890".
- llm_description: The recipient's phone number. Prefix with 'whatsapp:' for WhatsApp messages, e.g., "whatsapp:+1234567890".
- form: llm
diff --git a/api/core/tools/provider/builtin/twilio/twilio.py b/api/core/tools/provider/builtin/twilio/twilio.py
deleted file mode 100644
index b1d100aad9..0000000000
--- a/api/core/tools/provider/builtin/twilio/twilio.py
+++ /dev/null
@@ -1,29 +0,0 @@
-from typing import Any
-
-from twilio.base.exceptions import TwilioRestException
-from twilio.rest import Client
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class TwilioProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- # Extract credentials
- account_sid = credentials["account_sid"]
- auth_token = credentials["auth_token"]
- from_number = credentials["from_number"]
-
- # Initialize twilio client
- client = Client(account_sid, auth_token)
-
- # fetch account
- client.api.accounts(account_sid).fetch()
-
- except TwilioRestException as e:
- raise ToolProviderCredentialValidationError(f"Twilio API error: {e.msg}") from e
- except KeyError as e:
- raise ToolProviderCredentialValidationError(f"Missing required credential: {e}") from e
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/twilio/twilio.yaml b/api/core/tools/provider/builtin/twilio/twilio.yaml
deleted file mode 100644
index 21867c1da5..0000000000
--- a/api/core/tools/provider/builtin/twilio/twilio.yaml
+++ /dev/null
@@ -1,48 +0,0 @@
-identity:
- author: Yash Parmar
- name: twilio
- label:
- en_US: Twilio
- zh_Hans: Twilio
- pt_BR: Twilio
- description:
- en_US: Send messages through SMS or Twilio Messaging Channels.
- zh_Hans: 通过SMS或Twilio消息通道发送消息。
- pt_BR: Send messages through SMS or Twilio Messaging Channels.
- icon: icon.svg
- tags:
- - social
-credentials_for_provider:
- account_sid:
- type: secret-input
- required: true
- label:
- en_US: Account SID
- zh_Hans: 账户SID
- pt_BR: Account SID
- placeholder:
- en_US: Please input your Twilio Account SID
- zh_Hans: 请输入您的Twilio账户SID
- pt_BR: Please input your Twilio Account SID
- auth_token:
- type: secret-input
- required: true
- label:
- en_US: Auth Token
- zh_Hans: 认证令牌
- pt_BR: Auth Token
- placeholder:
- en_US: Please input your Twilio Auth Token
- zh_Hans: 请输入您的Twilio认证令牌
- pt_BR: Please input your Twilio Auth Token
- from_number:
- type: secret-input
- required: true
- label:
- en_US: From Number
- zh_Hans: 发信号码
- pt_BR: De Número
- placeholder:
- en_US: Please input your Twilio phone number
- zh_Hans: 请输入您的Twilio电话号码
- pt_BR: Please input your Twilio phone number
diff --git a/api/core/tools/provider/builtin/vanna/_assets/icon.png b/api/core/tools/provider/builtin/vanna/_assets/icon.png
deleted file mode 100644
index 3a9011b54d..0000000000
Binary files a/api/core/tools/provider/builtin/vanna/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/vanna/tools/vanna.py b/api/core/tools/provider/builtin/vanna/tools/vanna.py
deleted file mode 100644
index c90d766e48..0000000000
--- a/api/core/tools/provider/builtin/vanna/tools/vanna.py
+++ /dev/null
@@ -1,129 +0,0 @@
-from typing import Any, Union
-
-from vanna.remote import VannaDefault
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class VannaTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- api_key = self.runtime.credentials.get("api_key", None)
- if not api_key:
- raise ToolProviderCredentialValidationError("Please input api key")
-
- model = tool_parameters.get("model", "")
- if not model:
- return self.create_text_message("Please input RAG model")
-
- prompt = tool_parameters.get("prompt", "")
- if not prompt:
- return self.create_text_message("Please input prompt")
-
- url = tool_parameters.get("url", "")
- if not url:
- return self.create_text_message("Please input URL/Host/DSN")
-
- db_name = tool_parameters.get("db_name", "")
- username = tool_parameters.get("username", "")
- password = tool_parameters.get("password", "")
- port = tool_parameters.get("port", 0)
-
- vn = VannaDefault(model=model, api_key=api_key)
-
- db_type = tool_parameters.get("db_type", "")
- if db_type in {"Postgres", "MySQL", "Hive", "ClickHouse"}:
- if not db_name:
- return self.create_text_message("Please input database name")
- if not username:
- return self.create_text_message("Please input username")
- if port < 1:
- return self.create_text_message("Please input port")
-
- schema_sql = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS"
- match db_type:
- case "SQLite":
- schema_sql = "SELECT type, sql FROM sqlite_master WHERE sql is not null"
- vn.connect_to_sqlite(url)
- case "Postgres":
- vn.connect_to_postgres(host=url, dbname=db_name, user=username, password=password, port=port)
- case "DuckDB":
- vn.connect_to_duckdb(url=url)
- case "SQLServer":
- vn.connect_to_mssql(url)
- case "MySQL":
- vn.connect_to_mysql(host=url, dbname=db_name, user=username, password=password, port=port)
- case "Oracle":
- vn.connect_to_oracle(user=username, password=password, dsn=url)
- case "Hive":
- vn.connect_to_hive(host=url, dbname=db_name, user=username, password=password, port=port)
- case "ClickHouse":
- vn.connect_to_clickhouse(host=url, dbname=db_name, user=username, password=password, port=port)
-
- enable_training = tool_parameters.get("enable_training", False)
- reset_training_data = tool_parameters.get("reset_training_data", False)
- if enable_training:
- if reset_training_data:
- existing_training_data = vn.get_training_data()
- if len(existing_training_data) > 0:
- for _, training_data in existing_training_data.iterrows():
- vn.remove_training_data(training_data["id"])
-
- ddl = tool_parameters.get("ddl", "")
- question = tool_parameters.get("question", "")
- sql = tool_parameters.get("sql", "")
- memos = tool_parameters.get("memos", "")
- training_metadata = tool_parameters.get("training_metadata", False)
-
- if training_metadata:
- if db_type == "SQLite":
- df_ddl = vn.run_sql(schema_sql)
- for ddl in df_ddl["sql"].to_list():
- vn.train(ddl=ddl)
- else:
- df_information_schema = vn.run_sql(schema_sql)
- plan = vn.get_training_plan_generic(df_information_schema)
- vn.train(plan=plan)
-
- if ddl:
- vn.train(ddl=ddl)
-
- if sql:
- if question:
- vn.train(question=question, sql=sql)
- else:
- vn.train(sql=sql)
- if memos:
- vn.train(documentation=memos)
-
- #########################################################################################
- # Due to CVE-2024-5565, we have to disable the chart generation feature
- # The Vanna library uses a prompt function to present the user with visualized results,
- # it is possible to alter the prompt using prompt injection and run arbitrary Python code
- # instead of the intended visualization code.
- # Specifically - allowing external input to the library’s “ask” method
- # with "visualize" set to True (default behavior) leads to remote code execution.
- # Affected versions: <= 0.5.5
- #########################################################################################
- generate_chart = False
- # generate_chart = tool_parameters.get("generate_chart", True)
- res = vn.ask(prompt, False, True, generate_chart)
-
- result = []
-
- if res is not None:
- result.append(self.create_text_message(res[0]))
- if len(res) > 1 and res[1] is not None:
- result.append(self.create_text_message(res[1].to_markdown()))
- if len(res) > 2 and res[2] is not None:
- result.append(
- self.create_blob_message(blob=res[2].to_image(format="svg"), meta={"mime_type": "image/svg+xml"})
- )
-
- return result
diff --git a/api/core/tools/provider/builtin/vanna/tools/vanna.yaml b/api/core/tools/provider/builtin/vanna/tools/vanna.yaml
deleted file mode 100644
index ae2eae94c4..0000000000
--- a/api/core/tools/provider/builtin/vanna/tools/vanna.yaml
+++ /dev/null
@@ -1,213 +0,0 @@
-identity:
- name: vanna
- author: QCTC
- label:
- en_US: Vanna.AI
- zh_Hans: Vanna.AI
-description:
- human:
- en_US: The fastest way to get actionable insights from your database just by asking questions.
- zh_Hans: 一个基于大模型和RAG的Text2SQL工具。
- llm: A tool for converting text to SQL.
-parameters:
- - name: prompt
- type: string
- required: true
- label:
- en_US: Prompt
- zh_Hans: 提示词
- pt_BR: Prompt
- human_description:
- en_US: used for generating SQL
- zh_Hans: 用于生成SQL
- llm_description: key words for generating SQL
- form: llm
- - name: model
- type: string
- required: true
- label:
- en_US: RAG Model
- zh_Hans: RAG模型
- human_description:
- en_US: RAG Model for your database DDL
- zh_Hans: 存储数据库训练数据的RAG模型
- llm_description: RAG Model for generating SQL
- form: form
- - name: db_type
- type: select
- required: true
- options:
- - value: SQLite
- label:
- en_US: SQLite
- zh_Hans: SQLite
- - value: Postgres
- label:
- en_US: Postgres
- zh_Hans: Postgres
- - value: DuckDB
- label:
- en_US: DuckDB
- zh_Hans: DuckDB
- - value: SQLServer
- label:
- en_US: Microsoft SQL Server
- zh_Hans: 微软 SQL Server
- - value: MySQL
- label:
- en_US: MySQL
- zh_Hans: MySQL
- - value: Oracle
- label:
- en_US: Oracle
- zh_Hans: Oracle
- - value: Hive
- label:
- en_US: Hive
- zh_Hans: Hive
- - value: ClickHouse
- label:
- en_US: ClickHouse
- zh_Hans: ClickHouse
- default: SQLite
- label:
- en_US: DB Type
- zh_Hans: 数据库类型
- human_description:
- en_US: Database type.
- zh_Hans: 选择要链接的数据库类型。
- form: form
- - name: url
- type: string
- required: true
- label:
- en_US: URL/Host/DSN
- zh_Hans: URL/Host/DSN
- human_description:
- en_US: Please input depending on DB type, visit https://vanna.ai/docs/ for more specification
- zh_Hans: 请根据数据库类型,填入对应值,详情参考https://vanna.ai/docs/
- form: form
- - name: db_name
- type: string
- required: false
- label:
- en_US: DB name
- zh_Hans: 数据库名
- human_description:
- en_US: Database name
- zh_Hans: 数据库名
- form: form
- - name: username
- type: string
- required: false
- label:
- en_US: Username
- zh_Hans: 用户名
- human_description:
- en_US: Username
- zh_Hans: 用户名
- form: form
- - name: password
- type: secret-input
- required: false
- label:
- en_US: Password
- zh_Hans: 密码
- human_description:
- en_US: Password
- zh_Hans: 密码
- form: form
- - name: port
- type: number
- required: false
- label:
- en_US: Port
- zh_Hans: 端口
- human_description:
- en_US: Port
- zh_Hans: 端口
- form: form
- - name: ddl
- type: string
- required: false
- label:
- en_US: Training DDL
- zh_Hans: 训练DDL
- human_description:
- en_US: DDL statements for training data
- zh_Hans: 用于训练RAG Model的建表语句
- form: form
- - name: question
- type: string
- required: false
- label:
- en_US: Training Question
- zh_Hans: 训练问题
- human_description:
- en_US: Question-SQL Pairs
- zh_Hans: Question-SQL中的问题
- form: form
- - name: sql
- type: string
- required: false
- label:
- en_US: Training SQL
- zh_Hans: 训练SQL
- human_description:
- en_US: SQL queries to your training data
- zh_Hans: 用于训练RAG Model的SQL语句
- form: form
- - name: memos
- type: string
- required: false
- label:
- en_US: Training Memos
- zh_Hans: 训练说明
- human_description:
- en_US: Sometimes you may want to add documentation about your business terminology or definitions
- zh_Hans: 添加更多关于数据库的业务说明
- form: form
- - name: enable_training
- type: boolean
- required: false
- default: false
- label:
- en_US: Training Data
- zh_Hans: 训练数据
- human_description:
- en_US: You only need to train once. Do not train again unless you want to add more training data
- zh_Hans: 训练数据无更新时,训练一次即可
- form: form
- - name: reset_training_data
- type: boolean
- required: false
- default: false
- label:
- en_US: Reset Training Data
- zh_Hans: 重置训练数据
- human_description:
- en_US: Remove all training data in the current RAG Model
- zh_Hans: 删除当前RAG Model中的所有训练数据
- form: form
- - name: training_metadata
- type: boolean
- required: false
- default: false
- label:
- en_US: Training Metadata
- zh_Hans: 训练元数据
- human_description:
- en_US: If enabled, it will attempt to train on the metadata of that database
- zh_Hans: 是否自动从数据库获取元数据来训练
- form: form
- - name: generate_chart
- type: boolean
- required: false
- default: True
- label:
- en_US: Generate Charts
- zh_Hans: 生成图表
- human_description:
- en_US: Generate Charts
- zh_Hans: 是否生成图表
- form: form
diff --git a/api/core/tools/provider/builtin/vanna/vanna.py b/api/core/tools/provider/builtin/vanna/vanna.py
deleted file mode 100644
index 84724e921a..0000000000
--- a/api/core/tools/provider/builtin/vanna/vanna.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.vanna.tools.vanna import VannaTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class VannaProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- VannaTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "model": "chinook",
- "db_type": "SQLite",
- "url": "https://vanna.ai/Chinook.sqlite",
- "query": "What are the top 10 customers by sales?",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/vanna/vanna.yaml b/api/core/tools/provider/builtin/vanna/vanna.yaml
deleted file mode 100644
index b29fa103e1..0000000000
--- a/api/core/tools/provider/builtin/vanna/vanna.yaml
+++ /dev/null
@@ -1,25 +0,0 @@
-identity:
- author: QCTC
- name: vanna
- label:
- en_US: Vanna.AI
- zh_Hans: Vanna.AI
- description:
- en_US: The fastest way to get actionable insights from your database just by asking questions.
- zh_Hans: 一个基于大模型和RAG的Text2SQL工具。
- icon: icon.png
-credentials_for_provider:
- api_key:
- type: secret-input
- required: true
- label:
- en_US: API key
- zh_Hans: API key
- placeholder:
- en_US: Please input your API key
- zh_Hans: 请输入你的 API key
- pt_BR: Please input your API key
- help:
- en_US: Get your API key from Vanna.AI
- zh_Hans: 从 Vanna.AI 获取你的 API key
- url: https://vanna.ai/account/profile
diff --git a/api/core/tools/provider/builtin/vectorizer/_assets/icon.png b/api/core/tools/provider/builtin/vectorizer/_assets/icon.png
deleted file mode 100644
index 52f18db843..0000000000
Binary files a/api/core/tools/provider/builtin/vectorizer/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/vectorizer/tools/test_data.py b/api/core/tools/provider/builtin/vectorizer/tools/test_data.py
deleted file mode 100644
index 8effa9818a..0000000000
--- a/api/core/tools/provider/builtin/vectorizer/tools/test_data.py
+++ /dev/null
@@ -1 +0,0 @@
-VECTORIZER_ICON_PNG = "iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAboSURBVHgB7Z09bBxFFMffRoAvcQqbguBUxu4wCUikMCZ0TmQK4NLQJCJOlQIkokgEGhQ7NCFIKEhQuIqNnIaGMxRY2GVwmlggDHS+pIHELmIXMTEULPP3eeXz7e7szO7MvE1ufpKV03nuNn7/mfcxH7tEHo/H42lXgqwG1bGw65+/aTQM6K0gpJdCoi7ypCIMui5s9Qv9R1OVTqrVxoL1jPbpvH4hrIp/rnmj5+YOhTQ++1kwmdZgT9ovRi6EF4Xhv/XGL0Sv6OLXYMu0BokjYOSDcBQfJI8xhKFP/HAlqCW8v5vqubBr8yn6maCexxiIDR376LnWmBBzQZtPEvx+L3mMAleOZKb1/XgM2EOnyWMFZJKt78UEQKpJHisk2TYmgM967JFk2z3kYcULwIwXgBkvADNeAGa8AMw8Qcwc6N55/eAh0cYmGaOzQtR/kOhQX+M6+/c23r+3RlT/i2ipTrSyRqw4F+CwMMbgANHQwG7jRywLw/wqDDNzI79xYPjqa2L262jjtYzaT0QT3xEbsck4MXUakgWOvUx08liy0ZPYEKNhel4Y6AZpgR7/8Tvq1wEQ+sMJN6Nh9kqwy+bWYwAM8elZovNv6xmlU7iLs280RNO9ls51os/h/8eBVQEig8Dt5OXUsNrno2tluZw0cI3qUXKONQHy9sYkVHqnjntLA2LnFTAv1gSA+zBhfIDvkfVO/B4xRgWZn4fbe2WAnGJFAAxn03+I7PtUXdzE90Sjl4ne+6L4d5nCigAyYyHPn7tFdPN30uJwX/qI6jtISkQZFVLdhd9SrtNPTrFSB6QZBAaYntsptpAyfvk+KYOCamVR/XrNtLqepduiFnkh3g4iIw6YLAhlOJmKwB9zaarhApr/MPREjAZVisSU1s/KYsGzhmKXClYEWLm/8xpV7btXhcv5I7lt2vtJFA3q/T07r1HopdG5l5xhxQVdn28YFn8kBJCBOZmiPHio1m5QuJzlu9ntXApgZwSsNYJslvGjtjrfm8Sq4neceFUtz3dZCzwW09Gqo2hreuPN7HZRnNqa1BP1x8lhczVNK+zT0TqkjYAF4e7Okxoo2PZX5K4IrhNpb/P8FTK2S1+TcUq1HpBFmquJYo1qEYU6RVarJE0c2ooL7C5IRwBZ5nJ9joyRtk5hA3YBdHqWzG1gBKgE/bzMaK5LqMIugKrbUDHu59/YWVRBsWhrsYZdANV5HBUXYGNlC9dFBW8LdgH6FQVYUnQvkQgm3NH8YuO7bM4LsWZBfT3qRY9OxRyJgJRz+Ij+FDPEQ1C3GVMiWAVQ7f31u/ncytxi4wdZTbRGgdcHnpYLD/FcwSrAoOKizfKfVAiIF4kBMPK+Opfe1iWsMUB1BJh2BRgBabSNAOiFqkXYbcNFUF9P+u82FGdWTcEmgGrvh0FUppB1kC073muXEaDq/21kIjLxV9tFAC7/n5X6tkUM0PH/dcP+P0v41fvkFBYBVHs/MD0CDmVsOzEdb7JgEYDT/8uq4rpj44NSjwDTc/CyzV1gxbH7Ac4F0PH/S4ZHAOaFZLiY+2nFuQA6/t9kQMTCz1CG66tbWvWS4VwAVf9vugAbel6efqrsYbKBcwFeVNz8ajobyTppw2F84FQAnfl/kwER6wJZcWdBc7e2KZwKoOP/TVakWb0f7md+kVhwOwI0BDCFyq42rt4PSiuAiRGAEXdK4ZQlV+8HTgVwefwHvR7nhbOA0FwBGDgTIM/Z3SLXUj2hOW1wR10eSrs7Ou9eTB3jo/dzuh/gTABdn35c8dhpM3BxOmeTuXs/cDoCdDY4qe7l32pbaZxL1jF+GXo/cLotBcWVTiZU3T7RMn8rHiijW9FgauP4Ef1TLdhHWgacCgAj6tYCqGKjU/DNbqxIkMYZNs7MpxmnLuhmwYJna1dbdzHjY42hDL4/wqkA6HWuDkAngRH0iYVjRkVwnoZO/0gsuLwpkw7OBcAtwlwvfESHxctmfMBSiOG0oStj4HCF7T3+RWARwIU7QK/HbWlqls52mYJtezqMj3v34C5VOveFy8Ll4QoTsJ8Txp0RsW8/Os2im2LCtSC1RIqLw3RldTVplOKkPEYDhMAPqttnune2rzTv5Y+WKdEem2ixkWqZYSeDSUp3qwIYNOrR7cBjcbOORxkvADNeAGa8AMx4AZjxAjATf5Ab0Tp5rJBk2/iD3PAwYo8Vkmyb9CjDGfLYIaCp1rdiAnT8S5PeDVkgoDuVCsWeJxwToHZ163m3Z8hjloDGk54vn5gFbT/5eZw8phifvZz8XPlA9qmRj8JRCumi+OkljzbbrvxM0qPMm9rIqY6FXZubVBUinMbzcP3jbuXA6Mh2kMx07KPJJLfj8Xg8Hg/4H+KfFYb2WM4MAAAAAElFTkSuQmCC" # noqa: E501
diff --git a/api/core/tools/provider/builtin/vectorizer/tools/vectorizer.py b/api/core/tools/provider/builtin/vectorizer/tools/vectorizer.py
deleted file mode 100644
index 4bd601c0bd..0000000000
--- a/api/core/tools/provider/builtin/vectorizer/tools/vectorizer.py
+++ /dev/null
@@ -1,69 +0,0 @@
-from base64 import b64decode
-from typing import Any, Union
-
-from httpx import post
-
-from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameter
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.vectorizer.tools.test_data import VECTORIZER_ICON_PNG
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class VectorizerTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- api_key_name = self.runtime.credentials.get("api_key_name", None)
- api_key_value = self.runtime.credentials.get("api_key_value", None)
- mode = tool_parameters.get("mode", "test")
- if mode == "production":
- mode = "preview"
-
- if not api_key_name or not api_key_value:
- raise ToolProviderCredentialValidationError("Please input api key name and value")
-
- image_id = tool_parameters.get("image_id", "")
- if not image_id:
- return self.create_text_message("Please input image id")
-
- if image_id.startswith("__test_"):
- image_binary = b64decode(VECTORIZER_ICON_PNG)
- else:
- image_binary = self.get_variable_file(self.VariableKey.IMAGE)
- if not image_binary:
- return self.create_text_message("Image not found, please request user to generate image firstly.")
-
- response = post(
- "https://vectorizer.ai/api/v1/vectorize",
- files={"image": image_binary},
- data={"mode": mode} if mode == "test" else {},
- auth=(api_key_name, api_key_value),
- timeout=30,
- )
-
- if response.status_code != 200:
- raise Exception(response.text)
-
- return [
- self.create_text_message("the vectorized svg is saved as an image."),
- self.create_blob_message(blob=response.content, meta={"mime_type": "image/svg+xml"}),
- ]
-
- def get_runtime_parameters(self) -> list[ToolParameter]:
- """
- override the runtime parameters
- """
- return [
- ToolParameter.get_simple_instance(
- name="image_id",
- llm_description=f"the image id that you want to vectorize, \
- and the image id should be specified in \
- {[i.name for i in self.list_default_image_variables()]}",
- type=ToolParameter.ToolParameterType.SELECT,
- required=True,
- options=[i.name for i in self.list_default_image_variables()],
- )
- ]
diff --git a/api/core/tools/provider/builtin/vectorizer/tools/vectorizer.yaml b/api/core/tools/provider/builtin/vectorizer/tools/vectorizer.yaml
deleted file mode 100644
index 4b4fb9e245..0000000000
--- a/api/core/tools/provider/builtin/vectorizer/tools/vectorizer.yaml
+++ /dev/null
@@ -1,38 +0,0 @@
-identity:
- name: vectorizer
- author: Dify
- label:
- en_US: Vectorizer.AI
- zh_Hans: Vectorizer.AI
- pt_BR: Vectorizer.AI
-description:
- human:
- en_US: Convert your PNG and JPG images to SVG vectors quickly and easily. Fully automatically. Using AI.
- zh_Hans: 一个将 PNG 和 JPG 图像快速轻松地转换为 SVG 矢量图的工具。
- pt_BR: Convert your PNG and JPG images to SVG vectors quickly and easily. Fully automatically. Using AI.
- llm: A tool for converting images to SVG vectors. you should input the image id as the input of this tool. the image id can be got from parameters.
-parameters:
- - name: mode
- type: select
- required: true
- options:
- - value: production
- label:
- en_US: production
- zh_Hans: 生产模式
- pt_BR: production
- - value: test
- label:
- en_US: test
- zh_Hans: 测试模式
- pt_BR: test
- default: test
- label:
- en_US: Mode
- zh_Hans: 模式
- pt_BR: Mode
- human_description:
- en_US: It is free to integrate with and test out the API in test mode, no subscription required.
- zh_Hans: 在测试模式下,可以免费测试API。
- pt_BR: It is free to integrate with and test out the API in test mode, no subscription required.
- form: form
diff --git a/api/core/tools/provider/builtin/vectorizer/vectorizer.py b/api/core/tools/provider/builtin/vectorizer/vectorizer.py
deleted file mode 100644
index 3b868572f9..0000000000
--- a/api/core/tools/provider/builtin/vectorizer/vectorizer.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.vectorizer.tools.vectorizer import VectorizerTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class VectorizerProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- VectorizerTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={"mode": "test", "image_id": "__test_123"},
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/vectorizer/vectorizer.yaml b/api/core/tools/provider/builtin/vectorizer/vectorizer.yaml
deleted file mode 100644
index 1257f8d285..0000000000
--- a/api/core/tools/provider/builtin/vectorizer/vectorizer.yaml
+++ /dev/null
@@ -1,47 +0,0 @@
-identity:
- author: Dify
- name: vectorizer
- label:
- en_US: Vectorizer.AI
- zh_Hans: Vectorizer.AI
- pt_BR: Vectorizer.AI
- description:
- en_US: Convert your PNG and JPG images to SVG vectors quickly and easily. Fully automatically. Using AI.
- zh_Hans: 一个将 PNG 和 JPG 图像快速轻松地转换为 SVG 矢量图的工具。
- pt_BR: Convert your PNG and JPG images to SVG vectors quickly and easily. Fully automatically. Using AI.
- icon: icon.png
- tags:
- - productivity
- - image
-credentials_for_provider:
- api_key_name:
- type: secret-input
- required: true
- label:
- en_US: Vectorizer.AI API Key name
- zh_Hans: Vectorizer.AI API Key name
- pt_BR: Vectorizer.AI API Key name
- placeholder:
- en_US: Please input your Vectorizer.AI ApiKey name
- zh_Hans: 请输入你的 Vectorizer.AI ApiKey name
- pt_BR: Please input your Vectorizer.AI ApiKey name
- help:
- en_US: Get your Vectorizer.AI API Key from Vectorizer.AI.
- zh_Hans: 从 Vectorizer.AI 获取您的 Vectorizer.AI API Key。
- pt_BR: Get your Vectorizer.AI API Key from Vectorizer.AI.
- url: https://vectorizer.ai/api
- api_key_value:
- type: secret-input
- required: true
- label:
- en_US: Vectorizer.AI API Key
- zh_Hans: Vectorizer.AI API Key
- pt_BR: Vectorizer.AI API Key
- placeholder:
- en_US: Please input your Vectorizer.AI ApiKey
- zh_Hans: 请输入你的 Vectorizer.AI ApiKey
- pt_BR: Please input your Vectorizer.AI ApiKey
- help:
- en_US: Get your Vectorizer.AI API Key from Vectorizer.AI.
- zh_Hans: 从 Vectorizer.AI 获取您的 Vectorizer.AI API Key。
- pt_BR: Get your Vectorizer.AI API Key from Vectorizer.AI.
diff --git a/api/core/tools/provider/builtin/webscraper/_assets/icon.svg b/api/core/tools/provider/builtin/webscraper/_assets/icon.svg
deleted file mode 100644
index 8123199a38..0000000000
--- a/api/core/tools/provider/builtin/webscraper/_assets/icon.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/webscraper/tools/webscraper.py b/api/core/tools/provider/builtin/webscraper/tools/webscraper.py
deleted file mode 100644
index 12670b4b8b..0000000000
--- a/api/core/tools/provider/builtin/webscraper/tools/webscraper.py
+++ /dev/null
@@ -1,33 +0,0 @@
-from typing import Any, Union
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.errors import ToolInvokeError
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class WebscraperTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- try:
- url = tool_parameters.get("url", "")
- user_agent = tool_parameters.get("user_agent", "")
- if not url:
- return self.create_text_message("Please input url")
-
- # get webpage
- result = self.get_url(url, user_agent=user_agent)
-
- if tool_parameters.get("generate_summary"):
- # summarize and return
- return self.create_text_message(self.summary(user_id=user_id, content=result))
- else:
- # return full webpage
- return self.create_text_message(result)
- except Exception as e:
- raise ToolInvokeError(str(e))
diff --git a/api/core/tools/provider/builtin/webscraper/tools/webscraper.yaml b/api/core/tools/provider/builtin/webscraper/tools/webscraper.yaml
deleted file mode 100644
index 0bb48a941d..0000000000
--- a/api/core/tools/provider/builtin/webscraper/tools/webscraper.yaml
+++ /dev/null
@@ -1,60 +0,0 @@
-identity:
- name: webscraper
- author: Dify
- label:
- en_US: Web Scraper
- zh_Hans: 网页爬虫
- pt_BR: Web Scraper
-description:
- human:
- en_US: A tool for scraping webpages.
- zh_Hans: 一个用于爬取网页的工具。
- pt_BR: A tool for scraping webpages.
- llm: A tool for scraping webpages. Input should be a URL.
-parameters:
- - name: url
- type: string
- required: true
- label:
- en_US: URL
- zh_Hans: 网页链接
- pt_BR: URL
- human_description:
- en_US: used for linking to webpages
- zh_Hans: 用于链接到网页
- pt_BR: used for linking to webpages
- llm_description: url for scraping
- form: llm
- - name: user_agent
- type: string
- required: false
- label:
- en_US: User Agent
- zh_Hans: User Agent
- pt_BR: User Agent
- human_description:
- en_US: used for identifying the browser.
- zh_Hans: 用于识别浏览器。
- pt_BR: used for identifying the browser.
- form: form
- default: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.1000.0 Safari/537.36
- - name: generate_summary
- type: boolean
- required: false
- label:
- en_US: Whether to generate summary
- zh_Hans: 是否生成摘要
- human_description:
- en_US: If true, the crawler will only return the page summary content.
- zh_Hans: 如果启用,爬虫将仅返回页面摘要内容。
- form: form
- options:
- - value: 'true'
- label:
- en_US: 'Yes'
- zh_Hans: 是
- - value: 'false'
- label:
- en_US: 'No'
- zh_Hans: 否
- default: 'false'
diff --git a/api/core/tools/provider/builtin/webscraper/webscraper.py b/api/core/tools/provider/builtin/webscraper/webscraper.py
deleted file mode 100644
index 3c51393ac6..0000000000
--- a/api/core/tools/provider/builtin/webscraper/webscraper.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.webscraper.tools.webscraper import WebscraperTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class WebscraperProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- WebscraperTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "url": "https://www.google.com",
- "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/webscraper/webscraper.yaml b/api/core/tools/provider/builtin/webscraper/webscraper.yaml
deleted file mode 100644
index 6c2eb97784..0000000000
--- a/api/core/tools/provider/builtin/webscraper/webscraper.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-identity:
- author: Dify
- name: webscraper
- label:
- en_US: WebScraper
- zh_Hans: 网页抓取
- pt_BR: WebScraper
- description:
- en_US: Web Scrapper tool kit is used to scrape web
- zh_Hans: 一个用于抓取网页的工具。
- pt_BR: Web Scrapper tool kit is used to scrape web
- icon: icon.svg
- tags:
- - productivity
-credentials_for_provider:
diff --git a/api/core/tools/provider/builtin/websearch/_assets/icon.svg b/api/core/tools/provider/builtin/websearch/_assets/icon.svg
deleted file mode 100644
index d6ef5d878f..0000000000
--- a/api/core/tools/provider/builtin/websearch/_assets/icon.svg
+++ /dev/null
@@ -1,23 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/websearch/tools/get_markdown.py b/api/core/tools/provider/builtin/websearch/tools/get_markdown.py
deleted file mode 100644
index 043879deea..0000000000
--- a/api/core/tools/provider/builtin/websearch/tools/get_markdown.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from typing import Any, Union
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-BASE_URL = "https://api.serply.io/v1/request"
-
-
-class SerplyApi:
- """
- SerplyAPI tool provider.
- """
-
- def __init__(self, api_key: str) -> None:
- """Initialize SerplyAPI tool provider."""
- self.serply_api_key = api_key
-
- def run(self, url: str, **kwargs: Any) -> str:
- """Run query through SerplyAPI and parse result."""
-
- location = kwargs.get("location", "US")
-
- headers = {
- "X-API-KEY": self.serply_api_key,
- "X-User-Agent": kwargs.get("device", "desktop"),
- "X-Proxy-Location": location,
- "User-Agent": "Dify",
- }
- data = {"url": url, "method": "GET", "response_type": "markdown"}
- res = requests.post(url, headers=headers, json=data)
- return res.text
-
-
-class GetMarkdownTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke the SerplyApi tool.
- """
- url = tool_parameters["url"]
- location = tool_parameters.get("location")
-
- api_key = self.runtime.credentials["serply_api_key"]
- result = SerplyApi(api_key).run(url, location=location)
-
- return self.create_text_message(text=result)
diff --git a/api/core/tools/provider/builtin/websearch/tools/get_markdown.yaml b/api/core/tools/provider/builtin/websearch/tools/get_markdown.yaml
deleted file mode 100644
index 06a302bd14..0000000000
--- a/api/core/tools/provider/builtin/websearch/tools/get_markdown.yaml
+++ /dev/null
@@ -1,96 +0,0 @@
-identity:
- name: get_markdown
- author: Dify
- label:
- en_US: Get Markdown API
- zh_Hans: Get Markdown API
-description:
- human:
- en_US: A tool to perform convert a webpage to markdown to make it easier for LLMs to understand.
- zh_Hans: 一个将网页转换为 Markdown 的工具,以便模型更容易理解
- llm: A tool to perform convert a webpage to markdown to make it easier for LLMs to understand.
-parameters:
- - name: url
- type: string
- required: true
- label:
- en_US: URL
- zh_Hans: URL
- human_description:
- en_US: URL that you want to grab the content from
- zh_Hans: 您要从中获取内容的 URL
- llm_description: Defines the link want to grab content from.
- form: llm
- - name: location
- type: string
- required: false
- default: US
- label:
- en_US: Location
- zh_Hans: 询问
- human_description:
- en_US: Defines from where you want the search to originate. (For example - New York)
- zh_Hans: 定义您想要搜索的起始位置。 (例如 - 纽约)
- llm_description: Defines from where you want the search to originate. (For example - New York)
- form: form
- options:
- - value: AU
- label:
- en_US: Australia
- zh_Hans: 澳大利亚
- pt_BR: Australia
- - value: BR
- label:
- en_US: Brazil
- zh_Hans: 巴西
- pt_BR: Brazil
- - value: CA
- label:
- en_US: Canada
- zh_Hans: 加拿大
- pt_BR: Canada
- - value: DE
- label:
- en_US: Germany
- zh_Hans: 德国
- pt_BR: Germany
- - value: FR
- label:
- en_US: France
- zh_Hans: 法国
- pt_BR: France
- - value: GB
- label:
- en_US: United Kingdom
- zh_Hans: 英国
- pt_BR: United Kingdom
- - value: US
- label:
- en_US: United States
- zh_Hans: 美国
- pt_BR: United States
- - value: JP
- label:
- en_US: Japan
- zh_Hans: 日本
- pt_BR: Japan
- - value: IN
- label:
- en_US: India
- zh_Hans: 印度
- pt_BR: India
- - value: KR
- label:
- en_US: Korea
- zh_Hans: 韩国
- pt_BR: Korea
- - value: SG
- label:
- en_US: Singapore
- zh_Hans: 新加坡
- pt_BR: Singapore
- - value: SE
- label:
- en_US: Sweden
- zh_Hans: 瑞典
- pt_BR: Sweden
diff --git a/api/core/tools/provider/builtin/websearch/tools/job_search.py b/api/core/tools/provider/builtin/websearch/tools/job_search.py
deleted file mode 100644
index 293f4f6329..0000000000
--- a/api/core/tools/provider/builtin/websearch/tools/job_search.py
+++ /dev/null
@@ -1,88 +0,0 @@
-from typing import Any, Union
-from urllib.parse import urlencode
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-BASE_URL = "https://api.serply.io/v1/news/"
-
-
-class SerplyApi:
- """
- SerplyAPI tool provider.
- """
-
- def __init__(self, api_key: str) -> None:
- """Initialize SerplyAPI tool provider."""
- self.serply_api_key = api_key
-
- def run(self, query: str, **kwargs: Any) -> str:
- """Run query through SerplyAPI and parse result."""
- params = {"q": query, "hl": kwargs.get("hl", "en"), "gl": kwargs.get("gl", "US"), "num": kwargs.get("num", 10)}
- location = kwargs.get("location", "US")
-
- headers = {
- "X-API-KEY": self.serply_api_key,
- "X-User-Agent": kwargs.get("device", "desktop"),
- "X-Proxy-Location": location,
- "User-Agent": "Dify",
- }
-
- url = f"{BASE_URL}{urlencode(params)}"
- res = requests.get(
- url,
- headers=headers,
- )
- res = res.json()
-
- return self.parse_results(res)
-
- @staticmethod
- def parse_results(res: dict) -> str:
- """Process response from Serply Job Search."""
- jobs = res.get("jobs", [])
- if not jobs:
- raise ValueError(f"Got error from Serply: {res}")
-
- string = []
- for job in jobs[:10]:
- try:
- string.append(
- "\n".join(
- [
- f"Position: {job['position']}",
- f"Employer: {job['employer']}",
- f"Location: {job['location']}",
- f"Link: {job['link']}",
- f"""Highest: {", ".join(list(job["highlights"]))}""",
- "---",
- ]
- )
- )
- except KeyError:
- continue
-
- content = "\n".join(string)
- return f"\nJobs results:\n {content}\n"
-
-
-class JobSearchTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke the SerplyApi tool.
- """
- query = tool_parameters["query"]
- gl = tool_parameters.get("gl", "us")
- hl = tool_parameters.get("hl", "en")
- location = tool_parameters.get("location")
-
- api_key = self.runtime.credentials["serply_api_key"]
- result = SerplyApi(api_key).run(query, gl=gl, hl=hl, location=location)
-
- return self.create_text_message(text=result)
diff --git a/api/core/tools/provider/builtin/websearch/tools/job_search.yaml b/api/core/tools/provider/builtin/websearch/tools/job_search.yaml
deleted file mode 100644
index b5ede3df46..0000000000
--- a/api/core/tools/provider/builtin/websearch/tools/job_search.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
-identity:
- name: job_search
- author: Dify
- label:
- en_US: Job Search API
- zh_Hans: Job Search API
-description:
- human:
- en_US: A tool to retrieve job titles, company names and description from Google Jobs engine.
- zh_Hans: 一个从 Google 招聘引擎检索职位名称、公司名称和描述的工具。
- llm: A tool to retrieve job titles, company names and description from Google Jobs engine.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query
- zh_Hans: 询问
- human_description:
- en_US: Defines the query you want to search.
- zh_Hans: 定义您要搜索的查询。
- llm_description: Defines the search query you want to search.
- form: llm
- - name: location
- type: string
- required: false
- default: US
- label:
- en_US: Location
- zh_Hans: 询问
- human_description:
- en_US: Defines from where you want the search to originate. (For example - New York)
- zh_Hans: 定义您想要搜索的起始位置。 (例如 - 纽约)
- llm_description: Defines from where you want the search to originate. (For example - New York)
- form: form
- options:
- - value: US
- label:
- en_US: United States
- zh_Hans: 美国
- pt_BR: United States
diff --git a/api/core/tools/provider/builtin/websearch/tools/news_search.py b/api/core/tools/provider/builtin/websearch/tools/news_search.py
deleted file mode 100644
index 9b5482fe18..0000000000
--- a/api/core/tools/provider/builtin/websearch/tools/news_search.py
+++ /dev/null
@@ -1,90 +0,0 @@
-from typing import Any, Union
-from urllib.parse import urlencode
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-BASE_URL = "https://api.serply.io/v1/news/"
-
-
-class SerplyApi:
- """
- SerplyApi tool provider.
- """
-
- def __init__(self, api_key: str) -> None:
- """Initialize SerplyApi tool provider."""
- self.serply_api_key = api_key
-
- def run(self, query: str, **kwargs: Any) -> str:
- """Run query through SerplyApi and parse result."""
- params = {"q": query, "hl": kwargs.get("hl", "en"), "gl": kwargs.get("gl", "US"), "num": kwargs.get("num", 10)}
- location = kwargs.get("location", "US")
-
- headers = {
- "X-API-KEY": self.serply_api_key,
- "X-User-Agent": kwargs.get("device", "desktop"),
- "X-Proxy-Location": location,
- "User-Agent": "Dify",
- }
-
- url = f"{BASE_URL}{urlencode(params)}"
- res = requests.get(
- url,
- headers=headers,
- )
- res = res.json()
-
- return self.parse_results(res)
-
- @staticmethod
- def parse_results(res: dict) -> str:
- """Process response from Serply News Search."""
- news = res.get("entries", [])
- if not news:
- raise ValueError(f"Got error from Serply: {res}")
-
- string = []
- for entry in news:
- try:
- # follow url
- r = requests.get(entry["link"])
- final_link = r.history[-1].headers["Location"]
- string.append(
- "\n".join(
- [
- f"Title: {entry['title']}",
- f"Link: {final_link}",
- f"Source: {entry['source']['title']}",
- f"Published: {entry['published']}",
- "---",
- ]
- )
- )
- except KeyError:
- continue
-
- content = "\n".join(string)
- return f"\nNews:\n {content}\n"
-
-
-class NewsSearchTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke the SerplyApi tool.
- """
- query = tool_parameters["query"]
- gl = tool_parameters.get("gl", "us")
- hl = tool_parameters.get("hl", "en")
- location = tool_parameters.get("location")
-
- api_key = self.runtime.credentials["serply_api_key"]
- result = SerplyApi(api_key).run(query, gl=gl, hl=hl, location=location)
-
- return self.create_text_message(text=result)
diff --git a/api/core/tools/provider/builtin/websearch/tools/news_search.yaml b/api/core/tools/provider/builtin/websearch/tools/news_search.yaml
deleted file mode 100644
index 126c610825..0000000000
--- a/api/core/tools/provider/builtin/websearch/tools/news_search.yaml
+++ /dev/null
@@ -1,501 +0,0 @@
-identity:
- name: news_search
- author: Dify
- label:
- en_US: News Search API
- zh_Hans: News Search API
-description:
- human:
- en_US: A tool to retrieve organic search results snippets and links from Google News engine.
- zh_Hans: 一种从 Google 新闻引擎检索有机搜索结果片段和链接的工具。
- llm: A tool to retrieve organic search results snippets and links from Google News engine.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query
- zh_Hans: 询问
- human_description:
- en_US: Defines the query you want to search.
- zh_Hans: 定义您要搜索的查询。
- llm_description: Defines the search query you want to search.
- form: llm
- - name: location
- type: string
- required: false
- default: US
- label:
- en_US: Location
- zh_Hans: 询问
- human_description:
- en_US: Defines from where you want the search to originate. (For example - New York)
- zh_Hans: 定义您想要搜索的起始位置。 (例如 - 纽约)
- llm_description: Defines from where you want the search to originate. (For example - New York)
- form: form
- options:
- - value: AU
- label:
- en_US: Australia
- zh_Hans: 澳大利亚
- pt_BR: Australia
- - value: BR
- label:
- en_US: Brazil
- zh_Hans: 巴西
- pt_BR: Brazil
- - value: CA
- label:
- en_US: Canada
- zh_Hans: 加拿大
- pt_BR: Canada
- - value: DE
- label:
- en_US: Germany
- zh_Hans: 德国
- pt_BR: Germany
- - value: FR
- label:
- en_US: France
- zh_Hans: 法国
- pt_BR: France
- - value: GB
- label:
- en_US: United Kingdom
- zh_Hans: 英国
- pt_BR: United Kingdom
- - value: US
- label:
- en_US: United States
- zh_Hans: 美国
- pt_BR: United States
- - value: JP
- label:
- en_US: Japan
- zh_Hans: 日本
- pt_BR: Japan
- - value: IN
- label:
- en_US: India
- zh_Hans: 印度
- pt_BR: India
- - value: KR
- label:
- en_US: Korea
- zh_Hans: 韩国
- pt_BR: Korea
- - value: SG
- label:
- en_US: Singapore
- zh_Hans: 新加坡
- pt_BR: Singapore
- - value: SE
- label:
- en_US: Sweden
- zh_Hans: 瑞典
- pt_BR: Sweden
- - name: gl
- type: select
- label:
- en_US: Country
- zh_Hans: 国家/地区
- required: false
- human_description:
- en_US: Defines the country of the search. Default is "US".
- zh_Hans: 定义搜索的国家/地区。默认为“美国”。
- llm_description: Defines the gl parameter of the Google search.
- form: form
- default: US
- options:
- - value: AR
- label:
- en_US: Argentina
- zh_Hans: 阿根廷
- pt_BR: Argentina
- - value: AU
- label:
- en_US: Australia
- zh_Hans: 澳大利亚
- pt_BR: Australia
- - value: AT
- label:
- en_US: Austria
- zh_Hans: 奥地利
- pt_BR: Austria
- - value: BE
- label:
- en_US: Belgium
- zh_Hans: 比利时
- pt_BR: Belgium
- - value: BR
- label:
- en_US: Brazil
- zh_Hans: 巴西
- pt_BR: Brazil
- - value: CA
- label:
- en_US: Canada
- zh_Hans: 加拿大
- pt_BR: Canada
- - value: CL
- label:
- en_US: Chile
- zh_Hans: 智利
- pt_BR: Chile
- - value: CO
- label:
- en_US: Colombia
- zh_Hans: 哥伦比亚
- pt_BR: Colombia
- - value: CN
- label:
- en_US: China
- zh_Hans: 中国
- pt_BR: China
- - value: CZ
- label:
- en_US: Czech Republic
- zh_Hans: 捷克共和国
- pt_BR: Czech Republic
- - value: DK
- label:
- en_US: Denmark
- zh_Hans: 丹麦
- pt_BR: Denmark
- - value: FI
- label:
- en_US: Finland
- zh_Hans: 芬兰
- pt_BR: Finland
- - value: FR
- label:
- en_US: France
- zh_Hans: 法国
- pt_BR: France
- - value: DE
- label:
- en_US: Germany
- zh_Hans: 德国
- pt_BR: Germany
- - value: HK
- label:
- en_US: Hong Kong
- zh_Hans: 香港
- pt_BR: Hong Kong
- - value: IN
- label:
- en_US: India
- zh_Hans: 印度
- pt_BR: India
- - value: ID
- label:
- en_US: Indonesia
- zh_Hans: 印度尼西亚
- pt_BR: Indonesia
- - value: IT
- label:
- en_US: Italy
- zh_Hans: 意大利
- pt_BR: Italy
- - value: JP
- label:
- en_US: Japan
- zh_Hans: 日本
- pt_BR: Japan
- - value: KR
- label:
- en_US: Korea
- zh_Hans: 韩国
- pt_BR: Korea
- - value: MY
- label:
- en_US: Malaysia
- zh_Hans: 马来西亚
- pt_BR: Malaysia
- - value: MX
- label:
- en_US: Mexico
- zh_Hans: 墨西哥
- pt_BR: Mexico
- - value: NL
- label:
- en_US: Netherlands
- zh_Hans: 荷兰
- pt_BR: Netherlands
- - value: NZ
- label:
- en_US: New Zealand
- zh_Hans: 新西兰
- pt_BR: New Zealand
- - value: NO
- label:
- en_US: Norway
- zh_Hans: 挪威
- pt_BR: Norway
- - value: PH
- label:
- en_US: Philippines
- zh_Hans: 菲律宾
- pt_BR: Philippines
- - value: PL
- label:
- en_US: Poland
- zh_Hans: 波兰
- pt_BR: Poland
- - value: PT
- label:
- en_US: Portugal
- zh_Hans: 葡萄牙
- pt_BR: Portugal
- - value: RU
- label:
- en_US: Russia
- zh_Hans: 俄罗斯
- pt_BR: Russia
- - value: SA
- label:
- en_US: Saudi Arabia
- zh_Hans: 沙特阿拉伯
- pt_BR: Saudi Arabia
- - value: SG
- label:
- en_US: Singapore
- zh_Hans: 新加坡
- pt_BR: Singapore
- - value: ZA
- label:
- en_US: South Africa
- zh_Hans: 南非
- pt_BR: South Africa
- - value: ES
- label:
- en_US: Spain
- zh_Hans: 西班牙
- pt_BR: Spain
- - value: SE
- label:
- en_US: Sweden
- zh_Hans: 瑞典
- pt_BR: Sweden
- - value: CH
- label:
- en_US: Switzerland
- zh_Hans: 瑞士
- pt_BR: Switzerland
- - value: TW
- label:
- en_US: Taiwan
- zh_Hans: 台湾
- pt_BR: Taiwan
- - value: TH
- label:
- en_US: Thailand
- zh_Hans: 泰国
- pt_BR: Thailand
- - value: TR
- label:
- en_US: Turkey
- zh_Hans: 土耳其
- pt_BR: Turkey
- - value: GB
- label:
- en_US: United Kingdom
- zh_Hans: 英国
- pt_BR: United Kingdom
- - value: US
- label:
- en_US: United States
- zh_Hans: 美国
- pt_BR: United States
- - name: hl
- type: select
- label:
- en_US: Language
- zh_Hans: 语言
- human_description:
- en_US: Defines the interface language of the search. Default is "en".
- zh_Hans: 定义搜索的界面语言。默认为“en”。
- required: false
- default: en
- form: form
- options:
- - value: ar
- label:
- en_US: Arabic
- zh_Hans: 阿拉伯语
- - value: bg
- label:
- en_US: Bulgarian
- zh_Hans: 保加利亚语
- - value: ca
- label:
- en_US: Catalan
- zh_Hans: 加泰罗尼亚语
- - value: zh-cn
- label:
- en_US: Chinese (Simplified)
- zh_Hans: 中文(简体)
- - value: zh-tw
- label:
- en_US: Chinese (Traditional)
- zh_Hans: 中文(繁体)
- - value: cs
- label:
- en_US: Czech
- zh_Hans: 捷克语
- - value: da
- label:
- en_US: Danish
- zh_Hans: 丹麦语
- - value: nl
- label:
- en_US: Dutch
- zh_Hans: 荷兰语
- - value: en
- label:
- en_US: English
- zh_Hans: 英语
- - value: et
- label:
- en_US: Estonian
- zh_Hans: 爱沙尼亚语
- - value: fi
- label:
- en_US: Finnish
- zh_Hans: 芬兰语
- - value: fr
- label:
- en_US: French
- zh_Hans: 法语
- - value: de
- label:
- en_US: German
- zh_Hans: 德语
- - value: el
- label:
- en_US: Greek
- zh_Hans: 希腊语
- - value: iw
- label:
- en_US: Hebrew
- zh_Hans: 希伯来语
- - value: hi
- label:
- en_US: Hindi
- zh_Hans: 印地语
- - value: hu
- label:
- en_US: Hungarian
- zh_Hans: 匈牙利语
- - value: id
- label:
- en_US: Indonesian
- zh_Hans: 印尼语
- - value: it
- label:
- en_US: Italian
- zh_Hans: 意大利语
- - value: ja
- label:
- en_US: Japanese
- zh_Hans: 日语
- - value: kn
- label:
- en_US: Kannada
- zh_Hans: 卡纳达语
- - value: ko
- label:
- en_US: Korean
- zh_Hans: 韩语
- - value: lv
- label:
- en_US: Latvian
- zh_Hans: 拉脱维亚语
- - value: lt
- label:
- en_US: Lithuanian
- zh_Hans: 立陶宛语
- - value: my
- label:
- en_US: Malay
- zh_Hans: 马来语
- - value: ml
- label:
- en_US: Malayalam
- zh_Hans: 马拉雅拉姆语
- - value: mr
- label:
- en_US: Marathi
- zh_Hans: 马拉地语
- - value: "no"
- label:
- en_US: Norwegian
- zh_Hans: 挪威语
- - value: pl
- label:
- en_US: Polish
- zh_Hans: 波兰语
- - value: pt-br
- label:
- en_US: Portuguese (Brazil)
- zh_Hans: 葡萄牙语(巴西)
- - value: pt-pt
- label:
- en_US: Portuguese (Portugal)
- zh_Hans: 葡萄牙语(葡萄牙)
- - value: pa
- label:
- en_US: Punjabi
- zh_Hans: 旁遮普语
- - value: ro
- label:
- en_US: Romanian
- zh_Hans: 罗马尼亚语
- - value: ru
- label:
- en_US: Russian
- zh_Hans: 俄语
- - value: sr
- label:
- en_US: Serbian
- zh_Hans: 塞尔维亚语
- - value: sk
- label:
- en_US: Slovak
- zh_Hans: 斯洛伐克语
- - value: sl
- label:
- en_US: Slovenian
- zh_Hans: 斯洛文尼亚语
- - value: es
- label:
- en_US: Spanish
- zh_Hans: 西班牙语
- - value: sv
- label:
- en_US: Swedish
- zh_Hans: 瑞典语
- - value: ta
- label:
- en_US: Tamil
- zh_Hans: 泰米尔语
- - value: te
- label:
- en_US: Telugu
- zh_Hans: 泰卢固语
- - value: th
- label:
- en_US: Thai
- zh_Hans: 泰语
- - value: tr
- label:
- en_US: Turkish
- zh_Hans: 土耳其语
- - value: uk
- label:
- en_US: Ukrainian
- zh_Hans: 乌克兰语
- - value: vi
- label:
- en_US: Vietnamese
- zh_Hans: 越南语
diff --git a/api/core/tools/provider/builtin/websearch/tools/scholar_search.py b/api/core/tools/provider/builtin/websearch/tools/scholar_search.py
deleted file mode 100644
index 798d059b51..0000000000
--- a/api/core/tools/provider/builtin/websearch/tools/scholar_search.py
+++ /dev/null
@@ -1,93 +0,0 @@
-from typing import Any, Union
-from urllib.parse import urlencode
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-BASE_URL = "https://api.serply.io/v1/scholar/"
-
-
-class SerplyApi:
- """
- SerplyApi tool provider.
- """
-
- def __init__(self, api_key: str) -> None:
- """Initialize SerplyApi tool provider."""
- self.serply_api_key = api_key
-
- def run(self, query: str, **kwargs: Any) -> str:
- """Run query through SerplyApi and parse result."""
- params = {"q": query, "hl": kwargs.get("hl", "en"), "gl": kwargs.get("gl", "US"), "num": kwargs.get("num", 10)}
- location = kwargs.get("location", "US")
-
- headers = {
- "X-API-KEY": self.serply_api_key,
- "X-User-Agent": kwargs.get("device", "desktop"),
- "X-Proxy-Location": location,
- "User-Agent": "Dify",
- }
-
- url = f"{BASE_URL}{urlencode(params)}"
- res = requests.get(
- url,
- headers=headers,
- )
- res = res.json()
-
- return self.parse_results(res)
-
- @staticmethod
- def parse_results(res: dict) -> str:
- """Process response from Serply News Search."""
- articles = res.get("articles", [])
- if not articles:
- raise ValueError(f"Got error from Serply: {res}")
-
- string = []
- for article in articles:
- try:
- if "doc" in article:
- link = article["doc"]["link"]
- else:
- link = article["link"]
- authors = [author["name"] for author in article["author"]["authors"]]
- string.append(
- "\n".join(
- [
- f"Title: {article['title']}",
- f"Link: {link}",
- f"Description: {article['description']}",
- f"Cite: {article['cite']}",
- f"Authors: {', '.join(authors)}",
- "---",
- ]
- )
- )
- except KeyError:
- continue
-
- content = "\n".join(string)
- return f"\nScholar results:\n {content}\n"
-
-
-class ScholarSearchTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke the SerplyApi tool.
- """
- query = tool_parameters["query"]
- gl = tool_parameters.get("gl", "us")
- hl = tool_parameters.get("hl", "en")
- location = tool_parameters.get("location")
-
- api_key = self.runtime.credentials["serply_api_key"]
- result = SerplyApi(api_key).run(query, gl=gl, hl=hl, location=location)
-
- return self.create_text_message(text=result)
diff --git a/api/core/tools/provider/builtin/websearch/tools/scholar_search.yaml b/api/core/tools/provider/builtin/websearch/tools/scholar_search.yaml
deleted file mode 100644
index 63e79d7ebf..0000000000
--- a/api/core/tools/provider/builtin/websearch/tools/scholar_search.yaml
+++ /dev/null
@@ -1,501 +0,0 @@
-identity:
- name: scholar_search
- author: Dify
- label:
- en_US: Scholar API
- zh_Hans: Scholar API
-description:
- human:
- en_US: A tool to retrieve scholarly literature.
- zh_Hans: 学术文献检索工具
- llm: A tool to retrieve scholarly literature.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query
- zh_Hans: 询问
- human_description:
- en_US: Defines the query you want to search.
- zh_Hans: 定义您要搜索的查询。
- llm_description: Defines the search query you want to search.
- form: llm
- - name: location
- type: string
- required: false
- default: US
- label:
- en_US: Location
- zh_Hans: 询问
- human_description:
- en_US: Defines from where you want the search to originate. (For example - New York)
- zh_Hans: 定义您想要搜索的起始位置。 (例如 - 纽约)
- llm_description: Defines from where you want the search to originate. (For example - New York)
- form: form
- options:
- - value: AU
- label:
- en_US: Australia
- zh_Hans: 澳大利亚
- pt_BR: Australia
- - value: BR
- label:
- en_US: Brazil
- zh_Hans: 巴西
- pt_BR: Brazil
- - value: CA
- label:
- en_US: Canada
- zh_Hans: 加拿大
- pt_BR: Canada
- - value: DE
- label:
- en_US: Germany
- zh_Hans: 德国
- pt_BR: Germany
- - value: FR
- label:
- en_US: France
- zh_Hans: 法国
- pt_BR: France
- - value: GB
- label:
- en_US: United Kingdom
- zh_Hans: 英国
- pt_BR: United Kingdom
- - value: US
- label:
- en_US: United States
- zh_Hans: 美国
- pt_BR: United States
- - value: JP
- label:
- en_US: Japan
- zh_Hans: 日本
- pt_BR: Japan
- - value: IN
- label:
- en_US: India
- zh_Hans: 印度
- pt_BR: India
- - value: KR
- label:
- en_US: Korea
- zh_Hans: 韩国
- pt_BR: Korea
- - value: SG
- label:
- en_US: Singapore
- zh_Hans: 新加坡
- pt_BR: Singapore
- - value: SE
- label:
- en_US: Sweden
- zh_Hans: 瑞典
- pt_BR: Sweden
- - name: gl
- type: select
- label:
- en_US: Country
- zh_Hans: 国家/地区
- required: false
- human_description:
- en_US: Defines the country of the search. Default is "US".
- zh_Hans: 定义搜索的国家/地区。默认为“美国”。
- llm_description: Defines the gl parameter of the Google search.
- form: form
- default: US
- options:
- - value: AR
- label:
- en_US: Argentina
- zh_Hans: 阿根廷
- pt_BR: Argentina
- - value: AU
- label:
- en_US: Australia
- zh_Hans: 澳大利亚
- pt_BR: Australia
- - value: AT
- label:
- en_US: Austria
- zh_Hans: 奥地利
- pt_BR: Austria
- - value: BE
- label:
- en_US: Belgium
- zh_Hans: 比利时
- pt_BR: Belgium
- - value: BR
- label:
- en_US: Brazil
- zh_Hans: 巴西
- pt_BR: Brazil
- - value: CA
- label:
- en_US: Canada
- zh_Hans: 加拿大
- pt_BR: Canada
- - value: CL
- label:
- en_US: Chile
- zh_Hans: 智利
- pt_BR: Chile
- - value: CO
- label:
- en_US: Colombia
- zh_Hans: 哥伦比亚
- pt_BR: Colombia
- - value: CN
- label:
- en_US: China
- zh_Hans: 中国
- pt_BR: China
- - value: CZ
- label:
- en_US: Czech Republic
- zh_Hans: 捷克共和国
- pt_BR: Czech Republic
- - value: DK
- label:
- en_US: Denmark
- zh_Hans: 丹麦
- pt_BR: Denmark
- - value: FI
- label:
- en_US: Finland
- zh_Hans: 芬兰
- pt_BR: Finland
- - value: FR
- label:
- en_US: France
- zh_Hans: 法国
- pt_BR: France
- - value: DE
- label:
- en_US: Germany
- zh_Hans: 德国
- pt_BR: Germany
- - value: HK
- label:
- en_US: Hong Kong
- zh_Hans: 香港
- pt_BR: Hong Kong
- - value: IN
- label:
- en_US: India
- zh_Hans: 印度
- pt_BR: India
- - value: ID
- label:
- en_US: Indonesia
- zh_Hans: 印度尼西亚
- pt_BR: Indonesia
- - value: IT
- label:
- en_US: Italy
- zh_Hans: 意大利
- pt_BR: Italy
- - value: JP
- label:
- en_US: Japan
- zh_Hans: 日本
- pt_BR: Japan
- - value: KR
- label:
- en_US: Korea
- zh_Hans: 韩国
- pt_BR: Korea
- - value: MY
- label:
- en_US: Malaysia
- zh_Hans: 马来西亚
- pt_BR: Malaysia
- - value: MX
- label:
- en_US: Mexico
- zh_Hans: 墨西哥
- pt_BR: Mexico
- - value: NL
- label:
- en_US: Netherlands
- zh_Hans: 荷兰
- pt_BR: Netherlands
- - value: NZ
- label:
- en_US: New Zealand
- zh_Hans: 新西兰
- pt_BR: New Zealand
- - value: "NO"
- label:
- en_US: Norway
- zh_Hans: 挪威
- pt_BR: Norway
- - value: PH
- label:
- en_US: Philippines
- zh_Hans: 菲律宾
- pt_BR: Philippines
- - value: PL
- label:
- en_US: Poland
- zh_Hans: 波兰
- pt_BR: Poland
- - value: PT
- label:
- en_US: Portugal
- zh_Hans: 葡萄牙
- pt_BR: Portugal
- - value: RU
- label:
- en_US: Russia
- zh_Hans: 俄罗斯
- pt_BR: Russia
- - value: SA
- label:
- en_US: Saudi Arabia
- zh_Hans: 沙特阿拉伯
- pt_BR: Saudi Arabia
- - value: SG
- label:
- en_US: Singapore
- zh_Hans: 新加坡
- pt_BR: Singapore
- - value: ZA
- label:
- en_US: South Africa
- zh_Hans: 南非
- pt_BR: South Africa
- - value: ES
- label:
- en_US: Spain
- zh_Hans: 西班牙
- pt_BR: Spain
- - value: SE
- label:
- en_US: Sweden
- zh_Hans: 瑞典
- pt_BR: Sweden
- - value: CH
- label:
- en_US: Switzerland
- zh_Hans: 瑞士
- pt_BR: Switzerland
- - value: TW
- label:
- en_US: Taiwan
- zh_Hans: 台湾
- pt_BR: Taiwan
- - value: TH
- label:
- en_US: Thailand
- zh_Hans: 泰国
- pt_BR: Thailand
- - value: TR
- label:
- en_US: Turkey
- zh_Hans: 土耳其
- pt_BR: Turkey
- - value: GB
- label:
- en_US: United Kingdom
- zh_Hans: 英国
- pt_BR: United Kingdom
- - value: US
- label:
- en_US: United States
- zh_Hans: 美国
- pt_BR: United States
- - name: hl
- type: select
- label:
- en_US: Language
- zh_Hans: 语言
- human_description:
- en_US: Defines the interface language of the search. Default is "en".
- zh_Hans: 定义搜索的界面语言。默认为“en”。
- required: false
- default: en
- form: form
- options:
- - value: ar
- label:
- en_US: Arabic
- zh_Hans: 阿拉伯语
- - value: bg
- label:
- en_US: Bulgarian
- zh_Hans: 保加利亚语
- - value: ca
- label:
- en_US: Catalan
- zh_Hans: 加泰罗尼亚语
- - value: zh-cn
- label:
- en_US: Chinese (Simplified)
- zh_Hans: 中文(简体)
- - value: zh-tw
- label:
- en_US: Chinese (Traditional)
- zh_Hans: 中文(繁体)
- - value: cs
- label:
- en_US: Czech
- zh_Hans: 捷克语
- - value: da
- label:
- en_US: Danish
- zh_Hans: 丹麦语
- - value: nl
- label:
- en_US: Dutch
- zh_Hans: 荷兰语
- - value: en
- label:
- en_US: English
- zh_Hans: 英语
- - value: et
- label:
- en_US: Estonian
- zh_Hans: 爱沙尼亚语
- - value: fi
- label:
- en_US: Finnish
- zh_Hans: 芬兰语
- - value: fr
- label:
- en_US: French
- zh_Hans: 法语
- - value: de
- label:
- en_US: German
- zh_Hans: 德语
- - value: el
- label:
- en_US: Greek
- zh_Hans: 希腊语
- - value: iw
- label:
- en_US: Hebrew
- zh_Hans: 希伯来语
- - value: hi
- label:
- en_US: Hindi
- zh_Hans: 印地语
- - value: hu
- label:
- en_US: Hungarian
- zh_Hans: 匈牙利语
- - value: id
- label:
- en_US: Indonesian
- zh_Hans: 印尼语
- - value: it
- label:
- en_US: Italian
- zh_Hans: 意大利语
- - value: ja
- label:
- en_US: Japanese
- zh_Hans: 日语
- - value: kn
- label:
- en_US: Kannada
- zh_Hans: 卡纳达语
- - value: ko
- label:
- en_US: Korean
- zh_Hans: 韩语
- - value: lv
- label:
- en_US: Latvian
- zh_Hans: 拉脱维亚语
- - value: lt
- label:
- en_US: Lithuanian
- zh_Hans: 立陶宛语
- - value: my
- label:
- en_US: Malay
- zh_Hans: 马来语
- - value: ml
- label:
- en_US: Malayalam
- zh_Hans: 马拉雅拉姆语
- - value: mr
- label:
- en_US: Marathi
- zh_Hans: 马拉地语
- - value: "no"
- label:
- en_US: Norwegian
- zh_Hans: 挪威语
- - value: pl
- label:
- en_US: Polish
- zh_Hans: 波兰语
- - value: pt-br
- label:
- en_US: Portuguese (Brazil)
- zh_Hans: 葡萄牙语(巴西)
- - value: pt-pt
- label:
- en_US: Portuguese (Portugal)
- zh_Hans: 葡萄牙语(葡萄牙)
- - value: pa
- label:
- en_US: Punjabi
- zh_Hans: 旁遮普语
- - value: ro
- label:
- en_US: Romanian
- zh_Hans: 罗马尼亚语
- - value: ru
- label:
- en_US: Russian
- zh_Hans: 俄语
- - value: sr
- label:
- en_US: Serbian
- zh_Hans: 塞尔维亚语
- - value: sk
- label:
- en_US: Slovak
- zh_Hans: 斯洛伐克语
- - value: sl
- label:
- en_US: Slovenian
- zh_Hans: 斯洛文尼亚语
- - value: es
- label:
- en_US: Spanish
- zh_Hans: 西班牙语
- - value: sv
- label:
- en_US: Swedish
- zh_Hans: 瑞典语
- - value: ta
- label:
- en_US: Tamil
- zh_Hans: 泰米尔语
- - value: te
- label:
- en_US: Telugu
- zh_Hans: 泰卢固语
- - value: th
- label:
- en_US: Thai
- zh_Hans: 泰语
- - value: tr
- label:
- en_US: Turkish
- zh_Hans: 土耳其语
- - value: uk
- label:
- en_US: Ukrainian
- zh_Hans: 乌克兰语
- - value: vi
- label:
- en_US: Vietnamese
- zh_Hans: 越南语
diff --git a/api/core/tools/provider/builtin/websearch/tools/web_search.py b/api/core/tools/provider/builtin/websearch/tools/web_search.py
deleted file mode 100644
index fe363ac7a4..0000000000
--- a/api/core/tools/provider/builtin/websearch/tools/web_search.py
+++ /dev/null
@@ -1,90 +0,0 @@
-import typing
-from urllib.parse import urlencode
-
-import requests
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class SerplyApi:
- """
- SerplyApi tool provider.
- """
-
- def __init__(self, api_key: str) -> None:
- """Initialize Serply Web Search Tool provider."""
- self.serply_api_key = api_key
- self.base_url = "https://api.serply.io/v1/search/"
-
- def run(self, query: str, **kwargs: typing.Any) -> str:
- """Run query through Serply and parse result."""
- params = {"q": query, "hl": kwargs.get("hl", "en"), "gl": kwargs.get("gl", "US"), "num": kwargs.get("num", 10)}
- location = kwargs.get("location", "US")
-
- headers = {
- "X-API-KEY": self.serply_api_key,
- "X-User-Agent": kwargs.get("device", "desktop"),
- "X-Proxy-Location": location,
- "User-Agent": "Dify",
- }
-
- url = f"{self.base_url}{urlencode(params)}"
- res = requests.get(
- url,
- headers=headers,
- )
- res = res.json()
-
- return self.parse_results(res)
-
- @staticmethod
- def parse_results(res: dict) -> str:
- """Process response from Serply Web Search."""
- results = res.get("results", [])
- if not results:
- raise ValueError(f"Got error from Serply: {res}")
-
- string = []
- for result in results:
- try:
- string.append(
- "\n".join(
- [
- f"Title: {result['title']}",
- f"Link: {result['link']}",
- f"Description: {result['description'].strip()}",
- "---",
- ]
- )
- )
- except KeyError:
- continue
-
- if related_questions := res.get("related_questions", []):
- string.append("---")
- string.append("Related Questions: ")
- string.append("\n".join(related_questions))
-
- content = "\n".join(string)
- return f"\nSearch results:\n {content}\n"
-
-
-class WebSearchTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, typing.Any],
- ) -> typing.Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- Invoke the SerplyApi tool.
- """
- query = tool_parameters["query"]
- num = tool_parameters.get("num", 10)
- gl = tool_parameters.get("gl", "us")
- hl = tool_parameters.get("hl", "en")
- location = tool_parameters.get("location", "None")
-
- api_key = self.runtime.credentials["serply_api_key"]
- result = SerplyApi(api_key).run(query=query, num=num, gl=gl, hl=hl, location=location)
- return self.create_text_message(text=result)
diff --git a/api/core/tools/provider/builtin/websearch/tools/web_search.yaml b/api/core/tools/provider/builtin/websearch/tools/web_search.yaml
deleted file mode 100644
index 055029253c..0000000000
--- a/api/core/tools/provider/builtin/websearch/tools/web_search.yaml
+++ /dev/null
@@ -1,376 +0,0 @@
-identity:
- name: web_search
- author: Dify
- label:
- en_US: Web Search API
- zh_Hans: Web Search API
-description:
- human:
- en_US: A tool to retrieve answer boxes, knowledge graphs, snippets, and webpages from Google Search engine.
- zh_Hans: 一种从 Google 搜索引擎检索答案框、知识图、片段和网页的工具。
- llm: A tool to retrieve answer boxes, knowledge graphs, snippets, and webpages from Google Search engine.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query
- zh_Hans: 询问
- human_description:
- en_US: Defines the query you want to search.
- zh_Hans: 定义您要搜索的查询。
- llm_description: Defines the search query you want to search.
- form: llm
- - name: location
- type: string
- required: false
- default: US
- label:
- en_US: Location
- zh_Hans: 询问
- human_description:
- en_US: Defines from where you want the search to originate. (For example - New York)
- zh_Hans: 定义您想要搜索的起始位置。 (例如 - 纽约)
- llm_description: Defines from where you want the search to originate. (For example - New York)
- form: form
- options:
- - value: AU
- label:
- en_US: Australia
- zh_Hans: 澳大利亚
- pt_BR: Australia
- - value: BR
- label:
- en_US: Brazil
- zh_Hans: 巴西
- pt_BR: Brazil
- - value: CA
- label:
- en_US: Canada
- zh_Hans: 加拿大
- pt_BR: Canada
- - value: DE
- label:
- en_US: Germany
- zh_Hans: 德国
- pt_BR: Germany
- - value: FR
- label:
- en_US: France
- zh_Hans: 法国
- pt_BR: France
- - value: GB
- label:
- en_US: United Kingdom
- zh_Hans: 英国
- pt_BR: United Kingdom
- - value: US
- label:
- en_US: United States
- zh_Hans: 美国
- pt_BR: United States
- - value: JP
- label:
- en_US: Japan
- zh_Hans: 日本
- pt_BR: Japan
- - value: IN
- label:
- en_US: India
- zh_Hans: 印度
- pt_BR: India
- - value: KR
- label:
- en_US: Korea
- zh_Hans: 韩国
- pt_BR: Korea
- - value: SG
- label:
- en_US: Singapore
- zh_Hans: 新加坡
- pt_BR: Singapore
- - value: SE
- label:
- en_US: Sweden
- zh_Hans: 瑞典
- pt_BR: Sweden
- - name: device
- type: select
- label:
- en_US: Device Type
- zh_Hans: 汉斯先生
- human_description:
- en_US: Defines the device to make interface search. Default is "desktop".
- zh_Hans: 定义进行接口搜索的设备。默认为“桌面”
- required: false
- default: desktop
- form: form
- options:
- - value: desktop
- label:
- en_US: Desktop
- zh_Hans: 桌面
- - value: mobile
- label:
- en_US: Mobile
- zh_Hans: 移动的
- - name: gl
- type: select
- label:
- en_US: Country
- zh_Hans: 国家/地区
- required: false
- human_description:
- en_US: Defines the country of the search. Default is "US".
- zh_Hans: 定义搜索的国家/地区。默认为“美国”。
- llm_description: Defines the gl parameter of the Google search.
- form: form
- default: US
- options:
- - value: AU
- label:
- en_US: Australia
- zh_Hans: 澳大利亚
- pt_BR: Australia
- - value: BR
- label:
- en_US: Brazil
- zh_Hans: 巴西
- pt_BR: Brazil
- - value: CA
- label:
- en_US: Canada
- zh_Hans: 加拿大
- pt_BR: Canada
- - value: DE
- label:
- en_US: Germany
- zh_Hans: 德国
- pt_BR: Germany
- - value: FR
- label:
- en_US: France
- zh_Hans: 法国
- pt_BR: France
- - value: GB
- label:
- en_US: United Kingdom
- zh_Hans: 英国
- pt_BR: United Kingdom
- - value: IN
- label:
- en_US: India
- zh_Hans: 印度
- pt_BR: India
- - value: KR
- label:
- en_US: Korea
- zh_Hans: 韩国
- pt_BR: Korea
- - value: SE
- label:
- en_US: Sweden
- zh_Hans: 瑞典
- pt_BR: Sweden
- - value: SG
- label:
- en_US: Singapore
- zh_Hans: 新加坡
- pt_BR: Singapore
- - value: US
- label:
- en_US: United States
- zh_Hans: 美国
- pt_BR: United States
- - name: hl
- type: select
- label:
- en_US: Language
- zh_Hans: 语言
- human_description:
- en_US: Defines the interface language of the search. Default is "en".
- zh_Hans: 定义搜索的界面语言。默认为“en”。
- required: false
- default: en
- form: form
- options:
- - value: ar
- label:
- en_US: Arabic
- zh_Hans: 阿拉伯语
- - value: bg
- label:
- en_US: Bulgarian
- zh_Hans: 保加利亚语
- - value: ca
- label:
- en_US: Catalan
- zh_Hans: 加泰罗尼亚语
- - value: zh-cn
- label:
- en_US: Chinese (Simplified)
- zh_Hans: 中文(简体)
- - value: zh-tw
- label:
- en_US: Chinese (Traditional)
- zh_Hans: 中文(繁体)
- - value: cs
- label:
- en_US: Czech
- zh_Hans: 捷克语
- - value: da
- label:
- en_US: Danish
- zh_Hans: 丹麦语
- - value: nl
- label:
- en_US: Dutch
- zh_Hans: 荷兰语
- - value: en
- label:
- en_US: English
- zh_Hans: 英语
- - value: et
- label:
- en_US: Estonian
- zh_Hans: 爱沙尼亚语
- - value: fi
- label:
- en_US: Finnish
- zh_Hans: 芬兰语
- - value: fr
- label:
- en_US: French
- zh_Hans: 法语
- - value: de
- label:
- en_US: German
- zh_Hans: 德语
- - value: el
- label:
- en_US: Greek
- zh_Hans: 希腊语
- - value: iw
- label:
- en_US: Hebrew
- zh_Hans: 希伯来语
- - value: hi
- label:
- en_US: Hindi
- zh_Hans: 印地语
- - value: hu
- label:
- en_US: Hungarian
- zh_Hans: 匈牙利语
- - value: id
- label:
- en_US: Indonesian
- zh_Hans: 印尼语
- - value: it
- label:
- en_US: Italian
- zh_Hans: 意大利语
- - value: ja
- label:
- en_US: Japanese
- zh_Hans: 日语
- - value: kn
- label:
- en_US: Kannada
- zh_Hans: 卡纳达语
- - value: ko
- label:
- en_US: Korean
- zh_Hans: 韩语
- - value: lv
- label:
- en_US: Latvian
- zh_Hans: 拉脱维亚语
- - value: lt
- label:
- en_US: Lithuanian
- zh_Hans: 立陶宛语
- - value: my
- label:
- en_US: Malay
- zh_Hans: 马来语
- - value: ml
- label:
- en_US: Malayalam
- zh_Hans: 马拉雅拉姆语
- - value: mr
- label:
- en_US: Marathi
- zh_Hans: 马拉地语
- - value: "no"
- label:
- en_US: Norwegian
- zh_Hans: 挪威语
- - value: pl
- label:
- en_US: Polish
- zh_Hans: 波兰语
- - value: pt-br
- label:
- en_US: Portuguese (Brazil)
- zh_Hans: 葡萄牙语(巴西)
- - value: pt-pt
- label:
- en_US: Portuguese (Portugal)
- zh_Hans: 葡萄牙语(葡萄牙)
- - value: pa
- label:
- en_US: Punjabi
- zh_Hans: 旁遮普语
- - value: ro
- label:
- en_US: Romanian
- zh_Hans: 罗马尼亚语
- - value: ru
- label:
- en_US: Russian
- zh_Hans: 俄语
- - value: sr
- label:
- en_US: Serbian
- zh_Hans: 塞尔维亚语
- - value: sk
- label:
- en_US: Slovak
- zh_Hans: 斯洛伐克语
- - value: sl
- label:
- en_US: Slovenian
- zh_Hans: 斯洛文尼亚语
- - value: es
- label:
- en_US: Spanish
- zh_Hans: 西班牙语
- - value: sv
- label:
- en_US: Swedish
- zh_Hans: 瑞典语
- - value: ta
- label:
- en_US: Tamil
- zh_Hans: 泰米尔语
- - value: te
- label:
- en_US: Telugu
- zh_Hans: 泰卢固语
- - value: th
- label:
- en_US: Thai
- zh_Hans: 泰语
- - value: tr
- label:
- en_US: Turkish
- zh_Hans: 土耳其语
- - value: uk
- label:
- en_US: Ukrainian
- zh_Hans: 乌克兰语
- - value: vi
- label:
- en_US: Vietnamese
- zh_Hans: 越南语
diff --git a/api/core/tools/provider/builtin/websearch/websearch.py b/api/core/tools/provider/builtin/websearch/websearch.py
deleted file mode 100644
index 90cc0c573a..0000000000
--- a/api/core/tools/provider/builtin/websearch/websearch.py
+++ /dev/null
@@ -1,21 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.websearch.tools.web_search import WebSearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class WebSearchAPIProvider(BuiltinToolProviderController):
- # validate when saving the api_key
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- WebSearchTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={"query": "what is llm"},
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/websearch/websearch.yaml b/api/core/tools/provider/builtin/websearch/websearch.yaml
deleted file mode 100644
index c4267e1022..0000000000
--- a/api/core/tools/provider/builtin/websearch/websearch.yaml
+++ /dev/null
@@ -1,34 +0,0 @@
-identity:
- name: websearch
- author: Serply.io
- label:
- en_US: Serply.io
- zh_Hans: Serply.io
- pt_BR: Serply.io
- description:
- en_US: Serply.io is a robust real-time SERP API delivering structured data from a collection of search engines including Web Search, Jobs, News, and many more.
- zh_Hans: Serply.io 是一个强大的实时 SERP API,可提供来自 搜索 招聘 新闻等搜索引擎集合的结构化数据。
- pt_BR: Serply.io is a robust real-time SERP API delivering structured data from a collection of search engines including Web Search, Jobs, News, and many more.
- icon: icon.svg
- tags:
- - search
- - business
- - news
- - productivity
-credentials_for_provider:
- serply_api_key:
- type: secret-input
- required: true
- label:
- en_US: Serply.io API key
- zh_Hans: Serply.io API key
- pt_BR: Serply.io API key
- placeholder:
- en_US: Please input your Serply.io API key
- zh_Hans: 请输入你的 Serply.io API key
- pt_BR: Please input your Serply.io API key
- help:
- en_US: Get your Serply.io API key from https://Serply.io/
- zh_Hans: 从 Serply.io 获取您的 Serply.io API key
- pt_BR: Get your Serply.io API key from Serply.io
- url: https://Serply.io/
diff --git a/api/core/tools/provider/builtin/wecom/_assets/icon.png b/api/core/tools/provider/builtin/wecom/_assets/icon.png
deleted file mode 100644
index 8588c20d57..0000000000
Binary files a/api/core/tools/provider/builtin/wecom/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/wecom/tools/wecom_group_bot.py b/api/core/tools/provider/builtin/wecom/tools/wecom_group_bot.py
deleted file mode 100644
index 545d9f4f8d..0000000000
--- a/api/core/tools/provider/builtin/wecom/tools/wecom_group_bot.py
+++ /dev/null
@@ -1,57 +0,0 @@
-from typing import Any, Union
-
-import httpx
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-from core.tools.utils.uuid_utils import is_valid_uuid
-
-
-class WecomGroupBotTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- content = tool_parameters.get("content", "")
- if not content:
- return self.create_text_message("Invalid parameter content")
-
- hook_key = tool_parameters.get("hook_key", "")
- if not is_valid_uuid(hook_key):
- return self.create_text_message(f"Invalid parameter hook_key ${hook_key}, not a valid UUID")
-
- message_type = tool_parameters.get("message_type", "text")
- if message_type == "markdown":
- payload = {
- "msgtype": "markdown",
- "markdown": {
- "content": content,
- },
- }
- else:
- payload = {
- "msgtype": "text",
- "text": {
- "content": content,
- },
- }
- api_url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send"
- headers = {
- "Content-Type": "application/json",
- }
- params = {
- "key": hook_key,
- }
-
- try:
- res = httpx.post(api_url, headers=headers, params=params, json=payload)
- if res.is_success:
- return self.create_text_message("Text message sent successfully")
- else:
- return self.create_text_message(
- f"Failed to send the text message, status code: {res.status_code}, response: {res.text}"
- )
- except Exception as e:
- return self.create_text_message("Failed to send message to group chat bot. {}".format(e))
diff --git a/api/core/tools/provider/builtin/wecom/tools/wecom_group_bot.yaml b/api/core/tools/provider/builtin/wecom/tools/wecom_group_bot.yaml
deleted file mode 100644
index 379005a102..0000000000
--- a/api/core/tools/provider/builtin/wecom/tools/wecom_group_bot.yaml
+++ /dev/null
@@ -1,64 +0,0 @@
-identity:
- name: wecom_group_bot
- author: Bowen Liang
- label:
- en_US: Send Group Message
- zh_Hans: 发送群消息
- pt_BR: Send Group Message
- icon: icon.svg
-description:
- human:
- en_US: Sending a group message on Wecom via the webhook of group bot
- zh_Hans: 通过企业微信的群机器人webhook发送群消息
- pt_BR: Sending a group message on Wecom via the webhook of group bot
- llm: A tool for sending messages to a chat group on Wecom(企业微信) .
-parameters:
- - name: hook_key
- type: secret-input
- required: true
- label:
- en_US: Wecom Group bot webhook key
- zh_Hans: 群机器人webhook的key
- pt_BR: Wecom Group bot webhook key
- human_description:
- en_US: Wecom Group bot webhook key
- zh_Hans: 群机器人webhook的key
- pt_BR: Wecom Group bot webhook key
- form: form
- - name: content
- type: string
- required: true
- label:
- en_US: content
- zh_Hans: 消息内容
- pt_BR: content
- human_description:
- en_US: Content to sent to the group.
- zh_Hans: 群消息文本
- pt_BR: Content to sent to the group.
- llm_description: Content of the message
- form: llm
- - name: message_type
- type: select
- default: text
- required: true
- label:
- en_US: Wecom Group bot message type
- zh_Hans: 群机器人webhook的消息类型
- pt_BR: Wecom Group bot message type
- human_description:
- en_US: Wecom Group bot message type
- zh_Hans: 群机器人webhook的消息类型
- pt_BR: Wecom Group bot message type
- options:
- - value: text
- label:
- en_US: Text
- zh_Hans: 文本
- pt_BR: Text
- - value: markdown
- label:
- en_US: Markdown
- zh_Hans: Markdown
- pt_BR: Markdown
- form: form
diff --git a/api/core/tools/provider/builtin/wecom/wecom.py b/api/core/tools/provider/builtin/wecom/wecom.py
deleted file mode 100644
index 573f76ee56..0000000000
--- a/api/core/tools/provider/builtin/wecom/wecom.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from core.tools.provider.builtin.wecom.tools.wecom_group_bot import WecomGroupBotTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class WecomProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- WecomGroupBotTool()
diff --git a/api/core/tools/provider/builtin/wecom/wecom.yaml b/api/core/tools/provider/builtin/wecom/wecom.yaml
deleted file mode 100644
index a544055ba4..0000000000
--- a/api/core/tools/provider/builtin/wecom/wecom.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-identity:
- author: Bowen Liang
- name: wecom
- label:
- en_US: Wecom
- zh_Hans: 企业微信
- pt_BR: Wecom
- description:
- en_US: Wecom group bot
- zh_Hans: 企业微信群机器人
- pt_BR: Wecom group bot
- icon: icon.png
- tags:
- - social
-credentials_for_provider:
diff --git a/api/core/tools/provider/builtin/wikipedia/_assets/icon.svg b/api/core/tools/provider/builtin/wikipedia/_assets/icon.svg
deleted file mode 100644
index fe652aacf9..0000000000
--- a/api/core/tools/provider/builtin/wikipedia/_assets/icon.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/wikipedia/tools/wikipedia_search.py b/api/core/tools/provider/builtin/wikipedia/tools/wikipedia_search.py
deleted file mode 100644
index cb88e9519a..0000000000
--- a/api/core/tools/provider/builtin/wikipedia/tools/wikipedia_search.py
+++ /dev/null
@@ -1,105 +0,0 @@
-from typing import Any, Optional, Union
-
-import wikipedia
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-WIKIPEDIA_MAX_QUERY_LENGTH = 300
-
-
-class WikipediaAPIWrapper:
- """Wrapper around WikipediaAPI.
-
- To use, you should have the ``wikipedia`` python package installed.
- This wrapper will use the Wikipedia API to conduct searches and
- fetch page summaries. By default, it will return the page summaries
- of the top-k results.
- It limits the Document content by doc_content_chars_max.
- """
-
- top_k_results: int = 3
- lang: str = "en"
- load_all_available_meta: bool = False
- doc_content_chars_max: int = 4000
-
- def __init__(self, doc_content_chars_max: int = 4000):
- self.doc_content_chars_max = doc_content_chars_max
-
- def run(self, query: str, lang: str = "") -> str:
- if lang in wikipedia.languages():
- self.lang = lang
-
- wikipedia.set_lang(self.lang)
- wiki_client = wikipedia
-
- """Run Wikipedia search and get page summaries."""
- page_titles = wiki_client.search(query[:WIKIPEDIA_MAX_QUERY_LENGTH])
- summaries = []
- for page_title in page_titles[: self.top_k_results]:
- if wiki_page := self._fetch_page(page_title):
- if summary := self._formatted_page_summary(page_title, wiki_page):
- summaries.append(summary)
- if not summaries:
- return "No good Wikipedia Search Result was found"
- return "\n\n".join(summaries)[: self.doc_content_chars_max]
-
- @staticmethod
- def _formatted_page_summary(page_title: str, wiki_page: Any) -> Optional[str]:
- return f"Page: {page_title}\nSummary: {wiki_page.summary}"
-
- def _fetch_page(self, page: str) -> Optional[str]:
- try:
- return wikipedia.page(title=page, auto_suggest=False)
- except (
- wikipedia.exceptions.PageError,
- wikipedia.exceptions.DisambiguationError,
- ):
- return None
-
-
-class WikipediaQueryRun:
- """Tool that searches the Wikipedia API."""
-
- name = "Wikipedia"
- description = (
- "A wrapper around Wikipedia. "
- "Useful for when you need to answer general questions about "
- "people, places, companies, facts, historical events, or other subjects. "
- "Input should be a search query."
- )
- api_wrapper: WikipediaAPIWrapper
-
- def __init__(self, api_wrapper: WikipediaAPIWrapper):
- self.api_wrapper = api_wrapper
-
- def _run(
- self,
- query: str,
- lang: str = "",
- ) -> str:
- """Use the Wikipedia tool."""
- return self.api_wrapper.run(query, lang)
-
-
-class WikiPediaSearchTool(BuiltinTool):
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- query = tool_parameters.get("query", "")
- lang = tool_parameters.get("language", "")
- if not query:
- return self.create_text_message("Please input query")
-
- tool = WikipediaQueryRun(
- api_wrapper=WikipediaAPIWrapper(doc_content_chars_max=4000),
- )
-
- result = tool._run(query, lang)
-
- return self.create_text_message(self.summary(user_id=user_id, content=result))
diff --git a/api/core/tools/provider/builtin/wikipedia/tools/wikipedia_search.yaml b/api/core/tools/provider/builtin/wikipedia/tools/wikipedia_search.yaml
deleted file mode 100644
index 98d002df1c..0000000000
--- a/api/core/tools/provider/builtin/wikipedia/tools/wikipedia_search.yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-identity:
- name: wikipedia_search
- author: Dify
- label:
- en_US: WikipediaSearch
- zh_Hans: 维基百科搜索
- pt_BR: WikipediaSearch
- icon: icon.svg
-description:
- human:
- en_US: A tool for performing a Wikipedia search and extracting snippets and webpages.
- zh_Hans: 一个用于执行维基百科搜索并提取片段和网页的工具。
- pt_BR: A tool for performing a Wikipedia search and extracting snippets and webpages.
- llm: A tool for performing a Wikipedia search and extracting snippets and webpages. Input should be a search query.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query string
- zh_Hans: 查询语句
- pt_BR: Query string
- human_description:
- en_US: key words for searching
- zh_Hans: 查询关键词
- pt_BR: key words for searching
- llm_description: key words for searching, this should be in the language of "language" parameter
- form: llm
- - name: language
- type: string
- required: true
- label:
- en_US: Language
- zh_Hans: 语言
- human_description:
- en_US: The language of the Wikipedia to be searched
- zh_Hans: 要搜索的维基百科语言
- llm_description: >-
- language of the wikipedia to be searched,
- only "de" for German,
- "en" for English,
- "fr" for French,
- "hi" for Hindi,
- "ja" for Japanese,
- "ko" for Korean,
- "pl" for Polish,
- "pt" for Portuguese,
- "ro" for Romanian,
- "uk" for Ukrainian,
- "vi" for Vietnamese,
- and "zh" for Chinese are supported
- form: llm
- options:
- - value: de
- label:
- en_US: German
- zh_Hans: 德语
- - value: en
- label:
- en_US: English
- zh_Hans: 英语
- - value: fr
- label:
- en_US: French
- zh_Hans: 法语
- - value: hi
- label:
- en_US: Hindi
- zh_Hans: 印地语
- - value: ja
- label:
- en_US: Japanese
- zh_Hans: 日语
- - value: ko
- label:
- en_US: Korean
- zh_Hans: 韩语
- - value: pl
- label:
- en_US: Polish
- zh_Hans: 波兰语
- - value: pt
- label:
- en_US: Portuguese
- zh_Hans: 葡萄牙语
- - value: ro
- label:
- en_US: Romanian
- zh_Hans: 罗马尼亚语
- - value: uk
- label:
- en_US: Ukrainian
- zh_Hans: 乌克兰语
- - value: vi
- label:
- en_US: Vietnamese
- zh_Hans: 越南语
- - value: zh
- label:
- en_US: Chinese
- zh_Hans: 中文
diff --git a/api/core/tools/provider/builtin/wikipedia/wikipedia.py b/api/core/tools/provider/builtin/wikipedia/wikipedia.py
deleted file mode 100644
index 178bf7b0ce..0000000000
--- a/api/core/tools/provider/builtin/wikipedia/wikipedia.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.wikipedia.tools.wikipedia_search import WikiPediaSearchTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class WikiPediaProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- WikiPediaSearchTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "query": "misaka mikoto",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/wikipedia/wikipedia.yaml b/api/core/tools/provider/builtin/wikipedia/wikipedia.yaml
deleted file mode 100644
index c582824022..0000000000
--- a/api/core/tools/provider/builtin/wikipedia/wikipedia.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-identity:
- author: Dify
- name: wikipedia
- label:
- en_US: Wikipedia
- zh_Hans: 维基百科
- pt_BR: Wikipedia
- description:
- en_US: Wikipedia is a free online encyclopedia, created and edited by volunteers around the world.
- zh_Hans: 维基百科是一个由全世界的志愿者创建和编辑的免费在线百科全书。
- pt_BR: Wikipedia is a free online encyclopedia, created and edited by volunteers around the world.
- icon: icon.svg
- tags:
- - social
-credentials_for_provider:
diff --git a/api/core/tools/provider/builtin/wolframalpha/_assets/icon.svg b/api/core/tools/provider/builtin/wolframalpha/_assets/icon.svg
deleted file mode 100644
index 2caf32ee67..0000000000
--- a/api/core/tools/provider/builtin/wolframalpha/_assets/icon.svg
+++ /dev/null
@@ -1,23 +0,0 @@
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/wolframalpha/tools/wolframalpha.py b/api/core/tools/provider/builtin/wolframalpha/tools/wolframalpha.py
deleted file mode 100644
index 9dc5bed824..0000000000
--- a/api/core/tools/provider/builtin/wolframalpha/tools/wolframalpha.py
+++ /dev/null
@@ -1,72 +0,0 @@
-from typing import Any, Union
-
-from httpx import get
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.errors import ToolInvokeError, ToolProviderCredentialValidationError
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class WolframAlphaTool(BuiltinTool):
- _base_url = "https://api.wolframalpha.com/v2/query"
-
- def _invoke(
- self,
- user_id: str,
- tool_parameters: dict[str, Any],
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- query = tool_parameters.get("query", "")
- if not query:
- return self.create_text_message("Please input query")
- appid = self.runtime.credentials.get("appid", "")
- if not appid:
- raise ToolProviderCredentialValidationError("Please input appid")
-
- params = {"appid": appid, "input": query, "includepodid": "Result", "format": "plaintext", "output": "json"}
-
- finished = False
- result = None
- # try 3 times at most
- counter = 0
-
- while not finished and counter < 3:
- counter += 1
- try:
- response = get(self._base_url, params=params, timeout=20)
- response.raise_for_status()
- response_data = response.json()
- except Exception as e:
- raise ToolInvokeError(str(e))
-
- if "success" not in response_data["queryresult"] or response_data["queryresult"]["success"] != True:
- query_result = response_data.get("queryresult", {})
- if query_result.get("error"):
- if "msg" in query_result["error"]:
- if query_result["error"]["msg"] == "Invalid appid":
- raise ToolProviderCredentialValidationError("Invalid appid")
- raise ToolInvokeError("Failed to invoke tool")
-
- if "didyoumeans" in response_data["queryresult"]:
- # get the most likely interpretation
- query = ""
- max_score = 0
- for didyoumean in response_data["queryresult"]["didyoumeans"]:
- if float(didyoumean["score"]) > max_score:
- query = didyoumean["val"]
- max_score = float(didyoumean["score"])
-
- params["input"] = query
- else:
- finished = True
- if "souces" in response_data["queryresult"]:
- return self.create_link_message(response_data["queryresult"]["sources"]["url"])
- elif "pods" in response_data["queryresult"]:
- result = response_data["queryresult"]["pods"][0]["subpods"][0]["plaintext"]
-
- if not finished or not result:
- return self.create_text_message("No result found")
-
- return self.create_text_message(result)
diff --git a/api/core/tools/provider/builtin/wolframalpha/tools/wolframalpha.yaml b/api/core/tools/provider/builtin/wolframalpha/tools/wolframalpha.yaml
deleted file mode 100644
index 08b5668691..0000000000
--- a/api/core/tools/provider/builtin/wolframalpha/tools/wolframalpha.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-identity:
- name: wolframalpha
- author: Dify
- label:
- en_US: WolframAlpha
- zh_Hans: WolframAlpha
- pt_BR: WolframAlpha
-description:
- human:
- en_US: WolframAlpha is a powerful computational knowledge engine.
- zh_Hans: WolframAlpha 是一个强大的计算知识引擎。
- pt_BR: WolframAlpha is a powerful computational knowledge engine.
- llm: WolframAlpha is a powerful computational knowledge engine. one single query can get the answer of a question.
-parameters:
- - name: query
- type: string
- required: true
- label:
- en_US: Query string
- zh_Hans: 计算语句
- pt_BR: Query string
- human_description:
- en_US: used for calculating
- zh_Hans: 用于计算最终结果
- pt_BR: used for calculating
- llm_description: a single query for calculating
- form: llm
diff --git a/api/core/tools/provider/builtin/wolframalpha/wolframalpha.py b/api/core/tools/provider/builtin/wolframalpha/wolframalpha.py
deleted file mode 100644
index 7be288b538..0000000000
--- a/api/core/tools/provider/builtin/wolframalpha/wolframalpha.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from typing import Any
-
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.wolframalpha.tools.wolframalpha import WolframAlphaTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class GoogleProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- WolframAlphaTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "query": "1+2+....+111",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/wolframalpha/wolframalpha.yaml b/api/core/tools/provider/builtin/wolframalpha/wolframalpha.yaml
deleted file mode 100644
index 91265eb3c0..0000000000
--- a/api/core/tools/provider/builtin/wolframalpha/wolframalpha.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-identity:
- author: Dify
- name: wolframalpha
- label:
- en_US: WolframAlpha
- zh_Hans: WolframAlpha
- pt_BR: WolframAlpha
- description:
- en_US: WolframAlpha is a powerful computational knowledge engine.
- zh_Hans: WolframAlpha 是一个强大的计算知识引擎。
- pt_BR: WolframAlpha is a powerful computational knowledge engine.
- icon: icon.svg
- tags:
- - productivity
- - utilities
-credentials_for_provider:
- appid:
- type: secret-input
- required: true
- label:
- en_US: WolframAlpha AppID
- zh_Hans: WolframAlpha AppID
- pt_BR: WolframAlpha AppID
- placeholder:
- en_US: Please input your WolframAlpha AppID
- zh_Hans: 请输入你的 WolframAlpha AppID
- pt_BR: Please input your WolframAlpha AppID
- help:
- en_US: Get your WolframAlpha AppID from WolframAlpha, please use "full results" api access.
- zh_Hans: 从 WolframAlpha 获取您的 WolframAlpha AppID,请使用 "full results" API。
- pt_BR: Get your WolframAlpha AppID from WolframAlpha, please use "full results" api access.
- url: https://products.wolframalpha.com/api
diff --git a/api/core/tools/provider/builtin/yahoo/_assets/icon.png b/api/core/tools/provider/builtin/yahoo/_assets/icon.png
deleted file mode 100644
index 35d756f754..0000000000
Binary files a/api/core/tools/provider/builtin/yahoo/_assets/icon.png and /dev/null differ
diff --git a/api/core/tools/provider/builtin/yahoo/tools/analytics.py b/api/core/tools/provider/builtin/yahoo/tools/analytics.py
deleted file mode 100644
index f044fbe540..0000000000
--- a/api/core/tools/provider/builtin/yahoo/tools/analytics.py
+++ /dev/null
@@ -1,70 +0,0 @@
-from datetime import datetime
-from typing import Any, Union
-
-import pandas as pd
-from requests.exceptions import HTTPError, ReadTimeout
-from yfinance import download
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class YahooFinanceAnalyticsTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- symbol = tool_parameters.get("symbol", "")
- if not symbol:
- return self.create_text_message("Please input symbol")
-
- time_range = [None, None]
- start_date = tool_parameters.get("start_date", "")
- if start_date:
- time_range[0] = start_date
- else:
- time_range[0] = "1800-01-01"
-
- end_date = tool_parameters.get("end_date", "")
- if end_date:
- time_range[1] = end_date
- else:
- time_range[1] = datetime.now().strftime("%Y-%m-%d")
-
- stock_data = download(symbol, start=time_range[0], end=time_range[1])
- max_segments = min(15, len(stock_data))
- rows_per_segment = len(stock_data) // (max_segments or 1)
- summary_data = []
- for i in range(max_segments):
- start_idx = i * rows_per_segment
- end_idx = (i + 1) * rows_per_segment if i < max_segments - 1 else len(stock_data)
- segment_data = stock_data.iloc[start_idx:end_idx]
- segment_summary = {
- "Start Date": segment_data.index[0],
- "End Date": segment_data.index[-1],
- "Average Close": segment_data["Close"].mean(),
- "Average Volume": segment_data["Volume"].mean(),
- "Average Open": segment_data["Open"].mean(),
- "Average High": segment_data["High"].mean(),
- "Average Low": segment_data["Low"].mean(),
- "Average Adj Close": segment_data["Adj Close"].mean(),
- "Max Close": segment_data["Close"].max(),
- "Min Close": segment_data["Close"].min(),
- "Max Volume": segment_data["Volume"].max(),
- "Min Volume": segment_data["Volume"].min(),
- "Max Open": segment_data["Open"].max(),
- "Min Open": segment_data["Open"].min(),
- "Max High": segment_data["High"].max(),
- "Min High": segment_data["High"].min(),
- }
-
- summary_data.append(segment_summary)
-
- summary_df = pd.DataFrame(summary_data)
-
- try:
- return self.create_text_message(str(summary_df.to_dict()))
- except (HTTPError, ReadTimeout):
- return self.create_text_message("There is a internet connection problem. Please try again later.")
diff --git a/api/core/tools/provider/builtin/yahoo/tools/analytics.yaml b/api/core/tools/provider/builtin/yahoo/tools/analytics.yaml
deleted file mode 100644
index 89e66fb581..0000000000
--- a/api/core/tools/provider/builtin/yahoo/tools/analytics.yaml
+++ /dev/null
@@ -1,54 +0,0 @@
-identity:
- name: yahoo_finance_analytics
- author: Dify
- label:
- en_US: Analytics
- zh_Hans: 分析
- pt_BR: Análises
- icon: icon.svg
-description:
- human:
- en_US: A tool for get analytics about a ticker from Yahoo Finance.
- zh_Hans: 一个用于从雅虎财经获取分析数据的工具。
- pt_BR: Uma ferramenta para obter análises sobre um ticker do Yahoo Finance.
- llm: A tool for get analytics from Yahoo Finance. Input should be the ticker symbol like AAPL.
-parameters:
- - name: symbol
- type: string
- required: true
- label:
- en_US: Ticker symbol
- zh_Hans: 股票代码
- pt_BR: Símbolo do ticker
- human_description:
- en_US: The ticker symbol of the company you want to analyze.
- zh_Hans: 你想要搜索的公司的股票代码。
- pt_BR: O símbolo do ticker da empresa que você deseja analisar.
- llm_description: The ticker symbol of the company you want to analyze.
- form: llm
- - name: start_date
- type: string
- required: false
- label:
- en_US: Start date
- zh_Hans: 开始日期
- pt_BR: Data de início
- human_description:
- en_US: The start date of the analytics.
- zh_Hans: 分析的开始日期。
- pt_BR: A data de início das análises.
- llm_description: The start date of the analytics, the format of the date must be YYYY-MM-DD like 2020-01-01.
- form: llm
- - name: end_date
- type: string
- required: false
- label:
- en_US: End date
- zh_Hans: 结束日期
- pt_BR: Data de término
- human_description:
- en_US: The end date of the analytics.
- zh_Hans: 分析的结束日期。
- pt_BR: A data de término das análises.
- llm_description: The end date of the analytics, the format of the date must be YYYY-MM-DD like 2024-01-01.
- form: llm
diff --git a/api/core/tools/provider/builtin/yahoo/tools/news.py b/api/core/tools/provider/builtin/yahoo/tools/news.py
deleted file mode 100644
index ff820430f9..0000000000
--- a/api/core/tools/provider/builtin/yahoo/tools/news.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from typing import Any, Union
-
-import yfinance
-from requests.exceptions import HTTPError, ReadTimeout
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class YahooFinanceSearchTickerTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
-
- query = tool_parameters.get("symbol", "")
- if not query:
- return self.create_text_message("Please input symbol")
-
- try:
- return self.run(ticker=query, user_id=user_id)
- except (HTTPError, ReadTimeout):
- return self.create_text_message("There is a internet connection problem. Please try again later.")
-
- def run(self, ticker: str, user_id: str) -> ToolInvokeMessage:
- company = yfinance.Ticker(ticker)
- try:
- if company.isin is None:
- return self.create_text_message(f"Company ticker {ticker} not found.")
- except (HTTPError, ReadTimeout, ConnectionError):
- return self.create_text_message(f"Company ticker {ticker} not found.")
-
- links = []
- try:
- links = [n["link"] for n in company.news if n["type"] == "STORY"]
- except (HTTPError, ReadTimeout, ConnectionError):
- if not links:
- return self.create_text_message(f"There is nothing about {ticker} ticker")
- if not links:
- return self.create_text_message(f"No news found for company that searched with {ticker} ticker.")
-
- result = "\n\n".join([self.get_url(link) for link in links])
-
- return self.create_text_message(self.summary(user_id=user_id, content=result))
diff --git a/api/core/tools/provider/builtin/yahoo/tools/news.yaml b/api/core/tools/provider/builtin/yahoo/tools/news.yaml
deleted file mode 100644
index 4118c1a82f..0000000000
--- a/api/core/tools/provider/builtin/yahoo/tools/news.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-identity:
- name: yahoo_finance_news
- author: Dify
- label:
- en_US: News
- zh_Hans: 新闻
- pt_BR: Notícias
- icon: icon.svg
-description:
- human:
- en_US: A tool for get news about a ticker from Yahoo Finance.
- zh_Hans: 一个用于从雅虎财经获取新闻的工具。
- pt_BR: Uma ferramenta para obter notícias sobre um ticker da Yahoo Finance.
- llm: A tool for get news from Yahoo Finance. Input should be the ticker symbol like AAPL.
-parameters:
- - name: symbol
- type: string
- required: true
- label:
- en_US: Ticker symbol
- zh_Hans: 股票代码
- pt_BR: Símbolo do ticker
- human_description:
- en_US: The ticker symbol of the company you want to search.
- zh_Hans: 你想要搜索的公司的股票代码。
- pt_BR: O símbolo do ticker da empresa que você deseja pesquisar.
- llm_description: The ticker symbol of the company you want to search.
- form: llm
diff --git a/api/core/tools/provider/builtin/yahoo/tools/ticker.py b/api/core/tools/provider/builtin/yahoo/tools/ticker.py
deleted file mode 100644
index dfc7e46047..0000000000
--- a/api/core/tools/provider/builtin/yahoo/tools/ticker.py
+++ /dev/null
@@ -1,27 +0,0 @@
-from typing import Any, Union
-
-from requests.exceptions import HTTPError, ReadTimeout
-from yfinance import Ticker
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class YahooFinanceSearchTickerTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- query = tool_parameters.get("symbol", "")
- if not query:
- return self.create_text_message("Please input symbol")
-
- try:
- return self.create_text_message(self.run(ticker=query))
- except (HTTPError, ReadTimeout):
- return self.create_text_message("There is a internet connection problem. Please try again later.")
-
- def run(self, ticker: str) -> str:
- return str(Ticker(ticker).info)
diff --git a/api/core/tools/provider/builtin/yahoo/tools/ticker.yaml b/api/core/tools/provider/builtin/yahoo/tools/ticker.yaml
deleted file mode 100644
index 3c1ee9cf31..0000000000
--- a/api/core/tools/provider/builtin/yahoo/tools/ticker.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-identity:
- name: yahoo_finance_ticker
- author: Dify
- label:
- en_US: Ticker
- zh_Hans: 股票信息
- pt_BR: Ticker
- icon: icon.svg
-description:
- human:
- en_US: A tool for search ticker information from Yahoo Finance.
- zh_Hans: 一个用于从雅虎财经搜索股票信息的工具。
- pt_BR: Uma ferramenta para buscar informações de ticker do Yahoo Finance.
- llm: A tool for search ticker information from Yahoo Finance. Input should be the ticker symbol like AAPL.
-parameters:
- - name: symbol
- type: string
- required: true
- label:
- en_US: Ticker symbol
- zh_Hans: 股票代码
- pt_BR: Símbolo do ticker
- human_description:
- en_US: The ticker symbol of the company you want to search.
- zh_Hans: 你想要搜索的公司的股票代码。
- pt_BR: O símbolo do ticker da empresa que você deseja pesquisar.
- llm_description: The ticker symbol of the company you want to search.
- form: llm
diff --git a/api/core/tools/provider/builtin/yahoo/yahoo.py b/api/core/tools/provider/builtin/yahoo/yahoo.py
deleted file mode 100644
index 8d82084e76..0000000000
--- a/api/core/tools/provider/builtin/yahoo/yahoo.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.yahoo.tools.ticker import YahooFinanceSearchTickerTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class YahooFinanceProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- YahooFinanceSearchTickerTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "ticker": "MSFT",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/yahoo/yahoo.yaml b/api/core/tools/provider/builtin/yahoo/yahoo.yaml
deleted file mode 100644
index f1e82952c0..0000000000
--- a/api/core/tools/provider/builtin/yahoo/yahoo.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-identity:
- author: Dify
- name: yahoo
- label:
- en_US: YahooFinance
- zh_Hans: 雅虎财经
- pt_BR: YahooFinance
- description:
- en_US: Finance, and Yahoo! get the latest news, stock quotes, and interactive chart with Yahoo!
- zh_Hans: 雅虎财经,获取并整理出最新的新闻、股票报价等一切你想要的财经信息。
- pt_BR: Finance, and Yahoo! get the latest news, stock quotes, and interactive chart with Yahoo!
- icon: icon.png
- tags:
- - business
- - finance
-credentials_for_provider:
diff --git a/api/core/tools/provider/builtin/youtube/_assets/icon.svg b/api/core/tools/provider/builtin/youtube/_assets/icon.svg
deleted file mode 100644
index 83b0700fec..0000000000
--- a/api/core/tools/provider/builtin/youtube/_assets/icon.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
\ No newline at end of file
diff --git a/api/core/tools/provider/builtin/youtube/tools/videos.py b/api/core/tools/provider/builtin/youtube/tools/videos.py
deleted file mode 100644
index 95dec2eac9..0000000000
--- a/api/core/tools/provider/builtin/youtube/tools/videos.py
+++ /dev/null
@@ -1,74 +0,0 @@
-from datetime import datetime
-from typing import Any, Union
-
-from googleapiclient.discovery import build
-
-from core.tools.entities.tool_entities import ToolInvokeMessage
-from core.tools.tool.builtin_tool import BuiltinTool
-
-
-class YoutubeVideosAnalyticsTool(BuiltinTool):
- def _invoke(
- self, user_id: str, tool_parameters: dict[str, Any]
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
- """
- invoke tools
- """
- channel = tool_parameters.get("channel", "")
- if not channel:
- return self.create_text_message("Please input symbol")
-
- time_range = [None, None]
- start_date = tool_parameters.get("start_date", "")
- if start_date:
- time_range[0] = start_date
- else:
- time_range[0] = "1800-01-01"
-
- end_date = tool_parameters.get("end_date", "")
- if end_date:
- time_range[1] = end_date
- else:
- time_range[1] = datetime.now().strftime("%Y-%m-%d")
-
- if "google_api_key" not in self.runtime.credentials or not self.runtime.credentials["google_api_key"]:
- return self.create_text_message("Please input api key")
-
- youtube = build("youtube", "v3", developerKey=self.runtime.credentials["google_api_key"])
-
- # try to get channel id
- search_results = youtube.search().list(q=channel, type="channel", order="relevance", part="id").execute()
- channel_id = search_results["items"][0]["id"]["channelId"]
-
- start_date, end_date = time_range
-
- start_date = datetime.strptime(start_date, "%Y-%m-%d").strftime("%Y-%m-%dT%H:%M:%SZ")
- end_date = datetime.strptime(end_date, "%Y-%m-%d").strftime("%Y-%m-%dT%H:%M:%SZ")
-
- # get videos
- time_range_videos = (
- youtube.search()
- .list(
- part="snippet",
- channelId=channel_id,
- order="date",
- type="video",
- publishedAfter=start_date,
- publishedBefore=end_date,
- )
- .execute()
- )
-
- def extract_video_data(video_list):
- data = []
- for video in video_list["items"]:
- video_id = video["id"]["videoId"]
- video_info = youtube.videos().list(part="snippet,statistics", id=video_id).execute()
- title = video_info["items"][0]["snippet"]["title"]
- views = video_info["items"][0]["statistics"]["viewCount"]
- data.append({"Title": title, "Views": views})
- return data
-
- summary = extract_video_data(time_range_videos)
-
- return self.create_text_message(str(summary))
diff --git a/api/core/tools/provider/builtin/youtube/tools/videos.yaml b/api/core/tools/provider/builtin/youtube/tools/videos.yaml
deleted file mode 100644
index 976699eb62..0000000000
--- a/api/core/tools/provider/builtin/youtube/tools/videos.yaml
+++ /dev/null
@@ -1,54 +0,0 @@
-identity:
- name: youtube_video_statistics
- author: Dify
- label:
- en_US: Video statistics
- zh_Hans: 视频统计
- pt_BR: Estatísticas de vídeo
- icon: icon.svg
-description:
- human:
- en_US: A tool for get statistics about a channel's videos.
- zh_Hans: 一个用于获取油管频道视频统计数据的工具。
- pt_BR: Uma ferramenta para obter estatísticas sobre os vídeos de um canal.
- llm: A tool for get statistics about a channel's videos. Input should be the name of the channel like PewDiePie.
-parameters:
- - name: channel
- type: string
- required: true
- label:
- en_US: Channel name
- zh_Hans: 频道名
- pt_BR: Nome do canal
- human_description:
- en_US: The name of the channel you want to search.
- zh_Hans: 你想要搜索的油管频道名。
- pt_BR: O nome do canal que você deseja pesquisar.
- llm_description: The name of the channel you want to search.
- form: llm
- - name: start_date
- type: string
- required: false
- label:
- en_US: Start date
- zh_Hans: 开始日期
- pt_BR: Data de início
- human_description:
- en_US: The start date of the analytics.
- zh_Hans: 分析的开始日期。
- pt_BR: A data de início da análise.
- llm_description: The start date of the analytics, the format of the date must be YYYY-MM-DD like 2020-01-01.
- form: llm
- - name: end_date
- type: string
- required: false
- label:
- en_US: End date
- zh_Hans: 结束日期
- pt_BR: Data de término
- human_description:
- en_US: The end date of the analytics.
- zh_Hans: 分析的结束日期。
- pt_BR: A data de término da análise.
- llm_description: The end date of the analytics, the format of the date must be YYYY-MM-DD like 2024-01-01.
- form: llm
diff --git a/api/core/tools/provider/builtin/youtube/youtube.py b/api/core/tools/provider/builtin/youtube/youtube.py
deleted file mode 100644
index aad876491c..0000000000
--- a/api/core/tools/provider/builtin/youtube/youtube.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from core.tools.errors import ToolProviderCredentialValidationError
-from core.tools.provider.builtin.youtube.tools.videos import YoutubeVideosAnalyticsTool
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-
-
-class YahooFinanceProvider(BuiltinToolProviderController):
- def _validate_credentials(self, credentials: dict) -> None:
- try:
- YoutubeVideosAnalyticsTool().fork_tool_runtime(
- runtime={
- "credentials": credentials,
- }
- ).invoke(
- user_id="",
- tool_parameters={
- "channel": "TOKYO GIRLS COLLECTION",
- "start_date": "2020-01-01",
- "end_date": "2024-12-31",
- },
- )
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
diff --git a/api/core/tools/provider/builtin/youtube/youtube.yaml b/api/core/tools/provider/builtin/youtube/youtube.yaml
deleted file mode 100644
index d6915b9a32..0000000000
--- a/api/core/tools/provider/builtin/youtube/youtube.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-identity:
- author: Dify
- name: youtube
- label:
- en_US: YouTube
- zh_Hans: YouTube
- pt_BR: YouTube
- description:
- en_US: YouTube
- zh_Hans: YouTube(油管)是全球最大的视频分享网站,用户可以在上面上传、观看和分享视频。
- pt_BR: YouTube é o maior site de compartilhamento de vídeos do mundo, onde os usuários podem fazer upload, assistir e compartilhar vídeos.
- icon: icon.svg
- tags:
- - videos
-credentials_for_provider:
- google_api_key:
- type: secret-input
- required: true
- label:
- en_US: Google API key
- zh_Hans: Google API key
- pt_BR: Chave da API do Google
- placeholder:
- en_US: Please input your Google API key
- zh_Hans: 请输入你的 Google API key
- pt_BR: Insira sua chave da API do Google
- help:
- en_US: Get your Google API key from Google
- zh_Hans: 从 Google 获取您的 Google API key
- pt_BR: Obtenha sua chave da API do Google no Google
- url: https://console.developers.google.com/apis/credentials
diff --git a/api/core/tools/tool_engine.py b/api/core/tools/tool_engine.py
index 469eea67a6..cb2f6a899c 100644
--- a/api/core/tools/tool_engine.py
+++ b/api/core/tools/tool_engine.py
@@ -13,6 +13,7 @@ from core.callback_handler.plugin_tool_callback_handler import DifyPluginCallbac
from core.callback_handler.workflow_tool_callback_handler import DifyWorkflowCallbackHandler
from core.file.file_obj import FileTransferMethod
from core.ops.ops_trace_manager import TraceQueueManager
+from core.tools.__base.tool import Tool
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolInvokeMessageBinary, ToolInvokeMeta, ToolParameter
from core.tools.errors import (
ToolEngineInvokeError,
@@ -23,9 +24,8 @@ from core.tools.errors import (
ToolProviderCredentialValidationError,
ToolProviderNotFoundError,
)
-from core.tools.tool.tool import Tool
-from core.tools.tool.workflow_tool import WorkflowTool
from core.tools.utils.message_transformer import ToolFileMessageTransformer
+from core.tools.workflow_as_tool.tool import WorkflowTool
from extensions.ext_database import db
from models.model import Message, MessageFile
diff --git a/api/core/tools/tool_label_manager.py b/api/core/tools/tool_label_manager.py
index 2a5a2944ef..f9a126bf9b 100644
--- a/api/core/tools/tool_label_manager.py
+++ b/api/core/tools/tool_label_manager.py
@@ -1,8 +1,8 @@
+from core.tools.__base.tool_provider import ToolProviderController
+from core.tools.builtin_tool.provider import BuiltinToolProviderController
+from core.tools.custom_tool.provider import ApiToolProviderController
from core.tools.entities.values import default_tool_label_name_list
-from core.tools.provider.api_tool_provider import ApiToolProviderController
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-from core.tools.provider.tool_provider import ToolProviderController
-from core.tools.provider.workflow_tool_provider import WorkflowToolProviderController
+from core.tools.workflow_as_tool.provider import WorkflowToolProviderController
from extensions.ext_database import db
from models.tools import ToolLabelBinding
@@ -55,7 +55,7 @@ class ToolLabelManager:
else:
raise ValueError("Unsupported tool type")
- labels: list[ToolLabelBinding] = (
+ labels = (
db.session.query(ToolLabelBinding.label_name)
.filter(
ToolLabelBinding.tool_id == provider_id,
@@ -84,7 +84,10 @@ class ToolLabelManager:
if not isinstance(controller, ApiToolProviderController | WorkflowToolProviderController):
raise ValueError("Unsupported tool type")
- provider_ids = [controller.provider_id for controller in tool_providers]
+ provider_ids = []
+ for controller in tool_providers:
+ assert isinstance(controller, ApiToolProviderController | WorkflowToolProviderController)
+ provider_ids.append(controller.provider_id)
labels: list[ToolLabelBinding] = (
db.session.query(ToolLabelBinding).filter(ToolLabelBinding.tool_id.in_(provider_ids)).all()
diff --git a/api/core/tools/tool_manager.py b/api/core/tools/tool_manager.py
index 108b74018d..0cfcb6d9b9 100644
--- a/api/core/tools/tool_manager.py
+++ b/api/core/tools/tool_manager.py
@@ -4,7 +4,11 @@ import mimetypes
from collections.abc import Generator
from os import listdir, path
from threading import Lock
-from typing import Any, Union, cast
+from typing import TYPE_CHECKING, Any, Union, cast
+
+if TYPE_CHECKING:
+ from core.workflow.nodes.tool.entities import ToolEntity
+
from configs import dify_config
from core.agent.entities import AgentToolEntity
@@ -12,20 +16,20 @@ from core.app.entities.app_invoke_entities import InvokeFrom
from core.helper.module_import_helper import load_single_subclass_from_source
from core.helper.position_helper import is_filtered
from core.model_runtime.utils.encoders import jsonable_encoder
+from core.tools.__base.tool import Tool
+from core.tools.builtin_tool.provider import BuiltinToolProviderController
+from core.tools.builtin_tool.providers._positions import BuiltinToolProviderSort
+from core.tools.builtin_tool.tool import BuiltinTool
+from core.tools.custom_tool.provider import ApiToolProviderController
+from core.tools.custom_tool.tool import ApiTool
from core.tools.entities.api_entities import UserToolProvider, UserToolProviderTypeLiteral
from core.tools.entities.common_entities import I18nObject
from core.tools.entities.tool_entities import ApiProviderAuthType, ToolInvokeFrom, ToolParameter, ToolProviderType
from core.tools.errors import ToolProviderNotFoundError
-from core.tools.provider.api_tool_provider import ApiToolProviderController
-from core.tools.provider.builtin._positions import BuiltinToolProviderSort
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-from core.tools.tool.api_tool import ApiTool
-from core.tools.tool.builtin_tool import BuiltinTool
-from core.tools.tool.tool import Tool
-from core.tools.tool.workflow_tool import WorkflowTool
from core.tools.tool_label_manager import ToolLabelManager
from core.tools.utils.configuration import ProviderConfigEncrypter, ToolParameterConfigurationManager
from core.tools.utils.tool_parameter_converter import ToolParameterConverter
+from core.tools.workflow_as_tool.tool import WorkflowTool
from extensions.ext_database import db
from models.tools import ApiToolProvider, BuiltinToolProvider, WorkflowToolProvider
from services.tools.tools_transform_service import ToolTransformService
@@ -328,8 +332,8 @@ class ToolManager:
absolute_path = path.join(
path.dirname(path.realpath(__file__)),
- "provider",
- "builtin",
+ "builtin_tool",
+ "providers",
provider,
"_assets",
provider_controller.identity.icon,
@@ -363,22 +367,22 @@ class ToolManager:
"""
list all the builtin providers
"""
- for provider_path in listdir(path.join(path.dirname(path.realpath(__file__)), "provider", "builtin")):
+ for provider_path in listdir(path.join(path.dirname(path.realpath(__file__)), "builtin_tool", "providers")):
if provider_path.startswith("__"):
continue
- if path.isdir(path.join(path.dirname(path.realpath(__file__)), "provider", "builtin", provider_path)):
+ if path.isdir(path.join(path.dirname(path.realpath(__file__)), "builtin_tool", "providers", provider_path)):
if provider_path.startswith("__"):
continue
# init provider
try:
provider_class = load_single_subclass_from_source(
- module_name=f"core.tools.provider.builtin.{provider_path}.{provider_path}",
+ module_name=f"core.tools.builtin_tool.providers.{provider_path}.{provider_path}",
script_path=path.join(
path.dirname(path.realpath(__file__)),
- "provider",
- "builtin",
+ "builtin_tool",
+ "providers",
provider_path,
f"{provider_path}.py",
),
@@ -391,7 +395,7 @@ class ToolManager:
yield provider
except Exception as e:
- logger.error(f"load builtin provider {provider} error: {e}")
+ logger.error(f"load builtin provider error: {e}")
continue
# set builtin providers loaded
cls._builtin_providers_loaded = True
diff --git a/api/core/tools/utils/configuration.py b/api/core/tools/utils/configuration.py
index f3fce03f8c..0ab2b0021a 100644
--- a/api/core/tools/utils/configuration.py
+++ b/api/core/tools/utils/configuration.py
@@ -8,11 +8,11 @@ from core.entities.provider_entities import BasicProviderConfig
from core.helper import encrypter
from core.helper.tool_parameter_cache import ToolParameterCache, ToolParameterCacheType
from core.helper.tool_provider_cache import ToolProviderCredentialsCache, ToolProviderCredentialsCacheType
+from core.tools.__base.tool import Tool
from core.tools.entities.tool_entities import (
ToolParameter,
ToolProviderType,
)
-from core.tools.tool.tool import Tool
class ProviderConfigEncrypter(BaseModel):
@@ -27,7 +27,7 @@ class ProviderConfigEncrypter(BaseModel):
"""
return deepcopy(data)
- def encrypt(self, data: dict[str, str]) -> Mapping[str, str]:
+ def encrypt(self, data: dict[str, str]) -> dict[str, str]:
"""
encrypt tool credentials with tenant id
@@ -45,7 +45,7 @@ class ProviderConfigEncrypter(BaseModel):
return data
- def mask_tool_credentials(self, data: dict[str, Any]) -> Mapping[str, Any]:
+ def mask_tool_credentials(self, data: dict[str, Any]) -> dict[str, Any]:
"""
mask tool credentials
@@ -68,7 +68,7 @@ class ProviderConfigEncrypter(BaseModel):
return data
- def decrypt(self, data: dict[str, str]) -> Mapping[str, str]:
+ def decrypt(self, data: dict[str, str]) -> dict[str, str]:
"""
decrypt tool credentials with tenant id
diff --git a/api/core/tools/tool/dataset_retriever/dataset_multi_retriever_tool.py b/api/core/tools/utils/dataset_retriever/dataset_multi_retriever_tool.py
similarity index 98%
rename from api/core/tools/tool/dataset_retriever/dataset_multi_retriever_tool.py
rename to api/core/tools/utils/dataset_retriever/dataset_multi_retriever_tool.py
index ab7b40a253..408dd43d22 100644
--- a/api/core/tools/tool/dataset_retriever/dataset_multi_retriever_tool.py
+++ b/api/core/tools/utils/dataset_retriever/dataset_multi_retriever_tool.py
@@ -9,7 +9,7 @@ from core.model_runtime.entities.model_entities import ModelType
from core.rag.datasource.retrieval_service import RetrievalService
from core.rag.rerank.rerank_model import RerankModelRunner
from core.rag.retrieval.retrieval_methods import RetrievalMethod
-from core.tools.tool.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool
+from core.tools.utils.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool
from extensions.ext_database import db
from models.dataset import Dataset, Document, DocumentSegment
diff --git a/api/core/tools/tool/dataset_retriever/dataset_retriever_base_tool.py b/api/core/tools/utils/dataset_retriever/dataset_retriever_base_tool.py
similarity index 100%
rename from api/core/tools/tool/dataset_retriever/dataset_retriever_base_tool.py
rename to api/core/tools/utils/dataset_retriever/dataset_retriever_base_tool.py
diff --git a/api/core/tools/tool/dataset_retriever/dataset_retriever_tool.py b/api/core/tools/utils/dataset_retriever/dataset_retriever_tool.py
similarity index 100%
rename from api/core/tools/tool/dataset_retriever/dataset_retriever_tool.py
rename to api/core/tools/utils/dataset_retriever/dataset_retriever_tool.py
diff --git a/api/core/tools/tool/dataset_retriever_tool.py b/api/core/tools/utils/dataset_retriever_tool.py
similarity index 96%
rename from api/core/tools/tool/dataset_retriever_tool.py
rename to api/core/tools/utils/dataset_retriever_tool.py
index 9f41b5d5eb..7b61222722 100644
--- a/api/core/tools/tool/dataset_retriever_tool.py
+++ b/api/core/tools/utils/dataset_retriever_tool.py
@@ -5,6 +5,7 @@ from core.app.app_config.entities import DatasetRetrieveConfigEntity
from core.app.entities.app_invoke_entities import InvokeFrom
from core.callback_handler.index_tool_callback_handler import DatasetIndexToolCallbackHandler
from core.rag.retrieval.dataset_retrieval import DatasetRetrieval
+from core.tools.__base.tool import Tool
from core.tools.entities.common_entities import I18nObject
from core.tools.entities.tool_entities import (
ToolDescription,
@@ -13,8 +14,7 @@ from core.tools.entities.tool_entities import (
ToolParameter,
ToolProviderType,
)
-from core.tools.tool.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool
-from core.tools.tool.tool import Tool
+from core.tools.utils.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool
class DatasetRetrieverTool(Tool):
diff --git a/api/core/tools/utils/web_reader_tool.py b/api/core/tools/utils/web_reader_tool.py
index 1ced7d0488..dcbae9f5aa 100644
--- a/api/core/tools/utils/web_reader_tool.py
+++ b/api/core/tools/utils/web_reader_tool.py
@@ -36,7 +36,7 @@ def page_result(text: str, cursor: int, max_length: int) -> str:
return text[cursor : cursor + max_length]
-def get_url(url: str, user_agent: str = None) -> str:
+def get_url(url: str, user_agent: str | None = None) -> str:
"""Fetch URL and return the contents as a string."""
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)"
diff --git a/api/core/tools/workflow_as_tool/provider.py b/api/core/tools/workflow_as_tool/provider.py
new file mode 100644
index 0000000000..cab5f84506
--- /dev/null
+++ b/api/core/tools/workflow_as_tool/provider.py
@@ -0,0 +1,207 @@
+from collections.abc import Mapping
+from typing import Optional
+
+from pydantic import Field
+
+from core.app.app_config.entities import VariableEntity, VariableEntityType
+from core.app.apps.workflow.app_config_manager import WorkflowAppConfigManager
+from core.tools.__base.tool_provider import ToolProviderController
+from core.tools.entities.common_entities import I18nObject
+from core.tools.entities.tool_entities import (
+ ToolDescription,
+ ToolIdentity,
+ ToolParameter,
+ ToolParameterOption,
+ ToolProviderType,
+)
+from core.tools.utils.workflow_configuration_sync import WorkflowToolConfigurationUtils
+from core.tools.workflow_as_tool.tool import WorkflowTool
+from extensions.ext_database import db
+from models.model import App, AppMode
+from models.tools import WorkflowToolProvider
+from models.workflow import Workflow
+
+VARIABLE_TO_PARAMETER_TYPE_MAPPING = {
+ VariableEntityType.TEXT_INPUT: ToolParameter.ToolParameterType.STRING,
+ VariableEntityType.PARAGRAPH: ToolParameter.ToolParameterType.STRING,
+ VariableEntityType.SELECT: ToolParameter.ToolParameterType.SELECT,
+ VariableEntityType.NUMBER: ToolParameter.ToolParameterType.NUMBER,
+}
+
+
+class WorkflowToolProviderController(ToolProviderController):
+ provider_id: str
+ tools: list[WorkflowTool] = Field(default_factory=list)
+
+ @classmethod
+ def from_db(cls, db_provider: WorkflowToolProvider) -> "WorkflowToolProviderController":
+ app = db_provider.app
+
+ if not app:
+ raise ValueError("app not found")
+
+ controller = WorkflowToolProviderController(
+ **{
+ "identity": {
+ "author": db_provider.user.name if db_provider.user_id and db_provider.user else "",
+ "name": db_provider.label,
+ "label": {"en_US": db_provider.label, "zh_Hans": db_provider.label},
+ "description": {"en_US": db_provider.description, "zh_Hans": db_provider.description},
+ "icon": db_provider.icon,
+ },
+ "credentials_schema": {},
+ "provider_id": db_provider.id or "",
+ }
+ )
+
+ # init tools
+
+ controller.tools = [controller._get_db_provider_tool(db_provider, app)]
+
+ return controller
+
+ @property
+ def provider_type(self) -> ToolProviderType:
+ return ToolProviderType.WORKFLOW
+
+ def _get_db_provider_tool(self, db_provider: WorkflowToolProvider, app: App) -> WorkflowTool:
+ """
+ get db provider tool
+ :param db_provider: the db provider
+ :param app: the app
+ :return: the tool
+ """
+ workflow: Workflow | None = db.session.query(Workflow).filter(
+ Workflow.app_id == db_provider.app_id,
+ Workflow.version == db_provider.version
+ ).first()
+
+ if not workflow:
+ raise ValueError("workflow not found")
+
+ # fetch start node
+ graph: Mapping = workflow.graph_dict
+ features_dict: Mapping = workflow.features_dict
+ features = WorkflowAppConfigManager.convert_features(
+ config_dict=features_dict,
+ app_mode=AppMode.WORKFLOW
+ )
+
+ parameters = db_provider.parameter_configurations
+ variables = WorkflowToolConfigurationUtils.get_workflow_graph_variables(graph)
+
+ def fetch_workflow_variable(variable_name: str) -> VariableEntity | None:
+ return next(filter(lambda x: x.variable == variable_name, variables), None)
+
+ user = db_provider.user
+
+ workflow_tool_parameters = []
+ for parameter in parameters:
+ variable = fetch_workflow_variable(parameter.name)
+ if variable:
+ parameter_type = None
+ options = []
+ if variable.type not in VARIABLE_TO_PARAMETER_TYPE_MAPPING:
+ raise ValueError(f"unsupported variable type {variable.type}")
+ parameter_type = VARIABLE_TO_PARAMETER_TYPE_MAPPING[variable.type]
+
+ if variable.type == VariableEntityType.SELECT and variable.options:
+ options = [
+ ToolParameterOption(value=option, label=I18nObject(en_US=option, zh_Hans=option))
+ for option in variable.options
+ ]
+
+ workflow_tool_parameters.append(
+ ToolParameter(
+ name=parameter.name,
+ label=I18nObject(en_US=variable.label, zh_Hans=variable.label),
+ human_description=I18nObject(en_US=parameter.description, zh_Hans=parameter.description),
+ type=parameter_type,
+ form=parameter.form,
+ llm_description=parameter.description,
+ required=variable.required,
+ options=options,
+ default=variable.default,
+ )
+ )
+ elif features.file_upload:
+ workflow_tool_parameters.append(
+ ToolParameter(
+ name=parameter.name,
+ label=I18nObject(en_US=parameter.name, zh_Hans=parameter.name),
+ human_description=I18nObject(en_US=parameter.description, zh_Hans=parameter.description),
+ type=ToolParameter.ToolParameterType.FILE,
+ llm_description=parameter.description,
+ required=False,
+ form=parameter.form,
+ )
+ )
+ else:
+ raise ValueError("variable not found")
+
+ return WorkflowTool(
+ identity=ToolIdentity(
+ author=user.name if user else "",
+ name=db_provider.name,
+ label=I18nObject(en_US=db_provider.label, zh_Hans=db_provider.label),
+ provider=self.provider_id,
+ icon=db_provider.icon,
+ ),
+ description=ToolDescription(
+ human=I18nObject(en_US=db_provider.description, zh_Hans=db_provider.description),
+ llm=db_provider.description,
+ ),
+ parameters=workflow_tool_parameters,
+ is_team_authorization=True,
+ workflow_app_id=app.id,
+ workflow_entities={
+ "app": app,
+ "workflow": workflow,
+ },
+ version=db_provider.version,
+ workflow_call_depth=0,
+ label=db_provider.label,
+ )
+
+ def get_tools(self, tenant_id: str) -> list[WorkflowTool]:
+ """
+ fetch tools from database
+
+ :param user_id: the user id
+ :param tenant_id: the tenant id
+ :return: the tools
+ """
+ if self.tools is not None:
+ return self.tools
+
+ db_providers: WorkflowToolProvider | None = db.session.query(WorkflowToolProvider).filter(
+ WorkflowToolProvider.tenant_id == tenant_id,
+ WorkflowToolProvider.app_id == self.provider_id,
+ ).first()
+
+ if not db_providers:
+ return []
+
+ app = db_providers.app
+ if not app:
+ raise ValueError("can not read app of workflow")
+
+ self.tools = [self._get_db_provider_tool(db_providers, app)]
+
+ return self.tools
+
+ def get_tool(self, tool_name: str) -> Optional[WorkflowTool]:
+ """
+ get tool by name
+
+ :param tool_name: the name of the tool
+ :return: the tool
+ """
+ if self.tools is None:
+ return None
+
+ for tool in self.tools:
+ if tool.identity.name == tool_name:
+ return tool
+
+ return None
diff --git a/api/core/tools/tool/workflow_tool.py b/api/core/tools/workflow_as_tool/tool.py
similarity index 99%
rename from api/core/tools/tool/workflow_tool.py
rename to api/core/tools/workflow_as_tool/tool.py
index 42ceffb834..72aae2796c 100644
--- a/api/core/tools/tool/workflow_tool.py
+++ b/api/core/tools/workflow_as_tool/tool.py
@@ -5,8 +5,8 @@ from copy import deepcopy
from typing import Any, Optional, Union
from core.file.file_obj import FileTransferMethod, FileVar
+from core.tools.__base.tool import Tool
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameter, ToolProviderType
-from core.tools.tool.tool import Tool
from extensions.ext_database import db
from models.account import Account
from models.model import App, EndUser
diff --git a/api/core/tools/provider/workflow_tool_provider.py b/api/core/tools/workflow_as_tool/workflow_tool_provider.py
similarity index 98%
rename from api/core/tools/provider/workflow_tool_provider.py
rename to api/core/tools/workflow_as_tool/workflow_tool_provider.py
index 6f80767bd5..cab5f84506 100644
--- a/api/core/tools/provider/workflow_tool_provider.py
+++ b/api/core/tools/workflow_as_tool/workflow_tool_provider.py
@@ -5,6 +5,7 @@ from pydantic import Field
from core.app.app_config.entities import VariableEntity, VariableEntityType
from core.app.apps.workflow.app_config_manager import WorkflowAppConfigManager
+from core.tools.__base.tool_provider import ToolProviderController
from core.tools.entities.common_entities import I18nObject
from core.tools.entities.tool_entities import (
ToolDescription,
@@ -13,9 +14,8 @@ from core.tools.entities.tool_entities import (
ToolParameterOption,
ToolProviderType,
)
-from core.tools.provider.tool_provider import ToolProviderController
-from core.tools.tool.workflow_tool import WorkflowTool
from core.tools.utils.workflow_configuration_sync import WorkflowToolConfigurationUtils
+from core.tools.workflow_as_tool.tool import WorkflowTool
from extensions.ext_database import db
from models.model import App, AppMode
from models.tools import WorkflowToolProvider
diff --git a/api/services/tools/api_tools_manage_service.py b/api/services/tools/api_tools_manage_service.py
index e1962305b9..11aa3ba529 100644
--- a/api/services/tools/api_tools_manage_service.py
+++ b/api/services/tools/api_tools_manage_service.py
@@ -5,6 +5,7 @@ from httpx import get
from core.entities.provider_entities import ProviderConfig
from core.model_runtime.utils.encoders import jsonable_encoder
+from core.tools.custom_tool.provider import ApiToolProviderController
from core.tools.entities.api_entities import UserTool, UserToolProvider
from core.tools.entities.common_entities import I18nObject
from core.tools.entities.tool_bundle import ApiToolBundle
@@ -12,7 +13,6 @@ from core.tools.entities.tool_entities import (
ApiProviderAuthType,
ApiProviderSchemaType,
)
-from core.tools.provider.api_tool_provider import ApiToolProviderController
from core.tools.tool_label_manager import ToolLabelManager
from core.tools.tool_manager import ToolManager
from core.tools.utils.configuration import ProviderConfigEncrypter
diff --git a/api/services/tools/builtin_tools_manage_service.py b/api/services/tools/builtin_tools_manage_service.py
index af1cdbacac..6db8718b6b 100644
--- a/api/services/tools/builtin_tools_manage_service.py
+++ b/api/services/tools/builtin_tools_manage_service.py
@@ -5,10 +5,10 @@ from pathlib import Path
from configs import dify_config
from core.helper.position_helper import is_filtered
from core.model_runtime.utils.encoders import jsonable_encoder
+from core.tools.__base.tool_provider import ToolProviderController
+from core.tools.builtin_tool.providers._positions import BuiltinToolProviderSort
from core.tools.entities.api_entities import UserTool, UserToolProvider
from core.tools.errors import ToolNotFoundError, ToolProviderCredentialValidationError, ToolProviderNotFoundError
-from core.tools.provider.builtin._positions import BuiltinToolProviderSort
-from core.tools.provider.tool_provider import ToolProviderController
from core.tools.tool_label_manager import ToolLabelManager
from core.tools.tool_manager import ToolManager
from core.tools.utils.configuration import ProviderConfigEncrypter
diff --git a/api/services/tools/tools_transform_service.py b/api/services/tools/tools_transform_service.py
index 552e2a0fbc..b7488621c6 100644
--- a/api/services/tools/tools_transform_service.py
+++ b/api/services/tools/tools_transform_service.py
@@ -3,6 +3,9 @@ import logging
from typing import Optional, Union
from configs import dify_config
+from core.tools.__base.tool import Tool
+from core.tools.builtin_tool.provider import BuiltinToolProviderController
+from core.tools.custom_tool.provider import ApiToolProviderController
from core.tools.entities.api_entities import UserTool, UserToolProvider
from core.tools.entities.common_entities import I18nObject
from core.tools.entities.tool_bundle import ApiToolBundle
@@ -11,12 +14,9 @@ from core.tools.entities.tool_entities import (
ToolParameter,
ToolProviderType,
)
-from core.tools.provider.api_tool_provider import ApiToolProviderController
-from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
-from core.tools.provider.workflow_tool_provider import WorkflowToolProviderController
-from core.tools.tool.tool import Tool
-from core.tools.tool.workflow_tool import WorkflowTool
from core.tools.utils.configuration import ProviderConfigEncrypter
+from core.tools.workflow_as_tool.provider import WorkflowToolProviderController
+from core.tools.workflow_as_tool.tool import WorkflowTool
from models.tools import ApiToolProvider, BuiltinToolProvider, WorkflowToolProvider
logger = logging.getLogger(__name__)
diff --git a/api/services/tools/workflow_tools_manage_service.py b/api/services/tools/workflow_tools_manage_service.py
index 1544b39c23..60e26aa282 100644
--- a/api/services/tools/workflow_tools_manage_service.py
+++ b/api/services/tools/workflow_tools_manage_service.py
@@ -5,9 +5,9 @@ from sqlalchemy import or_
from core.model_runtime.utils.encoders import jsonable_encoder
from core.tools.entities.api_entities import UserTool, UserToolProvider
-from core.tools.provider.workflow_tool_provider import WorkflowToolProviderController
from core.tools.tool_label_manager import ToolLabelManager
from core.tools.utils.workflow_configuration_sync import WorkflowToolConfigurationUtils
+from core.tools.workflow_as_tool.provider import WorkflowToolProviderController
from extensions.ext_database import db
from models.model import App
from models.tools import WorkflowToolProvider
diff --git a/api/tests/integration_tests/tools/api_tool/test_api_tool.py b/api/tests/integration_tests/tools/api_tool/test_api_tool.py
index 09729a961e..e4798e02c3 100644
--- a/api/tests/integration_tests/tools/api_tool/test_api_tool.py
+++ b/api/tests/integration_tests/tools/api_tool/test_api_tool.py
@@ -1,5 +1,5 @@
-from core.tools.tool.api_tool import ApiTool
-from core.tools.tool.tool import Tool
+from core.tools.__base.tool import Tool
+from core.tools.custom_tool.tool import ApiTool
from tests.integration_tests.tools.__mock.http import setup_http_mock
tool_bundle = {