Skip to content

Commit 753c317

Browse files
chore: remove unused imports, break long lines, and formatting cleanup
1 parent dbeb9f4 commit 753c317

File tree

2 files changed

+521
-361
lines changed

2 files changed

+521
-361
lines changed

examples/tracing/openai/openai_agents_tracing.ipynb

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@
7878
"import os\n",
7979
"\n",
8080
"# Set up OpenAI API key\n",
81-
"os.environ[\"OPENAI_API_KEY\"] = \"YOUR_OPENAI_API_KEY_HERE\" # Replace with your actual OpenAI API key\n",
81+
"os.environ[\"OPENAI_API_KEY\"] = \"YOUR_OPENAI_API_KEY_HERE\"\n",
8282
"\n",
8383
"# Set up Openlayer environment variables\n",
84-
"os.environ[\"OPENLAYER_INFERENCE_PIPELINE_ID\"] = \"YOUR_OPENLAYER_INFERENCE_PIPELINE_ID_HERE\" # Replace with your actual pipeline ID\n",
85-
"os.environ[\"OPENLAYER_API_KEY\"] = \"YOUR_OPENLAYER_API_KEY_HERE\" # Replace with your actual Openlayer API key\n"
84+
"os.environ[\"OPENLAYER_INFERENCE_PIPELINE_ID\"] = \"YOUR_OPENLAYER_INFERENCE_PIPELINE_ID_HERE\"\n",
85+
"os.environ[\"OPENLAYER_API_KEY\"] = \"YOUR_OPENLAYER_API_KEY_HERE\"\n"
8686
]
8787
},
8888
{
@@ -104,10 +104,8 @@
104104
"metadata": {},
105105
"outputs": [],
106106
"source": [
107-
"import asyncio\n",
108107
"import random\n",
109108
"import uuid\n",
110-
"import logging\n",
111109
"from pydantic import BaseModel\n",
112110
"\n",
113111
"# OpenAI Agents SDK imports\n",
@@ -211,7 +209,7 @@
211209
"outputs": [],
212210
"source": [
213211
"@function_tool(\n",
214-
" name_override=\"faq_lookup_tool\", \n",
212+
" name_override=\"faq_lookup_tool\",\n",
215213
" description_override=\"Lookup frequently asked questions.\"\n",
216214
")\n",
217215
"async def faq_lookup_tool(question: str) -> str:\n",
@@ -235,13 +233,13 @@
235233
"\n",
236234
"@function_tool\n",
237235
"async def update_seat(\n",
238-
" context: RunContextWrapper[AirlineAgentContext], \n",
239-
" confirmation_number: str, \n",
236+
" context: RunContextWrapper[AirlineAgentContext],\n",
237+
" confirmation_number: str,\n",
240238
" new_seat: str\n",
241239
") -> str:\n",
242240
" \"\"\"\n",
243241
" Update the seat for a given confirmation number.\n",
244-
" \n",
242+
"\n",
245243
" Args:\n",
246244
" confirmation_number: The confirmation number for the flight.\n",
247245
" new_seat: The new seat to update to.\n",
@@ -378,27 +376,27 @@
378376
" \"\"\"Run a single conversation turn with the agent system.\"\"\"\n",
379377
" if conversation_id is None:\n",
380378
" conversation_id = uuid.uuid4().hex[:16]\n",
381-
" \n",
379+
"\n",
382380
" current_agent = triage_agent\n",
383381
" context = AirlineAgentContext()\n",
384-
" \n",
382+
"\n",
385383
" print(f\"🎯 Starting conversation with ID: {conversation_id}\")\n",
386384
" print(f\"💬 Processing user input: '{user_input}'\")\n",
387-
" \n",
385+
"\n",
388386
" responses = []\n",
389-
" \n",
387+
"\n",
390388
" # Wrap the agent execution in a trace for Openlayer monitoring\n",
391389
" with agent_trace(\"Customer service\", group_id=conversation_id):\n",
392390
" print(\"🔍 Inside agent trace context\")\n",
393391
" print(f\"🤖 Running agent: {current_agent.name}\")\n",
394-
" \n",
392+
"\n",
395393
" result = await Runner.run(current_agent, user_input, context=context)\n",
396394
" print(f\"✅ Agent execution completed, got {len(result.new_items)} items\")\n",
397-
" \n",
395+
"\n",
398396
" # Process the results\n",
399397
" for new_item in result.new_items:\n",
400398
" agent_name = new_item.agent.name\n",
401-
" \n",
399+
"\n",
402400
" if isinstance(new_item, MessageOutputItem):\n",
403401
" message = ItemHelpers.text_message_output(new_item)\n",
404402
" responses.append(f\"{agent_name}: {message}\")\n",
@@ -411,9 +409,9 @@
411409
" responses.append(f\"{agent_name}: Tool call output: {new_item.output}\")\n",
412410
" else:\n",
413411
" responses.append(f\"{agent_name}: {new_item.__class__.__name__}\")\n",
414-
" \n",
412+
"\n",
415413
" print(\"📤 Exiting agent trace context - spans should be queued for export\")\n",
416-
" \n",
414+
"\n",
417415
" return \"\\n\".join(responses)\n",
418416
"\n",
419417
"print(\"✅ Conversation runner created!\")\n"
@@ -494,11 +492,18 @@
494492
"print(response)\n",
495493
"print(\"\\n\" + \"=\"*50 + \"\\n\")\n"
496494
]
495+
},
496+
{
497+
"cell_type": "code",
498+
"execution_count": null,
499+
"metadata": {},
500+
"outputs": [],
501+
"source": []
497502
}
498503
],
499504
"metadata": {
500505
"kernelspec": {
501-
"display_name": ".venv",
506+
"display_name": "agents",
502507
"language": "python",
503508
"name": "python3"
504509
},
@@ -512,7 +517,7 @@
512517
"name": "python",
513518
"nbconvert_exporter": "python",
514519
"pygments_lexer": "ipython3",
515-
"version": "3.10.16"
520+
"version": "3.10.14"
516521
}
517522
},
518523
"nbformat": 4,

0 commit comments

Comments
 (0)