Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ dependencies = [
"yaspin>=3.1.0",
"claude-agent-sdk>=0.1.0",
"anthropic>=0.40.0",
"partial-json-parser>=0.2.1", # For voice agent streaming JSON parsing
"google-auth>=2.0.0", # For Vertex AI authentication in voice agents
]

requires-python = ">= 3.12,<4"
Expand Down
32 changes: 23 additions & 9 deletions src/agentex/lib/cli/commands/init.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

from enum import Enum
from typing import Any, Dict
from typing import Any, Dict, Optional
from pathlib import Path

import typer
import questionary
from jinja2 import Environment, FileSystemLoader
from rich.rule import Rule
Expand All @@ -27,6 +28,7 @@ class TemplateType(str, Enum):
DEFAULT = "default"
SYNC = "sync"
SYNC_OPENAI_AGENTS = "sync-openai-agents"
VOICE = "voice"


def render_template(
Expand Down Expand Up @@ -60,6 +62,7 @@ def create_project_structure(
TemplateType.DEFAULT: ["acp.py"],
TemplateType.SYNC: ["acp.py"],
TemplateType.SYNC_OPENAI_AGENTS: ["acp.py"],
TemplateType.VOICE: ["acp.py"],
}[template_type]

# Create project/code files
Expand Down Expand Up @@ -102,9 +105,15 @@ def get_project_context(answers: Dict[str, Any], project_path: Path, manifest_ro
# Now, this is actually the exact same as the project_name because we changed the build root to be ../
project_path_from_build_root = project_name

# Create PascalCase class name from agent name
agent_class_name = "".join(
word.capitalize() for word in answers["agent_name"].split("-")
)

return {
**answers,
"project_name": project_name,
"agent_class_name": agent_class_name,
"workflow_class": "".join(
word.capitalize() for word in answers["agent_name"].split("-")
)
Expand Down Expand Up @@ -140,27 +149,32 @@ def init():
"[bold cyan]Sync ACP[/bold cyan]",
"Synchronous agent that processes one request per task with a simple request-response pattern. Best for low-latency use cases, FAQ bots, translation services, and data lookups.",
)
table.add_row(
"[bold cyan]Conversational Agent[/bold cyan]",
"Real-time conversational agent with built-in interruption handling, state management, and guardrail support. Best for voice assistants, interactive chatbots, and applications requiring natural turn-taking and streaming responses.",
)
console.print()
console.print(table)
console.print()

def validate_agent_name(text: str) -> bool | str:
"""Validate agent name follows required format"""
is_valid = len(text) >= 1 and text.replace("-", "").isalnum() and text.islower()
if not is_valid:
return "Invalid name. Use only lowercase letters, numbers, and hyphens. Examples: 'my-agent', 'newsbot'"
return True

# Gather project information
template_type = questionary.select(
"What type of template would you like to create?",
choices=[
{"name": "Async - ACP Only", "value": TemplateType.DEFAULT},
{"name": "Async - Temporal", "value": "temporal_submenu"},
{"name": "Sync ACP", "value": "sync_submenu"},
{"name": "Conversational Agent", "value": TemplateType.VOICE},
],
).ask()
if not template_type:

def validate_agent_name(text: str) -> bool | str:
"""Validate agent name follows required format"""
is_valid = len(text) >= 1 and text.replace("-", "").isalnum() and text.islower()
if not is_valid:
return "Invalid name. Use only lowercase letters, numbers, and hyphens. Examples: 'my-agent', 'newsbot'"
return True
if template_type is None:
return

# If Temporal was selected, show sub-menu for Temporal variants
Expand Down
43 changes: 43 additions & 0 deletions src/agentex/lib/cli/templates/voice/.dockerignore.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Environments
.env**
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# IDE
.idea/
.vscode/
*.swp
*.swo

# Git
.git
.gitignore

# Misc
.DS_Store
42 changes: 42 additions & 0 deletions src/agentex/lib/cli/templates/voice/Dockerfile-uv.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# syntax=docker/dockerfile:1.3
FROM python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:0.6.4 /uv /uvx /bin/

# Install system dependencies
RUN apt-get update && apt-get install -y \
htop \
vim \
curl \
tar \
python3-dev \
postgresql-client \
build-essential \
libpq-dev \
gcc \
cmake \
netcat-openbsd \
nodejs \
npm \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/**

RUN uv pip install --system --upgrade pip setuptools wheel

ENV UV_HTTP_TIMEOUT=1000

# Copy just the pyproject.toml file to optimize caching
COPY {{ project_path_from_build_root }}/pyproject.toml /app/{{ project_path_from_build_root }}/pyproject.toml

WORKDIR /app/{{ project_path_from_build_root }}

# Install the required Python packages using uv
RUN uv pip install --system .

# Copy the project code
COPY {{ project_path_from_build_root }}/project /app/{{ project_path_from_build_root }}/project

# Set environment variables
ENV PYTHONPATH=/app

# Run the agent using uvicorn
CMD ["uvicorn", "project.acp:acp", "--host", "0.0.0.0", "--port", "8000"]
43 changes: 43 additions & 0 deletions src/agentex/lib/cli/templates/voice/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# syntax=docker/dockerfile:1.3
FROM python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:0.6.4 /uv /uvx /bin/

# Install system dependencies
RUN apt-get update && apt-get install -y \
htop \
vim \
curl \
tar \
python3-dev \
postgresql-client \
build-essential \
libpq-dev \
gcc \
cmake \
netcat-openbsd \
node \
npm \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN uv pip install --system --upgrade pip setuptools wheel

ENV UV_HTTP_TIMEOUT=1000

# Copy just the requirements file to optimize caching
COPY {{ project_path_from_build_root }}/requirements.txt /app/{{ project_path_from_build_root }}/requirements.txt

WORKDIR /app/{{ project_path_from_build_root }}

# Install the required Python packages
RUN uv pip install --system -r requirements.txt

# Copy the project code
COPY {{ project_path_from_build_root }}/project /app/{{ project_path_from_build_root }}/project


# Set environment variables
ENV PYTHONPATH=/app

# Run the agent using uvicorn
CMD ["uvicorn", "project.acp:acp", "--host", "0.0.0.0", "--port", "8000"]
Loading
Loading