Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Build Binaries
on:
pull_request:
push:
branches:
- main
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = [
"workflow",
]
dependencies = [
"nexus-rpc>=1.1.0",
"nexus-rpc==1.1.0",
"protobuf>=3.20,<6",
"python-dateutil>=2.8.2,<3 ; python_version < '3.11'",
"types-protobuf>=3.20",
Expand Down Expand Up @@ -231,6 +231,3 @@ exclude = [
[tool.uv]
# Prevent uv commands from building the package by default
package = false

[tool.uv.sources]
nexus-rpc = { git = "https://github.com/nexus-rpc/sdk-python.git", rev = "35f574c711193a6e2560d3e6665732a5bb7ae92c" }
39 changes: 19 additions & 20 deletions temporalio/contrib/openai_agents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ import asyncio
from datetime import timedelta

from temporalio.client import Client
from temporalio.contrib.openai_agents import ModelActivity, ModelActivityParameters, set_open_ai_agent_temporal_overrides
from temporalio.contrib.pydantic import pydantic_data_converter
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin, ModelActivityParameters
from temporalio.worker import Worker

from hello_world_workflow import HelloWorldAgent
Expand All @@ -96,24 +95,24 @@ from hello_world_workflow import HelloWorldAgent
async def worker_main():
# Configure the OpenAI Agents SDK to use Temporal activities for LLM API calls
# and for tool calls.
model_params = ModelActivityParameters(
start_to_close_timeout=timedelta(seconds=10)
# Create a Temporal client connected to server at the given address
client = await Client.connect(
"localhost:7233",
plugins=[
OpenAIAgentsPlugin(
model_params=ModelActivityParameters(
start_to_close_timeout=timedelta(seconds=10)
)
)
]
)
with set_open_ai_agent_temporal_overrides(model_params):
# Create a Temporal client connected to server at the given address
# Use the OpenAI data converter to ensure proper serialization/deserialization
client = await Client.connect(
"localhost:7233",
data_converter=pydantic_data_converter,
)

worker = Worker(
client,
task_queue="my-task-queue",
workflows=[HelloWorldAgent],
activities=[ModelActivity().invoke_model_activity],
)
await worker.run()
worker = Worker(
client,
task_queue="my-task-queue",
workflows=[HelloWorldAgent],
)
await worker.run()


if __name__ == "__main__":
Expand All @@ -134,15 +133,15 @@ import asyncio

from temporalio.client import Client
from temporalio.common import WorkflowIDReusePolicy
from temporalio.contrib.pydantic import pydantic_data_converter
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin

from hello_world_workflow import HelloWorldAgent

async def main():
# Create client connected to server at the given address
client = await Client.connect(
"localhost:7233",
data_converter=pydantic_data_converter,
plugins=[OpenAIAgentsPlugin()]
)

# Execute a workflow
Expand Down
2 changes: 1 addition & 1 deletion temporalio/nexus/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async def _start(
return WorkflowRunOperationHandler(_start, input_type, output_type)

method_name = get_callable_name(start)
nexusrpc.set_operation(
nexusrpc.set_operation_definition(
operation_handler_factory,
nexusrpc.Operation(
name=name or method_name,
Expand Down
4 changes: 2 additions & 2 deletions temporalio/worker/_interceptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def __post_init__(self) -> None:
if isinstance(self.operation, nexusrpc.Operation):
self.output_type = self.operation.output_type
elif callable(self.operation):
if op := nexusrpc.get_operation(self.operation):
if op := nexusrpc.get_operation_definition(self.operation):
self.output_type = op.output_type
else:
raise ValueError(
Expand All @@ -325,7 +325,7 @@ def operation_name(self) -> str:
elif isinstance(self.operation, str):
return self.operation
elif callable(self.operation):
if op := nexusrpc.get_operation(self.operation):
if op := nexusrpc.get_operation_definition(self.operation):
return op.name
else:
raise ValueError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ async def test_run_nexus_service_from_programmatically_created_service_handler(
service_handler = nexusrpc.handler._core.ServiceHandler(
service=nexusrpc.ServiceDefinition(
name="MyService",
operation_definitions={
"increment": nexusrpc.OperationDefinition[int, int](
operations={
"increment": nexusrpc.Operation[int, int](
name="increment",
method_name="increment",
input_type=int,
Expand Down
4 changes: 3 additions & 1 deletion tests/nexus/test_handler_operation_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ async def test_collected_operation_names(
assert isinstance(service_defn, nexusrpc.ServiceDefinition)
assert service_defn.name == "Service"
for method_name, expected_op in test_case.expected_operations.items():
actual_op = nexusrpc.get_operation(getattr(test_case.Service, method_name))
actual_op = nexusrpc.get_operation_definition(
getattr(test_case.Service, method_name)
)
assert isinstance(actual_op, nexusrpc.Operation)
assert actual_op.name == expected_op.name
assert actual_op.input_type == expected_op.input_type
Expand Down
8 changes: 6 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.