Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
md 56 lines 2.09 KB
Rendered Raw
1 # composio-google
2
3 Adapts Composio tools to the Vertex AI SDK (`vertexai.generative_models`) as `FunctionDeclaration` objects for Gemini function calling.
4
5 ## Installation
6
7 ```bash
8 pip install composio composio-google google-cloud-aiplatform
9 ```
10
11 Set `COMPOSIO_API_KEY` (create one at https://dashboard.composio.dev/settings) in your environment. Vertex AI authenticates with Google Cloud credentials; run `gcloud auth application-default login` or set `GOOGLE_APPLICATION_CREDENTIALS`.
12
13 ## Quickstart
14
15 `GoogleProvider` is non-agentic: the model returns function calls, and `composio.provider.handle_response` executes every function call in the response through the session and returns the results.
16
17 ```python
18 import vertexai
19 from vertexai.generative_models import GenerativeModel, Tool
20
21 from composio import Composio
22 from composio_google import GoogleProvider
23
24 vertexai.init(project="your-gcp-project", location="us-central1")
25
26 composio = Composio(provider=GoogleProvider())
27
28 # Create a session for your user
29 session = composio.create(user_id="user_123")
30 tools = session.tools()
31
32 model = GenerativeModel(
33 "gemini-3.7-flash",
34 tools=[Tool(function_declarations=tools)],
35 )
36 chat = model.start_chat()
37
38 response = chat.send_message(
39 "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'"
40 )
41
42 # Execute the function calls the model requested
43 results = composio.provider.handle_response(session=session, response=response)
44 print(results)
45 ```
46
47 To execute a single call instead of the whole response, use `composio.provider.execute_tool_call(session=session, function_call=part.function_call)`. For tools fetched with `composio.tools.get()`, pass `user_id=` instead of `session=`.
48
49 ## composio-google vs composio-gemini
50
51 This package targets the Vertex AI SDK (`vertexai.generative_models`, installed via `google-cloud-aiplatform`). [`composio-gemini`](../gemini) targets the newer `google-genai` SDK with Automatic Function Calling. For new projects, use `composio-gemini`.
52
53 ## Links
54
55 - Google provider docs: https://docs.composio.dev/docs/providers/google
56 - Composio docs: https://docs.composio.dev