File size: 1,108 Bytes
2882c46
 
 
a6381a3
2882c46
 
 
 
 
 
 
a6381a3
2882c46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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()