From cb0aeb7f8581ad4c3facbec84afb3cf73b12f2bc Mon Sep 17 00:00:00 2001 From: LuZhuJun Date: Tue, 17 Dec 2024 09:42:57 +0800 Subject: [PATCH] feat: add a new built-in tool of Yunzhijia Group Robot --- .../builtin/yunzhijia/_assets/icon.jpg | Bin 0 -> 11397 bytes .../yunzhijia/tools/yunzhijia_group_robot.py | 41 ++++++++++++++++++ .../tools/yunzhijia_group_robot.yaml | 41 ++++++++++++++++++ .../provider/builtin/yunzhijia/yunzhijia.py | 6 +++ .../provider/builtin/yunzhijia/yunzhijia.yaml | 14 ++++++ 5 files changed, 102 insertions(+) create mode 100644 api/core/tools/provider/builtin/yunzhijia/_assets/icon.jpg create mode 100644 api/core/tools/provider/builtin/yunzhijia/tools/yunzhijia_group_robot.py create mode 100644 api/core/tools/provider/builtin/yunzhijia/tools/yunzhijia_group_robot.yaml create mode 100644 api/core/tools/provider/builtin/yunzhijia/yunzhijia.py create mode 100644 api/core/tools/provider/builtin/yunzhijia/yunzhijia.yaml 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 0000000000000000000000000000000000000000..34210747b131b1128bb3879620574e84c1844486 GIT binary patch literal 11397 zcmeHtbyQs0(r+UHLV{ax(nx~4TOb4tPNQiE(2dh*qd@{BI0Q>@LU5;Xm*5r>pb5}O z&=B0EvB%7vJKucwd+)9J`@N~P_v(F4Rqd)>>-0XqU3G4zZWixq*|@tqOYri-+<43( zP8LueOD9KOFLP&JejYwvfRwD4v$>@`)Sbx!YHbUX2JSYu1DR|g(m(@Ybv||Hr%)SP zWgl0lu8)SErH{R(I0Psw!zAS;;pOP;2z57S@^W;5xk-3Q1Am`f;&%MoZC)VL?;`H@ z(m=W2tTGv@YcV}_a)mMp^N4U;@(b}XiHh^^i|`2v^K&r?@bQcC@(J_uiE#7rOYn(F z2=FugLBLyUt`I8;9R7^6ry!4$t2HmbxVShkp8&6b0Qao~x0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(N-yfnv} z$*Ru%bH0u({qTXlx@-QjG)$c+FYKmG9i{sbk$P~ zsBl5-aLm2&jm2Ee90|wxjL^jq@0&4;KCd>h*`QKeBt>0t^BAHKbAI{Ti73QA9%WNK les9&_16}@>71w`d__F@9M)-gF@ZkUXPY(XK3n#mo{$DvZ-K78k literal 0 HcmV?d00001 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..b8774bc9d9d9b3 --- /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)) 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