from praisonai_tools import TavilyTool, Crawl4AITool
TOOLS = {}
def recipe_tool(name):
def decorator(func):
TOOLS[name] = func
return func
return decorator
@recipe_tool("tavily_search")
def tavily_search(query: str, max_results: int = 5):
return TavilyTool().search(query=query, max_results=max_results)
@recipe_tool("crawl_url")
def crawl_url(url: str):
return Crawl4AITool().crawl(url=url)
@recipe_tool("check_duplicate")
def check_duplicate(title: str):
from praisonaiwp.ai.duplicate_detector import DuplicateDetector
# ... implementation
return {"has_duplicates": False}
@recipe_tool("create_wp_post")
def create_wp_post(title: str, content: str, status: str = "publish"):
import subprocess
# Title blocklist validation
BLOCKED = ["verified", "sample", "example", "test"]
if any(b in title.lower() for b in BLOCKED):
return {"error": "Invalid title", "blocked": True}
cmd = ["praisonaiwp", "create", title, "--content", content]
result = subprocess.run(cmd, capture_output=True, text=True)
return {"success": result.returncode == 0}