composio-autogen 0.1.49__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- composio_autogen-0.1.49/PKG-INFO +20 -0
- composio_autogen-0.1.49/README.md +5 -0
- composio_autogen-0.1.49/composio_autogen/__init__.py +2 -0
- composio_autogen-0.1.49/composio_autogen/autogen_toolspec.py +169 -0
- composio_autogen-0.1.49/composio_autogen.egg-info/PKG-INFO +20 -0
- composio_autogen-0.1.49/composio_autogen.egg-info/SOURCES.txt +10 -0
- composio_autogen-0.1.49/composio_autogen.egg-info/dependency_links.txt +1 -0
- composio_autogen-0.1.49/composio_autogen.egg-info/requires.txt +2 -0
- composio_autogen-0.1.49/composio_autogen.egg-info/top_level.txt +1 -0
- composio_autogen-0.1.49/pyproject.toml +11 -0
- composio_autogen-0.1.49/setup.cfg +4 -0
- composio_autogen-0.1.49/setup.py +31 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: composio_autogen
|
|
3
|
+
Version: 0.1.49
|
|
4
|
+
Summary: Use Composio to get an array of tools with your Autogen agent.
|
|
5
|
+
Home-page: https://github.com/SamparkAI/composio_sdk
|
|
6
|
+
Author: Sawradip
|
|
7
|
+
Author-email: sawradip@composio.dev
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.7
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: composio_core===0.1.49
|
|
14
|
+
Requires-Dist: pyautogen===0.2.19
|
|
15
|
+
|
|
16
|
+
Composio <> Autogen
|
|
17
|
+
Use Composio to enhance your Autogen workflows with a suite of tools.
|
|
18
|
+
|
|
19
|
+
# Usage
|
|
20
|
+
Within your Autogen project:
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import types
|
|
2
|
+
import logging
|
|
3
|
+
from inspect import Parameter, Signature
|
|
4
|
+
from typing import Union, List, Annotated
|
|
5
|
+
|
|
6
|
+
import autogen
|
|
7
|
+
from composio import ComposioCore, App, Action
|
|
8
|
+
from pydantic import create_model, Field
|
|
9
|
+
from autogen.agentchat.conversable_agent import ConversableAgent
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
schema_type_python_type_dict = {
|
|
14
|
+
'string': str,
|
|
15
|
+
'number': float,
|
|
16
|
+
'boolean': bool,
|
|
17
|
+
'integer': int
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
fallback_values = {
|
|
21
|
+
'string': "",
|
|
22
|
+
'number': 0.0,
|
|
23
|
+
'integer': 0.0,
|
|
24
|
+
'boolean': False,
|
|
25
|
+
'object': {},
|
|
26
|
+
'array': []
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
def pydantic_model_from_param_schema(param_schema):
|
|
30
|
+
fields = {}
|
|
31
|
+
param_title = param_schema['title'].replace(" ", "")
|
|
32
|
+
required_props = param_schema.get('required', [])
|
|
33
|
+
for prop_name, prop_info in param_schema['properties'].items():
|
|
34
|
+
prop_type = prop_info["type"]
|
|
35
|
+
prop_title = prop_info['title'].replace(" ", "")
|
|
36
|
+
prop_default = prop_info.get('default', fallback_values[prop_type])
|
|
37
|
+
if prop_type in schema_type_python_type_dict:
|
|
38
|
+
signature_prop_type = schema_type_python_type_dict[prop_type]
|
|
39
|
+
else:
|
|
40
|
+
signature_prop_type = pydantic_model_from_param_schema(prop_info)
|
|
41
|
+
|
|
42
|
+
if prop_name in required_props:
|
|
43
|
+
fields[prop_name] = (signature_prop_type,
|
|
44
|
+
Field(...,
|
|
45
|
+
title=prop_title,
|
|
46
|
+
description=prop_info.get('description',
|
|
47
|
+
prop_info.get('desc',
|
|
48
|
+
prop_title))
|
|
49
|
+
))
|
|
50
|
+
else:
|
|
51
|
+
fields[prop_name] = (signature_prop_type,
|
|
52
|
+
Field(title=prop_title,
|
|
53
|
+
default=prop_default
|
|
54
|
+
))
|
|
55
|
+
fieldModel = create_model(param_title, **fields)
|
|
56
|
+
return fieldModel
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def get_signature_format_from_schema_params(
|
|
62
|
+
schema_params
|
|
63
|
+
):
|
|
64
|
+
parameters = []
|
|
65
|
+
required_params = schema_params.get('required', [])
|
|
66
|
+
|
|
67
|
+
for param_name, param_schema in schema_params['properties'].items():
|
|
68
|
+
param_type = param_schema['type']
|
|
69
|
+
param_title = param_schema['title'].replace(" ", "")
|
|
70
|
+
|
|
71
|
+
if param_type in schema_type_python_type_dict:
|
|
72
|
+
signature_param_type = schema_type_python_type_dict[param_type]
|
|
73
|
+
else:
|
|
74
|
+
signature_param_type = pydantic_model_from_param_schema(param_schema)
|
|
75
|
+
|
|
76
|
+
param_default = param_schema.get('default', fallback_values[param_type])
|
|
77
|
+
param_annotation = Annotated[signature_param_type, param_schema.get('description',
|
|
78
|
+
param_schema.get('desc',
|
|
79
|
+
param_title))]
|
|
80
|
+
param = Parameter(
|
|
81
|
+
name=param_name,
|
|
82
|
+
kind=Parameter.POSITIONAL_OR_KEYWORD,
|
|
83
|
+
annotation=param_annotation,
|
|
84
|
+
default=Parameter.empty if param_name in required_params else param_default
|
|
85
|
+
)
|
|
86
|
+
parameters.append(param)
|
|
87
|
+
return parameters
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class ComposioToolset:
|
|
91
|
+
def __init__(self, caller = None, executor = None):
|
|
92
|
+
self.caller = caller
|
|
93
|
+
self.executor = executor
|
|
94
|
+
self.client = ComposioCore()
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def register_tools(
|
|
98
|
+
self,
|
|
99
|
+
tools: Union[App, List[App]],
|
|
100
|
+
caller: ConversableAgent = None,
|
|
101
|
+
executor: ConversableAgent = None
|
|
102
|
+
):
|
|
103
|
+
if isinstance(tools, App):
|
|
104
|
+
tools = [tools]
|
|
105
|
+
assert caller or self.caller, "If caller hasn't been specified during initialization, has to be specified during registration"
|
|
106
|
+
assert executor or self.executor, "If executor hasn't been specified during initialization, has to be specified during registration"
|
|
107
|
+
|
|
108
|
+
action_schemas = self.client.sdk.get_list_of_actions(
|
|
109
|
+
apps=tools)
|
|
110
|
+
|
|
111
|
+
for schema in action_schemas:
|
|
112
|
+
self._register_schema_to_autogen(action_schema=schema,
|
|
113
|
+
caller = caller if caller else self.caller,
|
|
114
|
+
executor = executor if executor else self.executor)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def register_actions(
|
|
118
|
+
self,
|
|
119
|
+
actions: Union[Action, List[Action]],
|
|
120
|
+
caller: ConversableAgent = None,
|
|
121
|
+
executor: ConversableAgent = None
|
|
122
|
+
):
|
|
123
|
+
if isinstance(actions, Action):
|
|
124
|
+
actions = [actions]
|
|
125
|
+
|
|
126
|
+
assert caller or self.caller, "If caller hasn't been specified during initialization, has to be specified during registration"
|
|
127
|
+
assert executor or self.executor, "If executor hasn't been specified during initialization, has to be specified during registration"
|
|
128
|
+
|
|
129
|
+
action_schemas = self.client.sdk.get_list_of_actions(
|
|
130
|
+
actions=actions)
|
|
131
|
+
|
|
132
|
+
for schema in action_schemas:
|
|
133
|
+
self._register_schema_to_autogen(action_schema=schema,
|
|
134
|
+
caller = caller if caller else self.caller,
|
|
135
|
+
executor = executor if executor else self.executor)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _register_schema_to_autogen(self,
|
|
139
|
+
action_schema,
|
|
140
|
+
caller: ConversableAgent,
|
|
141
|
+
executor: ConversableAgent):
|
|
142
|
+
|
|
143
|
+
name = action_schema["name"]
|
|
144
|
+
appName = action_schema["appName"]
|
|
145
|
+
description = action_schema["description"]
|
|
146
|
+
|
|
147
|
+
parameters = get_signature_format_from_schema_params(
|
|
148
|
+
action_schema["parameters"])
|
|
149
|
+
action_signature = Signature(parameters=parameters)
|
|
150
|
+
|
|
151
|
+
placeholder_function = lambda **kwargs: self.client.execute_action(
|
|
152
|
+
self.client.get_action_enum(name, appName),
|
|
153
|
+
kwargs)
|
|
154
|
+
action_func = types.FunctionType(
|
|
155
|
+
placeholder_function.__code__,
|
|
156
|
+
globals=globals(),
|
|
157
|
+
name=name,
|
|
158
|
+
closure=placeholder_function.__closure__
|
|
159
|
+
)
|
|
160
|
+
action_func.__signature__ = action_signature
|
|
161
|
+
action_func.__doc__ = description
|
|
162
|
+
|
|
163
|
+
autogen.agentchat.register_function(
|
|
164
|
+
action_func,
|
|
165
|
+
caller=caller,
|
|
166
|
+
executor=executor,
|
|
167
|
+
name=name,
|
|
168
|
+
description=description
|
|
169
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: composio_autogen
|
|
3
|
+
Version: 0.1.49
|
|
4
|
+
Summary: Use Composio to get an array of tools with your Autogen agent.
|
|
5
|
+
Home-page: https://github.com/SamparkAI/composio_sdk
|
|
6
|
+
Author: Sawradip
|
|
7
|
+
Author-email: sawradip@composio.dev
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.7
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: composio_core===0.1.49
|
|
14
|
+
Requires-Dist: pyautogen===0.2.19
|
|
15
|
+
|
|
16
|
+
Composio <> Autogen
|
|
17
|
+
Use Composio to enhance your Autogen workflows with a suite of tools.
|
|
18
|
+
|
|
19
|
+
# Usage
|
|
20
|
+
Within your Autogen project:
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
setup.py
|
|
4
|
+
composio_autogen/__init__.py
|
|
5
|
+
composio_autogen/autogen_toolspec.py
|
|
6
|
+
composio_autogen.egg-info/PKG-INFO
|
|
7
|
+
composio_autogen.egg-info/SOURCES.txt
|
|
8
|
+
composio_autogen.egg-info/dependency_links.txt
|
|
9
|
+
composio_autogen.egg-info/requires.txt
|
|
10
|
+
composio_autogen.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
composio_autogen
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
dynamic = ["classifiers", "version", "readme", "authors", "requires-python", "description"]
|
|
3
|
+
dependencies = [
|
|
4
|
+
"composio_core===0.1.49",
|
|
5
|
+
"pyautogen===0.2.19"
|
|
6
|
+
]
|
|
7
|
+
name = "composio_autogen"
|
|
8
|
+
|
|
9
|
+
[build-system]
|
|
10
|
+
requires = [ "setuptools>=42", "wheel"]
|
|
11
|
+
build-backend = "setuptools.build_meta"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from setuptools import setup
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def get_current_dir():
|
|
6
|
+
return os.path.dirname(os.path.realpath(__file__))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def resolve_paths(*paths):
|
|
10
|
+
return os.path.join(*paths)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
readme_path = resolve_paths(get_current_dir(), "README.md")
|
|
14
|
+
|
|
15
|
+
setup(
|
|
16
|
+
name="composio_autogen",
|
|
17
|
+
version="0.1.49",
|
|
18
|
+
author="Sawradip",
|
|
19
|
+
author_email="sawradip@composio.dev",
|
|
20
|
+
description="Use Composio to get an array of tools with your Autogen agent.",
|
|
21
|
+
long_description=open(readme_path).read(),
|
|
22
|
+
long_description_content_type="text/markdown",
|
|
23
|
+
url="https://github.com/SamparkAI/composio_sdk",
|
|
24
|
+
classifiers=[
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"License :: OSI Approved :: Apache Software License",
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
],
|
|
29
|
+
python_requires=">=3.7",
|
|
30
|
+
include_package_data=True,
|
|
31
|
+
)
|