Skip to content
Merged
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
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Auto Release when Tag
on:
push:
tags:
- 'v*'
- 'test/v*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: read

jobs:
release:
runs-on: [self-hosted, trpc-agent-python-ci]
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install release dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-test.txt
pip install build twine flake8 yapf

- name: Validate tag version
run: |
TAG_VERSION="${GITHUB_REF_NAME#test/v}"
TAG_VERSION="${TAG_VERSION#v}"
PACKAGE_VERSION=$(python -c "from trpc_agent_sdk.version import __version__; print(__version__)")
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "::error::Tag version '$TAG_VERSION' does not match package version '$PACKAGE_VERSION'."
exit 1
fi

- name: Get changed Python files
id: changed
run: |
FILES=$(git diff --name-only --diff-filter=ACM HEAD~1...HEAD -- '*.py' | grep '^trpc_agent_sdk/' || true)
if [ -z "$FILES" ]; then
echo "has_files=false" >> "$GITHUB_OUTPUT"
else
echo "has_files=true" >> "$GITHUB_OUTPUT"
echo "$FILES" > "$RUNNER_TEMP/changed_py_files.txt"
echo "Changed Python files:"
echo "$FILES"
fi

- name: Check formatting with YAPF
if: steps.changed.outputs.has_files == 'true'
run: |
FILES=$(cat "$RUNNER_TEMP/changed_py_files.txt" | tr '\n' ' ')
diff_output=$(yapf --diff $FILES) || true
if [ -n "$diff_output" ]; then
echo "$diff_output"
echo "::error::Code formatting check failed for changed files. Run 'yapf -i <file>' to fix."
exit 1
fi

- name: Lint with flake8
if: steps.changed.outputs.has_files == 'true'
run: |
FILES=$(cat "$RUNNER_TEMP/changed_py_files.txt" | tr '\n' ' ')
flake8 $FILES

- name: Run tests with coverage
run: |
pytest --cov=trpc_agent_sdk --cov-report=xml --cov-report=term --cov-fail-under=80 tests/

- name: Build package
run: |
python -m build

- name: Check package
run: |
python -m twine check dist/*

- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/v')
run: |
python -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
9 changes: 6 additions & 3 deletions examples/langgraph_agent/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ def build_calculator_subgraph():
api_key, url, model_name = get_model_config()
model = init_chat_model(
model_name,
model_provider="openai",
api_key=api_key,
api_base=url,
base_url=url,
)

tools = [calculate]
Expand Down Expand Up @@ -79,8 +80,9 @@ def build_graph_with_subgraph():
api_key, url, model_name = get_model_config()
model = init_chat_model(
model_name,
model_provider="openai",
api_key=api_key,
api_base=url,
base_url=url,
)

# Build calculator subgraph
Expand Down Expand Up @@ -126,8 +128,9 @@ def build_graph():
api_key, url, model_name = get_model_config()
model = init_chat_model(
model_name,
model_provider="openai",
api_key=api_key,
api_base=url,
base_url=url,
)

tools = [calculate]
Expand Down
3 changes: 2 additions & 1 deletion examples/langgraph_agent_with_cancel/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ def build_graph():
api_key, url, model_name = get_model_config()
model = init_chat_model(
model_name,
model_provider="openai",
api_key=api_key,
api_base=url,
base_url=url,
)

tools = [calculate, analyze_data]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ def _build_graph():
api_key, url, model_name = get_model_config()
model = init_chat_model(
model_name,
model_provider="openai",
api_key=api_key,
api_base=url,
base_url=url,
)
tools = [execute_database_operation]
llm_with_tools = model.bind_tools(tools)
Expand Down
4 changes: 2 additions & 2 deletions examples/mem0_tools/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from trpc_agent_sdk.agents import LlmAgent
from trpc_agent_sdk.models import LLMModel
from trpc_agent_sdk.models import OpenAIModel
from trpc_agent_sdk.tools.mem0_tools import SaveMemoryTool
from trpc_agent_sdk.tools.mem0_tools import SearchMemoryTool
from trpc_agent_sdk.tools.mem0_tool import SaveMemoryTool
from trpc_agent_sdk.tools.mem0_tool import SearchMemoryTool

from .config import get_mem0_platform_config
from .config import get_memory_config
Expand Down
Loading
Loading