mirror of
https://github.com/ComposioHQ/composio.git
synced 2026-09-22 11:46:35 +08:00
feat(py): remove legacy custom tools (#3508)
This PR is **part 1 of 3** splitting https://github.com/ComposioHQ/composio/pull/3505 to make the removal of the old 2025 custom tools easier to review. It carries the **Python** slice. - removes the legacy `composio.tools.custom_tool` registry path: `core.models.custom_tools`, `ExecuteRequestFn`, the old fallback execution wiring, the security tests, and the example - preserves the 2026 tool-router APIs: `composio.experimental.tool()`, `composio.experimental.Toolkit`, inline custom-tool execution, preload/attach/use flows, and `session.custom_tools()` - bumps the Python workspace and all provider packages `0.13.1` → `0.14.0` ## Notes - This slice is a byte-identical subset of #3505 — the three split branches recombine to that PR's exact tree. See #3505 for the original local verification logs (`uv run --frozen nox -s chk`, targeted pytest); CI re-runs per PR.
This commit is contained in:
@@ -1,83 +0,0 @@
|
||||
import requests
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from composio import Composio
|
||||
from composio.types import ExecuteRequestFn
|
||||
|
||||
composio = Composio()
|
||||
|
||||
|
||||
class AddTwoNumbersInput(BaseModel):
|
||||
a: int = Field(
|
||||
...,
|
||||
description="The first number to add",
|
||||
)
|
||||
b: int = Field(
|
||||
...,
|
||||
description="The second number to add",
|
||||
)
|
||||
|
||||
|
||||
@composio.tools.custom_tool
|
||||
def add_two_numbers(request: AddTwoNumbersInput) -> int:
|
||||
"""Add two numbers."""
|
||||
return request.a + request.b
|
||||
|
||||
|
||||
class GetIssueInfoInput(BaseModel):
|
||||
issue_number: int = Field(
|
||||
...,
|
||||
description="The number of the issue to get information about",
|
||||
)
|
||||
|
||||
|
||||
@composio.tools.custom_tool(toolkit="github")
|
||||
def get_issue_info(
|
||||
request: GetIssueInfoInput,
|
||||
execute_request: ExecuteRequestFn,
|
||||
auth_credentials: dict,
|
||||
) -> dict:
|
||||
"""Get information about a GitHub issue."""
|
||||
response = execute_request(
|
||||
endpoint=f"/repos/composiohq/composio/issues/{request.issue_number}",
|
||||
method="GET",
|
||||
parameters=[
|
||||
{
|
||||
"name": "Accept",
|
||||
"value": "application/vnd.github.v3+json",
|
||||
"type": "header",
|
||||
},
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": f"Bearer {auth_credentials['access_token']}",
|
||||
"type": "header",
|
||||
},
|
||||
],
|
||||
)
|
||||
return {"data": response.data}
|
||||
|
||||
|
||||
@composio.tools.custom_tool(toolkit="github")
|
||||
def get_issue_info_direct(
|
||||
request: GetIssueInfoInput,
|
||||
execute_request: ExecuteRequestFn,
|
||||
auth_credentials: dict,
|
||||
) -> dict:
|
||||
"""Get information about a GitHub issue."""
|
||||
response = requests.get(
|
||||
f"https://api.github.com/repos/composiohq/composio/issues/{request.issue_number}",
|
||||
headers={
|
||||
"Accept": "application/vnd.github.v3+json",
|
||||
"Authorization": f"Bearer {auth_credentials['access_token']}",
|
||||
},
|
||||
)
|
||||
return {"data": response.json()}
|
||||
|
||||
|
||||
response = composio.tools.execute(
|
||||
user_id="default",
|
||||
slug=get_issue_info.slug,
|
||||
arguments={"issue_number": 1},
|
||||
)
|
||||
|
||||
print(response)
|
||||
Reference in New Issue
Block a user