composio-gemini 0.7.1__py3-none-any.whl

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,16 @@
1
+ from composio import WorkspaceType, action
2
+
3
+ from composio_langchain import Action, App, Tag, Trigger
4
+
5
+ from .toolset import ComposioToolSet
6
+
7
+
8
+ __all__ = (
9
+ "Action",
10
+ "App",
11
+ "Tag",
12
+ "Trigger",
13
+ "WorkspaceType",
14
+ "action",
15
+ "ComposioToolSet",
16
+ )
@@ -0,0 +1,118 @@
1
+ import types
2
+ import typing as t
3
+ from inspect import Signature
4
+
5
+ from composio import ActionType, AppType, TagType
6
+ from composio.client.collections import ActionModel
7
+ from composio.tools import ComposioToolSet as BaseComposioToolSet
8
+ from composio.utils.shared import get_signature_format_from_schema_params
9
+
10
+
11
+ class ComposioToolSet(
12
+ BaseComposioToolSet,
13
+ runtime="google_gemini",
14
+ description_char_limit=1024,
15
+ action_name_char_limit=64,
16
+ ):
17
+ """
18
+ Composio toolset for Google AI Python Gemini framework.
19
+
20
+ Example:
21
+ ```python
22
+ from google import genai
23
+ from google.genai import types
24
+
25
+ from composio_gemini import Action, ComposioToolSet
26
+
27
+
28
+ # Create composio client
29
+ toolset = ComposioToolSet()
30
+
31
+ # Create google client
32
+ client = genai.Client()
33
+
34
+ # Create genai client config
35
+ config = types.GenerateContentConfig(
36
+ tools=toolset.get_tools( # type: ignore
37
+ actions=[
38
+ Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER,
39
+ ]
40
+ )
41
+ )
42
+ # Use the chat interface.
43
+ chat = client.chats.create(model="gemini-2.0-flash", config=config)
44
+ response = chat.send_message(
45
+ "Can you star composiohq/composio repository on github",
46
+ )
47
+ print(response.text)
48
+ ```
49
+ """
50
+
51
+ def _wrap_tool(
52
+ self,
53
+ schema: ActionModel,
54
+ entity_id: t.Optional[str] = None,
55
+ ) -> t.Callable:
56
+ """Wraps composio tool as Google Genai SDK compatible function calling object."""
57
+
58
+ docstring = schema.description
59
+ docstring += "\nArgs:"
60
+ for _param, _schema in schema.parameters.properties.items():
61
+ docstring += "\n "
62
+ docstring += _param + ": " + _schema.get("description", _param.title())
63
+
64
+ docstring += "\nReturns:"
65
+ docstring += "\n A dictionary containing response from the action"
66
+
67
+ def _execute(**kwargs: t.Any) -> t.Dict:
68
+ return self.execute_action(
69
+ action=schema.name,
70
+ params=kwargs,
71
+ entity_id=entity_id,
72
+ )
73
+
74
+ function = types.FunctionType(
75
+ code=_execute.__code__,
76
+ name=schema.name,
77
+ globals=globals(),
78
+ closure=_execute.__closure__,
79
+ )
80
+ parameters = get_signature_format_from_schema_params(
81
+ schema_params=schema.parameters.model_dump(),
82
+ )
83
+ setattr(function, "__signature__", Signature(parameters=parameters))
84
+ setattr(
85
+ function,
86
+ "__annotations__",
87
+ {p.name: p.annotation for p in parameters} | {"return": dict},
88
+ )
89
+ function.__doc__ = docstring
90
+ return function
91
+
92
+ def get_tools(
93
+ self,
94
+ actions: t.Optional[t.Sequence[ActionType]] = None,
95
+ apps: t.Optional[t.Sequence[AppType]] = None,
96
+ tags: t.Optional[t.List[TagType]] = None,
97
+ entity_id: t.Optional[str] = None,
98
+ ) -> t.List[t.Callable]:
99
+ """
100
+ Get composio tools wrapped as Google Genai SDK compatible function calling object.
101
+
102
+ :param actions: List of actions to wrap
103
+ :param apps: List of apps to wrap
104
+ :param tags: Filter the apps by given tags
105
+ :param entity_id: Entity ID for the function wrapper
106
+
107
+ :return: Composio tools wrapped as python callable
108
+ """
109
+ self.validate_tools(apps=apps, actions=actions, tags=tags)
110
+ return [
111
+ self._wrap_tool(schema=tool, entity_id=entity_id)
112
+ for tool in self.get_action_schemas(
113
+ actions=actions,
114
+ apps=apps,
115
+ tags=tags,
116
+ _populate_requested=True,
117
+ )
118
+ ]
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.2
2
+ Name: composio_gemini
3
+ Version: 0.7.1
4
+ Summary: Use Composio to get an array of tools with your Gemini agent.
5
+ Home-page: https://github.com/ComposioHQ/composio
6
+ Author: Composio
7
+ Author-email: tech@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.8.0,>=0.7.0
14
+ Requires-Dist: google-genai
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: requires-dist
22
+ Dynamic: requires-python
23
+ Dynamic: summary
24
+
25
+ ## 🚀🔗 Integrating Composio with Google's Gemini SDK
26
+
27
+ 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.
28
+
29
+ ### Objective
30
+
31
+ - **Automate starring a GitHub repository** using conversational instructions via Google AI Python's Function Calling feature.
32
+
33
+ ### Installation and Setup
34
+
35
+ Ensure you have the necessary packages installed and connect your GitHub account to allow your agents to utilize GitHub functionalities.
36
+
37
+ ```bash
38
+ # Install Composio Gemini package
39
+ pip install composio-gemini
40
+
41
+ # Connect your GitHub account
42
+ composio add github
43
+
44
+ # View available applications you can connect with
45
+ composio apps
46
+ ```
47
+
48
+ ### Usage Steps
49
+
50
+ #### 1. Import Base Packages
51
+
52
+ Prepare your environment by initializing necessary imports from Google AI Python and setting up your client.
53
+
54
+ ```python
55
+ from google import genai
56
+
57
+ # Create google client
58
+ client = genai.Client()
59
+ ```
60
+
61
+ ### Step 2: Integrating GitHub Tools with Composio
62
+
63
+ This step involves fetching and integrating GitHub tools provided by Composio, enabling enhanced functionality for Google AI Python operations.
64
+ ```python
65
+ from google.genai import types
66
+
67
+ from composio_gemini import Action, ComposioToolSet
68
+
69
+ # Create composio client
70
+ toolset = ComposioToolSet()
71
+
72
+ # Create tools
73
+ tools = toolset.get_tools(
74
+ actions=[
75
+ Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER,
76
+ ]
77
+ )
78
+
79
+ # Create genai client config
80
+ config = types.GenerateContentConfig(
81
+ tools=tools, # type: ignore
82
+ )
83
+ ```
84
+
85
+ ### Step 3: Agent Execution
86
+
87
+ This step involves configuring and executing the agent to carry out actions, such as starring a GitHub repository.
88
+
89
+ ```python
90
+ # Use the chat interface.
91
+ chat = client.chats.create(model="gemini-2.0-flash", config=config)
92
+ response = chat.send_message(
93
+ "Can you star composiohq/composio repository on github",
94
+ )
95
+ print(response.text)
96
+ ```
@@ -0,0 +1,6 @@
1
+ composio_gemini/__init__.py,sha256=K-52LhU-kCkRQGeydL0TiO-oWYgDdHjuN_Fua1BenGg,264
2
+ composio_gemini/toolset.py,sha256=aWJaNEj73Vh5C90Kcl9HcFfPjfVKTFTzCXSRUX3F9_4,3777
3
+ composio_gemini-0.7.1.dist-info/METADATA,sha256=KggA07R20U3Bcn_H9KNG8PeLVKK97DR0nvjWbpCg5lk,2692
4
+ composio_gemini-0.7.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
5
+ composio_gemini-0.7.1.dist-info/top_level.txt,sha256=OXlT1cwZ_H8zLnD-WjZOokKdqRgsq5cqhx0uCnxCikk,16
6
+ composio_gemini-0.7.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.8.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ composio_gemini