Skip to content

Hubspot

HubspotReader #

Bases: BaseReader

Hubspot阅读器。从Hubspot账户中读取数据。

Parameters:

Name Type Description Default
access_token(str)

Hubspot API密钥。

required
Source code in llama_index/readers/hubspot/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
class HubspotReader(BaseReader):
    """Hubspot阅读器。从Hubspot账户中读取数据。

    Args:
        access_token(str): Hubspot API密钥。"""

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

    def load_data(self) -> List[Document]:
        """从Hubspot加载交易、联系人和公司数据。

返回:
    List[Document]:文档列表,其中每个文档代表一个Hubspot对象列表。
"""
        from hubspot import HubSpot

        api_client = HubSpot(access_token=self.access_token)
        all_deals = api_client.crm.deals.get_all()
        all_contacts = api_client.crm.contacts.get_all()
        all_companies = api_client.crm.companies.get_all()
        return [
            Document(
                text=f"{all_deals}".replace("\n", ""), extra_info={"type": "deals"}
            ),
            Document(
                text=f"{all_contacts}".replace("\n", ""),
                extra_info={"type": "contacts"},
            ),
            Document(
                text=f"{all_companies}".replace("\n", ""),
                extra_info={"type": "companies"},
            ),
        ]

load_data #

load_data() -> List[Document]

从Hubspot加载交易、联系人和公司数据。

返回: List[Document]:文档列表,其中每个文档代表一个Hubspot对象列表。

Source code in llama_index/readers/hubspot/base.py
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
    def load_data(self) -> List[Document]:
        """从Hubspot加载交易、联系人和公司数据。

返回:
    List[Document]:文档列表,其中每个文档代表一个Hubspot对象列表。
"""
        from hubspot import HubSpot

        api_client = HubSpot(access_token=self.access_token)
        all_deals = api_client.crm.deals.get_all()
        all_contacts = api_client.crm.contacts.get_all()
        all_companies = api_client.crm.companies.get_all()
        return [
            Document(
                text=f"{all_deals}".replace("\n", ""), extra_info={"type": "deals"}
            ),
            Document(
                text=f"{all_contacts}".replace("\n", ""),
                extra_info={"type": "contacts"},
            ),
            Document(
                text=f"{all_companies}".replace("\n", ""),
                extra_info={"type": "companies"},
            ),
        ]