-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
Nov 4, 2024
1 parent
f5d1c7c
commit 15b0d3c
Showing
113 changed files
with
4,693 additions
and
18 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
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
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
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
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
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
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
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
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
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
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
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
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
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.
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.lark_api_utils import lark_auth | ||
|
||
|
||
class LarkBaseProvider(BuiltinToolProviderController): | ||
def _validate_credentials(self, credentials: dict) -> None: | ||
lark_auth(credentials) |
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: 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 |
21 changes: 21 additions & 0 deletions
21
api/core/tools/provider/builtin/lark_base/tools/add_records.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,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) |
91 changes: 91 additions & 0 deletions
91
api/core/tools/provider/builtin/lark_base/tools/add_records.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,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 |
18 changes: 18 additions & 0 deletions
18
api/core/tools/provider/builtin/lark_base/tools/create_base.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.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) |
42 changes: 42 additions & 0 deletions
42
api/core/tools/provider/builtin/lark_base/tools/create_base.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,42 @@ | ||
identity: | ||
name: create_base | ||
author: Doug Lea | ||
label: | ||
en_US: Create Base | ||
zh_Hans: 创建多维表格 | ||
description: | ||
human: | ||
en_US: Create Multidimensional Table in Specified Directory | ||
zh_Hans: 在指定目录下创建多维表格 | ||
llm: A tool for creating a multidimensional table in a specified directory. (在指定目录下创建多维表格) | ||
parameters: | ||
- name: name | ||
type: string | ||
required: false | ||
label: | ||
en_US: name | ||
zh_Hans: 多维表格 App 名字 | ||
human_description: | ||
en_US: | | ||
Name of the multidimensional table App. Example value: "A new multidimensional table". | ||
zh_Hans: 多维表格 App 名字,示例值:"一篇新的多维表格"。 | ||
llm_description: 多维表格 App 名字,示例值:"一篇新的多维表格"。 | ||
form: llm | ||
|
||
- name: folder_token | ||
type: string | ||
required: false | ||
label: | ||
en_US: folder_token | ||
zh_Hans: 多维表格 App 归属文件夹 | ||
human_description: | ||
en_US: | | ||
Folder where the multidimensional table App belongs. Default is empty, meaning the table will be created in the root directory of the cloud space. Example values: Lf8uf6BoAlWkUfdGtpMjUV0PpZd or https://lark-japan.jp.larksuite.com/drive/folder/Lf8uf6BoAlWkUfdGtpMjUV0PpZd. | ||
The folder_token must be an existing folder and supports inputting folder token or folder URL. | ||
zh_Hans: | | ||
多维表格 App 归属文件夹。默认为空,表示多维表格将被创建在云空间根目录。示例值: Lf8uf6BoAlWkUfdGtpMjUV0PpZd 或者 https://lark-japan.jp.larksuite.com/drive/folder/Lf8uf6BoAlWkUfdGtpMjUV0PpZd。 | ||
folder_token 必须是已存在的文件夹,支持输入文件夹 token 或者文件夹 URL。 | ||
llm_description: | | ||
多维表格 App 归属文件夹。默认为空,表示多维表格将被创建在云空间根目录。示例值: Lf8uf6BoAlWkUfdGtpMjUV0PpZd 或者 https://lark-japan.jp.larksuite.com/drive/folder/Lf8uf6BoAlWkUfdGtpMjUV0PpZd。 | ||
folder_token 必须是已存在的文件夹,支持输入文件夹 token 或者文件夹 URL。 | ||
form: llm |
20 changes: 20 additions & 0 deletions
20
api/core/tools/provider/builtin/lark_base/tools/create_table.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.lark_api_utils import LarkRequest | ||
|
||
|
||
class CreateTableTool(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_name = tool_parameters.get("table_name") | ||
default_view_name = tool_parameters.get("default_view_name") | ||
fields = tool_parameters.get("fields") | ||
|
||
res = client.create_table(app_token, table_name, default_view_name, fields) | ||
return self.create_json_message(res) |
Oops, something went wrong.