chore(api/core): apply ruff reformatting (#7624)
This commit is contained in:
@@ -8,41 +8,41 @@ from core.tools.utils.uuid_utils import is_valid_uuid
|
||||
|
||||
|
||||
class WecomGroupBotTool(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
|
||||
invoke tools
|
||||
"""
|
||||
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")
|
||||
|
||||
message_type = tool_parameters.get('message_type', 'text')
|
||||
if message_type == 'markdown':
|
||||
message_type = tool_parameters.get("message_type", "text")
|
||||
if message_type == "markdown":
|
||||
payload = {
|
||||
"msgtype": 'markdown',
|
||||
"msgtype": "markdown",
|
||||
"markdown": {
|
||||
"content": content,
|
||||
}
|
||||
},
|
||||
}
|
||||
else:
|
||||
payload = {
|
||||
"msgtype": 'text',
|
||||
"msgtype": "text",
|
||||
"text": {
|
||||
"content": content,
|
||||
}
|
||||
},
|
||||
}
|
||||
api_url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send'
|
||||
api_url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send"
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
params = {
|
||||
'key': hook_key,
|
||||
"key": hook_key,
|
||||
}
|
||||
|
||||
try:
|
||||
@@ -51,6 +51,7 @@ class WecomGroupBotTool(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))
|
||||
|
||||
Reference in New Issue
Block a user