Update Notion Toolkit (#309)

1. The Arcade Worker doesn't like it when the package name is different
than the directory name. This PR renames the directory from
`arcade_notion` to `arcade_notion_toolkit`
2. `Notion` is not a well-known provider name in `arcade-ai==1.0.5`,
I've updated the dep to represent this.
This commit is contained in:
Eric Gustin 2025-03-17 20:15:00 -08:00 committed by GitHub
parent b3d254fe56
commit 7edaa0a996
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 54 additions and 201 deletions

View file

@ -1,11 +0,0 @@
from arcade_notion.tools.pages import create_page, get_page_content_by_id, get_page_content_by_title
from arcade_notion.tools.search import get_object_metadata, get_workspace_structure, search_by_title
__all__ = [
"create_page",
"get_object_metadata",
"get_page_content_by_id",
"get_page_content_by_title",
"search_by_title",
"get_workspace_structure",
]

View file

@ -3,8 +3,8 @@ from typing import Any, Optional
from arcade.sdk import ToolContext
from arcade_notion.enums import BlockType
from arcade_notion.utils import get_page_url
from arcade_notion_toolkit.enums import BlockType
from arcade_notion_toolkit.utils import get_page_url
class BlockToMarkdownConverter:

View file

@ -0,0 +1,19 @@
from arcade_notion_toolkit.tools.pages import (
create_page,
get_page_content_by_id,
get_page_content_by_title,
)
from arcade_notion_toolkit.tools.search import (
get_object_metadata,
get_workspace_structure,
search_by_title,
)
__all__ = [
"create_page",
"get_object_metadata",
"get_page_content_by_id",
"get_page_content_by_title",
"search_by_title",
"get_workspace_structure",
]

View file

@ -5,12 +5,12 @@ from arcade.sdk import ToolContext, tool
from arcade.sdk.auth import Notion
from arcade.sdk.errors import ToolExecutionError
from arcade_notion.block_to_markdown_converter import BlockToMarkdownConverter
from arcade_notion.enums import BlockType, ObjectType
from arcade_notion.markdown_to_block_converter import convert_markdown_to_blocks
from arcade_notion.tools.search import get_object_metadata
from arcade_notion.types import DatabaseParent, PageWithPageParentProperties, create_parent
from arcade_notion.utils import (
from arcade_notion_toolkit.block_to_markdown_converter import BlockToMarkdownConverter
from arcade_notion_toolkit.enums import BlockType, ObjectType
from arcade_notion_toolkit.markdown_to_block_converter import convert_markdown_to_blocks
from arcade_notion_toolkit.tools.search import get_object_metadata
from arcade_notion_toolkit.types import DatabaseParent, PageWithPageParentProperties, create_parent
from arcade_notion_toolkit.utils import (
extract_title,
get_headers,
get_next_page,

View file

@ -5,8 +5,8 @@ from arcade.sdk import ToolContext, tool
from arcade.sdk.auth import Notion
from arcade.sdk.errors import ToolExecutionError
from arcade_notion.enums import ObjectType, SortDirection
from arcade_notion.utils import (
from arcade_notion_toolkit.enums import ObjectType, SortDirection
from arcade_notion_toolkit.utils import (
build_workspace_structure,
get_headers,
get_url,
@ -222,163 +222,3 @@ async def get_workspace_structure(
workspace_tree = build_workspace_structure(items)
return workspace_tree
# {
# "workspace": [
# {
# "children": [
# {
# "id": "1b47a62b-04d4-800c-a6d4-e471ae371237",
# "title": "NextSteps",
# "type": "page",
# "url": "https://www.notion.so/Next-Steps-1b47a62b04d4800ca6d4e471ae371237",
# }
# ],
# "id": "1b37a62b-04d4-8079-a902-ce69ed7e7240",
# "title": "ArcadeNotes",
# "type": "page",
# "url": "https://www.notion.so/Arcade-Notes-1b37a62b04d48079a902ce69ed7e7240",
# },
# {
# "children": [
# {
# "id": "1b47a62b-04d4-8075-bf2d-c17daca86d2c",
# "title": "this is my subpage ofmy todos",
# "type": "page",
# "url": "https://www.notion.so/this-is-my-subpage-of-my-todos-1b47a62b04d48075bf2dc17daca86d2c",
# }
# ],
# "id": "1ad7a62b-04d4-8063-bbb9-dce59136e08d",
# "title": "Weekly To-doList",
# "type": "page",
# "url": "https://www.notion.so/Weekly-To-do-List-1ad7a62b04d48063bbb9dce59136e08d",
# },
# {
# "id": "1b27a62b-04d4-80d7-b372-e18300e71052",
# "title": "A pagehere!!",
# "type": "page",
# "url": "https://www.notion.so/A-page-here-1b27a62b04d480d7b372e18300e71052",
# },
# {
# "children": [
# {
# "children": [
# {
# "children": [
# {
# "children": [
# {
# "id": "1b37a62b-04d4-80b5-a7a2-f0c65cb3bf4d",
# "title": "Tooth",
# "type": "page",
# "url": "https://www.notion.so/Tooth-1b37a62b04d480b5a7a2f0c65cb3bf4d",
# }
# ],
# "id": "1b37a62b-04d4-80f8-b3b6-e5aef644b8ec",
# "title": "Teeth",
# "type": "page",
# "url": "https://www.notion.so/Teeth-1b37a62b04d480f8b3b6e5aef644b8ec",
# }
# ],
# "id": "1b37a62b-04d4-8096-94e2-ff9db2e5c2c5",
# "title": "Morning",
# "type": "page",
# "url": "https://www.notion.so/Morning-1b37a62b04d4809694e2ff9db2e5c2c5",
# }
# ],
# "id": "1ae7a62b-04d4-80ee-b291-fa69701d74d3",
# "title": "03/05/2025 - Wednesday, March5",
# "type": "page",
# "url": "https://www.notion.so/03-05-2025-Wednesday-March-5-1ae7a62b04d480eeb291fa69701d74d3",
# },
# {
# "id": "1b37a62b-04d4-80ee-b3da-d49d1ea043ac",
# "title": "how to call atool",
# "type": "page",
# "url": "https://www.notion.so/how-to-call-a-tool-1b37a62b04d480eeb3dad49d1ea043ac",
# },
# {
# "id": "1b37a62b-04d4-8103-a179-d27bef02c4b5",
# "title": "Atree",
# "type": "page",
# "url": "https://www.notion.so/A-tree-1b37a62b04d48103a179d27bef02c4b5",
# },
# {
# "id": "1b27a62b-04d4-8024-ae1a-db8d3deab4c8",
# "title": "adatabase",
# "type": "database",
# "url": "https://www.notion.so/1b27a62b04d48024ae1adb8d3deab4c8",
# },
# {
# "id": "1ae7a62b-04d4-8064-975b-fb27a6535eac",
# "title": "03/03/2025 - Tuesday, March3",
# "type": "page",
# "url": "https://www.notion.so/03-03-2025-Tuesday-March-3-1ae7a62b04d48064975bfb27a6535eac",
# },
# {
# "id": "1ae7a62b-04d4-8058-b273-ca9f8a88a15e",
# "title": "03/04/2025 - Tuesday,March 4",
# "type": "page",
# "url": "https://www.notion.so/03-04-2025-Tuesday-March-4-1ae7a62b04d48058b273ca9f8a88a15e",
# },
# ],
# "id": "1ae7a62b-04d4-80cd-8f30-fe64b5354cc0",
# "title": "Daily News byArcade.dev",
# "type": "page",
# "url": "https://www.notion.so/Daily-News-by-Arcade-dev-1ae7a62b04d480cd8f30fe64b5354cc0",
# },
# {
# "id": "1b27a62b-04d4-807f-8c69-d9c7c2d78255",
# "title": "sdf",
# "type": "page",
# "url": "https://www.notion.so/sdf-1b27a62b04d4807f8c69d9c7c2d78255",
# },
# {
# "children": [
# {
# "id": "1ae7a62b-04d4-8140-926b-eb5580022c27",
# "title": "HabitTracker",
# "type": "database",
# "url": "https://www.notion.so/1ae7a62b04d48140926beb5580022c27",
# },
# {
# "id": "1ae7a62b-04d4-818a-b1cc-d9a37b8f2fbb",
# "title": "Tasklist",
# "type": "database",
# "url": "https://www.notion.so/1ae7a62b04d4818ab1ccd9a37b8f2fbb",
# },
# {
# "id": "1ae7a62b-04d4-81d6-ae33-c14127f47b39",
# "title": "Schedule",
# "type": "database",
# "url": "https://www.notion.so/1ae7a62b04d481d6ae33c14127f47b39",
# },
# ],
# "id": "1ae7a62b-04d4-8068-918d-d39ade9183a3",
# "title": "D A I L Y P L A N N ER",
# "type": "page",
# "url": "https://www.notion.so/D-A-I-L-Y-P-L-A-N-N-E-R-1ae7a62b04d48068918dd39ade9183a3",
# },
# {
# "id": "1ae7a62b-04d4-808f-983c-f82f49250af5",
# "title": "Table: Daily News byArcade.dev",
# "type": "database",
# "url": "https://www.notion.so/1ae7a62b04d4808f983cf82f49250af5",
# },
# {
# "children": [
# {
# "id": "1ad7a62b-04d4-8169-92bd-d3232cae5e35",
# "title": "Income(Monthly)",
# "type": "database",
# "url": "https://www.notion.so/1ad7a62b04d4816992bdd3232cae5e35",
# }
# ],
# "id": "1ad7a62b-04d4-803d-855e-fa9d5adef96b",
# "title": "MonthlyBudget",
# "type": "page",
# "url": "https://www.notion.so/Monthly-Budget-1ad7a62b04d4803d855efa9d5adef96b",
# },
# ]
# }

View file

@ -3,7 +3,7 @@ from typing import Any, Optional
import httpx
from arcade.sdk import ToolContext
from arcade_notion.constants import ENDPOINTS, NOTION_API_URL, UNTITLED_TITLE
from arcade_notion_toolkit.constants import ENDPOINTS, NOTION_API_URL, UNTITLED_TITLE
def get_url(endpoint: str, **kwargs: Any) -> str:

View file

@ -8,8 +8,12 @@ from arcade.sdk.eval import (
tool_eval,
)
import arcade_notion
from arcade_notion.tools import create_page, get_page_content_by_id, get_page_content_by_title
import arcade_notion_toolkit
from arcade_notion_toolkit.tools import (
create_page,
get_page_content_by_id,
get_page_content_by_title,
)
# Evaluation rubric
rubric = EvalRubric(
@ -19,7 +23,7 @@ rubric = EvalRubric(
catalog = ToolCatalog()
catalog.add_module(arcade_notion)
catalog.add_module(arcade_notion_toolkit)
PAGE_CONTENT = """## Why Build Tools with Arcade?

View file

@ -8,9 +8,13 @@ from arcade.sdk.eval import (
tool_eval,
)
import arcade_notion
from arcade_notion.enums import ObjectType
from arcade_notion.tools import get_object_metadata, get_workspace_structure, search_by_title
import arcade_notion_toolkit
from arcade_notion_toolkit.enums import ObjectType
from arcade_notion_toolkit.tools import (
get_object_metadata,
get_workspace_structure,
search_by_title,
)
# Evaluation rubric
rubric = EvalRubric(
@ -20,7 +24,7 @@ rubric = EvalRubric(
catalog = ToolCatalog()
catalog.add_module(arcade_notion)
catalog.add_module(arcade_notion_toolkit)
# Additional messages
TOOL_CALLING_CONVERSATION = [

View file

@ -1,17 +1,12 @@
[tool.poetry]
name = "arcade_notion_toolkit"
version = "0.0.1"
version = "0.1.0"
description = "LLM tools for essential Notion interactions such as creating, updating, retrieving, and searching pages."
authors = ["ArcadeAI <dev@arcade.dev>"]
# Distribution name varies from directory name, so explicitly define the folder name
packages = [
{ include = "arcade_notion" }
]
[tool.poetry.dependencies]
python = "^3.10"
arcade-ai = "^1.0.5"
arcade-ai = "^1.1.2"
[tool.poetry.dev-dependencies]
pytest = "^8.3.0"
@ -26,7 +21,7 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.mypy]
files = ["arcade_notion/**/*.py"]
files = ["arcade_notion_toolkit/**/*.py"]
python_version = "3.10"
disallow_untyped_defs = "True"
disallow_any_unimported = "True"

View file

@ -1,6 +1,6 @@
import pytest
from arcade_notion.block_to_markdown_converter import BlockToMarkdownConverter
from arcade_notion_toolkit.block_to_markdown_converter import BlockToMarkdownConverter
@pytest.mark.asyncio
@ -126,7 +126,9 @@ async def test_convert_child_page(monkeypatch):
async def fake_get_page_url(context, block_id):
return f"http://example.com/{block_id}"
monkeypatch.setattr("arcade_notion.block_to_markdown_converter.get_page_url", fake_get_page_url)
monkeypatch.setattr(
"arcade_notion_toolkit.block_to_markdown_converter.get_page_url", fake_get_page_url
)
converter = BlockToMarkdownConverter(context=None)
result = await converter.convert_block(block)
expected = "[Child Title](http://example.com/child123) \n"

View file

@ -104,7 +104,7 @@ fake_get_next_page_parent_block = (
@pytest.fixture
def setup_notion_pages(monkeypatch):
from arcade_notion.tools import pages
from arcade_notion_toolkit.tools import pages
monkeypatch.setattr(pages, "get_headers", lambda ctx: {"Authorization": "Bearer test"})
monkeypatch.setattr(

View file

@ -1,6 +1,6 @@
import pytest
from arcade_notion.utils import simplify_search_result
from arcade_notion_toolkit.utils import simplify_search_result
@pytest.mark.parametrize(