Skip to content

Commit 43a7d2f

Browse files
ci: sort imports and remove prints
1 parent 4bab67f commit 43a7d2f

File tree

1 file changed

+12
-41
lines changed

1 file changed

+12
-41
lines changed

examples/tracing/openai/openai_agents_tracing.ipynb

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,24 @@
106106
"source": [
107107
"import random\n",
108108
"import uuid\n",
109-
"from pydantic import BaseModel\n",
110109
"\n",
111110
"# OpenAI Agents SDK imports\n",
112111
"from agents import (\n",
113112
" Agent,\n",
114113
" HandoffOutputItem,\n",
115114
" ItemHelpers,\n",
116115
" MessageOutputItem,\n",
117-
" Runner,\n",
118116
" RunContextWrapper,\n",
117+
" Runner,\n",
119118
" ToolCallItem,\n",
120119
" ToolCallOutputItem,\n",
121120
" function_tool,\n",
122121
" handoff,\n",
123-
" trace as agent_trace,\n",
124122
" set_trace_processors,\n",
125123
")\n",
124+
"from agents import trace as agent_trace\n",
126125
"from agents.extensions.handoff_prompt import RECOMMENDED_PROMPT_PREFIX\n",
126+
"from pydantic import BaseModel\n",
127127
"\n",
128128
"# Openlayer integration\n",
129129
"from openlayer.lib.integrations.openai_agents import OpenlayerTracerProcessor\n"
@@ -155,9 +155,7 @@
155155
" version=\"1.0.0\",\n",
156156
" environment=\"development\"\n",
157157
" )\n",
158-
"])\n",
159-
"\n",
160-
"print(\"✅ Openlayer tracing configured successfully!\")\n"
158+
"])"
161159
]
162160
},
163161
{
@@ -184,9 +182,7 @@
184182
" passenger_name: str | None = None\n",
185183
" confirmation_number: str | None = None\n",
186184
" seat_number: str | None = None\n",
187-
" flight_number: str | None = None\n",
188-
"\n",
189-
"print(\"✅ Context model defined!\")\n"
185+
" flight_number: str | None = None\n"
190186
]
191187
},
192188
{
@@ -249,9 +245,7 @@
249245
" context.context.seat_number = new_seat\n",
250246
" # Ensure that the flight number has been set by the incoming handoff\n",
251247
" assert context.context.flight_number is not None, \"Flight number is required\"\n",
252-
" return f\"Updated seat to {new_seat} for confirmation number {confirmation_number}\"\n",
253-
"\n",
254-
"print(\"✅ Function tools created!\")\n"
248+
" return f\"Updated seat to {new_seat} for confirmation number {confirmation_number}\""
255249
]
256250
},
257251
{
@@ -277,10 +271,7 @@
277271
" \"\"\"Hook that runs when handing off to the seat booking agent.\"\"\"\n",
278272
" # Generate a random flight number when booking seats\n",
279273
" flight_number = f\"FLT-{random.randint(100, 999)}\"\n",
280-
" context.context.flight_number = flight_number\n",
281-
" print(f\"🎫 Generated flight number: {flight_number}\")\n",
282-
"\n",
283-
"print(\"✅ Hook functions created!\")\n"
274+
" context.context.flight_number = flight_number"
284275
]
285276
},
286277
{
@@ -347,10 +338,7 @@
347338
"\n",
348339
"# Set up bidirectional handoffs (agents can return to triage)\n",
349340
"faq_agent.handoffs.append(triage_agent)\n",
350-
"seat_booking_agent.handoffs.append(triage_agent)\n",
351-
"\n",
352-
"print(\"✅ All agents created and configured!\")\n",
353-
"print(f\"👥 Agents: {triage_agent.name}, {faq_agent.name}, {seat_booking_agent.name}\")\n"
341+
"seat_booking_agent.handoffs.append(triage_agent)\n"
354342
]
355343
},
356344
{
@@ -380,18 +368,11 @@
380368
" current_agent = triage_agent\n",
381369
" context = AirlineAgentContext()\n",
382370
"\n",
383-
" print(f\"🎯 Starting conversation with ID: {conversation_id}\")\n",
384-
" print(f\"💬 Processing user input: '{user_input}'\")\n",
385-
"\n",
386371
" responses = []\n",
387372
"\n",
388373
" # Wrap the agent execution in a trace for Openlayer monitoring\n",
389374
" with agent_trace(\"Customer service\", group_id=conversation_id):\n",
390-
" print(\"🔍 Inside agent trace context\")\n",
391-
" print(f\"🤖 Running agent: {current_agent.name}\")\n",
392-
"\n",
393375
" result = await Runner.run(current_agent, user_input, context=context)\n",
394-
" print(f\"✅ Agent execution completed, got {len(result.new_items)} items\")\n",
395376
"\n",
396377
" # Process the results\n",
397378
" for new_item in result.new_items:\n",
@@ -410,11 +391,7 @@
410391
" else:\n",
411392
" responses.append(f\"{agent_name}: {new_item.__class__.__name__}\")\n",
412393
"\n",
413-
" print(\"📤 Exiting agent trace context - spans should be queued for export\")\n",
414-
"\n",
415-
" return \"\\n\".join(responses)\n",
416-
"\n",
417-
"print(\"✅ Conversation runner created!\")\n"
394+
" return \"\\n\".join(responses)\n"
418395
]
419396
},
420397
{
@@ -440,9 +417,7 @@
440417
"source": [
441418
"# Test FAQ functionality\n",
442419
"response = await run_conversation(\"What are the baggage restrictions?\")\n",
443-
"print(\"🎒 Baggage Query Response:\")\n",
444-
"print(response)\n",
445-
"print(\"\\n\" + \"=\"*50 + \"\\n\")\n"
420+
"response\n"
446421
]
447422
},
448423
{
@@ -464,9 +439,7 @@
464439
"source": [
465440
"# Test seat booking functionality\n",
466441
"response = await run_conversation(\"I want to change my seat\")\n",
467-
"print(\"💺 Seat Change Request Response:\")\n",
468-
"print(response)\n",
469-
"print(\"\\n\" + \"=\"*50 + \"\\n\")\n"
442+
"response\n"
470443
]
471444
},
472445
{
@@ -488,9 +461,7 @@
488461
"source": [
489462
"# Test a more complex interaction\n",
490463
"response = await run_conversation(\"I need help with my flight. Can you tell me about the seats and also help me change mine?\")\n",
491-
"print(\"🛫 Complex Query Response:\")\n",
492-
"print(response)\n",
493-
"print(\"\\n\" + \"=\"*50 + \"\\n\")\n"
464+
"response\n"
494465
]
495466
},
496467
{

0 commit comments

Comments
 (0)