You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: temporalio/contrib/openai_agents/README.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ To provide durable execution, Temporal needs to be able to recover from failures
33
33
To do this, Temporal requires separating an application's deterministic (repeatable) and non-deterministic parts:
34
34
35
35
1. Deterministic pieces, termed *workflows*, execute the same way if re-run with the same inputs.
36
-
2. Non-deterministic pieces, termed *activies*, have no limitations—they may perform I/O and any other operations.
36
+
2. Non-deterministic pieces, termed *activities*, have no limitations—they may perform I/O and any other operations.
37
37
38
38
Temporal maintains a server-side execution history of all state state passing in and out of a workflow, using it to recover when needed.
39
39
See the [Temporal documentation](https://docs.temporal.io/evaluate/understanding-temporal#temporal-application-the-building-blocks) for more information.
@@ -78,14 +78,14 @@ class HelloWorldAgent:
78
78
If you are familiar with Temporal and with Open AI Agents SDK, this code will look very familiar.
79
79
We annotate the `HelloWorldAgent` class with `@workflow.defn` to define a workflow, then use the `@workflow.run` annotation to define the entrypoint.
80
80
We use the `Agent` class to define a simple agent, one which always responds with haikus.
81
-
Within the workflow, we start agent using the `Runner`, as is typical, passing through `prompt` as an argument.
81
+
Within the workflow, we start the agent using the `Runner`, as is typical, passing through `prompt` as an argument.
82
82
83
83
Perhaps the most interesting thing about this code is the `workflow.unsafe.imports_passed_through()` context manager that precedes the OpenAI Agents SDK imports.
84
84
This statement tells Temporal to skip sandboxing for these trusted libraries.
85
85
This is important because Python's dynamic nature forces Temporal's Python's sandbox to re-validate imports every time a workflow runs, which comes at a performance cost.
86
86
The OpenAI Agents SDK also contains certain code that Temporal is not able to validate automatically for determinism.
87
87
88
-
The second file, `run_worker.py`, lauches a Temporal worker.
88
+
The second file, `run_worker.py`, launches a Temporal worker.
89
89
This is a program that connects to the Temporal server and receives work to run, in this case `HelloWorldAgent` invocations.
90
90
91
91
```python
@@ -131,7 +131,7 @@ if __name__ == "__main__":
131
131
We wrap the entire `worker_main` function body in the `set_open_ai_agent_temporal_overrides()` context manager.
132
132
This causes a Temporal activity to be invoked whenever the OpenAI Agents SDK invokes an LLM or calls a tool.
133
133
We also pass the `open_ai_data_converter` to the Temporal Client, which ensures proper serialization of OpenAI Agents SDK data.
134
-
We create a `ModelActivity` which serves as a generic wrapper for LLM calls, and we register this wrapper's invocation point, `model_activity.invoke_model_activity`, with the workflow.
134
+
We create a `ModelActivity` which serves as a generic wrapper for LLM calls, and we register this wrapper's invocation point, `model_activity.invoke_model_activity`, with the worker.
135
135
136
136
In order to launch the agent, use the standard Temporal workflow invocation:
137
137
@@ -169,7 +169,7 @@ if __name__ == "__main__":
169
169
170
170
This launcher script executes the Temporal workflow to start the agent.
171
171
172
-
Note that this basic example works without providing the `open_ai_data_converter` to the Temporal client that executes the workflow, but we include it because morem complex uses will generally need it.
172
+
Note that this basic example works without providing the `open_ai_data_converter` to the Temporal client that executes the workflow, but we include it because more complex uses will generally need it.
173
173
174
174
175
175
## Using Temporal Activities as OpenAI Agents Tools
0 commit comments