Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: small cleanups #793

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions python/composio/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# fmt: off

"""
Composio SDK client.
"""
Expand Down Expand Up @@ -63,7 +61,7 @@ def __init__(
self,
api_key: t.Optional[str] = None,
base_url: t.Optional[str] = None,
runtime: t.Optional[str] = None
runtime: t.Optional[str] = None,
) -> None:
"""
Initialize Composio SDK client
Expand Down Expand Up @@ -98,12 +96,10 @@ def api_key(self) -> str:
cache_dir = Path.home() / LOCAL_CACHE_DIRECTORY_NAME
user_data_path = cache_dir / USER_DATA_FILE_NAME
user_data = (
UserData.load(path=user_data_path)
if user_data_path.exists() else None
UserData.load(path=user_data_path) if user_data_path.exists() else None
)
env_api_key = (
(user_data.api_key if user_data else None)
or os.environ.get(ENV_COMPOSIO_API_KEY)
user_data.api_key if user_data else os.environ.get(ENV_COMPOSIO_API_KEY)
)
if env_api_key:
self._api_key = env_api_key
Expand Down Expand Up @@ -262,7 +258,7 @@ def execute(
entity_id=self.id,
session_id=session_id,
text=text,
auth=auth
auth=auth,
)

connected_account = self.get_connection(
Expand All @@ -277,7 +273,7 @@ def execute(
connected_account=connected_account.id,
session_id=session_id,
text=text,
auth=auth
auth=auth,
)

def get_connection(
Expand Down
10 changes: 3 additions & 7 deletions python/composio/client/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,9 @@ def __call__(self, queries: t.Dict[str, str]) -> "Endpoint":
if len(queries) == 0:
return self

endpoint = self.endpoint
endpoint += "?"
for key, value in queries.items():
endpoint += (
f"{urllib.parse.quote_plus(key)}={urllib.parse.quote_plus(value)}&"
)
return Endpoint(endpoint=endpoint[:-1])
return Endpoint(
urllib.parse.urljoin(self.endpoint, "?" + urllib.parse.urlencode(queries))
)


class _V1(Endpoint):
Expand Down
4 changes: 0 additions & 4 deletions python/composio/tools/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import typing_extensions as te
from pydantic import BaseModel
from pydantic.v1.main import BaseModel as V1BaseModel

from composio import Action, ActionType, App, AppType, TagType
from composio.client import Composio, Entity
Expand Down Expand Up @@ -579,9 +578,6 @@ def _serialize_execute_params(self, param: ParamType) -> ParamType:
if isinstance(param, BaseModel):
return param.model_dump_json(exclude_none=True) # type: ignore

if isinstance(param, V1BaseModel):
return param.dict(exclude_none=True) # type: ignore

if isinstance(param, list):
return [self._serialize_execute_params(p) for p in param] # type: ignore

Expand Down
7 changes: 1 addition & 6 deletions python/composio/utils/pydantic.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import typing as t

import pydantic
import pydantic.v1.error_wrappers


def parse_pydantic_error(
e: t.Union[pydantic.ValidationError, pydantic.v1.error_wrappers.ValidationError]
) -> str:
def parse_pydantic_error(e: pydantic.ValidationError) -> str:
"""Parse pydantic validation error."""
message = "Invalid request data provided"
missing = []
Expand Down
8 changes: 2 additions & 6 deletions python/plugins/langchain/composio_langchain/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import pydantic
import pydantic.error_wrappers
import pydantic.v1.error_wrappers
import typing_extensions as te
from langchain_core.tools import StructuredTool as BaseStructuredTool

Expand All @@ -22,10 +21,7 @@ class StructuredTool(BaseStructuredTool):
def run(self, *args, **kwargs):
try:
return super().run(*args, **kwargs)
except (
pydantic.ValidationError,
pydantic.v1.error_wrappers.ValidationError,
) as e:
except pydantic.ValidationError as e:
return {"successful": False, "error": parse_pydantic_error(e), "data": None}


Expand Down Expand Up @@ -64,7 +60,7 @@ class ComposioToolSet(
tools = composio_toolset.get_tools(apps=[App.GITHUB])

# Define task
task = "Star a repo SamparkAI/docs on GitHub"
task = "Star a repo composiohq/docs on GitHub"

# Define agent
agent = create_openai_functions_agent(openai_client, tools, prompt)
Expand Down
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def scan_for_package_data(
description="Core package to act as a bridge between composio platform and other services.",
long_description=(Path(__file__).parent / "README.md").read_text(encoding="utf-8"),
long_description_content_type="text/markdown",
url="https://github.com/SamparkAI/composio_sdk",
url="https://github.com/composiohq/composio",
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
Expand Down
2 changes: 1 addition & 1 deletion python/swe/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def scan_for_package_data(
description="Tools for running a SWE agent using Composio platform",
long_description=(Path(__file__).parent / "README.md").read_text(encoding="utf-8"),
long_description_content_type="text/markdown",
url="https://github.com/SamparkAI/composio_sdk",
url="https://github.com/composiohq/composio",
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
Expand Down
17 changes: 0 additions & 17 deletions python/tests/package.json

This file was deleted.

52 changes: 0 additions & 52 deletions python/tests/playwright.config.ts

This file was deleted.

98 changes: 0 additions & 98 deletions python/tests/pnpm-lock.yaml

This file was deleted.

Loading
Loading