基类:EventBaseReader
Trello 阅读器。从 Trello 看板和卡片中读取数据。
参数:
| 名称 |
类型 |
描述 |
默认 |
api_key
|
str
|
|
required
|
api_token
|
str
|
|
required
|
workflows/handler.py 中的源代码llama_index/readers/trello/base.py
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
50
51
52
53
54
55
56 | class TrelloReader(BaseReader):
"""
Trello reader. Reads data from Trello boards and cards.
Args:
api_key (str): Trello API key.
api_token (str): Trello API token.
"""
def __init__(self, api_key: str, api_token: str) -> None:
"""Initialize Trello reader."""
self.api_key = api_key
self.api_token = api_token
def load_data(self, board_id: str) -> List[Document]:
"""
Load data from a Trello board.
Args:
board_id (str): Trello board ID.
Returns:
List[Document]: List of documents representing Trello cards.
"""
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[文档]
从 Trello 看板加载数据。
参数:
| 名称 |
类型 |
描述 |
默认 |
board_id
|
str
|
|
required
|
返回:
| 类型 |
描述 |
List[文档]
|
List[Document]: 表示Trello卡片的文档列表。
|
workflows/handler.py 中的源代码llama_index/readers/trello/base.py
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
50
51
52
53
54
55
56 | def load_data(self, board_id: str) -> List[Document]:
"""
Load data from a Trello board.
Args:
board_id (str): Trello board ID.
Returns:
List[Document]: List of documents representing Trello cards.
"""
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
|