forked from ComposioHQ/composio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogle_adk_demo.py
More file actions
62 lines (55 loc) · 1.48 KB
/
Copy pathgoogle_adk_demo.py
File metadata and controls
62 lines (55 loc) · 1.48 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from composio_google_adk import GoogleAdkProvider
from google.adk.agents import Agent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types
from composio import Composio
# ADK config
model = "gemini-2.0-flash"
app_name = "weather_sentiment_agent"
session_id = "1234"
user_id = "user1234"
# Initialize composio tools
composio = Composio(provider=GoogleAdkProvider())
tools = composio.tools.get(user_id=user_id, toolkits=["GITHUB"])
# Agent
weather_sentiment_agent = Agent(
name=app_name,
model=model,
instruction="You are a github utility agent with ability to interact with github APIs",
tools=tools,
)
# Session and Runner
session_service = InMemorySessionService()
session = session_service.create_session_sync(
app_name=app_name,
user_id=user_id,
session_id=session_id,
)
runner = Runner(
agent=weather_sentiment_agent,
app_name=app_name,
session_service=session_service,
)
# Agent Interaction
content = types.Content(
role="user",
parts=[
types.Part(
text="Star github repository composiohq/composio",
)
],
)
events = runner.run(
user_id=user_id,
session_id=session_id,
new_message=content,
)
for event in events:
if (
event.is_final_response()
and event.content is not None
and event.content.parts
and len(event.content.parts) > 0
):
print("Agent Response: ", event.content.parts[0].text)