Skip to content

Trello

TrelloReader #

Bases: BaseReader

Trello阅读器。从Trello板和卡中读取数据。

Parameters:

Name Type Description Default
api_key str

Trello API密钥。

required
api_token str

Trello API令牌。

required
Source code in llama_index/readers/trello/base.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class TrelloReader(BaseReader):
    """Trello阅读器。从Trello板和卡中读取数据。

    Args:
        api_key (str): Trello API密钥。
        api_token (str): Trello API令牌。"""

    def __init__(self, api_key: str, api_token: str) -> None:
        """初始化Trello阅读器。"""
        self.api_key = api_key
        self.api_token = api_token

    def load_data(self, board_id: str) -> List[Document]:
        """从Trello板加载数据。

Args:
    board_id(str):Trello板ID。

Returns:
    List[Document]:表示Trello卡片的文档列表。
"""
        from trello import TrelloClient

        client = TrelloClient(api_key=self.api_key, token=self.api_token)
        board = client.get_board(board_id)
        cards = board.get_cards()

        documents = []
        for card in cards:
            document = Document(
                doc_id=card.name,
                text=card.description,
                extra_info={
                    "id": card.id,
                    "url": card.url,
                    "due_date": card.due_date,
                    "labels": [label.name for label in card.labels],
                },
            )
            documents.append(document)

        return documents

load_data #

load_data(board_id: str) -> List[Document]

从Trello板加载数据。

Returns:

Type Description
List[Document]

List[Document]:表示Trello卡片的文档列表。

Source code in llama_index/readers/trello/base.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
    def load_data(self, board_id: str) -> List[Document]:
        """从Trello板加载数据。

Args:
    board_id(str):Trello板ID。

Returns:
    List[Document]:表示Trello卡片的文档列表。
"""
        from trello import TrelloClient

        client = TrelloClient(api_key=self.api_key, token=self.api_token)
        board = client.get_board(board_id)
        cards = board.get_cards()

        documents = []
        for card in cards:
            document = Document(
                doc_id=card.name,
                text=card.description,
                extra_info={
                    "id": card.id,
                    "url": card.url,
                    "due_date": card.due_date,
                    "labels": [label.name for label in card.labels],
                },
            )
            documents.append(document)

        return documents