""" Reeling Toolkit for LangChain & LangGraph (v1.1.0) 15-Channel Social Publishing, AI Video Storyboards, Reddit/Quora Topic Radar & Pre-Publish Spam Shield. https://reeling.app/plugins/langchain """ import os import requests from typing import List, Optional try: from langchain_core.tools import tool except ImportError: def tool(f): return f def _headers(): api_key = os.getenv("REELING_API_KEY", "") return { "Authorization": f"Bearer {api_key}", "X-API-Key": api_key, "Content-Type": "application/json", } @tool def reeling_discover_community_questions( topics: List[str], platforms: Optional[List[str]] = None, time_range: str = "week", ) -> str: """ Discovers fresh daily questions on Reddit and Quora matching target topics and returns remaining anti-ban cadence quota (max 3 answers/day, 3 posts/week). """ base_url = os.getenv("REELING_API_URL", "https://api.reeling.app") res = requests.post( f"{base_url}/api/v1/community/discover", json={"topics": topics, "platforms": platforms or ["reddit", "quora"], "timeRange": time_range}, headers=_headers(), timeout=30, ) return str(res.json()) @tool def reeling_draft_community_answer( platform: str, question_title: str, question_url: Optional[str] = None, expertise_context: Optional[str] = None, ) -> str: """ Drafts a 120-220 word value-first Reddit or Quora answer and returns a 0-100 Pre-Publish Spam & Shadowban Safety Score. """ base_url = os.getenv("REELING_API_URL", "https://api.reeling.app") res = requests.post( f"{base_url}/api/v1/community/draft-answer", json={ "platform": platform, "questionTitle": question_title, "questionUrl": question_url, "expertiseContext": expertise_context, "includeSoftMention": False, }, headers=_headers(), timeout=45, ) return str(res.json()) @tool def reeling_publish_post( project_id: str, title: str, caption: str, platforms: List[str], video_url: Optional[str] = None, reply_to_url: Optional[str] = None, scheduled_for: Optional[str] = None, ) -> str: """ Publishes or schedules content across Reeling's 15 supported platforms (youtube, tiktok, instagram, facebook, linkedin, threads, pinterest, bluesky, x, reddit, medium, quora, telegram, discord, mastodon). """ base_url = os.getenv("REELING_API_URL", "https://api.reeling.app") payload = { "project_id": project_id, "title": title, "caption": caption, "platforms": platforms, "video_url": video_url, "reply_to_url": reply_to_url, "scheduled_for": scheduled_for, } res = requests.post( f"{base_url}/api/v1/publish", json={k: v for k, v in payload.items() if v is not None}, headers=_headers(), timeout=45, ) return str(res.json()) def get_reeling_tools(): return [ reeling_discover_community_questions, reeling_draft_community_answer, reeling_publish_post, ]