mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 03:32:23 +08:00
FEAT: Add Brave Search and Trello(12 Tools) Included (#3040)
This commit is contained in:
parent
84d118de07
commit
132269618d
1
api/core/tools/provider/builtin/brave/_assets/icon.svg
Normal file
1
api/core/tools/provider/builtin/brave/_assets/icon.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48px" height="48px" clip-rule="evenodd" baseProfile="basic"><linearGradient id="yG17B1EwMCiUUe9ON9hI5a" x1="-329.441" x2="-329.276" y1="-136.877" y2="-136.877" gradientTransform="matrix(217.6 0 0 -255.4727 71694.719 -34944.293)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#e68e00"/><stop offset=".437" stop-color="#d75500"/><stop offset=".562" stop-color="#cf3600"/><stop offset=".89" stop-color="#d22900"/><stop offset="1" stop-color="#d42400"/></linearGradient><path fill="url(#yG17B1EwMCiUUe9ON9hI5a)" fill-rule="evenodd" d="M40.635,13.075l0.984-2.418c0,0-1.252-1.343-2.772-2.865 s-4.74-0.627-4.74-0.627L30.439,3H24h-6.439l-3.667,4.165c0,0-3.22-0.895-4.74,0.627s-2.772,2.865-2.772,2.865l0.984,2.418 l-1.252,3.582c0,0,3.682,13.965,4.114,15.671c0.85,3.358,1.431,4.656,3.846,6.358c2.415,1.701,6.797,4.656,7.512,5.104 C22.301,44.237,23.195,45,24,45c0.805,0,1.699-0.763,2.415-1.21c0.715-0.448,5.098-3.403,7.512-5.104 c2.415-1.701,2.996-3,3.846-6.358c0.431-1.705,4.114-15.671,4.114-15.671L40.635,13.075z" clip-rule="evenodd"/><linearGradient id="yG17B1EwMCiUUe9ON9hI5b" x1="19.087" x2="31.755" y1="7.685" y2="32.547" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#fff"/><stop offset=".24" stop-color="#f8f8f7"/><stop offset="1" stop-color="#e3e3e1"/></linearGradient><path fill="url(#yG17B1EwMCiUUe9ON9hI5b)" fill-rule="evenodd" d="M33.078,9.807c0,0,4.716,5.709,4.716,6.929 s-0.593,1.542-1.19,2.176c-0.597,0.634-3.202,3.404-3.536,3.76c-0.335,0.356-1.031,0.895-0.621,1.866 c0.41,0.971,1.014,2.206,0.342,3.459c-0.672,1.253-1.824,2.089-2.561,1.951c-0.738-0.138-2.471-1.045-3.108-1.459 c-0.637-0.414-2.657-2.082-2.657-2.72c0-0.638,2.088-1.784,2.473-2.044c0.386-0.26,2.145-1.268,2.181-1.663 c0.036-0.396,0.022-0.511-0.497-1.489c-0.519-0.977-1.454-2.281-1.298-3.149c0.156-0.868,1.663-1.319,2.74-1.726 c1.076-0.407,3.148-1.175,3.406-1.295c0.259-0.12,0.192-0.233-0.592-0.308c-0.784-0.074-3.009-0.37-4.012-0.09 c-1.003,0.28-2.717,0.706-2.855,0.932c-0.139,0.226-0.261,0.233-0.119,1.012c0.142,0.779,0.876,4.517,0.948,5.181 c0.071,0.664,0.211,1.103-0.504,1.267c-0.715,0.164-1.919,0.448-2.332,0.448s-1.617-0.284-2.332-0.448 c-0.715-0.164-0.576-0.603-0.504-1.267s0.805-4.402,0.948-5.181c0.142-0.779,0.02-0.787-0.119-1.012 c-0.139-0.226-1.852-0.652-2.855-0.932c-1.003-0.28-3.228,0.016-4.012,0.09c-0.784,0.074-0.851,0.188-0.592,0.308 c0.259,0.119,2.331,0.888,3.406,1.295c1.076,0.407,2.584,0.858,2.74,1.726c0.156,0.868-0.779,2.172-1.298,3.149 c-0.519,0.977-0.533,1.093-0.497,1.489c0.036,0.395,1.795,1.403,2.181,1.663c0.386,0.26,2.473,1.406,2.473,2.044 c0,0.638-2.02,2.306-2.657,2.72c-0.637,0.414-2.37,1.321-3.108,1.459c-0.738,0.138-1.889-0.698-2.561-1.951 c-0.672-1.253-0.068-2.488,0.342-3.459c0.41-0.971-0.287-1.51-0.621-1.866c-0.334-0.356-2.94-3.126-3.536-3.76 c-0.597-0.634-1.19-0.956-1.19-2.176s4.716-6.929,4.716-6.929s3.98,0.761,4.516,0.761c0.537,0,1.699-0.448,2.772-0.806 C23.285,9.404,24,9.401,24,9.401s0.715,0.003,1.789,0.361c1.073,0.358,2.236,0.806,2.772,0.806 C29.098,10.568,33.078,9.807,33.078,9.807z M29.542,31.643c0.292,0.183,0.114,0.528-0.152,0.716 c-0.266,0.188-3.84,2.959-4.187,3.265c-0.347,0.306-0.857,0.812-1.203,0.812c-0.347,0-0.856-0.506-1.203-0.812 c-0.347-0.306-3.921-3.077-4.187-3.265c-0.266-0.188-0.444-0.533-0.152-0.716c0.292-0.183,1.205-0.645,2.466-1.298 c1.26-0.653,2.831-1.208,3.076-1.208c0.245,0,1.816,0.555,3.076,1.208C28.336,30.999,29.25,31.46,29.542,31.643z" clip-rule="evenodd"/><linearGradient id="yG17B1EwMCiUUe9ON9hI5c" x1="-329.279" x2="-329.074" y1="-140.492" y2="-140.492" gradientTransform="matrix(180.608 0 0 -46.0337 59468.86 -6460.583)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#e68e00"/><stop offset="1" stop-color="#d42400"/></linearGradient><path fill="url(#yG17B1EwMCiUUe9ON9hI5c)" fill-rule="evenodd" d="M34.106,7.165L30.439,3H24h-6.439l-3.667,4.165 c0,0-3.22-0.895-4.74,0.627c0,0,4.293-0.388,5.769,2.015c0,0,3.98,0.761,4.516,0.761c0.537,0,1.699-0.448,2.772-0.806 C23.285,9.404,24,9.401,24,9.401s0.715,0.003,1.789,0.361c1.073,0.358,2.236,0.806,2.772,0.806c0.537,0,4.516-0.761,4.516-0.761 c1.476-2.403,5.769-2.015,5.769-2.015C37.326,6.27,34.106,7.165,34.106,7.165" clip-rule="evenodd"/></svg>
|
After Width: | Height: | Size: 4.1 KiB |
22
api/core/tools/provider/builtin/brave/brave.py
Normal file
22
api/core/tools/provider/builtin/brave/brave.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from core.tools.errors import ToolProviderCredentialValidationError
|
||||||
|
from core.tools.provider.builtin.brave.tools.brave_search import BraveSearchTool
|
||||||
|
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
||||||
|
|
||||||
|
|
||||||
|
class BraveProvider(BuiltinToolProviderController):
|
||||||
|
def _validate_credentials(self, credentials: dict[str, Any]) -> None:
|
||||||
|
try:
|
||||||
|
BraveSearchTool().fork_tool_runtime(
|
||||||
|
meta={
|
||||||
|
"credentials": credentials,
|
||||||
|
}
|
||||||
|
).invoke(
|
||||||
|
user_id='',
|
||||||
|
tool_parameters={
|
||||||
|
"query": "Sachin Tendulkar",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
raise ToolProviderCredentialValidationError(str(e))
|
29
api/core/tools/provider/builtin/brave/brave.yaml
Normal file
29
api/core/tools/provider/builtin/brave/brave.yaml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
identity:
|
||||||
|
author: Yash Parmar
|
||||||
|
name: brave
|
||||||
|
label:
|
||||||
|
en_US: Brave
|
||||||
|
zh_Hans: Brave
|
||||||
|
pt_BR: Brave
|
||||||
|
description:
|
||||||
|
en_US: Brave
|
||||||
|
zh_Hans: Brave
|
||||||
|
pt_BR: Brave
|
||||||
|
icon: icon.svg
|
||||||
|
credentials_for_provider:
|
||||||
|
brave_search_api_key:
|
||||||
|
type: secret-input
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Brave Search API key
|
||||||
|
zh_Hans: Brave Search API key
|
||||||
|
pt_BR: Brave Search API key
|
||||||
|
placeholder:
|
||||||
|
en_US: Please input your Brave Search API key
|
||||||
|
zh_Hans: 请输入你的 Brave Search API key
|
||||||
|
pt_BR: Please input your Brave Search API key
|
||||||
|
help:
|
||||||
|
en_US: Get your Brave Search API key from Brave
|
||||||
|
zh_Hans: 从 Brave 获取您的 Brave Search API key
|
||||||
|
pt_BR: Get your Brave Search API key from Brave
|
||||||
|
url: https://brave.com/search/api/
|
40
api/core/tools/provider/builtin/brave/tools/brave_search.py
Normal file
40
api/core/tools/provider/builtin/brave/tools/brave_search.py
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from langchain.tools import BraveSearch
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class BraveSearchTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for performing a search using Brave search engine.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage | list[ToolInvokeMessage]:
|
||||||
|
"""
|
||||||
|
Invoke the Brave search tool.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Any]): The parameters for the tool invocation.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage | list[ToolInvokeMessage]: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
query = tool_parameters.get('query', '')
|
||||||
|
count = tool_parameters.get('count', 3)
|
||||||
|
api_key = self.runtime.credentials['brave_search_api_key']
|
||||||
|
|
||||||
|
if not query:
|
||||||
|
return self.create_text_message('Please input query')
|
||||||
|
|
||||||
|
tool = BraveSearch.from_api_key(api_key=api_key, search_kwargs={"count": count})
|
||||||
|
|
||||||
|
results = tool.run(query)
|
||||||
|
|
||||||
|
if not results:
|
||||||
|
return self.create_text_message(f"No results found for '{query}' in Tavily")
|
||||||
|
else:
|
||||||
|
return self.create_text_message(text=results)
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
identity:
|
||||||
|
name: brave_search
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: BraveSearch
|
||||||
|
zh_Hans: BraveSearch
|
||||||
|
pt_BR: BraveSearch
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: BraveSearch is a privacy-focused search engine that leverages its own index to deliver unbiased, independent, and fast search results. It's designed to respect user privacy by not tracking searches or personal information, making it a secure choice for those concerned about online privacy.
|
||||||
|
zh_Hans: BraveSearch 是一个注重隐私的搜索引擎,它利用自己的索引来提供公正、独立和快速的搜索结果。它旨在通过不跟踪搜索或个人信息来尊重用户隐私,为那些关注在线隐私的用户提供了一个安全的选择。
|
||||||
|
pt_BR: BraveSearch é um mecanismo de busca focado na privacidade que utiliza seu próprio índice para entregar resultados de busca imparciais, independentes e rápidos. Ele é projetado para respeitar a privacidade do usuário, não rastreando buscas ou informações pessoais, tornando-se uma escolha segura para aqueles preocupados com a privacidade online.
|
||||||
|
llm: BraveSearch is a privacy-centric search engine utilizing its unique index to offer unbiased, independent, and swift search results. It aims to protect user privacy by avoiding the tracking of search activities or personal data, presenting a secure option for users mindful of their online privacy.
|
||||||
|
parameters:
|
||||||
|
- name: query
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Query string
|
||||||
|
zh_Hans: 查询语句
|
||||||
|
pt_BR: Query string
|
||||||
|
human_description:
|
||||||
|
en_US: The text input used for initiating searches on the web, focusing on delivering relevant and accurate results without compromising user privacy.
|
||||||
|
zh_Hans: 用于在网上启动搜索的文本输入,专注于提供相关且准确的结果,同时不妨碍用户隐私。
|
||||||
|
pt_BR: A entrada de texto usada para iniciar pesquisas na web, focada em entregar resultados relevantes e precisos sem comprometer a privacidade do usuário.
|
||||||
|
llm_description: Keywords or phrases entered to perform searches, aimed at providing relevant and precise results while ensuring the privacy of the user is maintained.
|
||||||
|
form: llm
|
||||||
|
- name: count
|
||||||
|
type: number
|
||||||
|
required: false
|
||||||
|
default: 3
|
||||||
|
label:
|
||||||
|
en_US: Result count
|
||||||
|
zh_Hans: 结果数量
|
||||||
|
pt_BR: Contagem de resultados
|
||||||
|
human_description:
|
||||||
|
en_US: The number of search results to return, allowing users to control the breadth of their search output.
|
||||||
|
zh_Hans: 要返回的搜索结果数量,允许用户控制他们搜索输出的广度。
|
||||||
|
pt_BR: O número de resultados de pesquisa a serem retornados, permitindo que os usuários controlem a amplitude de sua saída de pesquisa.
|
||||||
|
llm_description: Specifies the amount of search results to be displayed, offering users the ability to adjust the scope of their search findings.
|
||||||
|
form: llm
|
1
api/core/tools/provider/builtin/trello/_assets/icon.svg
Normal file
1
api/core/tools/provider/builtin/trello/_assets/icon.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg width="2500" height="2500" viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid"><defs><linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="a"><stop stop-color="#0091E6" offset="0%"/><stop stop-color="#0079BF" offset="100%"/></linearGradient></defs><rect fill="url(#a)" width="256" height="256" rx="25"/><rect fill="#FFF" x="144.64" y="33.28" width="78.08" height="112" rx="12"/><rect fill="#FFF" x="33.28" y="33.28" width="78.08" height="176" rx="12"/></svg>
|
After Width: | Height: | Size: 501 B |
47
api/core/tools/provider/builtin/trello/tools/create_board.py
Normal file
47
api/core/tools/provider/builtin/trello/tools/create_board.py
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class CreateBoardTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for creating a new Trello board.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
|
||||||
|
"""
|
||||||
|
Invoke the tool to create a new Trello board.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get('trello_api_key')
|
||||||
|
token = self.runtime.credentials.get('trello_api_token')
|
||||||
|
board_name = tool_parameters.get('name')
|
||||||
|
|
||||||
|
if not (api_key and token and board_name):
|
||||||
|
return self.create_text_message("Missing required parameters: API key, token, or board name.")
|
||||||
|
|
||||||
|
url = "https://api.trello.com/1/boards/"
|
||||||
|
query_params = {
|
||||||
|
'name': board_name,
|
||||||
|
'key': api_key,
|
||||||
|
'token': token
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.post(url, params=query_params)
|
||||||
|
response.raise_for_status()
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to create board")
|
||||||
|
|
||||||
|
board = response.json()
|
||||||
|
return self.create_text_message(text=f"Board created successfully! Board name: {board['name']}, ID: {board['id']}")
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
identity:
|
||||||
|
name: create_board
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Create Board
|
||||||
|
zh_Hans: 创建看板
|
||||||
|
pt_BR: Criar Quadro
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Creates a new Trello board with a specified name. This tool allows users to quickly add new boards to their Trello account, facilitating project organization and management.
|
||||||
|
zh_Hans: 使用指定的名称创建一个新的 Trello 看板。此工具允许用户快速向其 Trello 账户添加新的看板,促进项目组织和管理。
|
||||||
|
pt_BR: Cria um novo quadro Trello com um nome especificado. Esta ferramenta permite que os usuários adicionem rapidamente novos quadros à sua conta Trello, facilitando a organização e gestão de projetos.
|
||||||
|
llm: Create a new Trello board using the specified name. This functionality simplifies the addition of boards, enhancing project organization and management within Trello.
|
||||||
|
parameters:
|
||||||
|
- name: name
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Board Name
|
||||||
|
zh_Hans: 看板名称
|
||||||
|
pt_BR: Nome do Quadro
|
||||||
|
human_description:
|
||||||
|
en_US: The name for the new Trello board. This name helps in identifying and organizing your projects on Trello.
|
||||||
|
zh_Hans: 新 Trello 看板的名称。这个名称有助于在 Trello 上识别和组织您的项目。
|
||||||
|
pt_BR: O nome para o novo quadro Trello. Este nome ajuda a identificar e organizar seus projetos no Trello.
|
||||||
|
llm_description: Specify the name for your new Trello board, aiding in project identification and organization within Trello.
|
||||||
|
form: llm
|
|
@ -0,0 +1,48 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class CreateListOnBoardTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for creating a list on a Trello board by its ID.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
|
||||||
|
"""
|
||||||
|
Invoke the tool to create a list on a Trello board by its ID.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation, including the board ID and list name.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get('trello_api_key')
|
||||||
|
token = self.runtime.credentials.get('trello_api_token')
|
||||||
|
board_id = tool_parameters.get('id')
|
||||||
|
list_name = tool_parameters.get('name')
|
||||||
|
|
||||||
|
if not (api_key and token and board_id and list_name):
|
||||||
|
return self.create_text_message("Missing required parameters: API key, token, board ID, or list name.")
|
||||||
|
|
||||||
|
url = f"https://api.trello.com/1/boards/{board_id}/lists"
|
||||||
|
params = {
|
||||||
|
'name': list_name,
|
||||||
|
'key': api_key,
|
||||||
|
'token': token
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.post(url, params=params)
|
||||||
|
response.raise_for_status()
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to create list")
|
||||||
|
|
||||||
|
new_list = response.json()
|
||||||
|
return self.create_text_message(text=f"List '{new_list['name']}' created successfully with Id {new_list['id']} on board {board_id}.")
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
identity:
|
||||||
|
name: create_list_on_board
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Create List on Board
|
||||||
|
zh_Hans: 在看板上创建列表
|
||||||
|
pt_BR: Criar Lista no Quadro
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Creates a new list on a specified Trello board by providing the board's ID and the desired name for the list. Streamlines the process of organizing board content.
|
||||||
|
zh_Hans: 通过提供看板的 ID 和列表的所需名称,在指定的 Trello 看板上创建一个新列表。简化了组织看板内容的过程。
|
||||||
|
pt_BR: Cria uma nova lista em um quadro Trello especificado, fornecendo o ID do quadro e o nome desejado para a lista. Facilita o processo de organização do conteúdo do quadro.
|
||||||
|
llm: Generate a new list within a Trello board by specifying the board's ID and a name for the list. Enhances board management by allowing quick additions of new lists.
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Board ID
|
||||||
|
zh_Hans: 看板 ID
|
||||||
|
pt_BR: ID do Quadro
|
||||||
|
human_description:
|
||||||
|
en_US: The unique identifier of the Trello board where the new list will be created.
|
||||||
|
zh_Hans: 新列表将被创建在其上的 Trello 看板的唯一标识符。
|
||||||
|
pt_BR: O identificador único do quadro Trello onde a nova lista será criada.
|
||||||
|
llm_description: Input the ID of the Trello board to pinpoint where the new list should be added, ensuring correct placement.
|
||||||
|
form: llm
|
||||||
|
- name: name
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: List Name
|
||||||
|
zh_Hans: 列表名称
|
||||||
|
pt_BR: Nome da Lista
|
||||||
|
human_description:
|
||||||
|
en_US: The name for the new list to be created on the Trello board.
|
||||||
|
zh_Hans: 将在 Trello 看板上创建的新列表的名称。
|
||||||
|
pt_BR: O nome para a nova lista que será criada no quadro Trello.
|
||||||
|
llm_description: Provide a name for the new list, defining its purpose or content focus, to facilitate board organization.
|
||||||
|
form: llm
|
|
@ -0,0 +1,43 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class CreateNewCardOnBoardTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for creating a new card on a Trello board.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool, None]]) -> ToolInvokeMessage:
|
||||||
|
"""
|
||||||
|
Invoke the tool to create a new card on a Trello board.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool, None]]): The parameters for the tool invocation, including details for the new card.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get('trello_api_key')
|
||||||
|
token = self.runtime.credentials.get('trello_api_token')
|
||||||
|
|
||||||
|
# Ensure required parameters are present
|
||||||
|
if 'name' not in tool_parameters or 'idList' not in tool_parameters:
|
||||||
|
return self.create_text_message("Missing required parameters: name or idList.")
|
||||||
|
|
||||||
|
url = "https://api.trello.com/1/cards"
|
||||||
|
params = {**tool_parameters, 'key': api_key, 'token': token}
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.post(url, params=params)
|
||||||
|
response.raise_for_status()
|
||||||
|
new_card = response.json()
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to create card")
|
||||||
|
|
||||||
|
return self.create_text_message(text=f"New card '{new_card['name']}' created successfully with ID {new_card['id']}.")
|
||||||
|
|
|
@ -0,0 +1,145 @@
|
||||||
|
identity:
|
||||||
|
name: create_new_card_on_board
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Create New Card on Board
|
||||||
|
zh_Hans: 在看板上创建新卡片
|
||||||
|
pt_BR: Criar Novo Cartão no Quadro
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Creates a new card on a Trello board with specified details like name, description, list ID, and other optional parameters. Facilitates task addition and project management within Trello.
|
||||||
|
zh_Hans: 用指定的详情(如名称、描述、列表 ID 和其他可选参数)在 Trello 看板上创建一个新卡片。便于在 Trello 中添加任务和管理项目。
|
||||||
|
pt_BR: Cria um novo cartão em um quadro Trello com detalhes especificados, como nome, descrição, ID da lista e outros parâmetros opcionais. Facilita a adição de tarefas e a gestão de projetos dentro do Trello.
|
||||||
|
llm: Initiate a new card on a Trello board by specifying essential details such as the card's name, description, and the list it belongs to, among other settings. Streamlines project task additions and organizational workflows.
|
||||||
|
parameters:
|
||||||
|
- name: name
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Card Name
|
||||||
|
zh_Hans: 卡片名称
|
||||||
|
pt_BR: Nome do Cartão
|
||||||
|
human_description:
|
||||||
|
en_US: The name for the new card. Acts as the primary identifier and summary of the card's purpose.
|
||||||
|
zh_Hans: 新卡片的名称。作为卡片目的的主要标识和总结。
|
||||||
|
pt_BR: O nome para o novo cartão. Funciona como o identificador principal e resumo do propósito do cartão.
|
||||||
|
llm_description: Provide a concise, descriptive name for the card, outlining its main focus or task.
|
||||||
|
form: llm
|
||||||
|
# Include additional parameters like desc, pos, due, idList, etc., following the same pattern.
|
||||||
|
- name: desc
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Card Description
|
||||||
|
zh_Hans: 卡片描述
|
||||||
|
pt_BR: Descrição do Cartão
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. A brief description of the card's purpose or contents.
|
||||||
|
zh_Hans: 可选。卡片目的或内容的简要描述。
|
||||||
|
pt_BR: Opcional. Uma breve descrição do propósito ou conteúdo do cartão.
|
||||||
|
llm_description: Add a brief description to the card to provide context or additional information about its purpose.
|
||||||
|
form: llm
|
||||||
|
- name: pos
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Position
|
||||||
|
zh_Hans: 位置
|
||||||
|
pt_BR: Posição
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The position of the card in the list. Can be 'top', 'bottom', or a positive number.
|
||||||
|
zh_Hans: 可选。卡片在列表中的位置。可以是“top”、“bottom” 或正数。
|
||||||
|
pt_BR: Opcional. A posição do cartão na lista. Pode ser 'top', 'bottom' ou um número positivo.
|
||||||
|
llm_description: Specify the position of the card within the list, either at the top, bottom, or a specific numerical index.
|
||||||
|
form: llm
|
||||||
|
- name: due
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Due Date
|
||||||
|
zh_Hans: 截止日期
|
||||||
|
pt_BR: Data de Vencimento
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The due date for the card in the format 'MM/DD/YYYY'.
|
||||||
|
zh_Hans: 可选。卡片的截止日期,格式为“MM/DD/YYYY”。
|
||||||
|
pt_BR: Opcional. A data de vencimento do cartão no formato 'MM/DD/YYYY'.
|
||||||
|
llm_description: Set a due date for the card to establish a deadline for completion or action.
|
||||||
|
form: llm
|
||||||
|
- name: start
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Start Date
|
||||||
|
zh_Hans: 开始日期
|
||||||
|
pt_BR: Data de Início
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The start date for the card in the format 'MM/DD/YYYY'.
|
||||||
|
zh_Hans: 可选。卡片的开始日期,格式为“MM/DD/YYYY”。
|
||||||
|
pt_BR: Opcional. A data de início do cartão no formato 'MM/DD/YYYY'.
|
||||||
|
llm_description: Specify a start date for the card to mark the beginning of a task or project phase.
|
||||||
|
form: llm
|
||||||
|
- name: dueComplete
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Due Complete
|
||||||
|
zh_Hans: 截止日期已完成
|
||||||
|
pt_BR: Vencimento Concluído
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. Set to true if the due date has been completed, or false if it is pending.
|
||||||
|
zh_Hans: 可选。如果截止日期已完成,则设置为 true;如果尚未完成,则设置为 false。
|
||||||
|
pt_BR: Opcional. Defina como true se a data de vencimento foi concluída, ou como false se estiver pendente.
|
||||||
|
llm_description: Indicate whether the due date for the card has been marked as complete or is still pending.
|
||||||
|
form: llm
|
||||||
|
- name: idList
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: List ID
|
||||||
|
zh_Hans: 列表 ID
|
||||||
|
pt_BR: ID da Lista
|
||||||
|
human_description:
|
||||||
|
en_US: The unique identifier of the list where the card will be added.
|
||||||
|
zh_Hans: 卡片将被添加到的列表的唯一标识符。
|
||||||
|
pt_BR: O identificador único da lista onde o cartão será adicionado.
|
||||||
|
llm_description: Input the ID of the list where the card should be placed, ensuring it is added to the correct list.
|
||||||
|
form: llm
|
||||||
|
- name: idMembers
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Member IDs
|
||||||
|
zh_Hans: 成员 ID
|
||||||
|
pt_BR: IDs de Membros
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The IDs of members to assign to the card.
|
||||||
|
zh_Hans: 可选。要分配给卡片的成员的 ID。
|
||||||
|
pt_BR: Opcional. Os IDs dos membros a serem atribuídos ao cartão.
|
||||||
|
llm_description: Specify the IDs of members to assign to the card, allowing for task delegation or collaboration.
|
||||||
|
form: llm
|
||||||
|
- name: idLabels
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Label IDs
|
||||||
|
zh_Hans: 标签 ID
|
||||||
|
pt_BR: IDs de Etiquetas
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The IDs of labels to assign to the card.
|
||||||
|
zh_Hans: 可选。要分配给卡片的标签的 ID。
|
||||||
|
pt_BR: Opcional. Os IDs das etiquetas a serem atribuídos ao cartão.
|
||||||
|
llm_description: Assign specific labels to the card by providing their IDs, aiding in visual categorization or prioritization.
|
||||||
|
form: llm
|
||||||
|
- name: urlSource
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Source URL
|
||||||
|
zh_Hans: 来源 URL
|
||||||
|
pt_BR: URL de Origem
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The URL to attach as the card's source.
|
||||||
|
zh_Hans: 可选。要附加为卡片来源的 URL。
|
||||||
|
pt_BR: Opcional. O URL a ser anexado como a fonte do cartão.
|
||||||
|
llm_description: Provide a URL to serve as the source reference for the card, linking to external resources or documents.
|
||||||
|
form: llm
|
41
api/core/tools/provider/builtin/trello/tools/delete_board.py
Normal file
41
api/core/tools/provider/builtin/trello/tools/delete_board.py
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class DeleteBoardTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for deleting a Trello board by ID.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
|
||||||
|
"""
|
||||||
|
Invoke the tool to delete a Trello board by its ID.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation, including the board ID.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get('trello_api_key')
|
||||||
|
token = self.runtime.credentials.get('trello_api_token')
|
||||||
|
board_id = tool_parameters.get('boardId')
|
||||||
|
|
||||||
|
if not (api_key and token and board_id):
|
||||||
|
return self.create_text_message("Missing required parameters: API key, token, or board ID.")
|
||||||
|
|
||||||
|
url = f"https://api.trello.com/1/boards/{board_id}?key={api_key}&token={token}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.delete(url)
|
||||||
|
response.raise_for_status()
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to delete board")
|
||||||
|
|
||||||
|
return self.create_text_message(text=f"Board with ID {board_id} deleted successfully.")
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
identity:
|
||||||
|
name: delete_board
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Delete Board
|
||||||
|
zh_Hans: 删除看板
|
||||||
|
pt_BR: Excluir Quadro
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Deletes a Trello board using its unique ID. This tool allows for the removal of boards that are no longer needed, ensuring a tidy workspace.
|
||||||
|
zh_Hans: 使用其唯一 ID 删除 Trello 看板。此工具允许删除不再需要的看板,确保工作区整洁。
|
||||||
|
pt_BR: Exclui um quadro Trello usando seu ID único. Esta ferramenta permite a remoção de quadros que não são mais necessários, garantindo um espaço de trabalho organizado.
|
||||||
|
llm: Remove a Trello board by specifying its ID. This functionality is helpful for cleaning up unnecessary boards from your Trello account.
|
||||||
|
parameters:
|
||||||
|
- name: boardId
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Board ID
|
||||||
|
zh_Hans: 看板 ID
|
||||||
|
pt_BR: ID do Quadro
|
||||||
|
human_description:
|
||||||
|
en_US: The unique identifier for the Trello board you wish to delete. This ensures the specific board is accurately targeted for deletion.
|
||||||
|
zh_Hans: 您希望删除的 Trello 看板的唯一标识符。这确保了准确地针对特定看板进行删除。
|
||||||
|
pt_BR: O identificador único para o quadro Trello que você deseja excluir. Isso garante que o quadro específico seja precisamente direcionado para exclusão.
|
||||||
|
llm_description: Enter the ID of the Trello board you want to remove. This ID is essential to identify the board precisely and perform the deletion.
|
||||||
|
form: llm
|
41
api/core/tools/provider/builtin/trello/tools/delete_card.py
Normal file
41
api/core/tools/provider/builtin/trello/tools/delete_card.py
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class DeleteCardByIdTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for deleting a Trello card by its ID.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
|
||||||
|
"""
|
||||||
|
Invoke the tool to delete a Trello card by its ID.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation, including the card ID.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get('trello_api_key')
|
||||||
|
token = self.runtime.credentials.get('trello_api_token')
|
||||||
|
card_id = tool_parameters.get('id')
|
||||||
|
|
||||||
|
if not (api_key and token and card_id):
|
||||||
|
return self.create_text_message("Missing required parameters: API key, token, or card ID.")
|
||||||
|
|
||||||
|
url = f"https://api.trello.com/1/cards/{card_id}?key={api_key}&token={token}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.delete(url)
|
||||||
|
response.raise_for_status()
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to delete card")
|
||||||
|
|
||||||
|
return self.create_text_message(text=f"Card with ID {card_id} has been successfully deleted.")
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
identity:
|
||||||
|
name: delete_card_by_id
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Delete Card by ID
|
||||||
|
zh_Hans: 通过 ID 删除卡片
|
||||||
|
pt_BR: Deletar Cartão por ID
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Deletes a Trello card using its unique ID. This tool facilitates the removal of cards that are no longer needed, maintaining an organized board.
|
||||||
|
zh_Hans: 使用其唯一 ID 删除 Trello 卡片。此工具便于删除不再需要的卡片,保持看板的有序。
|
||||||
|
pt_BR: Exclui um cartão Trello usando seu ID único. Esta ferramenta facilita a remoção de cartões que não são mais necessários, mantendo um quadro organizado.
|
||||||
|
llm: Remove a specific Trello card by providing its ID. Ideal for cleaning up and organizing your Trello boards by eliminating unwanted cards.
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Card ID
|
||||||
|
zh_Hans: 卡片 ID
|
||||||
|
pt_BR: ID do Cartão
|
||||||
|
human_description:
|
||||||
|
en_US: The unique identifier of the Trello card you wish to delete. This ensures the precise card is removed.
|
||||||
|
zh_Hans: 您希望删除的 Trello 卡片的唯一标识符。这确保了精确移除特定卡片。
|
||||||
|
pt_BR: O identificador único do cartão Trello que você deseja excluir. Isso garante que o cartão exato seja removido.
|
||||||
|
llm_description: Input the ID of the Trello card targeted for deletion to ensure accurate and specific removal.
|
||||||
|
form: llm
|
|
@ -0,0 +1,54 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class FetchAllBoardsTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for fetching all boards from Trello.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(
|
||||||
|
self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]
|
||||||
|
) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
||||||
|
"""
|
||||||
|
Invoke the fetch all boards tool.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Union[ToolInvokeMessage, List[ToolInvokeMessage]]: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get("trello_api_key")
|
||||||
|
token = self.runtime.credentials.get("trello_api_token")
|
||||||
|
|
||||||
|
if not (api_key and token):
|
||||||
|
return self.create_text_message(
|
||||||
|
"Missing Trello API key or token in credentials."
|
||||||
|
)
|
||||||
|
|
||||||
|
# Including board filter in the request if provided
|
||||||
|
board_filter = tool_parameters.get("boards", "open")
|
||||||
|
url = f"https://api.trello.com/1/members/me/boards?filter={board_filter}&key={api_key}&token={token}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.get(url)
|
||||||
|
response.raise_for_status() # Raises stored HTTPError, if one occurred.
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to fetch boards")
|
||||||
|
|
||||||
|
boards = response.json()
|
||||||
|
|
||||||
|
if not boards:
|
||||||
|
return self.create_text_message("No boards found in Trello.")
|
||||||
|
|
||||||
|
# Creating a string with both board names and IDs
|
||||||
|
boards_info = ", ".join(
|
||||||
|
[f"{board['name']} (ID: {board['id']})" for board in boards]
|
||||||
|
)
|
||||||
|
return self.create_text_message(text=f"Boards: {boards_info}")
|
|
@ -0,0 +1,28 @@
|
||||||
|
identity:
|
||||||
|
name: fetch_all_boards
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Fetch All Boards
|
||||||
|
zh_Hans: 获取所有看板
|
||||||
|
pt_BR: Buscar Todos os Quadros
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Retrieves all the Trello boards associated with the user's account. This tool provides a quick overview of all open boards, aiding in efficient project management and organization.
|
||||||
|
zh_Hans: 检索与用户账户关联的所有 Trello 看板。该工具提供了所有打开的看板的快速概览,有助于高效的项目管理和组织。
|
||||||
|
pt_BR: Recupera todos os quadros do Trello associados à conta do usuário. Esta ferramenta oferece uma visão geral rápida de todos os quadros abertos, auxiliando na gestão e organização eficiente do projeto.
|
||||||
|
llm: This tool fetches all Trello boards linked to the user's account, offering a swift snapshot of open boards to streamline project management and organization tasks.
|
||||||
|
parameters:
|
||||||
|
- name: boards
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
default: open
|
||||||
|
label:
|
||||||
|
en_US: Boards filter
|
||||||
|
zh_Hans: 看板过滤器
|
||||||
|
pt_BR: Filtro de quadros
|
||||||
|
human_description:
|
||||||
|
en_US: Specifies the type of boards to retrieve. Default is 'open', fetching all open boards. Other options include 'closed', 'members', 'organization', etc.
|
||||||
|
zh_Hans: 指定要检索的看板类型。默认为“open”,获取所有打开的看板。其他选项包括“closed”,“members”,“organization”等。
|
||||||
|
pt_BR: Especifica o tipo de quadros a serem recuperados. O padrão é 'open', buscando todos os quadros abertos. Outras opções incluem 'closed', 'members', 'organization', etc.
|
||||||
|
llm_description: Determines the category of boards to be displayed, with 'open' as the default setting to show all open boards. Variants like 'closed', 'members', and 'organization' are also selectable.
|
||||||
|
form: llm
|
|
@ -0,0 +1,43 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class GetBoardActionsTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for retrieving actions for a Trello board by its ID.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
|
||||||
|
"""
|
||||||
|
Invoke the tool to retrieve actions for a Trello board by its ID.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation, including the board ID.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get('trello_api_key')
|
||||||
|
token = self.runtime.credentials.get('trello_api_token')
|
||||||
|
board_id = tool_parameters.get('boardId')
|
||||||
|
|
||||||
|
if not (api_key and token and board_id):
|
||||||
|
return self.create_text_message("Missing required parameters: API key, token, or board ID.")
|
||||||
|
|
||||||
|
url = f"https://api.trello.com/1/boards/{board_id}/actions?key={api_key}&token={token}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.get(url)
|
||||||
|
response.raise_for_status()
|
||||||
|
actions = response.json()
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to retrieve board actions")
|
||||||
|
|
||||||
|
actions_summary = "\n".join([f"{action['type']}: {action.get('data', {}).get('text', 'No details available')}" for action in actions])
|
||||||
|
return self.create_text_message(text=f"Actions for Board ID {board_id}:\n{actions_summary}")
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
identity:
|
||||||
|
name: get_board_actions
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Get Board Actions
|
||||||
|
zh_Hans: 获取看板操作
|
||||||
|
pt_BR: Obter Ações do Quadro
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Retrieves a list of actions (such as updates, movements, and comments) for a Trello board by its ID. This tool provides insights into the board's activity history.
|
||||||
|
zh_Hans: 通过其 ID 为 Trello 看板检索操作列表(如更新、移动和评论)。此工具提供了看板活动历史的见解。
|
||||||
|
pt_BR: Recupera uma lista de ações (como atualizações, movimentos e comentários) para um quadro Trello pelo seu ID. Esta ferramenta oferece insights sobre o histórico de atividades do quadro.
|
||||||
|
llm: Fetch the sequence of actions performed on a Trello board, such as card updates, movements, and comments, by providing the board's ID. Offers a historical view of board activities.
|
||||||
|
parameters:
|
||||||
|
- name: boardId
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Board ID
|
||||||
|
zh_Hans: 看板 ID
|
||||||
|
pt_BR: ID do Quadro
|
||||||
|
human_description:
|
||||||
|
en_US: The unique identifier of the Trello board for which you want to retrieve actions. It targets the specific board to fetch its activity log.
|
||||||
|
zh_Hans: 您想要检索操作的 Trello 看板的唯一标识符。它定位特定的看板以获取其活动日志。
|
||||||
|
pt_BR: O identificador único do quadro Trello para o qual você deseja recuperar ações. Direciona especificamente para o quadro para buscar seu registro de atividades.
|
||||||
|
llm_description: Input the ID of the Trello board to access its detailed action history, including all updates, comments, and movements related to the board.
|
||||||
|
form: llm
|
|
@ -0,0 +1,66 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class GetBoardByIdTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for retrieving detailed information about a Trello board by its ID.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
|
||||||
|
"""
|
||||||
|
Invoke the tool to retrieve a Trello board by its ID.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation, including the board ID.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get('trello_api_key')
|
||||||
|
token = self.runtime.credentials.get('trello_api_token')
|
||||||
|
board_id = tool_parameters.get('boardId')
|
||||||
|
|
||||||
|
if not (api_key and token and board_id):
|
||||||
|
return self.create_text_message("Missing required parameters: API key, token, or board ID.")
|
||||||
|
|
||||||
|
url = f"https://api.trello.com/1/boards/{board_id}?key={api_key}&token={token}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.get(url)
|
||||||
|
response.raise_for_status()
|
||||||
|
board = response.json()
|
||||||
|
board_details = self.format_board_details(board)
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to retrieve board")
|
||||||
|
|
||||||
|
return self.create_text_message(text=board_details)
|
||||||
|
|
||||||
|
def format_board_details(self, board: dict) -> str:
|
||||||
|
"""
|
||||||
|
Format the board details into a human-readable string.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
board (dict): The board information as a dictionary.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: Formatted board details.
|
||||||
|
"""
|
||||||
|
details = (
|
||||||
|
f"Board Name: {board['name']}\n"
|
||||||
|
f"Board ID: {board['id']}\n"
|
||||||
|
f"Description: {board['desc'] or 'No description provided.'}\n"
|
||||||
|
f"Status: {'Closed' if board['closed'] else 'Open'}\n"
|
||||||
|
f"Organization ID: {board['idOrganization'] or 'Not part of an organization.'}\n"
|
||||||
|
f"URL: {board['url']}\n"
|
||||||
|
f"Short URL: {board['shortUrl']}\n"
|
||||||
|
f"Permission Level: {board['prefs']['permissionLevel']}\n"
|
||||||
|
f"Background Color: {board['prefs']['backgroundColor']}"
|
||||||
|
)
|
||||||
|
return details
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
identity:
|
||||||
|
name: get_board_by_id
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Get Board by ID
|
||||||
|
zh_Hans: 通过 ID 获取看板
|
||||||
|
pt_BR: Obter Quadro por ID
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Retrieves detailed information about a specific Trello board using its unique ID. This tool enables users to quickly access board details without navigating through the Trello interface.
|
||||||
|
zh_Hans: 使用其唯一 ID 检索有关特定 Trello 看板的详细信息。此工具使用户能够快速访问看板详情,无需通过 Trello 界面导航。
|
||||||
|
pt_BR: Recupera informações detalhadas sobre um quadro Trello específico usando seu ID único. Esta ferramenta permite que os usuários acessem rapidamente os detalhes do quadro sem navegar pela interface do Trello.
|
||||||
|
llm: Access details of a Trello board by providing its ID. This tool offers a direct way to view board information, simplifying the process of managing and reviewing Trello boards.
|
||||||
|
parameters:
|
||||||
|
- name: boardId
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Board ID
|
||||||
|
zh_Hans: 看板 ID
|
||||||
|
pt_BR: ID do Quadro
|
||||||
|
human_description:
|
||||||
|
en_US: The unique identifier for the Trello board you wish to retrieve. This ID enables precise targeting and fetching of the board's details.
|
||||||
|
zh_Hans: 您希望检索的 Trello 看板的唯一标识符。此 ID 使能够准确定位和获取看板的详细信息。
|
||||||
|
pt_BR: O identificador único do quadro Trello que você deseja recuperar. Este ID permite o direcionamento preciso e a obtenção dos detalhes do quadro.
|
||||||
|
llm_description: Input the ID of the Trello board to get its details. This unique ID ensures accurate retrieval of information about the specified board.
|
||||||
|
form: llm
|
|
@ -0,0 +1,43 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class GetBoardCardsTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for retrieving cards on a Trello board by its ID.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
|
||||||
|
"""
|
||||||
|
Invoke the tool to retrieve cards on a Trello board by its ID.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation, including the board ID.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get('trello_api_key')
|
||||||
|
token = self.runtime.credentials.get('trello_api_token')
|
||||||
|
board_id = tool_parameters.get('boardId')
|
||||||
|
|
||||||
|
if not (api_key and token and board_id):
|
||||||
|
return self.create_text_message("Missing required parameters: API key, token, or board ID.")
|
||||||
|
|
||||||
|
url = f"https://api.trello.com/1/boards/{board_id}/cards?key={api_key}&token={token}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.get(url)
|
||||||
|
response.raise_for_status()
|
||||||
|
cards = response.json()
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to retrieve board cards")
|
||||||
|
|
||||||
|
cards_summary = "\n".join([f"{card['name']} (ID: {card['id']})" for card in cards])
|
||||||
|
return self.create_text_message(text=f"Cards for Board ID {board_id}:\n{cards_summary}")
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
identity:
|
||||||
|
name: get_board_cards
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Get Board Cards
|
||||||
|
zh_Hans: 获取看板卡片
|
||||||
|
pt_BR: Obter Cartões do Quadro
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Retrieves all cards present on a specific Trello board by its ID, providing a list of card names and their IDs. Useful for managing and organizing project tasks.
|
||||||
|
zh_Hans: 通过其 ID 检索特定 Trello 看板上的所有卡片,提供卡片名称及其 ID 的列表。用于管理和组织项目任务。
|
||||||
|
pt_BR: Recupera todos os cartões presentes em um quadro Trello específico pelo seu ID, fornecendo uma lista dos nomes dos cartões e seus IDs. Útil para gerenciar e organizar tarefas de projetos.
|
||||||
|
llm: Obtain a list of all cards on a specific Trello board by entering the board's ID. This tool helps in quickly assessing the tasks or items associated with the board.
|
||||||
|
parameters:
|
||||||
|
- name: boardId
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Board ID
|
||||||
|
zh_Hans: 看板 ID
|
||||||
|
pt_BR: ID do Quadro
|
||||||
|
human_description:
|
||||||
|
en_US: The unique identifier of the Trello board from which you want to retrieve cards. It specifies the exact board to gather card details from.
|
||||||
|
zh_Hans: 您想要从中检索卡片的 Trello 看板的唯一标识符。它指定了要从中收集卡片详细信息的确切看板。
|
||||||
|
pt_BR: O identificador único do quadro Trello do qual você deseja recuperar os cartões. Especifica o quadro exato para obter detalhes dos cartões.
|
||||||
|
llm_description: Input the ID of the Trello board to fetch its cards, allowing for a detailed overview of the board's contents.
|
||||||
|
form: llm
|
|
@ -0,0 +1,44 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class GetFilteredBoardCardsTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for retrieving filtered cards on a Trello board by its ID and a specified filter.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
|
||||||
|
"""
|
||||||
|
Invoke the tool to retrieve filtered cards on a Trello board by its ID and filter.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation, including the board ID and filter.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get('trello_api_key')
|
||||||
|
token = self.runtime.credentials.get('trello_api_token')
|
||||||
|
board_id = tool_parameters.get('boardId')
|
||||||
|
filter = tool_parameters.get('filter')
|
||||||
|
|
||||||
|
if not (api_key and token and board_id and filter):
|
||||||
|
return self.create_text_message("Missing required parameters: API key, token, board ID, or filter.")
|
||||||
|
|
||||||
|
url = f"https://api.trello.com/1/boards/{board_id}/cards/{filter}?key={api_key}&token={token}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.get(url)
|
||||||
|
response.raise_for_status()
|
||||||
|
filtered_cards = response.json()
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to retrieve filtered cards")
|
||||||
|
|
||||||
|
card_details = "\n".join([f"{card['name']} (ID: {card['id']})" for card in filtered_cards])
|
||||||
|
return self.create_text_message(text=f"Filtered Cards for Board ID {board_id} with Filter '{filter}':\n{card_details}")
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
identity:
|
||||||
|
name: get_filtered_board_cards
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Get Filtered Board Cards
|
||||||
|
zh_Hans: 获取筛选的看板卡片
|
||||||
|
pt_BR: Obter Cartões Filtrados do Quadro
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Retrieves cards from a Trello board using a specified filter and the board's ID. Filters include options like 'all', 'open', 'closed', 'none', and 'visible', allowing for tailored views of board content.
|
||||||
|
zh_Hans: 使用指定的过滤器和看板的 ID 从 Trello 看板检索卡片。过滤器包括 'all', 'open', 'closed', 'none' 和 'visible' 等选项,允许对看板内容进行定制查看。
|
||||||
|
pt_BR: Recupera cartões de um quadro Trello usando um filtro especificado e o ID do quadro. Os filtros incluem opções como 'all', 'open', 'closed', 'none' e 'visible', permitindo visualizações personalizadas do conteúdo do quadro.
|
||||||
|
llm: Access cards on a Trello board through specific filters such as 'all', 'open', 'closed', 'none', and 'visible' by providing the board's ID. This feature enables focused examination of the board's cards.
|
||||||
|
parameters:
|
||||||
|
- name: boardId
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Board ID
|
||||||
|
zh_Hans: 看板 ID
|
||||||
|
pt_BR: ID do Quadro
|
||||||
|
human_description:
|
||||||
|
en_US: The unique identifier for the Trello board from which to retrieve the filtered cards.
|
||||||
|
zh_Hans: 用于检索筛选卡片的 Trello 看板的唯一标识符。
|
||||||
|
pt_BR: O identificador único do quadro Trello do qual os cartões filtrados serão recuperados.
|
||||||
|
llm_description: Enter the Trello board's ID to specify from which board to fetch the cards using the filter.
|
||||||
|
form: llm
|
||||||
|
- name: filter
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Filter
|
||||||
|
zh_Hans: 过滤器
|
||||||
|
pt_BR: Filtro
|
||||||
|
human_description:
|
||||||
|
en_US: The filter to apply when retrieving cards. Valid values are 'all', 'open', 'closed', 'none', and 'visible'.
|
||||||
|
zh_Hans: 检索卡片时应用的过滤器。有效值为 'all', 'open', 'closed', 'none', 和 'visible'。
|
||||||
|
pt_BR: O filtro a ser aplicado ao recuperar cartões. Os valores válidos são 'all', 'open', 'closed', 'none' e 'visible'.
|
||||||
|
llm_description: Specify the filter for card retrieval. Choose from 'all', 'open', 'closed', 'none', or 'visible' to control which cards are fetched.
|
||||||
|
form: llm
|
|
@ -0,0 +1,43 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class GetListsFromBoardTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for retrieving all lists from a specified Trello board by its ID.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool]]) -> ToolInvokeMessage:
|
||||||
|
"""
|
||||||
|
Invoke the tool to get all lists from a specified Trello board.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool]]): The parameters for the tool invocation, including the board ID.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get('trello_api_key')
|
||||||
|
token = self.runtime.credentials.get('trello_api_token')
|
||||||
|
board_id = tool_parameters.get('boardId')
|
||||||
|
|
||||||
|
if not (api_key and token and board_id):
|
||||||
|
return self.create_text_message("Missing required parameters: API key, token, or board ID.")
|
||||||
|
|
||||||
|
url = f"https://api.trello.com/1/boards/{board_id}/lists?key={api_key}&token={token}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.get(url)
|
||||||
|
response.raise_for_status()
|
||||||
|
lists = response.json()
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to retrieve lists")
|
||||||
|
|
||||||
|
lists_info = "\n".join([f"{list['name']} (ID: {list['id']})" for list in lists])
|
||||||
|
return self.create_text_message(text=f"Lists on Board ID {board_id}:\n{lists_info}")
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
identity:
|
||||||
|
name: get_lists_from_board
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Get Lists from Board
|
||||||
|
zh_Hans: 获取看板的列表
|
||||||
|
pt_BR: Obter Listas do Quadro
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Retrieves all lists from a specified Trello board by its ID, providing an overview of the board's organization and current phases or categories.
|
||||||
|
zh_Hans: 通过其 ID 从指定的 Trello 看板检索所有列表,提供看板组织和当前阶段或类别的概览。
|
||||||
|
pt_BR: Recupera todas as listas de um quadro Trello especificado pelo seu ID, fornecendo uma visão geral da organização do quadro e das fases ou categorias atuais.
|
||||||
|
llm: Fetch and display all lists from a specific Trello board by inputting the board's ID. This aids in understanding the board's structure and task categorization.
|
||||||
|
parameters:
|
||||||
|
- name: boardId
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Board ID
|
||||||
|
zh_Hans: 看板 ID
|
||||||
|
pt_BR: ID do Quadro
|
||||||
|
human_description:
|
||||||
|
en_US: The unique identifier of the Trello board from which to retrieve the lists.
|
||||||
|
zh_Hans: 用于检索列表的 Trello 看板的唯一标识符。
|
||||||
|
pt_BR: O identificador único do quadro Trello do qual as listas serão recuperadas.
|
||||||
|
llm_description: Enter the ID of the Trello board to obtain a detailed list of all its lists, providing insight into the board's structure.
|
||||||
|
form: llm
|
47
api/core/tools/provider/builtin/trello/tools/update_board.py
Normal file
47
api/core/tools/provider/builtin/trello/tools/update_board.py
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateBoardByIdTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for updating a Trello board by its ID with various parameters.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool, None]]) -> ToolInvokeMessage:
|
||||||
|
"""
|
||||||
|
Invoke the tool to update a Trello board by its ID.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool, None]]): The parameters for the tool invocation, including board ID and updates.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get('trello_api_key')
|
||||||
|
token = self.runtime.credentials.get('trello_api_token')
|
||||||
|
board_id = tool_parameters.pop('boardId', None)
|
||||||
|
|
||||||
|
if not (api_key and token and board_id):
|
||||||
|
return self.create_text_message("Missing required parameters: API key, token, or board ID.")
|
||||||
|
|
||||||
|
url = f"https://api.trello.com/1/boards/{board_id}"
|
||||||
|
|
||||||
|
# Removing parameters not intended for update action or with None value
|
||||||
|
params = {k: v for k, v in tool_parameters.items() if v is not None}
|
||||||
|
params['key'] = api_key
|
||||||
|
params['token'] = token
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.put(url, params=params)
|
||||||
|
response.raise_for_status()
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to update board")
|
||||||
|
|
||||||
|
updated_board = response.json()
|
||||||
|
return self.create_text_message(text=f"Board '{updated_board['name']}' updated successfully.")
|
||||||
|
|
157
api/core/tools/provider/builtin/trello/tools/update_board.yaml
Normal file
157
api/core/tools/provider/builtin/trello/tools/update_board.yaml
Normal file
|
@ -0,0 +1,157 @@
|
||||||
|
identity:
|
||||||
|
name: update_board_by_id
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Update Board by ID
|
||||||
|
zh_Hans: 通过 ID 更新看板
|
||||||
|
pt_BR: Atualizar Quadro por ID
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Updates a Trello board's settings based on the provided ID and parameters. Allows for changing the board's name, description, status, and other preferences.
|
||||||
|
zh_Hans: 根据提供的 ID 和参数更新 Trello 看板的设置。允许更改看板的名称、描述、状态和其他偏好设置。
|
||||||
|
pt_BR: Atualiza as configurações de um quadro Trello com base no ID fornecido e nos parâmetros. Permite alterar o nome, descrição, status e outras preferências do quadro.
|
||||||
|
llm: Modify a Trello board's attributes like its name, description, and visibility settings using the board's ID. This tool streamlines board customization and management.
|
||||||
|
parameters:
|
||||||
|
- name: boardId
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Board ID
|
||||||
|
zh_Hans: 看板 ID
|
||||||
|
pt_BR: ID do Quadro
|
||||||
|
human_description:
|
||||||
|
en_US: The unique identifier of the Trello board you want to update. Ensures targeted and precise updates.
|
||||||
|
zh_Hans: 您要更新的 Trello 看板的唯一标识符。确保目标准确和更新精确。
|
||||||
|
pt_BR: O identificador único do quadro Trello que você deseja atualizar. Garante atualizações direcionadas e precisas.
|
||||||
|
llm_description: Provide the specific ID of the Trello board you aim to update to ensure accuracy in modification process.
|
||||||
|
form: llm
|
||||||
|
- name: name
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Board Name
|
||||||
|
zh_Hans: 看板名称
|
||||||
|
pt_BR: Nome do Quadro
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The new name for the board.
|
||||||
|
zh_Hans: 可选。看板的新名称。
|
||||||
|
pt_BR: Opcional. O novo nome para o quadro.
|
||||||
|
llm_description: Enter a new name for the board if you wish to change it; this name identifies the board in Trello.
|
||||||
|
form: llm
|
||||||
|
- name: desc
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Board Description
|
||||||
|
zh_Hans: 看板描述
|
||||||
|
pt_BR: Descrição do Quadro
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The new description for the board.
|
||||||
|
zh_Hans: 可选。看板的新描述。
|
||||||
|
pt_BR: Opcional. A nova descrição para o quadro.
|
||||||
|
llm_description: Provide a new description for the board if you wish to update it; this description provides additional context about the board.
|
||||||
|
form: llm
|
||||||
|
- name: closed
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Closed
|
||||||
|
zh_Hans: 已关闭
|
||||||
|
pt_BR: Fechado
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. Set to true to close the board, or false to keep it open.
|
||||||
|
zh_Hans: 可选。设置为 true 以关闭看板,或设置为 false 以保持打开。
|
||||||
|
pt_BR: Opcional. Defina como true para fechar o quadro ou como false para mantê-lo aberto.
|
||||||
|
llm_description: Specify whether the board should be closed or kept open by setting this parameter to true or false.
|
||||||
|
form: llm
|
||||||
|
- name: subscribed
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Subscribed
|
||||||
|
zh_Hans: 订阅
|
||||||
|
pt_BR: Inscrito
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. Set to true to subscribe to the board, or false to unsubscribe.
|
||||||
|
zh_Hans: 可选。设置为 true 以订阅看板,或设置为 false 以取消订阅。
|
||||||
|
pt_BR: Opcional. Defina como true para se inscrever no quadro ou como false para cancelar a inscrição.
|
||||||
|
llm_description: Choose to subscribe or unsubscribe from the board by setting this parameter to true or false.
|
||||||
|
form: llm
|
||||||
|
- name: idOrganization
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Organization ID
|
||||||
|
zh_Hans: 组织 ID
|
||||||
|
pt_BR: ID da Organização
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The ID of the organization to which the board belongs.
|
||||||
|
zh_Hans: 可选。看板所属组织的 ID。
|
||||||
|
pt_BR: Opcional. O ID da organização à qual o quadro pertence.
|
||||||
|
llm_description: Input the ID of the organization to which the board is associated, if applicable.
|
||||||
|
form: llm
|
||||||
|
- name: prefs_permissionLevel
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Permission Level
|
||||||
|
zh_Hans: 权限级别
|
||||||
|
pt_BR: Nível de Permissão
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The permission level for the board. Valid values are 'private', 'org', or 'public'.
|
||||||
|
zh_Hans: 可选。看板的权限级别。有效值为 'private'、'org' 或 'public'。
|
||||||
|
pt_BR: Opcional. O nível de permissão para o quadro. Os valores válidos são 'private', 'org' ou 'public'.
|
||||||
|
llm_description: Specify the permission level for the board by choosing from 'private', 'org', or 'public'.
|
||||||
|
form: llm
|
||||||
|
- name: prefs_selfJoin
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Allow Self-Join
|
||||||
|
zh_Hans: 允许自行加入
|
||||||
|
pt_BR: Permitir Auto-Inscrição
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. Set to true to allow members to join the board without an invitation, or false to require an invitation.
|
||||||
|
zh_Hans: 可选。设置为 true 以允许成员加入看板而无需邀请,或设置为 false 以要求邀请。
|
||||||
|
pt_BR: Opcional. Defina como true para permitir que os membros se inscrevam no quadro sem um convite, ou como false para exigir um convite.
|
||||||
|
llm_description: Choose whether to allow members to join the board without an invitation by setting this parameter to true or false.
|
||||||
|
form: llm
|
||||||
|
- name: prefs_cardCovers
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Card Covers
|
||||||
|
zh_Hans: 卡片封面
|
||||||
|
pt_BR: Capas de Cartão
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. Set to true to enable card covers, or false to disable them.
|
||||||
|
zh_Hans: 可选。设置为 true 以启用卡片封面,或设置为 false 以禁用卡片封面。
|
||||||
|
pt_BR: Opcional. Defina como true para habilitar capas de cartão ou como false para desabilitá-las.
|
||||||
|
llm_description: Enable or disable card covers by setting this parameter to true or false.
|
||||||
|
form: llm
|
||||||
|
- name: prefs_hideVotes
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Hide Votes
|
||||||
|
zh_Hans: 隐藏投票
|
||||||
|
pt_BR: Ocultar Votos
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. Set to true to hide votes, or false to show them.
|
||||||
|
zh_Hans: 可选。设置为 true 以隐藏投票,或设置为 false 以显示投票。
|
||||||
|
pt_BR: Opcional. Defina como true para ocultar votos ou como false para mostrá-los.
|
||||||
|
llm_description: Choose to hide or show votes by setting this parameter to true or false.
|
||||||
|
form: llm
|
||||||
|
- name: prefs_invitations
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Invitations
|
||||||
|
zh_Hans: 邀请
|
||||||
|
pt_BR: Convites
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. Set to 'members' to allow only board members to send invitations, or 'admins' to allow admins to send invitations.
|
||||||
|
zh_Hans: 可选。设置为 'members' 以仅允许看板成员发送邀请,或设置为 'admins' 以允许管理员发送邀请。
|
||||||
|
pt_BR: Opcional. Defina como 'members' para permitir que apenas membros do quadro enviem convites, ou 'admins' para permitir que os administradores enviem convites.
|
||||||
|
llm_description: Choose who can send invitations by setting this parameter to 'members' or 'admins'.
|
||||||
|
form: llm
|
44
api/core/tools/provider/builtin/trello/tools/update_card.py
Normal file
44
api/core/tools/provider/builtin/trello/tools/update_card.py
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateCardByIdTool(BuiltinTool):
|
||||||
|
"""
|
||||||
|
Tool for updating a Trello card by its ID.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _invoke(self, user_id: str, tool_parameters: dict[str, Union[str, int, bool, None]]) -> ToolInvokeMessage:
|
||||||
|
"""
|
||||||
|
Invoke the tool to update a Trello card by its ID.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (str): The ID of the user invoking the tool.
|
||||||
|
tool_parameters (dict[str, Union[str, int, bool, None]]): The parameters for the tool invocation, including the card ID and updates.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ToolInvokeMessage: The result of the tool invocation.
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get('trello_api_key')
|
||||||
|
token = self.runtime.credentials.get('trello_api_token')
|
||||||
|
card_id = tool_parameters.get('id')
|
||||||
|
|
||||||
|
if not (api_key and token and card_id):
|
||||||
|
return self.create_text_message("Missing required parameters: API key, token, or card ID.")
|
||||||
|
|
||||||
|
# Constructing the URL and the payload for the PUT request
|
||||||
|
url = f"https://api.trello.com/1/cards/{card_id}"
|
||||||
|
params = {k: v for k, v in tool_parameters.items() if v is not None and k != 'id'}
|
||||||
|
params.update({'key': api_key, 'token': token})
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.put(url, params=params)
|
||||||
|
response.raise_for_status()
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return self.create_text_message("Failed to update card")
|
||||||
|
|
||||||
|
updated_card_info = f"Card '{card_id}' updated successfully."
|
||||||
|
return self.create_text_message(text=updated_card_info)
|
|
@ -0,0 +1,81 @@
|
||||||
|
identity:
|
||||||
|
name: update_card_by_id
|
||||||
|
author: Yash Parmar
|
||||||
|
label:
|
||||||
|
en_US: Update Card by ID
|
||||||
|
zh_Hans: 通过 ID 更新卡片
|
||||||
|
pt_BR: Atualizar Cartão por ID
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: Updates specified attributes of a Trello card, such as its name, description, list ID, and board ID, by providing the card's unique ID.
|
||||||
|
zh_Hans: 通过提供卡片的唯一 ID,更新 Trello 卡片的特定属性,如其名称、描述、列表 ID 和看板 ID。
|
||||||
|
pt_BR: Atualiza atributos específicos de um cartão Trello, como seu nome, descrição, ID da lista e ID do quadro, fornecendo o ID único do cartão.
|
||||||
|
llm: Modify a Trello card's key details, including name, description, and its placement on the board, by using the card's ID. Enables precise and targeted updates to card information.
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Card ID
|
||||||
|
zh_Hans: 卡片 ID
|
||||||
|
pt_BR: ID do Cartão
|
||||||
|
human_description:
|
||||||
|
en_US: The unique identifier of the Trello card you intend to update.
|
||||||
|
zh_Hans: 您打算更新的 Trello 卡片的唯一标识符。
|
||||||
|
pt_BR: O identificador único do cartão Trello que você pretende atualizar.
|
||||||
|
llm_description: Input the ID of the Trello card to be updated to ensure the correct card is targeted.
|
||||||
|
form: llm
|
||||||
|
# Include other parameters following the same pattern
|
||||||
|
- name: name
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: New Name
|
||||||
|
zh_Hans: 新名称
|
||||||
|
pt_BR: Novo Nome
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The new name to assign to the card.
|
||||||
|
zh_Hans: 可选。要分配给卡片的新名称。
|
||||||
|
pt_BR: Opcional. O novo nome a ser atribuído ao cartão.
|
||||||
|
llm_description: Specify a new name for the card if changing it. This name is what will be displayed on the Trello board.
|
||||||
|
form: llm
|
||||||
|
# Add definitions for desc, idList and idBoard parameters
|
||||||
|
- name: desc
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: New Description
|
||||||
|
zh_Hans: 新描述
|
||||||
|
pt_BR: Nova Descrição
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The new description to assign to the card.
|
||||||
|
zh_Hans: 可选。要分配给卡片的新描述。
|
||||||
|
pt_BR: Opcional. A nova descrição a ser atribuída ao cartão.
|
||||||
|
llm_description: Provide a new description for the card if you wish to update it; this description provides additional context about the card.
|
||||||
|
form: llm
|
||||||
|
- name: idList
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: List ID
|
||||||
|
zh_Hans: 列表 ID
|
||||||
|
pt_BR: ID da Lista
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The ID of the list to which the card should be moved.
|
||||||
|
zh_Hans: 可选。卡片应移动到的列表的 ID。
|
||||||
|
pt_BR: Opcional. O ID da lista para a qual o cartão deve ser movido.
|
||||||
|
llm_description: Enter the ID of the list where you want to move the card. This action relocates the card to the specified list.
|
||||||
|
form: llm
|
||||||
|
- name: idBoard
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
label:
|
||||||
|
en_US: Board ID
|
||||||
|
zh_Hans: 看板 ID
|
||||||
|
pt_BR: ID do Quadro
|
||||||
|
human_description:
|
||||||
|
en_US: Optional. The ID of the board to which the card should be moved.
|
||||||
|
zh_Hans: 可选。卡片应移动到的看板的 ID。
|
||||||
|
pt_BR: Opcional. O ID do quadro para o qual o cartão deve ser movido.
|
||||||
|
llm_description: Provide the ID of the board where you want to move the card. This action relocates the card to the specified board.
|
||||||
|
form: llm
|
34
api/core/tools/provider/builtin/trello/trello.py
Normal file
34
api/core/tools/provider/builtin/trello/trello.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from core.tools.errors import ToolProviderCredentialValidationError
|
||||||
|
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
||||||
|
|
||||||
|
|
||||||
|
class TrelloProvider(BuiltinToolProviderController):
|
||||||
|
def _validate_credentials(self, credentials: dict[str, Any]) -> None:
|
||||||
|
"""Validate Trello API credentials by making a test API call.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
credentials (dict[str, Any]): The Trello API credentials to validate.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ToolProviderCredentialValidationError: If the credentials are invalid.
|
||||||
|
"""
|
||||||
|
api_key = credentials.get("trello_api_key")
|
||||||
|
token = credentials.get("trello_api_token")
|
||||||
|
url = f"https://api.trello.com/1/members/me?key={api_key}&token={token}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.get(url)
|
||||||
|
response.raise_for_status() # Raises an HTTPError for bad responses
|
||||||
|
except requests.exceptions.HTTPError as e:
|
||||||
|
if response.status_code == 401:
|
||||||
|
# Unauthorized, indicating invalid credentials
|
||||||
|
raise ToolProviderCredentialValidationError("Invalid Trello credentials: Unauthorized.")
|
||||||
|
# Handle other potential HTTP errors
|
||||||
|
raise ToolProviderCredentialValidationError("Error validating Trello credentials")
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
# Handle other exceptions, such as connection errors
|
||||||
|
raise ToolProviderCredentialValidationError("Error validating Trello credentials")
|
45
api/core/tools/provider/builtin/trello/trello.yaml
Normal file
45
api/core/tools/provider/builtin/trello/trello.yaml
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
identity:
|
||||||
|
author: Yash Parmar
|
||||||
|
name: trello
|
||||||
|
label:
|
||||||
|
en_US: Trello
|
||||||
|
zh_Hans: Trello
|
||||||
|
pt_BR: Trello
|
||||||
|
description:
|
||||||
|
en_US: "Trello: A visual tool for organizing your work and life."
|
||||||
|
zh_Hans: "Trello: 一个用于组织工作和生活的视觉工具。"
|
||||||
|
pt_BR: "Trello: Uma ferramenta visual para organizar seu trabalho e vida."
|
||||||
|
icon: icon.svg
|
||||||
|
credentials_for_provider:
|
||||||
|
trello_api_key:
|
||||||
|
type: secret-input
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Trello API key
|
||||||
|
zh_Hans: Trello API key
|
||||||
|
pt_BR: Trello API key
|
||||||
|
placeholder:
|
||||||
|
en_US: Enter your Trello API key
|
||||||
|
zh_Hans: 输入您的 Trello API key
|
||||||
|
pt_BR: Insira sua chave API do Trello
|
||||||
|
help:
|
||||||
|
en_US: Obtain your API key from Trello's website.
|
||||||
|
zh_Hans: 从 Trello 网站获取您的 API key。
|
||||||
|
pt_BR: Obtenha sua chave API no site do Trello.
|
||||||
|
url: https://developer.atlassian.com/cloud/trello/guides/rest-api/api-introduction/
|
||||||
|
trello_api_token:
|
||||||
|
type: secret-input
|
||||||
|
required: true
|
||||||
|
label:
|
||||||
|
en_US: Trello API token
|
||||||
|
zh_Hans: Trello API token
|
||||||
|
pt_BR: Trello API token
|
||||||
|
placeholder:
|
||||||
|
en_US: Enter your Trello API token
|
||||||
|
zh_Hans: 输入您的 Trello API token
|
||||||
|
pt_BR: Insira seu token API do Trello
|
||||||
|
help:
|
||||||
|
en_US: Secure your API token from Trello's website.
|
||||||
|
zh_Hans: 从 Trello 网站获取您的 API token。
|
||||||
|
pt_BR: Garanta seu token API no site do Trello.
|
||||||
|
url: https://developer.atlassian.com/cloud/trello/guides/rest-api/api-introduction/
|
Loading…
Reference in New Issue
Block a user