openai-agents 0.2.1__py3-none-any.whl → 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of openai-agents might be problematic. Click here for more details.
- agents/realtime/runner.py +1 -43
- agents/realtime/session.py +23 -7
- {openai_agents-0.2.1.dist-info → openai_agents-0.2.2.dist-info}/METADATA +1 -1
- {openai_agents-0.2.1.dist-info → openai_agents-0.2.2.dist-info}/RECORD +6 -6
- {openai_agents-0.2.1.dist-info → openai_agents-0.2.2.dist-info}/WHEEL +0 -0
- {openai_agents-0.2.1.dist-info → openai_agents-0.2.2.dist-info}/licenses/LICENSE +0 -0
agents/realtime/runner.py
CHANGED
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
from ..run_context import RunContextWrapper, TContext
|
|
5
|
+
from ..run_context import TContext
|
|
8
6
|
from .agent import RealtimeAgent
|
|
9
7
|
from .config import (
|
|
10
8
|
RealtimeRunConfig,
|
|
11
|
-
RealtimeSessionModelSettings,
|
|
12
9
|
)
|
|
13
10
|
from .model import (
|
|
14
11
|
RealtimeModel,
|
|
@@ -67,16 +64,6 @@ class RealtimeRunner:
|
|
|
67
64
|
print(event)
|
|
68
65
|
```
|
|
69
66
|
"""
|
|
70
|
-
model_settings = await self._get_model_settings(
|
|
71
|
-
agent=self._starting_agent,
|
|
72
|
-
disable_tracing=self._config.get("tracing_disabled", False) if self._config else False,
|
|
73
|
-
initial_settings=model_config.get("initial_model_settings") if model_config else None,
|
|
74
|
-
overrides=self._config.get("model_settings") if self._config else None,
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
model_config = model_config.copy() if model_config else {}
|
|
78
|
-
model_config["initial_model_settings"] = model_settings
|
|
79
|
-
|
|
80
67
|
# Create and return the connection
|
|
81
68
|
session = RealtimeSession(
|
|
82
69
|
model=self._model,
|
|
@@ -87,32 +74,3 @@ class RealtimeRunner:
|
|
|
87
74
|
)
|
|
88
75
|
|
|
89
76
|
return session
|
|
90
|
-
|
|
91
|
-
async def _get_model_settings(
|
|
92
|
-
self,
|
|
93
|
-
agent: RealtimeAgent,
|
|
94
|
-
disable_tracing: bool,
|
|
95
|
-
context: TContext | None = None,
|
|
96
|
-
initial_settings: RealtimeSessionModelSettings | None = None,
|
|
97
|
-
overrides: RealtimeSessionModelSettings | None = None,
|
|
98
|
-
) -> RealtimeSessionModelSettings:
|
|
99
|
-
context_wrapper = RunContextWrapper(context)
|
|
100
|
-
model_settings = initial_settings.copy() if initial_settings else {}
|
|
101
|
-
|
|
102
|
-
instructions, tools = await asyncio.gather(
|
|
103
|
-
agent.get_system_prompt(context_wrapper),
|
|
104
|
-
agent.get_all_tools(context_wrapper),
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
if instructions is not None:
|
|
108
|
-
model_settings["instructions"] = instructions
|
|
109
|
-
if tools is not None:
|
|
110
|
-
model_settings["tools"] = tools
|
|
111
|
-
|
|
112
|
-
if overrides:
|
|
113
|
-
model_settings.update(overrides)
|
|
114
|
-
|
|
115
|
-
if disable_tracing:
|
|
116
|
-
model_settings["tracing"] = None
|
|
117
|
-
|
|
118
|
-
return model_settings
|
agents/realtime/session.py
CHANGED
|
@@ -114,8 +114,13 @@ class RealtimeSession(RealtimeModelListener):
|
|
|
114
114
|
# Add ourselves as a listener
|
|
115
115
|
self._model.add_listener(self)
|
|
116
116
|
|
|
117
|
+
model_config = self._model_config.copy()
|
|
118
|
+
model_config["initial_model_settings"] = await self._get_updated_model_settings_from_agent(
|
|
119
|
+
self._current_agent
|
|
120
|
+
)
|
|
121
|
+
|
|
117
122
|
# Connect to the model
|
|
118
|
-
await self._model.connect(
|
|
123
|
+
await self._model.connect(model_config)
|
|
119
124
|
|
|
120
125
|
# Emit initial history update
|
|
121
126
|
await self._put_event(
|
|
@@ -319,7 +324,9 @@ class RealtimeSession(RealtimeModelListener):
|
|
|
319
324
|
self._current_agent = result
|
|
320
325
|
|
|
321
326
|
# Get updated model settings from new agent
|
|
322
|
-
updated_settings = await self.
|
|
327
|
+
updated_settings = await self._get_updated_model_settings_from_agent(
|
|
328
|
+
self._current_agent
|
|
329
|
+
)
|
|
323
330
|
|
|
324
331
|
# Send handoff event
|
|
325
332
|
await self._put_event(
|
|
@@ -495,19 +502,28 @@ class RealtimeSession(RealtimeModelListener):
|
|
|
495
502
|
# Mark as closed
|
|
496
503
|
self._closed = True
|
|
497
504
|
|
|
498
|
-
async def
|
|
499
|
-
self,
|
|
505
|
+
async def _get_updated_model_settings_from_agent(
|
|
506
|
+
self,
|
|
507
|
+
agent: RealtimeAgent,
|
|
500
508
|
) -> RealtimeSessionModelSettings:
|
|
501
509
|
updated_settings: RealtimeSessionModelSettings = {}
|
|
502
510
|
instructions, tools, handoffs = await asyncio.gather(
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
self._get_handoffs(
|
|
511
|
+
agent.get_system_prompt(self._context_wrapper),
|
|
512
|
+
agent.get_all_tools(self._context_wrapper),
|
|
513
|
+
self._get_handoffs(agent, self._context_wrapper),
|
|
506
514
|
)
|
|
507
515
|
updated_settings["instructions"] = instructions or ""
|
|
508
516
|
updated_settings["tools"] = tools or []
|
|
509
517
|
updated_settings["handoffs"] = handoffs or []
|
|
510
518
|
|
|
519
|
+
# Override with initial settings
|
|
520
|
+
initial_settings = self._model_config.get("initial_model_settings", {})
|
|
521
|
+
updated_settings.update(initial_settings)
|
|
522
|
+
|
|
523
|
+
disable_tracing = self._run_config.get("tracing_disabled", False)
|
|
524
|
+
if disable_tracing:
|
|
525
|
+
updated_settings["tracing"] = None
|
|
526
|
+
|
|
511
527
|
return updated_settings
|
|
512
528
|
|
|
513
529
|
@classmethod
|
|
@@ -59,8 +59,8 @@ agents/realtime/model.py,sha256=YwMBwtj33Z6uADnz1AoYg4wSfmpfYdZNq7ZaK8hlekw,2188
|
|
|
59
59
|
agents/realtime/model_events.py,sha256=JDh70uDctVuwex5EiYUdWhqQvBarN3ge7eREd1aUznU,3386
|
|
60
60
|
agents/realtime/model_inputs.py,sha256=OW2bn3wD5_pXLunDUf35jhG2q_bTKbC_D7Qu-83aOEA,2243
|
|
61
61
|
agents/realtime/openai_realtime.py,sha256=YubVE1BbdnDpTbLxuh9WFy0eS2y1WzA8h0EdtIzfhC0,27190
|
|
62
|
-
agents/realtime/runner.py,sha256=
|
|
63
|
-
agents/realtime/session.py,sha256=
|
|
62
|
+
agents/realtime/runner.py,sha256=KfU7utmc9QFH2htIKN2IN9H-5EnB0qN9ezmvlRTnOm4,2511
|
|
63
|
+
agents/realtime/session.py,sha256=IZ_b28faA975VC169rBbKHrdh1GFd-vHnotoJ9nv4y0,21407
|
|
64
64
|
agents/tracing/__init__.py,sha256=5HO_6na5S6EwICgwl50OMtxiIIosUrqalhvldlYvSVc,2991
|
|
65
65
|
agents/tracing/create.py,sha256=Gm9N5O2DeBy6UU86tRN0wnmzWyXb-qAUBbTj9oxIHao,18106
|
|
66
66
|
agents/tracing/logger.py,sha256=J4KUDRSGa7x5UVfUwWe-gbKwoaq8AeETRqkPt3QvtGg,68
|
|
@@ -95,7 +95,7 @@ agents/voice/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
|
|
|
95
95
|
agents/voice/models/openai_model_provider.py,sha256=Khn0uT-VhsEbe7_OhBMGFQzXNwL80gcWZyTHl3CaBII,3587
|
|
96
96
|
agents/voice/models/openai_stt.py,sha256=LcVDS7f1pmbm--PWX-IaV9uLg9uv5_L3vSCbVnTJeGs,16864
|
|
97
97
|
agents/voice/models/openai_tts.py,sha256=4KoLQuFDHKu5a1VTJlu9Nj3MHwMlrn9wfT_liJDJ2dw,1477
|
|
98
|
-
openai_agents-0.2.
|
|
99
|
-
openai_agents-0.2.
|
|
100
|
-
openai_agents-0.2.
|
|
101
|
-
openai_agents-0.2.
|
|
98
|
+
openai_agents-0.2.2.dist-info/METADATA,sha256=xaLhodklHzACu9wxsG1fWtpr9KV7IL69N2CI_0cB4Hs,11560
|
|
99
|
+
openai_agents-0.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
100
|
+
openai_agents-0.2.2.dist-info/licenses/LICENSE,sha256=E994EspT7Krhy0qGiES7WYNzBHrh1YDk3r--8d1baRU,1063
|
|
101
|
+
openai_agents-0.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|