Spaces:
Configuration error
Configuration error
Download clients/python/composio.py from AnthropicallyHuggingFaces/ai-platform-toolbox: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/AnthropicallyHuggingFaces/ai-platform-toolbox/resolve/main/clients/python/composio.py
- Command line
-
hf download hf://spaces/AnthropicallyHuggingFaces/ai-platform-toolbox/clients/python/composio.py
-
curl -L -o composio.py https://huggingface.co/spaces/AnthropicallyHuggingFaces/ai-platform-toolbox/resolve/main/clients/python/composio.py
1.08 kB
| """Composio client - external app tool registry + execution.""" | |
| import os | |
| import requests | |
| BASE = os.getenv("COMPOSIO_API_BASE", "https://backend.composio.dev") | |
| KEY = os.getenv("COMPOSIO_API_KEY") | |
| def _h(): | |
| if not KEY: | |
| raise RuntimeError("COMPOSIO_API_KEY not set") | |
| return {"Authorization": f"Bearer {KEY}", "x-api-key": KEY, "Content-Type": "application/json"} | |
| def list_tools(**params): | |
| return requests.get(f"{BASE}/api/v1/tools", headers=_h(), params=params, timeout=60).json() | |
| def get_tool(tool_name: str): | |
| return requests.get(f"{BASE}/api/v1/tools/{tool_name}", headers=_h(), timeout=60).json() | |
| def execute_action(app, action, params, connected_account_id=None): | |
| body = {"app": app, "action": action, "params": params} | |
| if connected_account_id: | |
| body["connectedAccountId"] = connected_account_id | |
| return requests.post(f"{BASE}/api/v1/actions/execute", headers=_h(), json=body, timeout=120).json() | |
| def get_connected_accounts(): | |
| return requests.get(f"{BASE}/api/v1/connected_accounts", headers=_h(), timeout=60).json() | |