Skip to content

Use Cases EN

sungaowei edited this page Oct 16, 2026 · 1 revision

Use Cases

English | 简体中文


Every use case below follows the same pattern: a state (data or image content) plus a map of named questions. The question kind decides the answer shape.

Use Case Typical Questions Answer Kinds
Support ticket triage — route work to the right queue before a human reads it Which department? Is it about billing? How urgent is it? Choice, Noul, Score
Content moderation — screen user-generated text at ingest Is this spam or abuse? Which policy category? How severe? Noul, Choice, Score
Intent and sentiment analysis — turn free text into structured fields What is the intent? What is the tone? Is the customer at churn risk? Choice, Noul
Multimodal verification & object localization — inspect tickets with screenshots or documents Is there an official stamp? Where is the stamp? Is the receipt clear? Noul, Box, Score
LLM output evaluation — score a model's answer before showing it Is it grounded in the source? Does it follow format? How good is it? Noul, Score
Guardrails & routing for agent pipelines — decide what runs next Does this need a human? Is input in scope? Which tool should handle it? Noul, Choice
Data labeling and enrichment — tag a corpus or backlog Is this relevant to topic X? Project management vs. personal? Noul, Choice

Worked Example: Triaging Tickets as They Arrive

package main

import (
	"context"
	"log"

	typesafe "github.com/guchengod/typesafe-sdk-go"
)

type Ticket struct {
	ID       int
	Subject  string
	Body     string
	Customer string
}

func main() {
	client, _ := typesafe.NewClient()
	defer client.Close()

	ctx := context.Background()

	questions := typesafe.Questions{
		"queue": typesafe.NewChoice(
			map[string]any{
				"billing":   "Charges, refunds, invoices, or payment problems",
				"technical": "Bugs, crashes, or API problems",
				"account":   "Logins, access, or account settings",
				"other":     nil,
			},
			typesafe.WithInstructions("Which queue should handle this ticket?"),
		),
		"needs_human": typesafe.NewNoul(
			"",
			typesafe.WithInstructions("Does this ticket require a human response, or can it be automated?"),
		),
		"priority": typesafe.NewScore(
			[]any{"routine", "elevated", "critical"},
			typesafe.WithInstructions("How severe is this issue?"),
		),
	}

	tickets := []Ticket{
		{ID: 101, Subject: "Charged twice", Body: "I was billed twice for invoice #4912. Please refund.", Customer: "Enterprise"},
	}

	for _, ticket := range tickets {
		state := map[string]any{"subject": ticket.Subject, "body": ticket.Body, "customer": ticket.Customer}

		response, err := client.SystemOne(ctx, state, questions)
		if err != nil {
			log.Printf("ticket %d: %v", ticket.ID, err)
			continue
		}

		queueAns := response.Choices()["queue"]
		needsHuman := response.Nouls()["needs_human"]
		priority := response.Scores()["priority"]

		log.Printf("ticket %d -> queue: %s (confidence: %.2f) | needs_human: %v (p=%.2f) | priority: %.1f",
			ticket.ID, queueAns.Choice, queueAns.Confidence,
			needsHuman.Noul > 0.6, needsHuman.Noul,
			priority.Score)

		// Confidence-gated routing
		if queueAns.Confidence >= 0.85 {
			log.Printf("Auto-assign ticket %d to [%s]", ticket.ID, queueAns.Choice)
		} else {
			log.Printf("Low confidence (%.2f), queueing ticket %d for human review", queueAns.Confidence, ticket.ID)
		}
	}
}

Confidence-Gated Decision Routing

Every Choice and Score answer includes Confidence (0.0 ~ 1.0):

  • High Confidence ($\ge 0.85$): High certainty; execute fully automated downstream actions.
  • Medium Confidence ($0.50 \sim 0.85$): Plausible choice but slight ambiguity; flag for operator verification.
  • Low Confidence ($< 0.50$): Model is explicitly uncertain; fall back safely to human triage.

Batch and Stream

One client serves both. For high-volume work, share the client across goroutines and bound in-flight calls — see Concurrency.

Clone this wiki locally