Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/actions/run-adk-agent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Run ADK Agent

A reusable GitHub Action that runs `gradient agent run` to validate an ADK agent starts and is available at http://localhost:8080.

## Usage

```yaml
- uses: actions/checkout@v4
- uses: ./.github/actions/run-adk-agent
with:
working-directory: WebSearch
digitalocean-inference-key: ${{ secrets.DIGITALOCEAN_INFERENCE_KEY }}
```

## Inputs

| Input | Required | Default | Description |
|-------|----------|---------|-------------|
| `working-directory` | Yes | - | Path to agent directory (e.g., WebSearch, StateGraph, RAG) |
| `digitalocean-inference-key` | Yes | - | DigitalOcean GenAI inference key for LLM calls |
| `python-version` | No | `3.10` | Python version |
| `openai-api-key` | No | - | OpenAI API key (for RAG embeddings; not needed for WebSearch) |

## Secrets Setup

Add the required secret in your GitHub repo before the workflow can run:

1. Go to your repo on GitHub → **Settings** → **Secrets and variables** → **Actions**
2. Click **New repository secret**
3. Name: `DIGITALOCEAN_INFERENCE_KEY`
4. Value: Your DigitalOcean GenAI inference key (from [GenAI Settings](https://cloud.digitalocean.com/gen-ai))
5. Click **Add secret**

The secret is stored encrypted by GitHub and never shown in logs or to contributors.

## Secrets by Template

| Template | Required | Optional |
|----------|----------|----------|
| WebSearch | `DIGITALOCEAN_INFERENCE_KEY` | - |
| StateGraph | `DIGITALOCEAN_INFERENCE_KEY` | - |
| RAG | `DIGITALOCEAN_INFERENCE_KEY` | `OPENAI_API_KEY` |
| Others | See template `.env.example` | - |

## GitHub Enterprise

Works on GitHub.com and GitHub Enterprise Server. Uses standard `actions/checkout` and `actions/setup-python`.
39 changes: 39 additions & 0 deletions .github/actions/run-adk-agent/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Run ADK Agent'
description: 'Run gradient agent run to validate agent starts and is available at http://localhost:8080'
inputs:
working-directory:
required: true
description: 'Path to agent directory (e.g., WebSearch, StateGraph)'
digitalocean-inference-key:
required: true
description: 'DigitalOcean inference key (for LLM)'
python-version:
required: false
default: '3.10'
openai-api-key:
required: false
description: 'OpenAI API key (for RAG embeddings; not needed for WebSearch)'
runs:
using: composite
steps:
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- run: pip install gradient-adk
shell: bash
- run: pip install -r requirements.txt
working-directory: ${{ inputs.working-directory }}
shell: bash
- run: |
gradient agent run &
for i in $(seq 1 30); do
curl -s -o /dev/null --connect-timeout 2 http://127.0.0.1:8080/ && { echo "Port 8080 is listening"; exit 0; }
sleep 2
done
echo "Agent failed to start within 60 seconds"
exit 1
working-directory: ${{ inputs.working-directory }}
shell: bash
env:
DIGITALOCEAN_INFERENCE_KEY: ${{ inputs.digitalocean-inference-key }}
OPENAI_API_KEY: ${{ inputs.openai-api-key }}
13 changes: 13 additions & 0 deletions .github/workflows/validate-websearch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
on:
pull_request:
paths: ['WebSearch/**']
workflow_dispatch:
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/run-adk-agent
with:
working-directory: WebSearch
digitalocean-inference-key: ${{ secrets.DIGITALOCEAN_INFERENCE_KEY }}
12 changes: 8 additions & 4 deletions WebSearch/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
from gradient_adk import entrypoint
from langchain_core.tools import tool
from langchain_core.prompts import ChatPromptTemplate
from langchain_gradient import ChatGradient
from langchain_core.messages import HumanMessage
from langchain.agents import create_agent
from langgraph.prebuilt import create_react_agent
from pydantic import BaseModel

from langchain_community.tools import DuckDuckGoSearchRun
Expand All @@ -25,9 +26,12 @@ def web_search(query: str) -> str:
model="openai-gpt-oss-120b",
)

agent = create_agent(
llm, tools=[web_search], system_prompt=SYSTEM_PROMPT
)
prompt = ChatPromptTemplate.from_messages([
("system", SYSTEM_PROMPT),
("placeholder", "{messages}"),
])

agent = create_react_agent(model=llm, tools=[web_search], prompt=prompt)


class Message(BaseModel):
Expand Down
10 changes: 5 additions & 5 deletions WebSearch/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
gradient-adk
langchain==1.0.0
langchain-core==1.2.11
langchain-community
langgraph==1.0.0
langchain-gradient>=0.1.0
langchain>=0.3.0,<0.4.0
langchain-core>=0.3.15,<0.4.0
langchain-community>=0.3.0
langgraph
langchain-gradient
pydantic>=2.6,<3
ddgs