Skip to content

Commit c157941

Browse files
committed
move around samples
1 parent 1b6b026 commit c157941

23 files changed

Lines changed: 165 additions & 30 deletions

openai_agents/README.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This approach ensures that AI agent workflows are durable, observable, and can h
2525

2626
1. **Start the worker** (supports all samples):
2727
```bash
28-
uv run openai_agents/run_worker.py
28+
uv run openai_agents/basic/run_worker.py
2929
```
3030

3131
2. **Run individual samples** in separate terminals:
@@ -34,29 +34,53 @@ This approach ensures that AI agent workflows are durable, observable, and can h
3434

3535
- **Hello World Agent** - Simple agent that responds in haikus:
3636
```bash
37-
uv run openai_agents/run_hello_world_workflow.py
37+
uv run openai_agents/basic/run_hello_world_workflow.py
3838
```
3939

4040
- **Tools Agent** - Agent with access to external tools (weather API):
4141
```bash
42-
uv run openai_agents/run_tools_workflow.py
42+
uv run openai_agents/basic/run_tools_workflow.py
43+
```
44+
45+
### Agent Patterns
46+
47+
Start the worker:
48+
49+
```bash
50+
uv run openai_agents/agent_patterns/run_worker.py
51+
```
52+
53+
- **Agents as Tools** - Demonstrate using agents as tools within other agents:
54+
55+
```bash
56+
uv run openai_agents/agent_patterns/run_agents_as_tools_workflow.py
4357
```
4458

4559
### Advanced Multi-Agent Examples
4660

4761
- **Research Workflow** - Multi-agent research system with specialized roles:
62+
63+
Start the worker:
64+
65+
```bash
66+
uv run openai_agents/research_bot/run_worker.py
67+
```
68+
4869
```bash
49-
uv run openai_agents/run_research_workflow.py
70+
uv run openai_agents/research_bot/run_research_workflow.py
5071
```
5172
Features a planner agent, search agent, and writer agent working together.
5273

5374
- **Customer Service Workflow** - Customer service agent with escalation capabilities (interactive):
54-
```bash
55-
uv run openai_agents/run_customer_service_client.py --conversation-id my-conversation-123
56-
```
5775

58-
- **Agents as Tools** - Demonstrate using agents as tools within other agents:
76+
Start the worker:
77+
78+
```bash
79+
uv run openai_agents/customer_service/run_worker.py
80+
```
81+
5982
```bash
60-
uv run openai_agents/run_agents_as_tools_workflow.py
83+
uv run openai_agents/customer_service/run_customer_service_client.py --conversation-id my-conversation-123
6184
```
6285

86+

openai_agents/run_agents_as_tools_workflow.py renamed to openai_agents/agent_patterns/run_agents_as_tools_workflow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
from temporalio.client import Client
44
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
55

6-
from openai_agents.workflows.agents_as_tools_workflow import AgentsAsToolsWorkflow
6+
from openai_agents.agent_patterns.workflows.agents_as_tools_workflow import (
7+
AgentsAsToolsWorkflow,
8+
)
79

810

911
async def main():
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from __future__ import annotations
2+
3+
import asyncio
4+
from datetime import timedelta
5+
6+
from temporalio.client import Client
7+
from temporalio.contrib.openai_agents import ModelActivityParameters, OpenAIAgentsPlugin
8+
from temporalio.worker import Worker
9+
10+
from openai_agents.agent_patterns.workflows.agents_as_tools_workflow import (
11+
AgentsAsToolsWorkflow,
12+
)
13+
14+
15+
async def main():
16+
# Create client connected to server at the given address
17+
client = await Client.connect(
18+
"localhost:7233",
19+
plugins=[
20+
OpenAIAgentsPlugin(
21+
model_params=ModelActivityParameters(
22+
start_to_close_timeout=timedelta(seconds=120)
23+
)
24+
),
25+
],
26+
)
27+
28+
worker = Worker(
29+
client,
30+
task_queue="openai-agents-task-queue",
31+
workflows=[
32+
AgentsAsToolsWorkflow,
33+
],
34+
)
35+
await worker.run()
36+
37+
38+
if __name__ == "__main__":
39+
asyncio.run(main())

openai_agents/workflows/agents_as_tools_workflow.py renamed to openai_agents/agent_patterns/workflows/agents_as_tools_workflow.py

File renamed without changes.
File renamed without changes.

openai_agents/run_hello_world_workflow.py renamed to openai_agents/basic/run_hello_world_workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from temporalio.client import Client
44
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
55

6-
from openai_agents.workflows.hello_world_workflow import HelloWorldAgent
6+
from openai_agents.basic.workflows.hello_world_workflow import HelloWorldAgent
77

88

99
async def main():
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from temporalio.client import Client
44
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
55

6-
from openai_agents.workflows.tools_workflow import ToolsWorkflow
6+
from openai_agents.basic.workflows.tools_workflow import ToolsWorkflow
77

88

99
async def main():
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@
77
from temporalio.contrib.openai_agents import ModelActivityParameters, OpenAIAgentsPlugin
88
from temporalio.worker import Worker
99

10-
from openai_agents.workflows.agents_as_tools_workflow import AgentsAsToolsWorkflow
11-
from openai_agents.workflows.customer_service_workflow import CustomerServiceWorkflow
12-
from openai_agents.workflows.get_weather_activity import get_weather
13-
from openai_agents.workflows.hello_world_workflow import HelloWorldAgent
14-
from openai_agents.workflows.research_bot_workflow import ResearchWorkflow
15-
from openai_agents.workflows.tools_workflow import ToolsWorkflow
10+
from openai_agents.basic.activities.get_weather_activity import get_weather
11+
from openai_agents.basic.workflows.hello_world_workflow import HelloWorldAgent
12+
from openai_agents.basic.workflows.tools_workflow import ToolsWorkflow
1613

1714

1815
async def main():
@@ -22,7 +19,7 @@ async def main():
2219
plugins=[
2320
OpenAIAgentsPlugin(
2421
model_params=ModelActivityParameters(
25-
start_to_close_timeout=timedelta(seconds=120)
22+
start_to_close_timeout=timedelta(seconds=30)
2623
)
2724
),
2825
],
@@ -34,9 +31,6 @@ async def main():
3431
workflows=[
3532
HelloWorldAgent,
3633
ToolsWorkflow,
37-
ResearchWorkflow,
38-
CustomerServiceWorkflow,
39-
AgentsAsToolsWorkflow,
4034
],
4135
activities=[
4236
get_weather,
File renamed without changes.

openai_agents/workflows/tools_workflow.py renamed to openai_agents/basic/workflows/tools_workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from temporalio import workflow
77
from temporalio.contrib import openai_agents as temporal_agents
88

9-
from openai_agents.workflows.get_weather_activity import get_weather
9+
from openai_agents.basic.activities.get_weather_activity import get_weather
1010

1111

1212
@workflow.defn

0 commit comments

Comments
 (0)