Skip to content
Merged
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: 0 additions & 1 deletion openai-agents/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ The example is an agent that can search for the weather in certain city.
```
3. Start the services:
```shell
cd openai_sdk
uv run .
```
4. Register the services:
Expand Down
6 changes: 3 additions & 3 deletions openai-agents/template/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ requires-python = ">=3.12"
dependencies = [
"httpx",
"hypercorn",
"restate_sdk[serde]>=0.7.3",
"pydantic>=2.10.6",
"openai-agents==0.0.17",
"restate_sdk[serde]>=0.10.1",
"pydantic>=2.11.9",
"openai-agents==0.3.1",
]
41 changes: 3 additions & 38 deletions openai-agents/template/utils/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
from agents import (
Usage,
Model,
ModelSettings,
Tool,
TResponseInputItem,
Handoff,
ModelTracing,
AgentOutputSchemaBase,
)
from agents.models.multi_provider import MultiProvider
from agents.items import TResponseStreamEvent, TResponseOutputItem
Expand Down Expand Up @@ -60,28 +55,9 @@ def __init__(self, ctx: restate.Context, model: Model):
self.model = model
self.model_name = f"RestateModelWrapper"

async def get_response(
self,
system_instructions: str | None,
input: str | list[TResponseInputItem],
model_settings: ModelSettings,
tools: list[Tool],
output_schema: AgentOutputSchemaBase | None,
handoffs: list[Handoff],
tracing: ModelTracing,
previous_response_id: str | None,
) -> RestateModelResponse:
async def get_response(self, *args, **kwargs) -> RestateModelResponse:
async def call_llm() -> RestateModelResponse:
resp = await self.model.get_response(
system_instructions=system_instructions,
input=input,
model_settings=model_settings,
tools=tools,
output_schema=output_schema,
handoffs=handoffs,
tracing=tracing,
previous_response_id=previous_response_id,
)
resp = await self.model.get_response(*args, **kwargs)
return RestateModelResponse(
output=resp.output,
usage=resp.usage,
Expand All @@ -90,18 +66,7 @@ async def call_llm() -> RestateModelResponse:

return await self.ctx.run("call LLM", call_llm, max_attempts=3)

def stream_response(
self,
system_instructions: str | None,
input: str | list[TResponseInputItem],
model_settings: ModelSettings,
tools: list[Tool],
output_schema: AgentOutputSchemaBase | None,
handoffs: list[Handoff],
tracing: ModelTracing,
*,
previous_response_id: str | None,
) -> AsyncIterator[TResponseStreamEvent]:
def stream_response(self, *args, **kwargs) -> AsyncIterator[TResponseStreamEvent]:
raise restate.TerminalError(
"Streaming is not supported in Restate. Use `get_response` instead."
)
Loading