feat(Tools): add lark tools (#10117)
Co-authored-by: 黎斌 <libin.23@bytedance.com>
This commit is contained in:
parent
59f8d116af
commit
f562a88249
113 changed files with 4788 additions and 49 deletions
|
|
@ -48,6 +48,13 @@
|
|||
- feishu_task
|
||||
- feishu_calendar
|
||||
- feishu_spreadsheet
|
||||
- lark_base
|
||||
- lark_document
|
||||
- lark_message_and_group
|
||||
- lark_wiki
|
||||
- lark_task
|
||||
- lark_calendar
|
||||
- lark_spreadsheet
|
||||
- slack
|
||||
- twilio
|
||||
- wecom
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ parameters:
|
|||
Page size, default value: 20, maximum value: 100.
|
||||
zh_Hans: 分页大小,默认值:20,最大值:100。
|
||||
llm_description: 分页大小,默认值:20,最大值:100。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: page_token
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ parameters:
|
|||
Page size, default value: 20, maximum value: 500.
|
||||
zh_Hans: 分页大小,默认值:20,最大值:500。
|
||||
llm_description: 分页大小,默认值:20,最大值:500。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: page_token
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ parameters:
|
|||
en_US: The page size, i.e., the number of data entries returned in a single request. The default value is 50, and the value range is [50,1000].
|
||||
zh_Hans: 分页大小,即单次请求所返回的数据条目数。默认值为 50,取值范围为 [50,1000]。
|
||||
llm_description: 分页大小,即单次请求所返回的数据条目数。默认值为 50,取值范围为 [50,1000]。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: page_token
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ parameters:
|
|||
en_US: The page size, i.e., the number of data entries returned in a single request. The default value is 20, and the value range is [10,100].
|
||||
zh_Hans: 分页大小,即单次请求所返回的数据条目数。默认值为 20,取值范围为 [10,100]。
|
||||
llm_description: 分页大小,即单次请求所返回的数据条目数。默认值为 20,取值范围为 [10,100]。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: page_token
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ parameters:
|
|||
en_US: Paging size, the default and maximum value is 500.
|
||||
zh_Hans: 分页大小, 默认值和最大值为 500。
|
||||
llm_description: 分页大小, 表示一次请求最多返回多少条数据,默认值和最大值为 500。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: page_token
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ parameters:
|
|||
en_US: The page size, i.e., the number of data entries returned in a single request. The default value is 20, and the value range is [1,50].
|
||||
zh_Hans: 分页大小,即单次请求所返回的数据条目数。默认值为 20,取值范围为 [1,50]。
|
||||
llm_description: 分页大小,即单次请求所返回的数据条目数。默认值为 20,取值范围为 [1,50]。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: page_token
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ parameters:
|
|||
en_US: The page size, i.e., the number of data entries returned in a single request. The default value is 20, and the value range is [1,50].
|
||||
zh_Hans: 分页大小,即单次请求所返回的数据条目数。默认值为 20,取值范围为 [1,50]。
|
||||
llm_description: 分页大小,即单次请求所返回的数据条目数。默认值为 20,取值范围为 [1,50]。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: page_token
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ parameters:
|
|||
en_US: Number of columns to add, range (0-5000].
|
||||
zh_Hans: 要增加的列数,范围(0-5000]。
|
||||
llm_description: 要增加的列数,范围(0-5000]。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: values
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ parameters:
|
|||
en_US: Number of rows to add, range (0-5000].
|
||||
zh_Hans: 要增加行数,范围(0-5000]。
|
||||
llm_description: 要增加行数,范围(0-5000]。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: values
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ parameters:
|
|||
en_US: Starting column number, starting from 1.
|
||||
zh_Hans: 起始列号,从 1 开始。
|
||||
llm_description: 起始列号,从 1 开始。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: num_cols
|
||||
type: number
|
||||
|
|
@ -94,4 +94,4 @@ parameters:
|
|||
en_US: Number of columns to read.
|
||||
zh_Hans: 读取列数
|
||||
llm_description: 读取列数
|
||||
form: llm
|
||||
form: form
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ parameters:
|
|||
en_US: Starting row number, starting from 1.
|
||||
zh_Hans: 起始行号,从 1 开始。
|
||||
llm_description: 起始行号,从 1 开始。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: num_rows
|
||||
type: number
|
||||
|
|
@ -94,4 +94,4 @@ parameters:
|
|||
en_US: Number of rows to read.
|
||||
zh_Hans: 读取行数
|
||||
llm_description: 读取行数
|
||||
form: llm
|
||||
form: form
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ parameters:
|
|||
en_US: Starting row number, starting from 1.
|
||||
zh_Hans: 起始行号,从 1 开始。
|
||||
llm_description: 起始行号,从 1 开始。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: num_rows
|
||||
type: number
|
||||
|
|
@ -94,7 +94,7 @@ parameters:
|
|||
en_US: Number of rows to read.
|
||||
zh_Hans: 读取行数
|
||||
llm_description: 读取行数
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: range
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ parameters:
|
|||
en_US: The size of each page, with a maximum value of 50.
|
||||
zh_Hans: 分页大小,最大值 50。
|
||||
llm_description: 分页大小,最大值 50。
|
||||
form: llm
|
||||
form: form
|
||||
|
||||
- name: page_token
|
||||
type: string
|
||||
|
|
|
|||
BIN
api/core/tools/provider/builtin/lark_base/_assets/icon.png
Normal file
BIN
api/core/tools/provider/builtin/lark_base/_assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
7
api/core/tools/provider/builtin/lark_base/lark_base.py
Normal file
7
api/core/tools/provider/builtin/lark_base/lark_base.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
||||
from core.tools.utils.lark_api_utils import lark_auth
|
||||
|
||||
|
||||
class LarkBaseProvider(BuiltinToolProviderController):
|
||||
def _validate_credentials(self, credentials: dict) -> None:
|
||||
lark_auth(credentials)
|
||||
36
api/core/tools/provider/builtin/lark_base/lark_base.yaml
Normal file
36
api/core/tools/provider/builtin/lark_base/lark_base.yaml
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
identity:
|
||||
author: Doug Lea
|
||||
name: lark_base
|
||||
label:
|
||||
en_US: Lark Base
|
||||
zh_Hans: Lark 多维表格
|
||||
description:
|
||||
en_US: |
|
||||
Lark base, requires the following permissions: bitable:app.
|
||||
zh_Hans: |
|
||||
Lark 多维表格,需要开通以下权限: bitable:app。
|
||||
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 Lark app id
|
||||
zh_Hans: 请输入你的 Lark app id
|
||||
help:
|
||||
en_US: Get your app_id and app_secret from Lark
|
||||
zh_Hans: 从 Lark 获取您的 app_id 和 app_secret
|
||||
url: https://open.larksuite.com/app
|
||||
app_secret:
|
||||
type: secret-input
|
||||
required: true
|
||||
label:
|
||||
en_US: APP Secret
|
||||
placeholder:
|
||||
en_US: Please input your app secret
|
||||
zh_Hans: 请输入你的 Lark app secret
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
from typing import Any
|
||||
|
||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||
from core.tools.tool.builtin_tool import BuiltinTool
|
||||
from core.tools.utils.lark_api_utils import LarkRequest
|
||||
|
||||
|
||||
class AddRecordsTool(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 = LarkRequest(app_id, app_secret)
|
||||
|
||||
app_token = tool_parameters.get("app_token")
|
||||
table_id = tool_parameters.get("table_id")
|
||||
table_name = tool_parameters.get("table_name")
|
||||
records = tool_parameters.get("records")
|
||||
user_id_type = tool_parameters.get("user_id_type", "open_id")
|
||||
|
||||
res = client.add_records(app_token, table_id, table_name, records, user_id_type)
|
||||
return self.create_json_message(res)
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
identity:
|
||||
name: add_records
|
||||
author: Doug Lea
|
||||
label:
|
||||
en_US: Add Records
|
||||
zh_Hans: 新增多条记录
|
||||
description:
|
||||
human:
|
||||
en_US: Add Multiple Records to Multidimensional Table
|
||||
zh_Hans: 在多维表格数据表中新增多条记录
|
||||
llm: A tool for adding multiple records to a multidimensional table. (在多维表格数据表中新增多条记录)
|
||||
parameters:
|
||||
- name: app_token
|
||||
type: string
|
||||
required: true
|
||||
label:
|
||||
en_US: app_token
|
||||
zh_Hans: app_token
|
||||
human_description:
|
||||
en_US: Unique identifier for the multidimensional table, supports inputting document URL.
|
||||
zh_Hans: 多维表格的唯一标识符,支持输入文档 URL。
|
||||
llm_description: 多维表格的唯一标识符,支持输入文档 URL。
|
||||
form: llm
|
||||
|
||||
- name: table_id
|
||||
type: string
|
||||
required: false
|
||||
label:
|
||||
en_US: table_id
|
||||
zh_Hans: table_id
|
||||
human_description:
|
||||
en_US: Unique identifier for the multidimensional table data, either table_id or table_name must be provided, cannot be empty simultaneously.
|
||||
zh_Hans: 多维表格数据表的唯一标识符,table_id 和 table_name 至少需要提供一个,不能同时为空。
|
||||
llm_description: 多维表格数据表的唯一标识符,table_id 和 table_name 至少需要提供一个,不能同时为空。
|
||||
form: llm
|
||||
|
||||
- name: table_name
|
||||
type: string
|
||||
required: false
|
||||
label:
|
||||
en_US: table_name
|
||||
zh_Hans: table_name
|
||||
human_description:
|
||||
en_US: Name of the multidimensional table data, either table_name or table_id must be provided, cannot be empty simultaneously.
|
||||
zh_Hans: 多维表格数据表的名称,table_name 和 table_id 至少需要提供一个,不能同时为空。
|
||||
llm_description: 多维表格数据表的名称,table_name 和 table_id 至少需要提供一个,不能同时为空。
|
||||
form: llm
|
||||
|
||||
- name: records
|
||||
type: string
|
||||
required: true
|
||||
label:
|
||||
en_US: records
|
||||
zh_Hans: 记录列表
|
||||
human_description:
|
||||
en_US: |
|
||||
List of records to be added in this request. Example value: [{"multi-line-text":"text content","single_select":"option 1","date":1674206443000}]
|
||||
For supported field types, refer to the integration guide (https://open.larkoffice.com/document/server-docs/docs/bitable-v1/notification). For data structures of different field types, refer to the data structure overview (https://open.larkoffice.com/document/server-docs/docs/bitable-v1/bitable-structure).
|
||||
zh_Hans: |
|
||||
本次请求将要新增的记录列表,示例值:[{"多行文本":"文本内容","单选":"选项 1","日期":1674206443000}]。
|
||||
当前接口支持的字段类型请参考接入指南(https://open.larkoffice.com/document/server-docs/docs/bitable-v1/notification),不同类型字段的数据结构请参考数据结构概述(https://open.larkoffice.com/document/server-docs/docs/bitable-v1/bitable-structure)。
|
||||
llm_description: |
|
||||
本次请求将要新增的记录列表,示例值:[{"多行文本":"文本内容","单选":"选项 1","日期":1674206443000}]。
|
||||
当前接口支持的字段类型请参考接入指南(https://open.larkoffice.com/document/server-docs/docs/bitable-v1/notification),不同类型字段的数据结构请参考数据结构概述(https://open.larkoffice.com/document/server-docs/docs/bitable-v1/bitable-structure)。
|
||||
form: llm
|
||||
|
||||
- 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
|
||||
|
|
@ -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.lark_api_utils import LarkRequest
|
||||
|
||||
|
||||
class CreateBaseTool(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 = LarkRequest(app_id, app_secret)
|
||||
|
||||
name = tool_parameters.get("name")
|
||||
folder_token = tool_parameters.get("folder_token")
|
||||
|
||||
res = client.create_base(name, folder_token)
|
||||
return self.create_json_message(res)
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue