mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-20 14:39:16 +08:00
Enhance: tools wecom bot support markdown message (#5791)
This commit is contained in:
parent
1d3e96ffa6
commit
2a27568537
@ -22,7 +22,21 @@ class WecomGroupBotTool(BuiltinTool):
|
|||||||
return self.create_text_message(
|
return self.create_text_message(
|
||||||
f'Invalid parameter hook_key ${hook_key}, not a valid UUID')
|
f'Invalid parameter hook_key ${hook_key}, not a valid UUID')
|
||||||
|
|
||||||
msgtype = 'text'
|
message_type = tool_parameters.get('message_type', 'text')
|
||||||
|
if message_type == 'markdown':
|
||||||
|
payload = {
|
||||||
|
"msgtype": 'markdown',
|
||||||
|
"markdown": {
|
||||||
|
"content": content,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
payload = {
|
||||||
|
"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 = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -30,12 +44,6 @@ class WecomGroupBotTool(BuiltinTool):
|
|||||||
params = {
|
params = {
|
||||||
'key': hook_key,
|
'key': hook_key,
|
||||||
}
|
}
|
||||||
payload = {
|
|
||||||
"msgtype": msgtype,
|
|
||||||
"text": {
|
|
||||||
"content": content,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res = httpx.post(api_url, headers=headers, params=params, json=payload)
|
res = httpx.post(api_url, headers=headers, params=params, json=payload)
|
||||||
|
@ -38,3 +38,27 @@ parameters:
|
|||||||
pt_BR: Content to sent to the group.
|
pt_BR: Content to sent to the group.
|
||||||
llm_description: Content of the message
|
llm_description: Content of the message
|
||||||
form: llm
|
form: llm
|
||||||
|
- name: message_type
|
||||||
|
type: select
|
||||||
|
default: text
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Wecom Group bot message type
|
||||||
|
zh_Hans: 群机器人webhook的消息类型
|
||||||
|
pt_BR: Wecom Group bot message type
|
||||||
|
human_description:
|
||||||
|
en_US: Wecom Group bot message type
|
||||||
|
zh_Hans: 群机器人webhook的消息类型
|
||||||
|
pt_BR: Wecom Group bot message type
|
||||||
|
options:
|
||||||
|
- value: text
|
||||||
|
label:
|
||||||
|
en_US: Text
|
||||||
|
zh_Hans: 文本
|
||||||
|
pt_BR: Text
|
||||||
|
- value: markdown
|
||||||
|
label:
|
||||||
|
en_US: Markdown
|
||||||
|
zh_Hans: Markdown
|
||||||
|
pt_BR: Markdown
|
||||||
|
form: form
|
||||||
|
Loading…
x
Reference in New Issue
Block a user