DEV Community

shashank ms
shashank ms

Posted on

LLM vs Traditional Machine Learning Models

Most teams still maintain separate scikit-learn pipelines for classification, sentiment analysis, and response generation. We will replace that entire stack with a single LLM agent that triages customer support tickets, scores urgency, and drafts replies in one call. This removes the feature engineering bottleneck and cuts deployment time from weeks to minutes.

What you'll need

Step 1: Set up the Oxlo.ai client

Import the SDK and point it to Oxlo.ai. Because Oxlo.ai is fully OpenAI compatible, this is a drop-in replacement and no custom adapters are needed.

from openai import OpenAI
import json

client = OpenAI(
    base_url="https://api.oxlo.ai/v1",
    api_key="YOUR_OXLO_API_KEY"  # from https://portal.oxlo.ai
)

Step 2: Write the system prompt

The prompt is the only training we need. It tells the model to act as a tier-1 support analyst and to return strictly formatted JSON. Traditional ML would require labeled datasets for classification, sentiment, and text generation, but here we describe the task in plain English.

SYSTEM_PROMPT = """You are a support ticket triage agent.
Analyze the user message and return a single JSON object with these exact keys:
- category: one of [Billing, Technical, Account, General]
- urgency: one of [Low, Medium, High, Critical]
- sentiment: one of [Angry, Frustrated, Neutral, Satisfied]
- draft_response: a concise, helpful reply written in a professional tone

Rules:
1. Output ONLY valid JSON. No markdown fences, no explanations.
2. If the user is threatening churn or mentions payment failure, set urgency to Critical.
3. Keep draft_response under 120 words."""

Step 3: Build the processing function

This function takes raw ticket text, sends it to Oxlo.ai with the system prompt, and returns a Python dict. I use Llama 3.3 70B because it handles mixed instructions and JSON formatting reliably. If you prefer multilingual tickets, swap the model id to qwen-3-32b.

def handle_ticket(ticket_text: str) -> dict:
    response = client.chat.completions.create(
        model="llama-3.3-70b",
        messages=[
            {"role": "system", "content": SYSTEM_PROMPT},
            {"role": "user", "content": ticket_text},
        ],
        temperature=0.1,
    )
    
    raw = response.choices[0].message.content
    return json.loads(raw)

Step 4: Prepare test tickets

Here are three real-world style tickets we will process. In a traditional pipeline you would first vectorize these with TF-IDF, run them through a classifier, then feed them to a template engine. We skip all of that.

tickets = [
    "I was charged twice for my subscription this month and I need a refund immediately or I am canceling.",
    "How do I reset my webhook URL? The docs mention a settings page but I cannot find it.",
    "Love the new dashboard. Just wanted to say thanks to the team.",
]

Run it

Loop through the tickets, call handle_ticket, and print the structured results. Because Oxlo.ai uses request-based pricing, the cost is the same per ticket regardless of whether the user writes two sentences or two paragraphs. That makes this agent predictable to run in production, especially during incidents when tickets get long.

for t in tickets:
    result = handle_ticket(t)
    print(json.dumps(result, indent=2))
    print("-" * 40)

Example output:

{
  "category": "Billing",
  "urgency": "Critical",
  "sentiment": "Angry",
  "draft_response": "I sincerely apologize for the double charge. I have escalated this to our billing team and initiated a refund. You will see the credit within 3-5 business days."
}
----------------------------------------
{
  "category": "Technical",
  "urgency": "Medium",
  "sentiment": "Frustrated",
  "draft_response": "No problem. Go to Settings, Integrations, Webhooks and click Regenerate URL. If the menu is missing, clear your cache or try an incognito window."
}
----------------------------------------
{
  "category": "General",
  "urgency": "Low",
  "sentiment": "Satisfied",
  "draft_response": "Thank you for the kind words. We are glad you are enjoying the new dashboard."
}

Wrap-up

You now have a single LLM agent that replaces three separate traditional ML components. If you want to tighten output further, switch to deepseek-v3.2 and add a JSON schema constraint. For high volume, Oxlo.ai request-based pricing means your bill stays flat even when customers paste logs into the ticket. Check the details at https://oxlo.ai/pricing.

Top comments (0)