Skip to content

Commit

Permalink
feat: add a new built-in tool of Yunzhijia Group Robot
Browse files Browse the repository at this point in the history
  • Loading branch information
LuZhuJun committed Dec 19, 2024
1 parent 56cfdce commit cb0aeb7
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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))
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions api/core/tools/provider/builtin/yunzhijia/yunzhijia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController


class YunzhijiaProvider(BuiltinToolProviderController):
def _validate_credentials(self, credentials: dict) -> None:
pass
14 changes: 14 additions & 0 deletions api/core/tools/provider/builtin/yunzhijia/yunzhijia.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cb0aeb7

Please sign in to comment.