diff --git a/examples/agent_framework_integrations/openai_agents_sdk/README.md b/examples/agent_framework_integrations/openai_agents_sdk/README.md index 50a89b8059..312cf9d89c 100644 --- a/examples/agent_framework_integrations/openai_agents_sdk/README.md +++ b/examples/agent_framework_integrations/openai_agents_sdk/README.md @@ -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?"}}' @@ -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 \ No newline at end of file +- **ZenML Orchestration**: Full pipeline tracking and artifact management diff --git a/examples/agent_framework_integrations/openai_agents_sdk/openai_agent.py b/examples/agent_framework_integrations/openai_agents_sdk/openai_agent.py index cdbe2d9d2b..efe20f13dd 100644 --- a/examples/agent_framework_integrations/openai_agents_sdk/openai_agent.py +++ b/examples/agent_framework_integrations/openai_agents_sdk/openai_agent.py @@ -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() @@ -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], ) diff --git a/examples/agent_framework_integrations/openai_agents_sdk/run.py b/examples/agent_framework_integrations/openai_agents_sdk/run.py index 36b94b117f..7bcf440e42 100644 --- a/examples/agent_framework_integrations/openai_agents_sdk/run.py +++ b/examples/agent_framework_integrations/openai_agents_sdk/run.py @@ -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"), @@ -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. diff --git a/examples/agent_framework_integrations/openai_agents_sdk/ui/index.html b/examples/agent_framework_integrations/openai_agents_sdk/ui/index.html new file mode 100644 index 0000000000..2766e2ac46 --- /dev/null +++ b/examples/agent_framework_integrations/openai_agents_sdk/ui/index.html @@ -0,0 +1,664 @@ + + + + + + Travel Assistant | ZenML + + + + + + + + +
+
+ +
+
+

OpenAI Agents Travel Assistant

+

+ Ask free‑form travel questions—fun facts, quick weather checks, and city info—powered by the OpenAI Agents SDK. +

+
+ +
+ + +
+

Try it

+
+ + + +
+ Fun fact: Tokyo + Weather: Paris + NYC highlights + Quick facts: London + Tips: Berlin +
+ +
+ + + +
+
+ +
+ + +
+
+ + + +
+
+ + + + + +