Skip to content

Commit 85e9843

Browse files
jssmithtconley1428
andauthored
Update samples for 1.15 (#220)
* update for plugins * formatting * reference main branch * cleanup * switch to plugins on the runners * Update dependency to 1.15.0 release --------- Co-authored-by: Tim Conley <timothy.conley@temporal.io>
1 parent 90d3237 commit 85e9843

8 files changed

Lines changed: 244 additions & 67 deletions

openai_agents/run_agents_as_tools_workflow.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22

33
from temporalio.client import Client
4-
from temporalio.contrib.pydantic import pydantic_data_converter
4+
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
55

66
from openai_agents.workflows.agents_as_tools_workflow import AgentsAsToolsWorkflow
77

@@ -10,7 +10,9 @@ async def main():
1010
# Create client connected to server at the given address
1111
client = await Client.connect(
1212
"localhost:7233",
13-
data_converter=pydantic_data_converter,
13+
plugins=[
14+
OpenAIAgentsPlugin(),
15+
],
1416
)
1517

1618
# Execute a workflow

openai_agents/run_customer_service_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
WorkflowUpdateFailedError,
88
)
99
from temporalio.common import QueryRejectCondition
10-
from temporalio.contrib.pydantic import pydantic_data_converter
10+
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
1111
from temporalio.service import RPCError, RPCStatusCode
1212

1313
from openai_agents.workflows.customer_service_workflow import (
@@ -24,7 +24,9 @@ async def main():
2424
# Create client connected to server at the given address
2525
client = await Client.connect(
2626
"localhost:7233",
27-
data_converter=pydantic_data_converter,
27+
plugins=[
28+
OpenAIAgentsPlugin(),
29+
],
2830
)
2931

3032
handle = client.get_workflow_handle(args.conversation_id)

openai_agents/run_hello_world_workflow.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22

33
from temporalio.client import Client
4-
from temporalio.contrib.pydantic import pydantic_data_converter
4+
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
55

66
from openai_agents.workflows.hello_world_workflow import HelloWorldAgent
77

@@ -10,7 +10,9 @@ async def main():
1010
# Create client connected to server at the given address
1111
client = await Client.connect(
1212
"localhost:7233",
13-
data_converter=pydantic_data_converter,
13+
plugins=[
14+
OpenAIAgentsPlugin(),
15+
],
1416
)
1517

1618
# Execute a workflow

openai_agents/run_research_workflow.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22

33
from temporalio.client import Client
4-
from temporalio.contrib.pydantic import pydantic_data_converter
4+
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
55

66
from openai_agents.workflows.research_bot_workflow import ResearchWorkflow
77

@@ -10,7 +10,9 @@ async def main():
1010
# Create client connected to server at the given address
1111
client = await Client.connect(
1212
"localhost:7233",
13-
data_converter=pydantic_data_converter,
13+
plugins=[
14+
OpenAIAgentsPlugin(),
15+
],
1416
)
1517

1618
# Execute a workflow

openai_agents/run_tools_workflow.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22

33
from temporalio.client import Client
4-
from temporalio.contrib.pydantic import pydantic_data_converter
4+
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
55

66
from openai_agents.workflows.tools_workflow import ToolsWorkflow
77

@@ -10,7 +10,9 @@ async def main():
1010
# Create client connected to server at the given address
1111
client = await Client.connect(
1212
"localhost:7233",
13-
data_converter=pydantic_data_converter,
13+
plugins=[
14+
OpenAIAgentsPlugin(),
15+
],
1416
)
1517

1618
# Execute a workflow

openai_agents/run_worker.py

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44
from datetime import timedelta
55

66
from temporalio.client import Client
7-
from temporalio.contrib.openai_agents import (
8-
ModelActivity,
9-
ModelActivityParameters,
10-
OpenAIAgentsTracingInterceptor,
11-
set_open_ai_agent_temporal_overrides,
12-
)
13-
from temporalio.contrib.pydantic import pydantic_data_converter
7+
from temporalio.contrib.openai_agents import ModelActivityParameters, OpenAIAgentsPlugin
148
from temporalio.worker import Worker
159

1610
from openai_agents.workflows.agents_as_tools_workflow import AgentsAsToolsWorkflow
@@ -22,34 +16,33 @@
2216

2317

2418
async def main():
25-
with set_open_ai_agent_temporal_overrides(
26-
model_params=ModelActivityParameters(
27-
start_to_close_timeout=timedelta(seconds=60),
28-
),
29-
):
30-
# Create client connected to server at the given address
31-
client = await Client.connect(
32-
"localhost:7233",
33-
data_converter=pydantic_data_converter,
34-
)
35-
36-
worker = Worker(
37-
client,
38-
task_queue="openai-agents-task-queue",
39-
workflows=[
40-
HelloWorldAgent,
41-
ToolsWorkflow,
42-
ResearchWorkflow,
43-
CustomerServiceWorkflow,
44-
AgentsAsToolsWorkflow,
45-
],
46-
activities=[
47-
ModelActivity().invoke_model_activity,
48-
get_weather,
49-
],
50-
interceptors=[OpenAIAgentsTracingInterceptor()],
51-
)
52-
await worker.run()
19+
# Create client connected to server at the given address
20+
client = await Client.connect(
21+
"localhost:7233",
22+
plugins=[
23+
OpenAIAgentsPlugin(
24+
model_params=ModelActivityParameters(
25+
start_to_close_timeout=timedelta(seconds=120)
26+
)
27+
),
28+
],
29+
)
30+
31+
worker = Worker(
32+
client,
33+
task_queue="openai-agents-task-queue",
34+
workflows=[
35+
HelloWorldAgent,
36+
ToolsWorkflow,
37+
ResearchWorkflow,
38+
CustomerServiceWorkflow,
39+
AgentsAsToolsWorkflow,
40+
],
41+
activities=[
42+
get_weather,
43+
],
44+
)
45+
await worker.run()
5346

5447

5548
if __name__ == "__main__":

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = [{ name = "Temporal Technologies Inc", email = "sdk@temporal.io" }]
66
requires-python = ">=3.10"
77
readme = "README.md"
88
license = "MIT"
9-
dependencies = ["temporalio>=1.14.1,<2"]
9+
dependencies = ["temporalio>=1.15.0,<2"]
1010

1111
[project.urls]
1212
Homepage = "https://github.com/temporalio/samples-python"
@@ -55,8 +55,8 @@ open-telemetry = [
5555
"opentelemetry-exporter-otlp-proto-grpc",
5656
]
5757
openai-agents = [
58-
"openai-agents >= 0.0.19",
59-
"temporalio[openai-agents] >= 1.14.1",
58+
"openai-agents[litellm] >= 0.2.3",
59+
"temporalio[openai-agents] >= 1.15.0",
6060
]
6161
pydantic-converter = ["pydantic>=2.10.6,<3"]
6262
sentry = ["sentry-sdk>=1.11.0,<2"]

0 commit comments

Comments
 (0)