-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgoogle_agent.py
More file actions
60 lines (48 loc) · 1.83 KB
/
google_agent.py
File metadata and controls
60 lines (48 loc) · 1.83 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
from dotenv import load_dotenv
load_dotenv()
import os
from google.adk.agents import Agent
from google.adk.models.lite_llm import LiteLlm
from agentstr import NostrAgent, AgentCard, NostrAgentServer, NostrMCPClient
from agentstr.mcp.providers.google import to_google_tools
from agentstr.agents.providers.google import google_chat_generator
# Create Nostr MCP client
nostr_mcp_client = NostrMCPClient(relays=os.getenv("NOSTR_RELAYS").split(","),
private_key=os.getenv("GOOGLE_AGENT_NSEC"),
mcp_pubkey=os.getenv("MCP_SERVER_PUBKEY"),
nwc_str=os.getenv("MCP_CLIENT_NWC_CONN_STR"))
async def agent_server():
# Define tools
google_tools = await to_google_tools(nostr_mcp_client)
# Define Google agent
agent = Agent(
name="google_agent",
model=LiteLlm(
model=os.getenv("LLM_MODEL_NAME"),
api_base=os.getenv("LLM_BASE_URL").rstrip('/v1'),
api_key=os.getenv("LLM_API_KEY")
),
instruction="You are a helpful assistant.",
tools=google_tools,
)
# Define agent callable
#agent_callable = google_agent_callable(agent)
chat_generator = google_chat_generator(agent, [nostr_mcp_client])
# Create Nostr Agent
nostr_agent = NostrAgent(
agent_card=AgentCard(
name="Google Agent",
description="A helpful assistant",
skills=await nostr_mcp_client.get_skills(),
satoshis=2
),
chat_generator=chat_generator
)
# Create Nostr Agent Server
server = NostrAgentServer(nostr_mcp_client=nostr_mcp_client,
nostr_agent=nostr_agent)
# Start server
await server.start()
if __name__ == "__main__":
import asyncio
asyncio.run(agent_server())