{ "cells": [ { "cell_type": "markdown", "id": "b8f0b8c5", "metadata": {}, "source": [ "
\n",
" \n",
"
\n",
" Docs\n",
" |\n",
" GitHub\n",
" |\n",
" Community\n",
"
\n",
"
"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4f670acb",
"metadata": {},
"outputs": [],
"source": [
"TRIAGE_PROMPT = \"\"\"\n",
"You are a customer support summarization and triage assistant.\n",
"\n",
"Your task:\n",
"1. Read the input message from a user.\n",
"2. Summarize it in one short, clear sentence describing the issue.\n",
"3. Classify it into ONE of these categories:\n",
" - Account & Access\n",
" - Billing & Payments\n",
" - Performance & Reliability\n",
" - Integrations & APIs\n",
" - App Functionality & UI\n",
" - Other\n",
"4. Assign an urgency level:\n",
" - high β business-critical or blocking issue\n",
" - medium β major inconvenience or degraded experience\n",
" - low β minor inconvenience, cosmetic, or question\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0df7375b",
"metadata": {},
"outputs": [],
"source": [
"async def triage_issue(input: Any) -> dict[str, Any]:\n",
" response = await openai_client.chat.completions.create(\n",
" model=\"gpt-3.5-turbo\",\n",
" messages=[\n",
" {\"role\": \"system\", \"content\": TRIAGE_PROMPT},\n",
" {\"role\": \"user\", \"content\": str(input)},\n",
" ],\n",
" tools=[\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"triage\",\n",
" \"description\": (\n",
" \"Triage the input message into a summary, category, and urgency level.\"\n",
" ),\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"summary\": {\n",
" \"type\": \"string\",\n",
" \"description\": \"A short, clear sentence describing the issue.\",\n",
" },\n",
" \"category\": {\n",
" \"type\": \"string\",\n",
" \"description\": \"The category of the issue.\",\n",
" \"enum\": [\n",
" \"account_and_access\",\n",
" \"billing_and_payments\",\n",
" \"performance_and_reliability\",\n",
" \"integrations_and_apis\",\n",
" \"app_functionality_and_ui\",\n",
" \"other\",\n",
" ],\n",
" },\n",
" \"urgency\": {\n",
" \"type\": \"string\",\n",
" \"description\": \"The urgency level of the issue.\",\n",
" \"enum\": [\"High\", \"Medium\", \"Low\"],\n",
" },\n",
" },\n",
" \"required\": [\"summary\", \"category\", \"urgency\"],\n",
" },\n",
" },\n",
" }\n",
" ],\n",
" )\n",
" tool_calls = response.choices[0].message.tool_calls\n",
" if not tool_calls:\n",
" raise ValueError(\"No tool call found in response\")\n",
" arguments = tool_calls[0].function.arguments\n",
"\n",
" parsed = json.loads(arguments)\n",
" return parsed # type: ignore"
]
},
{
"cell_type": "markdown",
"id": "bfa7b338",
"metadata": {},
"source": [
"To get certain splits of your dataset, include the `splits` parameter in the `get_dataset()` parameter. Ex. `splits=[\"hard_examples\"]`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3369b2fe",
"metadata": {},
"outputs": [],
"source": [
"dataset = await phoenix_client.datasets.get_dataset(\n",
" dataset=\"triage-dataset\", splits=[\"hard_examples\"]\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ea0b23f6",
"metadata": {},
"outputs": [],
"source": [
"experiments = await phoenix_client.experiments.run_experiment(\n",
" dataset=dataset,\n",
" task=triage_issue,\n",
" experiment_name=\"few-shot-experiment\",\n",
")"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}