Skip to content

Commit 3244f8b

Browse files
authored
Fix readme to work with plugins (#1008)
1 parent 20bb869 commit 3244f8b

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

temporalio/contrib/openai_agents/README.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ import asyncio
8686
from datetime import timedelta
8787

8888
from temporalio.client import Client
89-
from temporalio.contrib.openai_agents import ModelActivity, ModelActivityParameters, set_open_ai_agent_temporal_overrides
90-
from temporalio.contrib.pydantic import pydantic_data_converter
89+
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin, ModelActivityParameters
9190
from temporalio.worker import Worker
9291

9392
from hello_world_workflow import HelloWorldAgent
@@ -96,24 +95,24 @@ from hello_world_workflow import HelloWorldAgent
9695
async def worker_main():
9796
# Configure the OpenAI Agents SDK to use Temporal activities for LLM API calls
9897
# and for tool calls.
99-
model_params = ModelActivityParameters(
100-
start_to_close_timeout=timedelta(seconds=10)
98+
# Create a Temporal client connected to server at the given address
99+
client = await Client.connect(
100+
"localhost:7233",
101+
plugins=[
102+
OpenAIAgentsPlugin(
103+
model_params=ModelActivityParameters(
104+
start_to_close_timeout=timedelta(seconds=10)
105+
)
106+
)
107+
]
101108
)
102-
with set_open_ai_agent_temporal_overrides(model_params):
103-
# Create a Temporal client connected to server at the given address
104-
# Use the OpenAI data converter to ensure proper serialization/deserialization
105-
client = await Client.connect(
106-
"localhost:7233",
107-
data_converter=pydantic_data_converter,
108-
)
109109

110-
worker = Worker(
111-
client,
112-
task_queue="my-task-queue",
113-
workflows=[HelloWorldAgent],
114-
activities=[ModelActivity().invoke_model_activity],
115-
)
116-
await worker.run()
110+
worker = Worker(
111+
client,
112+
task_queue="my-task-queue",
113+
workflows=[HelloWorldAgent],
114+
)
115+
await worker.run()
117116

118117

119118
if __name__ == "__main__":
@@ -134,15 +133,15 @@ import asyncio
134133

135134
from temporalio.client import Client
136135
from temporalio.common import WorkflowIDReusePolicy
137-
from temporalio.contrib.pydantic import pydantic_data_converter
136+
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
138137

139138
from hello_world_workflow import HelloWorldAgent
140139

141140
async def main():
142141
# Create client connected to server at the given address
143142
client = await Client.connect(
144143
"localhost:7233",
145-
data_converter=pydantic_data_converter,
144+
plugins=[OpenAIAgentsPlugin()]
146145
)
147146

148147
# Execute a workflow

0 commit comments

Comments
 (0)