Skip to content

Commit ac7abb4

Browse files
committed
reformat
1 parent 530af52 commit ac7abb4

5 files changed

Lines changed: 76 additions & 19 deletions

File tree

deepeval/evaluate/execute.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,11 @@ async def _a_execute_agentic_test_case(
12191219

12201220
test_case = LLMTestCase(
12211221
input=golden.input,
1222-
actual_output=str(current_trace.output) if current_trace.output is not None else None,
1222+
actual_output=(
1223+
str(current_trace.output)
1224+
if current_trace.output is not None
1225+
else None
1226+
),
12231227
expected_output=current_trace.expected_output,
12241228
context=current_trace.context,
12251229
retrieval_context=current_trace.retrieval_context,

deepeval/openai_agents/callback_handler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def on_trace_start(self, trace: "Trace") -> None:
5353
_trace.metadata = make_json_serializable(_trace_metadata)
5454
current_trace_context.set(_trace)
5555

56-
trace_manager.add_span( # adds a dummy root span
56+
trace_manager.add_span( # adds a dummy root span
5757
BaseSpan(
5858
uuid=_trace_uuid,
5959
trace_uuid=_trace_uuid,
@@ -77,7 +77,9 @@ def on_trace_end(self, trace: "Trace") -> None:
7777
_trace_metadata = trace_dict.get("metadata")
7878

7979
if _thread_id or _trace_metadata:
80-
trace_manager.remove_span(_trace_uuid) # removing the dummy root span
80+
trace_manager.remove_span(
81+
_trace_uuid
82+
) # removing the dummy root span
8183
trace_manager.end_trace(_trace_uuid)
8284
current_trace_context.set(None)
8385

deepeval/openai_agents/runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ async def run(
109109
metric_collection=metric_collection,
110110
metrics=metrics,
111111
func_name="run",
112-
function_kwargs={"input": input}, # also set below
112+
function_kwargs={"input": input}, # also set below
113113
) as observer:
114114
update_trace_attributes(
115115
name=name,
@@ -177,7 +177,7 @@ def run_sync(
177177
metric_collection=metric_collection,
178178
metrics=metrics,
179179
func_name="run_sync",
180-
function_kwargs={"input": input}, # also set below
180+
function_kwargs={"input": input}, # also set below
181181
) as observer:
182182
update_trace_attributes(
183183
name=name,
@@ -263,7 +263,7 @@ def run_streamed(
263263
current_trace = current_trace_context.get()
264264
if not current_trace.input:
265265
current_trace.input = input
266-
266+
267267
current_span = current_span_context.get()
268268
if current_span:
269269
current_span.input = input

tests/test_integrations/test_openai_agents/agents_app.py

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,42 +107,92 @@ async def run_weather_agent(user_input: str):
107107
)
108108
return result.final_output
109109

110+
110111
from agents import trace
111112
from multi_agents import triage_agent
113+
114+
112115
# with trace (group_id and metadata)
113116
async def main1():
114-
with trace(workflow_name="test_workflow_1", group_id="test_group_id_1", metadata={"test_metadata_1": "test_metadata_1"}):
117+
with trace(
118+
workflow_name="test_workflow_1",
119+
group_id="test_group_id_1",
120+
metadata={"test_metadata_1": "test_metadata_1"},
121+
):
115122
user_query = "What's the weather like in London today?"
116-
response_1 = await Runner.run(triage_agent, "Hola, ¿cómo estás?", metric_collection="test_collection_1", thread_id="test")
117-
response_2 = await Runner.run(weather_agent, user_query, metric_collection="test_collection_1")
123+
response_1 = await Runner.run(
124+
triage_agent,
125+
"Hola, ¿cómo estás?",
126+
metric_collection="test_collection_1",
127+
thread_id="test",
128+
)
129+
response_2 = await Runner.run(
130+
weather_agent, user_query, metric_collection="test_collection_1"
131+
)
118132
update_current_trace(input="initial input", output="final output")
119133

134+
120135
# without trace (group_id and metadata not present)
121136
async def main2():
122137
user_query = "What's the weather like in London today?"
123-
response_1 = await Runner.run(triage_agent, "Hola, ¿cómo estás?", metric_collection="test_collection_1", thread_id="test")
124-
response_2 = await Runner.run(weather_agent, user_query, metric_collection="test_collection_1")
125-
138+
response_1 = await Runner.run(
139+
triage_agent,
140+
"Hola, ¿cómo estás?",
141+
metric_collection="test_collection_1",
142+
thread_id="test",
143+
)
144+
response_2 = await Runner.run(
145+
weather_agent, user_query, metric_collection="test_collection_1"
146+
)
147+
126148

127149
async def main3():
128150
user_query = "What's the weather like in London today?"
129-
with trace(workflow_name="test_workflow_1", group_id="test_group_id_1", metadata={"test_metadata_1": "test_metadata_1"}):
130-
response_2 = await Runner.run(weather_agent, user_query, metric_collection="test_collection_1")
131-
with trace(workflow_name="test_workflow_2", group_id="test_group_id_2", metadata={"test_metadata_2": "test_metadata_2"}):
132-
response_1 = await Runner.run(triage_agent, "Hola, ¿cómo estás?", metric_collection="test_collection_1", thread_id="test")
151+
with trace(
152+
workflow_name="test_workflow_1",
153+
group_id="test_group_id_1",
154+
metadata={"test_metadata_1": "test_metadata_1"},
155+
):
156+
response_2 = await Runner.run(
157+
weather_agent, user_query, metric_collection="test_collection_1"
158+
)
159+
with trace(
160+
workflow_name="test_workflow_2",
161+
group_id="test_group_id_2",
162+
metadata={"test_metadata_2": "test_metadata_2"},
163+
):
164+
response_1 = await Runner.run(
165+
triage_agent,
166+
"Hola, ¿cómo estás?",
167+
metric_collection="test_collection_1",
168+
thread_id="test",
169+
)
170+
133171

134172
async def main4():
135173
user_query = "What's the weather like in London today?"
136-
with trace(workflow_name="test_workflow_1", group_id="test_group_id_1", metadata={"test_metadata_1": "test_metadata_1"}):
137-
run_streamed_1 = Runner.run_streamed(weather_agent, user_query, metric_collection="test_collection_1")
174+
with trace(
175+
workflow_name="test_workflow_1",
176+
group_id="test_group_id_1",
177+
metadata={"test_metadata_1": "test_metadata_1"},
178+
):
179+
run_streamed_1 = Runner.run_streamed(
180+
weather_agent, user_query, metric_collection="test_collection_1"
181+
)
138182
async for chunk in run_streamed_1.stream_events():
139183
print(chunk, end="", flush=True)
140184
print("=" * 50)
141-
run_streamed_2 = Runner.run_streamed(triage_agent, "Hola, ¿cómo estás?", metric_collection="test_collection_1", thread_id="test")
185+
run_streamed_2 = Runner.run_streamed(
186+
triage_agent,
187+
"Hola, ¿cómo estás?",
188+
metric_collection="test_collection_1",
189+
thread_id="test",
190+
)
142191
async for chunk in run_streamed_2.stream_events():
143192
print(chunk, end="", flush=True)
144193
print("=" * 50)
145194

195+
146196
def execute_agent():
147197
asyncio.run(main1())
148198
# asyncio.run(main2())

tests/test_integrations/test_openai_agents/multi_agents.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
from deepeval.openai_agents import Agent, Runner
33
from deepeval.prompt import Prompt
4+
45
# from deepeval.openai_agents import DeepEvalTracingProcessor
56

67
# from agents import add_trace_processor

0 commit comments

Comments
 (0)