get_plain_text_from_rich_text

def get_plain_text_from_rich_text(rich_text: List[dict]):

Extracts plain text from a list of rich text elements.

Parameters:

  • rich_text: A list of dictionaries representing rich text elements. Each dictionary should contain a key named “plain_text” with the plain text content.

Returns:

str: A string containing the combined plain text from all elements, joined together.

get_media_source_text

def get_media_source_text(block: dict):

Extracts the source URL and optional caption from a Notion media block.

Parameters:

  • block: A dictionary representing a Notion media block.

Returns:

A string containing the source URL and caption (if available), separated by a colon.

NotionToolkit

class NotionToolkit(BaseToolkit):

A toolkit for retrieving information from the user’s notion pages.

Attributes: notion_token (Optional[str], optional): The notion_token used to interact with notion APIs. (default: :obj:None) notion_client (module): The notion module for interacting with the notion APIs.

init

def __init__(
    self,
    notion_token: Optional[str] = None,
    timeout: Optional[float] = None
):

Initializes the NotionToolkit.

Parameters:

  • notion_token (Optional[str], optional): The optional notion_token used to interact with notion APIs.(default: :obj:None)

list_all_users

def list_all_users(self):

Returns:

List[dict]: A list of user objects with type, name, and workspace.

list_all_pages

def list_all_pages(self):

Returns:

List[dict]: A list of page objects with title and id.

get_notion_block_text_content

def get_notion_block_text_content(self, block_id: str):

Retrieves the text content of a Notion block.

Parameters:

  • block_id (str): The ID of the Notion block to retrieve.

Returns:

str: The text content of a Notion block, containing all the sub blocks.

get_text_from_block

def get_text_from_block(self, block: dict):

Extracts plain text from a Notion block based on its type.

Parameters:

  • block (dict): A dictionary representing a Notion block.

Returns:

str: A string containing the extracted plain text and block type.

get_tools

def get_tools(self):

Returns:

List[FunctionTool]: A list of FunctionTool objects representing the functions in the toolkit.