Skip to content

Commit 3588c1e

Browse files
committed
Add GenAI tool definitions to sample spans
1 parent 9ff5888 commit 3588c1e

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

lab/5-Observability/01-trace-agent-session.ipynb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,27 @@
7777
" \"price\": 24.0,\n",
7878
" \"available_stock\": 67\n",
7979
"}\n",
80+
"tool_definitions = [\n",
81+
" {\n",
82+
" \"type\": \"function\",\n",
83+
" \"name\": \"product_search\",\n",
84+
" \"description\": \"Searches the catalog for matching Zava retail products.\",\n",
85+
" \"parameters\": {\n",
86+
" \"type\": \"object\",\n",
87+
" \"properties\": {\n",
88+
" \"sku\": {\n",
89+
" \"type\": \"string\",\n",
90+
" \"description\": \"Unique product SKU to search for.\"\n",
91+
" },\n",
92+
" \"query\": {\n",
93+
" \"type\": \"string\",\n",
94+
" \"description\": \"Free-form text describing the desired product.\"\n",
95+
" }\n",
96+
" },\n",
97+
" \"required\": [\"sku\"]\n",
98+
" }\n",
99+
" }\n",
100+
"]\n",
80101
"input_messages = [\n",
81102
" {\n",
82103
" \"role\": \"system\",\n",
@@ -130,6 +151,7 @@
130151
" span.set_attribute(\"gen_ai.agent.description\", \"Cora retail assistant for Zava DIY customers.\")\n",
131152
" span.set_attribute(\"gen_ai.request.model\", \"gpt-4o-mini\")\n",
132153
" span.set_attribute(\"gen_ai.system_instructions\", system_prompt)\n",
154+
" span.set_attribute(\"gen_ai.tool.definitions\", json.dumps(tool_definitions, ensure_ascii=False))\n",
133155
" span.set_attribute(\"server.address\", \"cora-agents.eastus2.inference.ai.azure.com\")\n",
134156
" span.set_attribute(\"server.port\", 443)\n",
135157
" span.set_attribute(\"azure.resource_provider.namespace\", \"Microsoft.CognitiveServices\")\n",

lab/5-Observability/02-collect-span-snapshots.ipynb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,27 @@
7171
" \"name\": \"Zava SwiftCoat Satin\",\n",
7272
" \"inventory\": 142\n",
7373
" }\n",
74+
" tool_definitions = [\n",
75+
" {\n",
76+
" \"type\": \"function\",\n",
77+
" \"name\": \"inventory_lookup\",\n",
78+
" \"description\": \"Fetches inventory details for a specific product category and finish.\",\n",
79+
" \"parameters\": {\n",
80+
" \"type\": \"object\",\n",
81+
" \"properties\": {\n",
82+
" \"product_type\": {\n",
83+
" \"type\": \"string\",\n",
84+
" \"description\": \"Product category name to search.\"\n",
85+
" },\n",
86+
" \"finish\": {\n",
87+
" \"type\": \"string\",\n",
88+
" \"description\": \"Desired paint finish (e.g., satin, matte).\"\n",
89+
" }\n",
90+
" },\n",
91+
" \"required\": [\"product_type\"]\n",
92+
" }\n",
93+
" }\n",
94+
" ]\n",
7495
" input_messages = [\n",
7596
" {\n",
7697
" \"role\": \"system\",\n",
@@ -133,6 +154,7 @@
133154
" span.set_attribute(\"gen_ai.usage.output_tokens\", 41)\n",
134155
" span.set_attribute(\"gen_ai.conversation.id\", conversation_id)\n",
135156
" span.set_attribute(\"gen_ai.system_instructions\", system_prompt)\n",
157+
" span.set_attribute(\"gen_ai.tool.definitions\", json.dumps(tool_definitions, ensure_ascii=False))\n",
136158
" span.set_attribute(\"gen_ai.input.messages\", json.dumps(input_messages, ensure_ascii=False))\n",
137159
" span.set_attribute(\"gen_ai.output.messages\", json.dumps(output_messages, ensure_ascii=False))\n",
138160
" span.set_attribute(\"server.address\", \"cora-agents.eastus2.inference.ai.azure.com\")\n",

0 commit comments

Comments
 (0)