Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | """ |
| 2 | Google AI Python Gemini demo. |
| 3 | """ |
| 4 | |
| 5 | import dotenv |
| 6 | from composio_google import GoogleProvider |
| 7 | from vertexai.generative_models import GenerativeModel |
| 8 | |
| 9 | from composio import Composio |
| 10 | |
| 11 | # Load environment variables from .env |
| 12 | dotenv.load_dotenv() |
| 13 | |
| 14 | # Initialize tools |
| 15 | composio = Composio(provider=GoogleProvider()) |
| 16 | |
| 17 | # Get GitHub tools that are pre-configured |
| 18 | tool = composio.tools.get(user_id="default", toolkits=["GITHUB"]) |
| 19 | |
| 20 | # Initialize the Gemini model |
| 21 | model = GenerativeModel("gemini-3.7-flash", tools=[tool]) |
| 22 | |
| 23 | # Start a chat session |
| 24 | chat = model.start_chat() |
| 25 | |
| 26 | |
| 27 | def main(): |
| 28 | # Define task |
| 29 | task = "Star a repo composiohq/composio on GitHub" |
| 30 | |
| 31 | # Send a message to the model |
| 32 | response = chat.send_message(task) |
| 33 | |
| 34 | print("Model response:") |
| 35 | print(response) |
| 36 | |
| 37 | result = composio.provider.handle_response(user_id="default", response=response) |
| 38 | print("Function call result:") |
| 39 | print(result) |
| 40 | |
| 41 | |
| 42 | if __name__ == "__main__": |
| 43 | main() |