AgentRPC client for connecting to AgentRPC API.
| 3 | |
| 4 | |
| 5 | class AgentRPC: |
| 6 | """AgentRPC client for connecting to AgentRPC API.""" |
| 7 | |
| 8 | def __init__( |
| 9 | self, |
| 10 | api_secret: str, |
| 11 | endpoint: str = "https://api.agentrpc.com", |
| 12 | ): |
| 13 | """Initialize the AgentRPC client. |
| 14 | |
| 15 | Args: |
| 16 | api_secret: The API secret key. |
| 17 | endpoint: Custom API endpoint. Defaults to 'https://api.agentrpc.com'. |
| 18 | """ |
| 19 | |
| 20 | self.__api_secret = api_secret |
| 21 | self.__endpoint = endpoint |
| 22 | self.__http_client = HTTPClient(endpoint, api_secret) |
| 23 | self.openai = OpenAIIntegration(self) |
| 24 | |
| 25 | parts = api_secret.split("_") |
| 26 | if len(parts) != 3 or parts[0] != "sk": |
| 27 | raise ValueError("Invalid API Secret.") |
| 28 | else: |
| 29 | _, cluster_id, rand = parts |
| 30 | self.cluster_id = cluster_id |
| 31 | |
| 32 | def list_tools(self, params): |
| 33 | """List tools from the HTTP client.""" |
| 34 | return self.__http_client.list_tools(params) |
| 35 | |
| 36 | def create_and_poll_job(self, cluster_id: str, tool_name: str, input_data: dict): |
| 37 | """Create and poll a job using the HTTP client.""" |
| 38 | return self.__http_client.create_and_poll_job(cluster_id, tool_name, input_data) |
no outgoing calls