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
32 changes: 29 additions & 3 deletions examples/agent_framework_integrations/openai_agents_sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,37 @@ Deploy this agent as a real-time HTTP service:
```bash
# Deploy the pipeline as an HTTP service
zenml pipeline deploy run.agent_pipeline --name openai-agents-agent
```

Once deployed, you can interact with the service in multiple ways:

# Invoke via CLI
### 🎨 Custom Web UI
Navigate to the root endpoint in your browser to access an interactive web interface:
```
http://localhost:8000/
```

The UI provides:
- Free-form query input with example suggestions
- Real-time agent responses with markdown rendering
- Visual feedback and error handling

### 📚 API Documentation
FastAPI automatically generates interactive API documentation:
```
http://localhost:8000/docs # Swagger UI
http://localhost:8000/redoc # ReDoc alternative
```

### 🔧 Programmatic Access

**Via ZenML CLI:**
```bash
zenml deployment invoke openai-agents-agent --query="Tell me a fun fact about Tokyo"
```

# Invoke via HTTP API
**Via HTTP API:**
```bash
curl -X POST http://localhost:8000/invoke \
-H "Content-Type: application/json" \
-d '{"parameters": {"query": "What are some interesting facts about space exploration?"}}'
Expand All @@ -45,4 +71,4 @@ curl -X POST http://localhost:8000/invoke \
- **Function Tools**: Built-in tools with `@function_tool` decorator
- **Tracing & Monitoring**: Comprehensive execution tracking
- **Real-time Deployment**: Deploy as HTTP API for instant responses
- **ZenML Orchestration**: Full pipeline tracking and artifact management
- **ZenML Orchestration**: Full pipeline tracking and artifact management
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def get_city_info(city: str) -> str:
"paris": "Paris is the capital of France, famous for the Eiffel Tower, art museums, and cuisine.",
"new york": "New York City is the most populous city in the United States, known for its skyline, culture, and diversity.",
"london": "London is the capital of England and the United Kingdom, famous for its history, architecture, and royal heritage.",
"munich": "Munich is the capital of Bavaria, Germany's third-largest city, famous for Oktoberfest, beer gardens, BMW headquarters, and its proximity to the Alps.",
}

city_lower = city.lower()
Expand All @@ -48,6 +49,6 @@ def get_city_info(city: str) -> str:
instructions="""You are a helpful travel assistant. You can provide weather information
and general facts about cities around the world. When users ask about cities, use your
available tools to get specific information. Be friendly and informative in your responses.""",
model="gpt-4o-mini",
model="gpt-5-nano",
tools=[get_weather, get_city_info],
)
32 changes: 29 additions & 3 deletions examples/agent_framework_integrations/openai_agents_sdk/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,30 @@
from typing import Annotated, Any, Dict

from zenml import pipeline, step
from zenml.config import DockerSettings, PythonPackageInstaller
from zenml.config import (
DeploymentSettings,
DockerSettings,
SecureHeadersConfig,
)

deploy_settings = DeploymentSettings(
app_title="Travel Assistant",
app_description=(
"A travel assistant that can provide weather information and general facts about cities around the world."
),
app_version="0.1",
dashboard_files_path="ui",
secure_headers=SecureHeadersConfig(
csp=(
"default-src 'none'; "
"script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; "
"connect-src 'self' https://cdn.jsdelivr.net; "
"style-src 'self' 'unsafe-inline'"
),
),
)

docker_settings = DockerSettings(
python_package_installer=PythonPackageInstaller.UV,
requirements="requirements.txt", # relative to the pipeline directory
environment={
"OPENAI_API_KEY": os.getenv("OPENAI_API_KEY"),
Expand Down Expand Up @@ -162,7 +182,13 @@ def format_openai_response(
return formatted.strip()


@pipeline(settings={"docker": docker_settings}, enable_cache=False)
@pipeline(
settings={
"docker": docker_settings,
"deployment": deploy_settings,
},
enable_cache=False,
)
def agent_pipeline(query: str = "Tell me a fun fact about Tokyo") -> str:
"""ZenML pipeline that orchestrates the OpenAI Agents SDK.

Expand Down
Loading
Loading