Skip to content

Commit 208e0a2

Browse files
committed
updated README and added order_returns folder
1 parent 4838314 commit 208e0a2

File tree

5 files changed

+55
-41
lines changed

5 files changed

+55
-41
lines changed

samples-v2/openai_agents/function_app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
from openai import AsyncAzureOpenAI
1111

1212
from agents import set_default_openai_client
13-
from order_return_orchestrators import register_order_return_orchestrators
14-
13+
from order_returns.order_return_orchestrators import register_order_return_orchestrators
1514

1615
#region Regular Azure OpenAI setup
1716

samples-v2/openai_agents/ORDER_RETURNS.md renamed to samples-v2/openai_agents/order_returns/README.md

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
# Order Return Processing System
1+
# Order Return Processing Sample
22

3-
An order return processing system built with Azure Functions and OpenAI Agents, demonstrating advanced orchestration patterns and multi-agent workflows.
3+
This sample demonstrates an order return processing system built with Azure Durable Functions and OpenAI Agents. The system automatically processes customer return requests using AI agents to validate return reasons, process refunds, and route edge cases to human review.
44

5-
## Overview
5+
## Running the Sample
66

7-
This system automatically processes customer return requests using AI agents to validate return reasons, process refunds, and route edge cases to human review. It showcases real-world business logic implementation with Azure Durable Functions.
7+
**For complete setup instructions, configuration details, and troubleshooting, see the [Getting Started Guide](/docs/openai_agents/getting-started.md).**
88

9-
## Quick Start
9+
### Step 1: Start the Azure Functions App
10+
11+
From the OpenAI Agents samples root directory (`/samples-v2/openai_agents`), start the Azure Functions host:
12+
13+
```bash
14+
func start
15+
```
16+
17+
The function app will start and listen on `http://localhost:7071` by default.
18+
19+
### Step 2: Submit a Return Request
1020

11-
### Submit a Return Request
1221
```bash
1322
curl -X POST http://localhost:7071/api/order_return_processor \
1423
-H "Content-Type: application/json" \
@@ -21,12 +30,39 @@ curl -X POST http://localhost:7071/api/order_return_processor \
2130
}'
2231
```
2332

24-
### Check Processing Status
33+
### Step 3: Check Processing Status
34+
2535
```bash
2636
# Use the statusQueryGetUri from the submission response
2737
curl http://localhost:7071/runtime/webhooks/durabletask/instances/{instance_id}
2838
```
2939

40+
## Testing
41+
42+
### Test Valid Return (Auto-Approve)
43+
44+
```bash
45+
curl -X POST http://localhost:7071/api/order_return_processor \
46+
-H "Content-Type: application/json" \
47+
-d '{"order_id":"TEST-001","customer_id":"CUST-001","product_category":"Electronics","purchase_date":"2024-10-01","return_reason":"arrived damaged"}'
48+
```
49+
50+
### Test Invalid Return (Human Review)
51+
52+
```bash
53+
curl -X POST http://localhost:7071/api/order_return_processor \
54+
-H "Content-Type: application/json" \
55+
-d '{"order_id":"TEST-002","customer_id":"CUST-002","product_category":"Clothing","purchase_date":"2024-09-15","return_reason":"changed my mind"}'
56+
```
57+
58+
### Check Status
59+
60+
Use the `statusQueryGetUri` from the response to check the orchestration status:
61+
62+
```bash
63+
curl {statusQueryGetUri_from_response}
64+
```
65+
3066
## API Reference
3167

3268
### Endpoints
@@ -36,7 +72,6 @@ curl http://localhost:7071/runtime/webhooks/durabletask/instances/{instance_id}
3672
| `POST` | `/api/order_return_processor` | Submit a new return request |
3773
| `GET` | `/runtime/webhooks/durabletask/instances/{instance_id}` | Check processing status |
3874

39-
4075
### Request Schema
4176

4277
```json
@@ -71,6 +106,7 @@ curl http://localhost:7071/runtime/webhooks/durabletask/instances/{instance_id}
71106
## Example Responses
72107

73108
### Successful Auto-Approval
109+
74110
```json
75111
{
76112
"status": "approved_and_processed",
@@ -91,6 +127,7 @@ curl http://localhost:7071/runtime/webhooks/durabletask/instances/{instance_id}
91127
```
92128

93129
### Human Review Required
130+
94131
```json
95132
{
96133
"status": "pending_human_review",
@@ -118,31 +155,9 @@ The system uses a multi-agent orchestration pattern:
118155
## File Structure
119156

120157
```
121-
basic/
122-
├── order_return_validation.py # Validation agent
123-
└── refund_processing.py # Refund processing agent
124-
125-
order_return_orchestrators.py # Main orchestration logic
126-
test_order_return.py # Testing examples and utilities
127-
```
128-
129-
## Testing
130-
131-
```bash
132-
# Start the function app
133-
func start
134-
135-
# Test valid return (should auto-approve)
136-
curl -X POST http://localhost:7071/api/order_return_processor \
137-
-H "Content-Type: application/json" \
138-
-d '{"order_id":"TEST-001","customer_id":"CUST-001","product_category":"Electronics","purchase_date":"2024-10-01","return_reason":"arrived damaged"}'
139-
140-
# Test invalid return (should require human review)
141-
curl -X POST http://localhost:7071/api/order_return_processor \
142-
-H "Content-Type: application/json" \
143-
-d '{"order_id":"TEST-002","customer_id":"CUST-002","product_category":"Clothing","purchase_date":"2024-09-15","return_reason":"changed my mind"}'
144-
145-
# Check status using the response from above requests
146-
# Look for "statusQueryGetUri" in the response and use that URL
147-
curl {statusQueryGetUri_from_response}
158+
order_returns/
159+
├── order_return_orchestrators.py # Main orchestration logic
160+
├── order_return_validation.py # Validation agent
161+
├── refund_processing.py # Refund processing agent
162+
└── README.md # This file
148163
```

samples-v2/openai_agents/order_return_orchestrators.py renamed to samples-v2/openai_agents/order_returns/order_return_orchestrators.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ def order_return_processor(context: df.DurableOrchestrationContext):
7373
@app.durable_openai_agent_orchestrator
7474
def order_return_validation(context):
7575
"""Sub-orchestration that validates return reasons using AI agent"""
76-
import basic.order_return_validation
76+
import order_returns.order_return_validation
7777
return_request = context.get_input()
78-
return basic.order_return_validation.main(return_request)
78+
return order_returns.order_return_validation.main(return_request)
7979

8080
@app.orchestration_trigger(context_name="context")
8181
@app.durable_openai_agent_orchestrator
8282
def refund_processor(context):
8383
"""Sub-orchestration that processes refunds using AI agent"""
84-
import basic.refund_processing
84+
import order_returns.refund_processing
8585
validation_data = context.get_input()
86-
return basic.refund_processing.main(validation_data)
86+
return order_returns.refund_processing.main(validation_data)
8787

8888
@app.activity_trigger(input_name="review_data")
8989
async def route_for_human_review(review_data: dict) -> dict:

samples-v2/openai_agents/basic/order_return_validation.py renamed to samples-v2/openai_agents/order_returns/order_return_validation.py

File renamed without changes.

samples-v2/openai_agents/basic/refund_processing.py renamed to samples-v2/openai_agents/order_returns/refund_processing.py

File renamed without changes.

0 commit comments

Comments
 (0)