composio-google 0.5.26__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.
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.1
2
+ Name: composio_google
3
+ Version: 0.5.26
4
+ Summary: Use Composio to get an array of tools with your Google AI Python Gemini model.
5
+ Home-page: https://github.com/ComposioHQ/composio
6
+ Author: Assistant
7
+ Author-email: karan@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.9,<4
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: composio_core==0.5.26
14
+ Requires-Dist: google-cloud-aiplatform>=1.38.0
15
+
16
+ ## 🚀🔗 Integrating Composio with Google AI Python
17
+
18
+ Streamline the integration of Composio with Google AI Python to enhance the capabilities of Gemini models, allowing them to interact directly with external applications and expanding their operational scope.
19
+
20
+ ### Objective
21
+
22
+ - **Automate starring a GitHub repository** using conversational instructions via Google AI Python's Function Calling feature.
23
+
24
+ ### Installation and Setup
25
+
26
+ Ensure you have the necessary packages installed and connect your GitHub account to allow your agents to utilize GitHub functionalities.
27
+
28
+ ```bash
29
+ # Install Composio LangChain package
30
+ pip install composio-google
31
+
32
+ # Connect your GitHub account
33
+ composio-cli add github
34
+
35
+ # View available applications you can connect with
36
+ composio-cli show-apps
37
+ ```
38
+
39
+ ### Usage Steps
40
+
41
+ #### 1. Import Base Packages
42
+
43
+ Prepare your environment by initializing necessary imports from Google AI Python and setting up your client.
44
+
45
+ ```python
46
+ from vertexai.generative_models import GenerativeModel
47
+
48
+ # Initialize Google AI Python client
49
+ model = GenerativeModel("gemini-pro")
50
+ ```
51
+
52
+ ### Step 2: Integrating GitHub Tools with Composio
53
+
54
+ This step involves fetching and integrating GitHub tools provided by Composio, enabling enhanced functionality for Google AI Python operations.
55
+ ```python
56
+ from composio_google import App, ComposioToolset
57
+
58
+ toolset = ComposioToolset()
59
+ actions = toolset.get_tools(apps=[App.GITHUB])
60
+ ```
61
+
62
+ ### Step 3: Agent Execution
63
+
64
+ This step involves configuring and executing the agent to carry out actions, such as starring a GitHub repository.
65
+
66
+ ```python
67
+ # Define task
68
+ task = "Star a repo composiohq/composio on GitHub"
69
+
70
+ # Send a message to the model
71
+ response = chat.send_message(task)
72
+ ```
73
+
74
+ ### Step 4: Validate Execution Response
75
+
76
+ Execute the following code to validate the response, ensuring that the intended task has been successfully completed.
77
+
78
+ ```python
79
+ result = composio_toolset.handle_response(response)
80
+ print("Function call result:", result)
81
+ ```
@@ -0,0 +1,66 @@
1
+ ## 🚀🔗 Integrating Composio with Google AI Python
2
+
3
+ Streamline the integration of Composio with Google AI Python to enhance the capabilities of Gemini models, allowing them to interact directly with external applications and expanding their operational scope.
4
+
5
+ ### Objective
6
+
7
+ - **Automate starring a GitHub repository** using conversational instructions via Google AI Python's Function Calling feature.
8
+
9
+ ### Installation and Setup
10
+
11
+ Ensure you have the necessary packages installed and connect your GitHub account to allow your agents to utilize GitHub functionalities.
12
+
13
+ ```bash
14
+ # Install Composio LangChain package
15
+ pip install composio-google
16
+
17
+ # Connect your GitHub account
18
+ composio-cli add github
19
+
20
+ # View available applications you can connect with
21
+ composio-cli show-apps
22
+ ```
23
+
24
+ ### Usage Steps
25
+
26
+ #### 1. Import Base Packages
27
+
28
+ Prepare your environment by initializing necessary imports from Google AI Python and setting up your client.
29
+
30
+ ```python
31
+ from vertexai.generative_models import GenerativeModel
32
+
33
+ # Initialize Google AI Python client
34
+ model = GenerativeModel("gemini-pro")
35
+ ```
36
+
37
+ ### Step 2: Integrating GitHub Tools with Composio
38
+
39
+ This step involves fetching and integrating GitHub tools provided by Composio, enabling enhanced functionality for Google AI Python operations.
40
+ ```python
41
+ from composio_google import App, ComposioToolset
42
+
43
+ toolset = ComposioToolset()
44
+ actions = toolset.get_tools(apps=[App.GITHUB])
45
+ ```
46
+
47
+ ### Step 3: Agent Execution
48
+
49
+ This step involves configuring and executing the agent to carry out actions, such as starring a GitHub repository.
50
+
51
+ ```python
52
+ # Define task
53
+ task = "Star a repo composiohq/composio on GitHub"
54
+
55
+ # Send a message to the model
56
+ response = chat.send_message(task)
57
+ ```
58
+
59
+ ### Step 4: Validate Execution Response
60
+
61
+ Execute the following code to validate the response, ensuring that the intended task has been successfully completed.
62
+
63
+ ```python
64
+ result = composio_toolset.handle_response(response)
65
+ print("Function call result:", result)
66
+ ```
@@ -0,0 +1,13 @@
1
+ from composio_google.toolset import ComposioToolset
2
+
3
+ from composio import Action, App, Tag, Trigger, WorkspaceType
4
+
5
+
6
+ __all__ = (
7
+ "Action",
8
+ "App",
9
+ "Tag",
10
+ "Trigger",
11
+ "WorkspaceType",
12
+ "ComposioToolset",
13
+ )
@@ -0,0 +1,213 @@
1
+ """
2
+ Google AI Python Gemini tool spec.
3
+ """
4
+
5
+ import typing as t
6
+
7
+ import typing_extensions as te
8
+ from proto.marshal.collections.maps import MapComposite
9
+ from vertexai.generative_models import (
10
+ Content,
11
+ FunctionDeclaration,
12
+ GenerationResponse,
13
+ Part,
14
+ Tool,
15
+ )
16
+
17
+ from composio import Action, ActionType, AppType, TagType
18
+ from composio.constants import DEFAULT_ENTITY_ID
19
+ from composio.tools import ComposioToolSet as BaseComposioToolSet
20
+ from composio.utils.shared import json_schema_to_model
21
+
22
+
23
+ class ComposioToolset(
24
+ BaseComposioToolSet,
25
+ runtime="google_ai",
26
+ description_char_limit=1024,
27
+ ):
28
+ """
29
+ Composio toolset for Google AI Python Gemini framework.
30
+
31
+ Example:
32
+ ```python
33
+ import os
34
+ import dotenv
35
+ from vertexai.generative_models import GenerativeModel
36
+ from composio_google import ComposioToolSet, App
37
+
38
+ # Load environment variables from .env
39
+ dotenv.load_dotenv()
40
+
41
+ # Initialize tools
42
+ composio_toolset = ComposioToolSet()
43
+
44
+ # Get GitHub tools that are pre-configured
45
+ tools = composio_toolset.get_tools(apps=[App.GITHUB])
46
+
47
+ # Initialize the Gemini model
48
+ model = GenerativeModel("gemini-pro", tools=tools)
49
+
50
+ # Start a chat
51
+ chat = model.start_chat()
52
+
53
+ # Define task
54
+ task = "Star a repo composiohq/composio on GitHub"
55
+
56
+ # Send a message to the model
57
+ response = chat.send_message(task)
58
+
59
+ print(response.text)
60
+
61
+ # Handle function calls if any
62
+ result = composio_toolset.handle_response(response)
63
+ if result:
64
+ print(result)
65
+ ```
66
+ """
67
+
68
+ def validate_entity_id(self, entity_id: str) -> str:
69
+ """Validate entity ID."""
70
+ if (
71
+ self.entity_id != DEFAULT_ENTITY_ID
72
+ and entity_id != DEFAULT_ENTITY_ID
73
+ and self.entity_id != entity_id
74
+ ):
75
+ raise ValueError(
76
+ "separate `entity_id` can not be provided during "
77
+ "initialization and handling tool calls"
78
+ )
79
+ if self.entity_id != DEFAULT_ENTITY_ID:
80
+ entity_id = self.entity_id
81
+ return entity_id
82
+
83
+ def _wrap_tool(
84
+ self,
85
+ schema: t.Dict[str, t.Any],
86
+ ) -> FunctionDeclaration:
87
+ """Wraps composio tool as Google AI Python Gemini FunctionDeclaration object."""
88
+ action = schema["name"]
89
+ description = schema.get("description", action)
90
+ parameters = json_schema_to_model(schema["parameters"])
91
+
92
+ # Clean up properties by removing 'examples' field
93
+ properties = parameters.schema().get("properties", {})
94
+ cleaned_properties = {
95
+ prop_name: {k: v for k, v in prop_schema.items() if k != "examples"}
96
+ for prop_name, prop_schema in properties.items()
97
+ }
98
+
99
+ # Create cleaned parameters
100
+ cleaned_parameters = {
101
+ "type": "object",
102
+ "properties": cleaned_properties,
103
+ "required": parameters.schema().get("required", []),
104
+ }
105
+
106
+ return FunctionDeclaration(
107
+ name=action,
108
+ description=description,
109
+ parameters=cleaned_parameters,
110
+ )
111
+
112
+ @te.deprecated("Use `ComposioToolSet.get_tools` instead")
113
+ def get_actions(
114
+ self,
115
+ actions: t.Sequence[ActionType],
116
+ entity_id: t.Optional[str] = None,
117
+ ) -> Tool:
118
+ """
119
+ Get composio tools wrapped as Google AI Python Gemini FunctionDeclaration objects.
120
+
121
+ :param actions: List of actions to wrap
122
+ :param entity_id: Entity ID for the function wrapper
123
+
124
+ :return: Composio tools wrapped as `FunctionDeclaration` objects
125
+ """
126
+ return self.get_tool(actions=actions, entity_id=entity_id)
127
+
128
+ def get_tool(
129
+ self,
130
+ actions: t.Optional[t.Sequence[ActionType]] = None,
131
+ apps: t.Optional[t.Sequence[AppType]] = None,
132
+ tags: t.Optional[t.List[TagType]] = None,
133
+ entity_id: t.Optional[str] = None,
134
+ ) -> Tool:
135
+ """
136
+ Get composio tools wrapped as Google AI Python Gemini FunctionDeclaration objects.
137
+
138
+ :param actions: List of actions to wrap
139
+ :param apps: List of apps to wrap
140
+ :param tags: Filter the apps by given tags
141
+ :param entity_id: Entity ID for the function wrapper
142
+
143
+ :return: Composio tools wrapped as `FunctionDeclaration` objects
144
+ """
145
+ entity_id = self.validate_entity_id(entity_id or self.entity_id)
146
+ self.validate_tools(apps=apps, actions=actions, tags=tags)
147
+ return Tool(
148
+ function_declarations=[
149
+ self._wrap_tool(
150
+ schema=tool.model_dump(
151
+ exclude_none=True,
152
+ ),
153
+ )
154
+ for tool in self.get_action_schemas(
155
+ actions=actions, apps=apps, tags=tags
156
+ )
157
+ ]
158
+ )
159
+
160
+ def execute_function_call(
161
+ self,
162
+ function_call: t.Any,
163
+ entity_id: t.Optional[str] = DEFAULT_ENTITY_ID,
164
+ ) -> t.Dict:
165
+ """
166
+ Execute a function call.
167
+
168
+ :param function_call: Function call metadata from Gemini model response.
169
+ :param entity_id: Entity ID to use for executing the function call.
170
+ :return: Object containing output data from the function call.
171
+ """
172
+ entity_id = self.validate_entity_id(entity_id or self.entity_id)
173
+
174
+ def convert_map_composite(obj):
175
+ if isinstance(obj, MapComposite):
176
+ return {k: convert_map_composite(v) for k, v in obj.items()}
177
+ if isinstance(obj, (list, tuple)):
178
+ return [convert_map_composite(item) for item in obj]
179
+ return obj
180
+
181
+ args = convert_map_composite(function_call.args)
182
+
183
+ return self.execute_action(
184
+ action=Action(value=function_call.name),
185
+ params=args,
186
+ entity_id=entity_id,
187
+ )
188
+
189
+ def handle_response(
190
+ self,
191
+ response: GenerationResponse,
192
+ entity_id: t.Optional[str] = None,
193
+ ) -> t.List[t.Dict]:
194
+ """
195
+ Handle response from Google AI Python Gemini model.
196
+
197
+ :param response: Generation response from the Gemini model.
198
+ :param entity_id: Entity ID to use for executing the function call.
199
+ :return: A list of output objects from the function calls.
200
+ """
201
+ entity_id = self.validate_entity_id(entity_id or self.entity_id)
202
+ outputs = []
203
+ for candidate in response.candidates:
204
+ if isinstance(candidate.content, Content) and candidate.content.parts:
205
+ for part in candidate.content.parts:
206
+ if isinstance(part, Part) and part.function_call:
207
+ outputs.append(
208
+ self.execute_function_call(
209
+ function_call=part.function_call,
210
+ entity_id=entity_id,
211
+ )
212
+ )
213
+ return outputs
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.1
2
+ Name: composio_google
3
+ Version: 0.5.26
4
+ Summary: Use Composio to get an array of tools with your Google AI Python Gemini model.
5
+ Home-page: https://github.com/ComposioHQ/composio
6
+ Author: Assistant
7
+ Author-email: karan@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.9,<4
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: composio_core==0.5.26
14
+ Requires-Dist: google-cloud-aiplatform>=1.38.0
15
+
16
+ ## 🚀🔗 Integrating Composio with Google AI Python
17
+
18
+ Streamline the integration of Composio with Google AI Python to enhance the capabilities of Gemini models, allowing them to interact directly with external applications and expanding their operational scope.
19
+
20
+ ### Objective
21
+
22
+ - **Automate starring a GitHub repository** using conversational instructions via Google AI Python's Function Calling feature.
23
+
24
+ ### Installation and Setup
25
+
26
+ Ensure you have the necessary packages installed and connect your GitHub account to allow your agents to utilize GitHub functionalities.
27
+
28
+ ```bash
29
+ # Install Composio LangChain package
30
+ pip install composio-google
31
+
32
+ # Connect your GitHub account
33
+ composio-cli add github
34
+
35
+ # View available applications you can connect with
36
+ composio-cli show-apps
37
+ ```
38
+
39
+ ### Usage Steps
40
+
41
+ #### 1. Import Base Packages
42
+
43
+ Prepare your environment by initializing necessary imports from Google AI Python and setting up your client.
44
+
45
+ ```python
46
+ from vertexai.generative_models import GenerativeModel
47
+
48
+ # Initialize Google AI Python client
49
+ model = GenerativeModel("gemini-pro")
50
+ ```
51
+
52
+ ### Step 2: Integrating GitHub Tools with Composio
53
+
54
+ This step involves fetching and integrating GitHub tools provided by Composio, enabling enhanced functionality for Google AI Python operations.
55
+ ```python
56
+ from composio_google import App, ComposioToolset
57
+
58
+ toolset = ComposioToolset()
59
+ actions = toolset.get_tools(apps=[App.GITHUB])
60
+ ```
61
+
62
+ ### Step 3: Agent Execution
63
+
64
+ This step involves configuring and executing the agent to carry out actions, such as starring a GitHub repository.
65
+
66
+ ```python
67
+ # Define task
68
+ task = "Star a repo composiohq/composio on GitHub"
69
+
70
+ # Send a message to the model
71
+ response = chat.send_message(task)
72
+ ```
73
+
74
+ ### Step 4: Validate Execution Response
75
+
76
+ Execute the following code to validate the response, ensuring that the intended task has been successfully completed.
77
+
78
+ ```python
79
+ result = composio_toolset.handle_response(response)
80
+ print("Function call result:", result)
81
+ ```
@@ -0,0 +1,9 @@
1
+ README.md
2
+ setup.py
3
+ composio_google/__init__.py
4
+ composio_google/toolset.py
5
+ composio_google.egg-info/PKG-INFO
6
+ composio_google.egg-info/SOURCES.txt
7
+ composio_google.egg-info/dependency_links.txt
8
+ composio_google.egg-info/requires.txt
9
+ composio_google.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ composio_core==0.5.26
2
+ google-cloud-aiplatform>=1.38.0
@@ -0,0 +1 @@
1
+ composio_google
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,30 @@
1
+ """
2
+ Setup configuration for Composio Google AI Python Gemini plugin
3
+ """
4
+
5
+ from pathlib import Path
6
+
7
+ from setuptools import setup
8
+
9
+
10
+ setup(
11
+ name="composio_google",
12
+ version="0.5.26",
13
+ author="Assistant",
14
+ author_email="karan@composio.dev",
15
+ description="Use Composio to get an array of tools with your Google AI Python Gemini model.",
16
+ long_description=(Path(__file__).parent / "README.md").read_text(encoding="utf-8"),
17
+ long_description_content_type="text/markdown",
18
+ url="https://github.com/ComposioHQ/composio",
19
+ classifiers=[
20
+ "Programming Language :: Python :: 3",
21
+ "License :: OSI Approved :: Apache Software License",
22
+ "Operating System :: OS Independent",
23
+ ],
24
+ python_requires=">=3.9,<4",
25
+ install_requires=[
26
+ "composio_core==0.5.26",
27
+ "google-cloud-aiplatform>=1.38.0",
28
+ ],
29
+ include_package_data=True,
30
+ )