diff --git a/api/core/tools/provider/builtin/yunzhijia/_assets/icon.jpg b/api/core/tools/provider/builtin/yunzhijia/_assets/icon.jpg new file mode 100644 index 00000000000000..34210747b131b1 Binary files /dev/null and b/api/core/tools/provider/builtin/yunzhijia/_assets/icon.jpg differ diff --git a/api/core/tools/provider/builtin/yunzhijia/tools/yunzhijia_group_robot.py b/api/core/tools/provider/builtin/yunzhijia/tools/yunzhijia_group_robot.py new file mode 100644 index 00000000000000..984d1a3d8d1d33 --- /dev/null +++ b/api/core/tools/provider/builtin/yunzhijia/tools/yunzhijia_group_robot.py @@ -0,0 +1,41 @@ +from typing import Any, Union + +import httpx +from core.tools.entities.tool_entities import ToolInvokeMessage +from core.tools.tool.builtin_tool import BuiltinTool + + +class YunzhijiaGroupRobotTool(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") + + webhook_url = tool_parameters.get("webhook_url", "") + if not webhook_url: + return self.create_text_message("Invalid parameter webhook_url") + + payload = { + "content": content, + } + headers = { + "Content-Type": "application/json", + } + params = { + } + + try: + res = httpx.post(webhook_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 robot. {}".format(e)) \ No newline at end of file diff --git a/api/core/tools/provider/builtin/yunzhijia/tools/yunzhijia_group_robot.yaml b/api/core/tools/provider/builtin/yunzhijia/tools/yunzhijia_group_robot.yaml new file mode 100644 index 00000000000000..d4b5981c0da8aa --- /dev/null +++ b/api/core/tools/provider/builtin/yunzhijia/tools/yunzhijia_group_robot.yaml @@ -0,0 +1,41 @@ +identity: + name: yunzhijia_group_robot + author: Zhujun Lu + label: + en_US: Send Group Robot Message + zh_Hans: 发送群组消息 + pt_BR: Send Group Robot Message + icon: icon.svg +description: + human: + en_US: Sending a group message on Yunzhijia via the webhook of group Robot + zh_Hans: 通过云之家的群组机器人webhook发送群消息 + pt_BR: Sending a group message on Yunzhijia via the webhook of group Robot + llm: A tool for sending messages to a chat group on Yunzhijia(云之家) . +parameters: + - name: webhook_url + type: string + required: true + label: + en_US: Webhook URL + zh_Hans: 群组机器人Webhook + pt_BR: Webhook URL + human_description: + en_US: Webhook URL. + zh_Hans: 群组机器人Webhook + pt_BR: Webhook URL. + llm_description: 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 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/yunzhijia/yunzhijia.py b/api/core/tools/provider/builtin/yunzhijia/yunzhijia.py new file mode 100644 index 00000000000000..88a7475c0aab05 --- /dev/null +++ b/api/core/tools/provider/builtin/yunzhijia/yunzhijia.py @@ -0,0 +1,6 @@ +from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController + + +class YunzhijiaProvider(BuiltinToolProviderController): + def _validate_credentials(self, credentials: dict) -> None: + pass diff --git a/api/core/tools/provider/builtin/yunzhijia/yunzhijia.yaml b/api/core/tools/provider/builtin/yunzhijia/yunzhijia.yaml new file mode 100644 index 00000000000000..9f74f33133ae01 --- /dev/null +++ b/api/core/tools/provider/builtin/yunzhijia/yunzhijia.yaml @@ -0,0 +1,14 @@ +identity: + author: ZhuJun Lu + name: yunzhijia + label: + en_US: CloudHub + zh_Hans: 云之家 + pt_BR: CloudHub + description: + en_US: CloudHub open api + zh_Hans: 云之家相关开放能力 + pt_BR: CloudHub open api + icon: icon.jpg + tags: + - social