forked from ComposioHQ/composio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogle_demo.py
More file actions
43 lines (29 loc) · 947 Bytes
/
Copy pathgoogle_demo.py
File metadata and controls
43 lines (29 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
Google AI Python Gemini demo.
"""
import dotenv
from composio_google import GoogleProvider
from vertexai.generative_models import GenerativeModel
from composio import Composio
# Load environment variables from .env
dotenv.load_dotenv()
# Initialize tools
composio = Composio(provider=GoogleProvider())
# Get GitHub tools that are pre-configured
tool = composio.tools.get(user_id="default", toolkits=["GITHUB"])
# Initialize the Gemini model
model = GenerativeModel("gemini-1.5-pro", tools=[tool])
# Start a chat session
chat = model.start_chat()
def main():
# Define task
task = "Star a repo composiohq/composio on GitHub"
# Send a message to the model
response = chat.send_message(task)
print("Model response:")
print(response)
result = composio.provider.handle_response(user_id="default", response=response)
print("Function call result:")
print(result)
if __name__ == "__main__":
main()