Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
f25cec26
Unverified
Commit
f25cec26
authored
Mar 04, 2024
by
Bowen Liang
Committed by
GitHub
Mar 04, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add Wecom(企业微信) tool for sending message to chat group bot via webhook (#2638)
parent
8e66b962
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
108 additions
and
0 deletions
+108
-0
_position.yaml
api/core/tools/provider/_position.yaml
+1
-0
icon.png
api/core/tools/provider/builtin/wecom/_assets/icon.png
+0
-0
wecom_group_bot.py
...ore/tools/provider/builtin/wecom/tools/wecom_group_bot.py
+46
-0
wecom_group_bot.yaml
...e/tools/provider/builtin/wecom/tools/wecom_group_bot.yaml
+40
-0
wecom.py
api/core/tools/provider/builtin/wecom/wecom.py
+8
-0
wecom.yaml
api/core/tools/provider/builtin/wecom/wecom.yaml
+13
-0
No files found.
api/core/tools/provider/_position.yaml
View file @
f25cec26
...
...
@@ -17,3 +17,4 @@
-
time
-
vectorizer
-
gaode
-
wecom
api/core/tools/provider/builtin/wecom/_assets/icon.png
0 → 100644
View file @
f25cec26
257 KB
api/core/tools/provider/builtin/wecom/tools/wecom_group_bot.py
0 → 100644
View file @
f25cec26
from
typing
import
Any
,
Union
import
httpx
from
core.tools.entities.tool_entities
import
ToolInvokeMessage
from
core.tools.tool.builtin_tool
import
BuiltinTool
class
WecomRepositoriesTool
(
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'
)
hook_key
=
tool_parameters
.
get
(
'hook_key'
,
''
)
if
not
hook_key
:
return
self
.
create_text_message
(
'Invalid parameter hook_key'
)
msgtype
=
'text'
api_url
=
'https://qyapi.weixin.qq.com/cgi-bin/webhook/send'
headers
=
{
'Content-Type'
:
'application/json'
,
}
params
=
{
'key'
:
hook_key
,
}
payload
=
{
"msgtype"
:
msgtype
,
"text"
:
{
"content"
:
content
,
}
}
try
:
res
=
httpx
.
post
(
api_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 chat bot. {}"
.
format
(
e
))
api/core/tools/provider/builtin/wecom/tools/wecom_group_bot.yaml
0 → 100644
View file @
f25cec26
identity
:
name
:
wecom_group_bot
author
:
Bowen Liang
label
:
en_US
:
Send Group Message
zh_Hans
:
发送群消息
pt_BR
:
Send Group Message
icon
:
icon.svg
description
:
human
:
en_US
:
Sending a group message on Wecom via the webhook of group bot
zh_Hans
:
通过企业微信的群机器人webhook发送群消息
pt_BR
:
Sending a group message on Wecom via the webhook of group bot
llm
:
A tool for sending messages to a chat group on Wecom(企业微信) .
parameters
:
-
name
:
hook_key
type
:
string
required
:
true
label
:
en_US
:
Wecom Group bot webhook key
zh_Hans
:
群机器人webhook的key
pt_BR
:
Wecom Group bot webhook key
human_description
:
en_US
:
Wecom Group bot webhook key
zh_Hans
:
群机器人webhook的key
pt_BR
:
Wecom Group bot webhook key
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
api/core/tools/provider/builtin/wecom/wecom.py
0 → 100644
View file @
f25cec26
from
core.tools.provider.builtin.wecom.tools.wecom_group_bot
import
WecomRepositoriesTool
from
core.tools.provider.builtin_tool_provider
import
BuiltinToolProviderController
class
GaodeProvider
(
BuiltinToolProviderController
):
def
_validate_credentials
(
self
,
credentials
:
dict
)
->
None
:
WecomRepositoriesTool
()
pass
api/core/tools/provider/builtin/wecom/wecom.yaml
0 → 100644
View file @
f25cec26
identity
:
author
:
Bowen Liang
name
:
wecom
label
:
en_US
:
Wecom
zh_Hans
:
企业微信
pt_BR
:
Wecom
description
:
en_US
:
Wecom group bot
zh_Hans
:
企业微信群机器人
pt_BR
:
Wecom group bot
icon
:
icon.png
credentials_for_provider
:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment