Google ADK
This guide demonstrates how to use SEA-LION models as intelligent agents using Google's Agent Development Kit (ADK). The examples show how to build both general-purpose agents with multiple tools and specialized single-purpose agents.
Prerequisites
Python 3.9+
Google ADK installed (Quickstart)
SEA-LION API or Google Vertex AI access
Environment variables configured
The sample code in this guide will be configuring the model via SEA-LION API through LiteLLM, which follows an OpenAI-compatible format. Google ADK is also compatible with other model providers including Google's own Vertex AI. For configuring SEA-LION in Google ADK, you may refer to this page. Click here for instructions on deploying SEA-LION in Vertex AI.
Environment Setup
Create a .env file with your configuration:
## For using SEA-LION API, uncomment if needed
OPENAI_API_KEY=your-sea-lion-api-key-here
OPENAI_API_BASE=https://api.sea-lion.ai/v1
MODEL=aisingapore/Llama-SEA-LION-v3-70B-IT
## For using Google Vertex AI, uncomment if needed
# GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
# GOOGLE_CLOUD_LOCATION="YOUR_VERTEX_AI_LOCATION" # e.g., us-central1
GOOGLE_GENAI_USE_VERTEXAI=TRUE # Set to TRUE if NOT using Google AI Studio, due to function declaration issue: https://github.com/google/adk-python/issues/26#issuecomment-2911749485
# Environment variable for custom tool
SEARXNG_URL=https://your-searxng-instance-url-hereProject Structure
Basic Agent Setup
Here's how to create a basic SEA-LION agent with tool-calling capabilities:
agent.py
__init__.py
Custom Tool Development
You can create custom tools for your agents. Here's an example of custom web search tool using a locally-deployed SearXNG search engine:
tools.py
Agent as a Tool
Create a specialized agent that can be used as a tool by other agents:
translator.py
Running the Agent
Web Interface (Recommended)
Google ADK provides a built-in web interface. Simply run:
This will start a web server accessible at http://localhost:8000 using your agent.py configuration.
CLI Interface (Optional)
For command-line interaction, you can use the optional CLI script:
chat-cli.py
To run the CLI:
Best Practices
Model Selection
Use
aisingapore/Llama-SEA-LION-v3-70B-ITfor complex reasoning and tool-callingUse
aisingapore/Gemma-SEA-LION-v3-9B-ITfor specialized, single-purpose agents
Agent Configuration
Use clear, descriptive names for your agents
Provide specific instructions about tool usage guidelines
Include examples when tools have specific parameter formats
Clearly define the agent's role and capabilities
Session Management
Google ADK uses session-based interactions for maintaining context
Use
InMemorySessionServicefor development and testingConsider persistent session storage for production applications
More information and examples on session/memory management available here
Tool Documentation
Always provide clear docstrings for custom tools, including:
Purpose and functionality
Parameter descriptions with types
Return value format
Usage examples
Exception handling
Troubleshooting
Common Issues:
Tool not being called: Ensure your instruction mentions the tool and its use cases
LiteLLM connection errors: Verify your API keys and base URLs in the
.envfileFunction declaration issues: Set
GOOGLE_GENAI_USE_VERTEXAI=TRUEif not using Google AI StudioSession creation failures: Check your session service configuration and permissions
Async/await issues: Ensure proper async handling in CLI implementations
Performance Tips:
Use appropriate model sizes for your use case
Implement proper error handling and fallbacks
Monitor token usage to optimize costs
Google ADK Specific:
Web interface (
adk web) is the recommended way to interact with agentsCLI implementation requires proper session management
Agent composition using
AgentToolallows for specialised agents to do focused singular tasks. For using agents in a workflow or loop, consider the difference between sub-agents and agent tools. If it suits your use-case, you can explore workflow agents and sub-agents
Last updated