-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
黎斌
committed
Sep 26, 2024
1 parent
008e0ef
commit 0b10247
Showing
71 changed files
with
2,755 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions
7
api/core/tools/provider/builtin/feishu_calendar/feishu_calendar.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController | ||
from core.tools.utils.feishu_api_utils import auth | ||
|
||
|
||
class FeishuCalendarProvider(BuiltinToolProviderController): | ||
def _validate_credentials(self, credentials: dict) -> None: | ||
auth(credentials) |
36 changes: 36 additions & 0 deletions
36
api/core/tools/provider/builtin/feishu_calendar/feishu_calendar.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
identity: | ||
author: Doug Lea | ||
name: feishu_calendar | ||
label: | ||
en_US: Feishu Calendar | ||
zh_Hans: 飞书日历 | ||
description: | ||
en_US: | | ||
Feishu calendar, requires the following permissions: calendar:calendar:read、calendar:calendar、contact:user.id:readonly. | ||
zh_Hans: | | ||
飞书日历,需要开通以下权限: calendar:calendar:read、calendar:calendar、contact:user.id:readonly。 | ||
icon: icon.png | ||
tags: | ||
- social | ||
- productivity | ||
credentials_for_provider: | ||
app_id: | ||
type: text-input | ||
required: true | ||
label: | ||
en_US: APP ID | ||
placeholder: | ||
en_US: Please input your feishu app id | ||
zh_Hans: 请输入你的飞书 app id | ||
help: | ||
en_US: Get your app_id and app_secret from Feishu | ||
zh_Hans: 从飞书获取您的 app_id 和 app_secret | ||
url: https://open.larkoffice.com/app | ||
app_secret: | ||
type: secret-input | ||
required: true | ||
label: | ||
en_US: APP Secret | ||
placeholder: | ||
en_US: Please input your app secret | ||
zh_Hans: 请输入你的飞书 app secret |
20 changes: 20 additions & 0 deletions
20
api/core/tools/provider/builtin/feishu_calendar/tools/add_event_attendees.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import Any | ||
|
||
from core.tools.entities.tool_entities import ToolInvokeMessage | ||
from core.tools.tool.builtin_tool import BuiltinTool | ||
from core.tools.utils.feishu_api_utils import FeishuRequest | ||
|
||
|
||
class AddEventAttendeesTool(BuiltinTool): | ||
def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage: | ||
app_id = self.runtime.credentials.get("app_id") | ||
app_secret = self.runtime.credentials.get("app_secret") | ||
client = FeishuRequest(app_id, app_secret) | ||
|
||
event_id = tool_parameters.get("event_id") | ||
attendee_phone_or_email = tool_parameters.get("attendee_phone_or_email") | ||
need_notification = tool_parameters.get("need_notification", True) | ||
|
||
res = client.add_event_attendees(event_id, attendee_phone_or_email, need_notification) | ||
|
||
return self.create_json_message(res) |
54 changes: 54 additions & 0 deletions
54
api/core/tools/provider/builtin/feishu_calendar/tools/add_event_attendees.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
identity: | ||
name: add_event_attendees | ||
author: Doug Lea | ||
label: | ||
en_US: Add Event Attendees | ||
zh_Hans: 添加日程参会人 | ||
description: | ||
human: | ||
en_US: Add Event Attendees | ||
zh_Hans: 添加日程参会人 | ||
llm: A tool for adding attendees to events in Feishu. (在飞书中添加日程参会人) | ||
parameters: | ||
- name: event_id | ||
type: string | ||
required: true | ||
label: | ||
en_US: Event ID | ||
zh_Hans: 日程 ID | ||
human_description: | ||
en_US: | | ||
The ID of the event, which will be returned when the event is created. For example: fb2a6406-26d6-4c8d-a487-6f0246c94d2f_0. | ||
zh_Hans: | | ||
创建日程时会返回日程 ID。例如: fb2a6406-26d6-4c8d-a487-6f0246c94d2f_0。 | ||
llm_description: | | ||
日程 ID,创建日程时会返回日程 ID。例如: fb2a6406-26d6-4c8d-a487-6f0246c94d2f_0。 | ||
form: llm | ||
|
||
- name: need_notification | ||
type: boolean | ||
required: false | ||
default: true | ||
label: | ||
en_US: Need Notification | ||
zh_Hans: 是否需要通知 | ||
human_description: | ||
en_US: | | ||
Whether to send a Bot notification to attendees. true: send, false: do not send. | ||
zh_Hans: | | ||
是否给参与人发送 Bot 通知,true: 发送,false: 不发送。 | ||
llm_description: | | ||
是否给参与人发送 Bot 通知,true: 发送,false: 不发送。 | ||
form: form | ||
|
||
- name: attendee_phone_or_email | ||
type: string | ||
required: true | ||
label: | ||
en_US: Attendee Phone or Email | ||
zh_Hans: 参会人电话或邮箱 | ||
human_description: | ||
en_US: The list of attendee emails or phone numbers, separated by commas. | ||
zh_Hans: 日程参会人邮箱或者手机号列表,使用逗号分隔。 | ||
llm_description: 日程参会人邮箱或者手机号列表,使用逗号分隔。 | ||
form: llm |
26 changes: 26 additions & 0 deletions
26
api/core/tools/provider/builtin/feishu_calendar/tools/create_event.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Any | ||
|
||
from core.tools.entities.tool_entities import ToolInvokeMessage | ||
from core.tools.tool.builtin_tool import BuiltinTool | ||
from core.tools.utils.feishu_api_utils import FeishuRequest | ||
|
||
|
||
class CreateEventTool(BuiltinTool): | ||
def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage: | ||
app_id = self.runtime.credentials.get("app_id") | ||
app_secret = self.runtime.credentials.get("app_secret") | ||
client = FeishuRequest(app_id, app_secret) | ||
|
||
summary = tool_parameters.get("summary") | ||
description = tool_parameters.get("description") | ||
start_time = tool_parameters.get("start_time") | ||
end_time = tool_parameters.get("end_time") | ||
attendee_ability = tool_parameters.get("attendee_ability") | ||
need_notification = tool_parameters.get("need_notification", True) | ||
auto_record = tool_parameters.get("auto_record", False) | ||
|
||
res = client.create_event( | ||
summary, description, start_time, end_time, attendee_ability, need_notification, auto_record | ||
) | ||
|
||
return self.create_json_message(res) |
119 changes: 119 additions & 0 deletions
119
api/core/tools/provider/builtin/feishu_calendar/tools/create_event.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
identity: | ||
name: create_event | ||
author: Doug Lea | ||
label: | ||
en_US: Create Event | ||
zh_Hans: 创建日程 | ||
description: | ||
human: | ||
en_US: Create Event | ||
zh_Hans: 创建日程 | ||
llm: A tool for creating events in Feishu.(创建飞书日程) | ||
parameters: | ||
- name: summary | ||
type: string | ||
required: false | ||
label: | ||
en_US: Summary | ||
zh_Hans: 日程标题 | ||
human_description: | ||
en_US: The title of the event. If not filled, the event title will display (No Subject). | ||
zh_Hans: 日程标题,若不填则日程标题显示 (无主题)。 | ||
llm_description: 日程标题,若不填则日程标题显示 (无主题)。 | ||
form: llm | ||
|
||
- name: description | ||
type: string | ||
required: false | ||
label: | ||
en_US: Description | ||
zh_Hans: 日程描述 | ||
human_description: | ||
en_US: The description of the event. | ||
zh_Hans: 日程描述。 | ||
llm_description: 日程描述。 | ||
form: llm | ||
|
||
- name: need_notification | ||
type: boolean | ||
required: false | ||
default: true | ||
label: | ||
en_US: Need Notification | ||
zh_Hans: 是否发送通知 | ||
human_description: | ||
en_US: | | ||
Whether to send a bot message when the event is created, true: send, false: do not send. | ||
zh_Hans: 创建日程时是否发送 bot 消息,true:发送,false:不发送。 | ||
llm_description: 创建日程时是否发送 bot 消息,true:发送,false:不发送。 | ||
form: form | ||
|
||
- name: start_time | ||
type: string | ||
required: true | ||
label: | ||
en_US: Start Time | ||
zh_Hans: 开始时间 | ||
human_description: | ||
en_US: | | ||
The start time of the event, format: 2006-01-02 15:04:05. | ||
zh_Hans: 日程开始时间,格式:2006-01-02 15:04:05。 | ||
llm_description: 日程开始时间,格式:2006-01-02 15:04:05。 | ||
form: llm | ||
|
||
- name: end_time | ||
type: string | ||
required: true | ||
label: | ||
en_US: End Time | ||
zh_Hans: 结束时间 | ||
human_description: | ||
en_US: | | ||
The end time of the event, format: 2006-01-02 15:04:05. | ||
zh_Hans: 日程结束时间,格式:2006-01-02 15:04:05。 | ||
llm_description: 日程结束时间,格式:2006-01-02 15:04:05。 | ||
form: llm | ||
|
||
- name: attendee_ability | ||
type: select | ||
required: false | ||
options: | ||
- value: none | ||
label: | ||
en_US: none | ||
zh_Hans: 无 | ||
- value: can_see_others | ||
label: | ||
en_US: can_see_others | ||
zh_Hans: 可以查看参与人列表 | ||
- value: can_invite_others | ||
label: | ||
en_US: can_invite_others | ||
zh_Hans: 可以邀请其它参与人 | ||
- value: can_modify_event | ||
label: | ||
en_US: can_modify_event | ||
zh_Hans: 可以编辑日程 | ||
default: "none" | ||
label: | ||
en_US: attendee_ability | ||
zh_Hans: 参会人权限 | ||
human_description: | ||
en_US: Attendee ability, optional values are none, can_see_others, can_invite_others, can_modify_event, with a default value of none. | ||
zh_Hans: 参会人权限,可选值有无、可以查看参与人列表、可以邀请其它参与人、可以编辑日程,默认值为无。 | ||
llm_description: 参会人权限,可选值有无、可以查看参与人列表、可以邀请其它参与人、可以编辑日程,默认值为无。 | ||
form: form | ||
|
||
- name: auto_record | ||
type: boolean | ||
required: false | ||
default: false | ||
label: | ||
en_US: Auto Record | ||
zh_Hans: 自动录制 | ||
human_description: | ||
en_US: | | ||
Whether to enable automatic recording, true: enabled, automatically record when the meeting starts; false: not enabled. | ||
zh_Hans: 是否开启自动录制,true:开启,会议开始后自动录制;false:不开启。 | ||
llm_description: 是否开启自动录制,true:开启,会议开始后自动录制;false:不开启。 | ||
form: form |
19 changes: 19 additions & 0 deletions
19
api/core/tools/provider/builtin/feishu_calendar/tools/delete_event.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import Any | ||
|
||
from core.tools.entities.tool_entities import ToolInvokeMessage | ||
from core.tools.tool.builtin_tool import BuiltinTool | ||
from core.tools.utils.feishu_api_utils import FeishuRequest | ||
|
||
|
||
class DeleteEventTool(BuiltinTool): | ||
def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage: | ||
app_id = self.runtime.credentials.get("app_id") | ||
app_secret = self.runtime.credentials.get("app_secret") | ||
client = FeishuRequest(app_id, app_secret) | ||
|
||
event_id = tool_parameters.get("event_id") | ||
need_notification = tool_parameters.get("need_notification", True) | ||
|
||
res = client.delete_event(event_id, need_notification) | ||
|
||
return self.create_json_message(res) |
38 changes: 38 additions & 0 deletions
38
api/core/tools/provider/builtin/feishu_calendar/tools/delete_event.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
identity: | ||
name: delete_event | ||
author: Doug Lea | ||
label: | ||
en_US: Delete Event | ||
zh_Hans: 删除日程 | ||
description: | ||
human: | ||
en_US: Delete Event | ||
zh_Hans: 删除日程 | ||
llm: A tool for deleting events in Feishu.(在飞书中删除日程) | ||
parameters: | ||
- name: event_id | ||
type: string | ||
required: true | ||
label: | ||
en_US: Event ID | ||
zh_Hans: 日程 ID | ||
human_description: | ||
en_US: | | ||
The ID of the event, for example: e8b9791c-39ae-4908-8ad8-66b13159b9fb_0. | ||
zh_Hans: 日程 ID,例如:e8b9791c-39ae-4908-8ad8-66b13159b9fb_0。 | ||
llm_description: 日程 ID,例如:e8b9791c-39ae-4908-8ad8-66b13159b9fb_0。 | ||
form: llm | ||
|
||
- name: need_notification | ||
type: boolean | ||
required: false | ||
default: true | ||
label: | ||
en_US: Need Notification | ||
zh_Hans: 是否需要通知 | ||
human_description: | ||
en_US: | | ||
Indicates whether to send bot notifications to event participants upon deletion. true: send, false: do not send. | ||
zh_Hans: 删除日程是否给日程参与人发送 bot 通知,true:发送,false:不发送。 | ||
llm_description: 删除日程是否给日程参与人发送 bot 通知,true:发送,false:不发送。 | ||
form: form |
18 changes: 18 additions & 0 deletions
18
api/core/tools/provider/builtin/feishu_calendar/tools/get_primary_calendar.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from typing import Any | ||
|
||
from core.tools.entities.tool_entities import ToolInvokeMessage | ||
from core.tools.tool.builtin_tool import BuiltinTool | ||
from core.tools.utils.feishu_api_utils import FeishuRequest | ||
|
||
|
||
class GetPrimaryCalendarTool(BuiltinTool): | ||
def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage: | ||
app_id = self.runtime.credentials.get("app_id") | ||
app_secret = self.runtime.credentials.get("app_secret") | ||
client = FeishuRequest(app_id, app_secret) | ||
|
||
user_id_type = tool_parameters.get("user_id_type", "open_id") | ||
|
||
res = client.get_primary_calendar(user_id_type) | ||
|
||
return self.create_json_message(res) |
37 changes: 37 additions & 0 deletions
37
api/core/tools/provider/builtin/feishu_calendar/tools/get_primary_calendar.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
identity: | ||
name: get_primary_calendar | ||
author: Doug Lea | ||
label: | ||
en_US: Get Primary Calendar | ||
zh_Hans: 查询主日历信息 | ||
description: | ||
human: | ||
en_US: Get Primary Calendar | ||
zh_Hans: 查询主日历信息 | ||
llm: A tool for querying primary calendar information in Feishu.(在飞书中查询主日历信息) | ||
parameters: | ||
- name: user_id_type | ||
type: select | ||
required: false | ||
options: | ||
- value: open_id | ||
label: | ||
en_US: open_id | ||
zh_Hans: open_id | ||
- value: union_id | ||
label: | ||
en_US: union_id | ||
zh_Hans: union_id | ||
- value: user_id | ||
label: | ||
en_US: user_id | ||
zh_Hans: user_id | ||
default: "open_id" | ||
label: | ||
en_US: user_id_type | ||
zh_Hans: 用户 ID 类型 | ||
human_description: | ||
en_US: User ID type, optional values are open_id, union_id, user_id, with a default value of open_id. | ||
zh_Hans: 用户 ID 类型,可选值有 open_id、union_id、user_id,默认值为 open_id。 | ||
llm_description: 用户 ID 类型,可选值有 open_id、union_id、user_id,默认值为 open_id。 | ||
form: form |
Oops, something went wrong.