Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

feat: make the file downloadable path configuerable

angrybayblade8c69fa1e630d
diff --git a/python/composio/core/models/_files.py b/python/composio/core/models/_files.py
index 7d931c707..985a0b84d 100644
--- a/python/composio/core/models/_files.py
+++ b/python/composio/core/models/_files.py
@@ -157,9 +157,10 @@ class FileDownloadable(BaseModel):
class FileHelper(WithLogger):
- def __init__(self, client: HttpClient):
+ def __init__(self, client: HttpClient, outdir: t.Optional[str] = None):
super().__init__()
self._client = client
+ self._outdir = Path(outdir or LOCAL_OUTPUT_FILE_DIRECTORY)
def _file_uploadable(self, schema: t.Dict):
if "allOf" in schema:
diff --git a/python/composio/core/models/tools.py b/python/composio/core/models/tools.py
index 93a46e210..e8ce0f5ac 100644
--- a/python/composio/core/models/tools.py
+++ b/python/composio/core/models/tools.py
@@ -51,17 +51,23 @@ class Tools(Resource, t.Generic[TProvider]):
provider: TProvider
- def __init__(self, client: HttpClient, provider: TProvider):
+ def __init__(
+ self,
+ client: HttpClient,
+ provider: TProvider,
+ file_download_dir: t.Optional[str] = None,
+ ):
"""
Initialize the tools resource.
:param client: The client to use for the tools resource.
:param provider: The provider to use for the tools resource.
+ :param file_download_dir: Output directory for downloadable files
"""
self._client = client
self._custom_tools = CustomTools(client)
self._tool_schemas: t.Dict[str, Tool] = {}
- self._file_helper = FileHelper(client=self._client)
+ self._file_helper = FileHelper(client=self._client, outdir=file_download_dir)
self.custom_tool = self._custom_tools.register
self.provider = provider
diff --git a/python/composio/sdk.py b/python/composio/sdk.py
index 165e051cf..3fc2d9c30 100644
--- a/python/composio/sdk.py
+++ b/python/composio/sdk.py
@@ -29,6 +29,7 @@ class SDKConfig(te.TypedDict):
timeout: te.NotRequired[int]
max_retries: te.NotRequired[int]
allow_tracking: te.NotRequired[bool]
+ file_download_dir: te.NotRequired[str]
class Composio(t.Generic[TProvider], WithLogger):
@@ -68,7 +69,11 @@ class Composio(t.Generic[TProvider], WithLogger):
max_retries=kwargs.get("max_retries", DEFAULT_MAX_RETRIES),
)
self.provider = provider
- self.tools = Tools(client=self._client, provider=self.provider)
+ self.tools = Tools(
+ client=self._client,
+ provider=self.provider,
+ file_download_dir=kwargs.get("file_download_dir"),
+ )
self.toolkits = Toolkits(client=self._client)
self.triggers = Triggers(client=self._client)
self.auth_configs = AuthConfigs(client=self._client)