chore(api/core): apply ruff reformatting (#7624)

This commit is contained in:
Bowen Liang
2024-09-10 17:00:20 +08:00
committed by GitHub
parent 178730266d
commit 2cf1187b32
724 changed files with 21180 additions and 21123 deletions

View File

@@ -8,35 +8,35 @@ 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]]:
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
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', '')
content = tool_parameters.get("content", "")
if not content:
return self.create_text_message('Invalid parameter content')
return self.create_text_message("Invalid parameter content")
hook_key = tool_parameters.get('hook_key', '')
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')
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}'
msg_type = "text"
api_url = f"{url}/{hook_key}"
headers = {
'Content-Type': 'application/json',
"Content-Type": "application/json",
}
params = {}
payload = {
"msg_type": msg_type,
"content": {
"text": content,
}
},
}
try:
@@ -45,6 +45,7 @@ class FeishuGroupBotTool(BuiltinTool):
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}")
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))
return self.create_text_message("Failed to send message to group chat bot. {}".format(e))