Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a new built-in tool of Yunzhijia Group Robot #11715

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading