composio-gemini 0.7.17__py3-none-any.whl → 1.0.0rc1__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.
@@ -1,14 +1,6 @@
1
- from composio import Action, App, Tag, Trigger, WorkspaceType, action
2
-
3
- from .toolset import ComposioToolSet
1
+ from .provider import GeminiProvider
4
2
 
5
3
 
6
4
  __all__ = (
7
- "Action",
8
- "App",
9
- "Tag",
10
- "Trigger",
11
- "WorkspaceType",
12
- "action",
13
- "ComposioToolSet",
5
+ "GeminiProvider",
14
6
  )
@@ -0,0 +1,60 @@
1
+ import types
2
+ import typing as t
3
+ from inspect import Signature
4
+
5
+ from composio.client.types import Tool
6
+ from composio.core.provider import AgenticProvider
7
+ from composio.core.provider.agentic import AgenticProviderExecuteFn
8
+ from composio.utils.openapi import function_signature_from_jsonschema
9
+
10
+
11
+ class GeminiProvider(AgenticProvider[t.Callable, list[t.Callable]], name="gemini"):
12
+ """
13
+ Composio toolset for Google AI Python Gemini framework.
14
+ """
15
+
16
+ def wrap_tool(
17
+ self,
18
+ tool: Tool,
19
+ execute_tool: AgenticProviderExecuteFn,
20
+ ) -> t.Callable:
21
+ """Wraps composio tool as Google Genai SDK compatible function calling object."""
22
+
23
+ docstring = tool.description
24
+ docstring += "\nArgs:"
25
+ for _param, _schema in tool.input_parameters["properties"].items(): # type: ignore
26
+ docstring += "\n "
27
+ docstring += _param + ": " + _schema.get("description", _param.title())
28
+
29
+ docstring += "\nReturns:"
30
+ docstring += "\n A dictionary containing response from the action"
31
+
32
+ def _execute(**kwargs: t.Any) -> t.Dict:
33
+ return execute_tool(slug=tool.slug, arguments=kwargs)
34
+
35
+ function = types.FunctionType(
36
+ code=_execute.__code__,
37
+ name=tool.slug,
38
+ globals=globals(),
39
+ closure=_execute.__closure__,
40
+ )
41
+ parameters = function_signature_from_jsonschema(
42
+ schema=tool.input_parameters,
43
+ skip_default=True,
44
+ )
45
+ setattr(function, "__signature__", Signature(parameters=parameters))
46
+ setattr(
47
+ function,
48
+ "__annotations__",
49
+ {p.name: p.annotation for p in parameters} | {"return": dict},
50
+ )
51
+ function.__doc__ = docstring
52
+ return function
53
+
54
+ def wrap_tools(
55
+ self,
56
+ tools: t.Sequence[Tool],
57
+ execute_tool: AgenticProviderExecuteFn,
58
+ ) -> list[t.Callable]:
59
+ """Get composio tools wrapped as Google Genai SDK compatible function calling object."""
60
+ return [self.wrap_tool(tool, execute_tool) for tool in tools]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: composio_gemini
3
- Version: 0.7.17
3
+ Version: 1.0.0rc1
4
4
  Summary: Use Composio to get an array of tools with your Gemini agent.
5
5
  Home-page: https://github.com/ComposioHQ/composio
6
6
  Author: Composio
@@ -10,7 +10,6 @@ Classifier: License :: OSI Approved :: Apache Software License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.9,<4
12
12
  Description-Content-Type: text/markdown
13
- Requires-Dist: composio_core<0.8.0,>=0.7.0
14
13
  Requires-Dist: google-genai
15
14
  Dynamic: author
16
15
  Dynamic: author-email
@@ -0,0 +1,6 @@
1
+ composio_gemini/__init__.py,sha256=9S9oUYw-AB66xkTGxivUZkKGMC_gWEb9ylhNeMxT8Ik,75
2
+ composio_gemini/provider.py,sha256=1rKIAzXasJsAuU_OL1Ht-XBAMdsGD0tKnFV0cmSR1D4,2104
3
+ composio_gemini-1.0.0rc1.dist-info/METADATA,sha256=plNx2TxwguYHgpKm5Xvi8WSWYbVE9Pc1BCRGTGq3TeA,2652
4
+ composio_gemini-1.0.0rc1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
+ composio_gemini-1.0.0rc1.dist-info/top_level.txt,sha256=OXlT1cwZ_H8zLnD-WjZOokKdqRgsq5cqhx0uCnxCikk,16
6
+ composio_gemini-1.0.0rc1.dist-info/RECORD,,
@@ -1,124 +0,0 @@
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.openapi import function_signature_from_jsonschema
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
- skip_default: bool = False,
56
- ) -> t.Callable:
57
- """Wraps composio tool as Google Genai SDK compatible function calling object."""
58
-
59
- docstring = schema.description
60
- docstring += "\nArgs:"
61
- for _param, _schema in schema.parameters.properties.items():
62
- docstring += "\n "
63
- docstring += _param + ": " + _schema.get("description", _param.title())
64
-
65
- docstring += "\nReturns:"
66
- docstring += "\n A dictionary containing response from the action"
67
-
68
- def _execute(**kwargs: t.Any) -> t.Dict:
69
- return self.execute_action(
70
- action=schema.name,
71
- params=kwargs,
72
- entity_id=entity_id,
73
- )
74
-
75
- function = types.FunctionType(
76
- code=_execute.__code__,
77
- name=schema.name,
78
- globals=globals(),
79
- closure=_execute.__closure__,
80
- )
81
- parameters = function_signature_from_jsonschema(
82
- schema=schema.parameters.model_dump(exclude_none=True),
83
- skip_default=skip_default,
84
- )
85
- setattr(function, "__signature__", Signature(parameters=parameters))
86
- setattr(
87
- function,
88
- "__annotations__",
89
- {p.name: p.annotation for p in parameters} | {"return": dict},
90
- )
91
- function.__doc__ = docstring
92
- return function
93
-
94
- def get_tools(
95
- self,
96
- actions: t.Optional[t.Sequence[ActionType]] = None,
97
- apps: t.Optional[t.Sequence[AppType]] = None,
98
- tags: t.Optional[t.List[TagType]] = None,
99
- *,
100
- entity_id: t.Optional[str] = None,
101
- skip_default: bool = False,
102
- check_connected_accounts: bool = True,
103
- ) -> t.List[t.Callable]:
104
- """
105
- Get composio tools wrapped as Google Genai SDK compatible function calling object.
106
-
107
- :param actions: List of actions to wrap
108
- :param apps: List of apps to wrap
109
- :param tags: Filter the apps by given tags
110
- :param entity_id: Entity ID for the function wrapper
111
-
112
- :return: Composio tools wrapped as python callable
113
- """
114
- self.validate_tools(apps=apps, actions=actions, tags=tags)
115
- return [
116
- self._wrap_tool(schema=tool, entity_id=entity_id, skip_default=skip_default)
117
- for tool in self.get_action_schemas(
118
- actions=actions,
119
- apps=apps,
120
- tags=tags,
121
- _populate_requested=True,
122
- check_connected_accounts=check_connected_accounts,
123
- )
124
- ]
@@ -1,6 +0,0 @@
1
- composio_gemini/__init__.py,sha256=6sKzEl6ZrosTaUQ3SiE0qioM2gD2izRvjU4DerbuAN8,233
2
- composio_gemini/toolset.py,sha256=QxkIiJtKjcPAZV6siCGhGVhEahzkmjRn88DIav8dPXg,4041
3
- composio_gemini-0.7.17.dist-info/METADATA,sha256=yqWl74YQqKQ4Nn3CLA9A-GRbne5_JhBAUp5TArXxSSg,2693
4
- composio_gemini-0.7.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
- composio_gemini-0.7.17.dist-info/top_level.txt,sha256=OXlT1cwZ_H8zLnD-WjZOokKdqRgsq5cqhx0uCnxCikk,16
6
- composio_gemini-0.7.17.dist-info/RECORD,,