import os
from dotenv import load_dotenv
from bindu.penguin.bindufy import bindufy
from agno.agent import Agent
from agno.models.openrouter import OpenRouter
from notion_client import Client
load_dotenv()
NOTION_API_KEY = os.getenv("NOTION_API_KEY")
NOTION_DATABASE_ID = os.getenv("NOTION_DATABASE_ID")
OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY")
notion = Client(auth=NOTION_API_KEY)
def create_notion_page(title: str, content: str):
"""Create a page in Notion database"""
return notion.pages.create(
parent={"database_id": NOTION_DATABASE_ID},
properties={"Name": {"title": [{"text": {"content": title}}]}},
children=[{
"object": "block",
"type": "paragraph",
"paragraph": {"text": [{"type": "text", "text": {"content": content}}]},
}],
)
def search_notion(query: str):
"""Search pages in Notion database"""
return notion.databases.query(
database_id=NOTION_DATABASE_ID,
filter={
"or": [
{"property": "Name", "title": {"contains": query}},
{"property": "Content", "rich_text": {"contains": query}},
]
}
)
agent = Agent(
instructions="You are a Notion assistant. Use tools to create and search Notion pages.",
model=OpenRouter(id="openai/gpt-oss-120b", api_key=OPENROUTER_API_KEY),
tools=[create_notion_page, search_notion],
)
config = {
"author": "[email protected]",
"name": "agno-notion-agent",
"description": "Notion assistant agent (OpenRouter)",
"deployment": {
"url": "http://localhost:3773",
"expose": True,
"cors_origins": ["http://localhost:5173"]
},
"skills": ["skills/pdf-processing", "skills/question-answering"],
}
def handler(messages: list[dict[str, str]]):
return agent.run(input=messages)
bindufy(config, handler)