tonby's picture
Upload Upload-Post smolagents tool
a6381a3 verified
Raw History Blame Contribute Delete
1.11 kB
from typing import Any, Optional
from smolagents.tools import Tool
import os
import upload_post
class UploadPostProfilesTool(Tool):
name = "upload_post_profiles"
description = "List the Upload-Post profiles of the account and the social accounts connected to each one (TikTok, Instagram, YouTube, LinkedIn, X, ...). Call it first to find which profile to publish from and which platforms it can post to."
inputs = {}
output_type = "object"
def __init__(self, api_key=None, **kwargs):
super().__init__()
import os
self.api_key = api_key or os.environ.get("UPLOAD_POST_API_KEY")
self.client = None
def setup(self):
from upload_post import UploadPostClient
if not self.api_key:
raise ValueError(
"Missing Upload-Post API key: pass api_key=... or set UPLOAD_POST_API_KEY."
)
self.client = UploadPostClient(self.api_key)
self.is_initialized = True
def forward(self) -> Any:
if not self.is_initialized:
self.setup()
return self.client.list_users()