What You'll Learn
- What Jev is and how it differs from traditional LLMs
- What "System One" models are (and how they relate to Kahneman's thinking framework)
- The three question types: Choice, Score, and Noul
- How to use Jev with LangChain (
langchain-typesafe) - Real-world use cases: Model Routing, Agent Guardrails, Email Triage, Support Ticket Classification
- Where Jev fits in the agent loop alongside GPT/Gemini/Claude
1. What Is Jev?
The Simple Idea
Jev is a classification model built by TypeSafe AI. Unlike GPT or Gemini, Jev does NOT generate text. Instead, it answers structured questions about data and returns typed answers with probabilities.
TRADITIONAL LLM (GPT, Gemini, Claude):
Input: "Is this support ticket urgent?"
Output: "Yes, based on the language used, this appears to be an urgent request..."
Speed: ~500-2000ms
Cost: ~$0.01 per call
JEV (System One Model):
Input: State + Question { "is_urgent": noul }
Output: { "is_urgent": { "noul": 0.999 } } ← 99.9% probability
Speed: ~2-5ms (200x faster)
Cost: ~$0.00003 per call (400x cheaper)
💡 Analogy: Think of a company. The LLM is the CEO — brilliant, can write reports, reason through complex problems, but slow and expensive. Jev is the security guard at the front gate — instantly decides "allowed" or "blocked" without needing to write a paragraph about it. You wouldn't ask the CEO to check ID badges; you wouldn't ask the guard to write the quarterly report.
2. What Are "System One" Models?
The name comes from Daniel Kahneman's famous book Thinking, Fast and Slow:
| System | Thinking Type | Example | AI Equivalent |
|---|---|---|---|
| System 1 | Fast, automatic, intuitive | "Is this email spam?" → Instantly know | Jev — fast classification |
| System 2 | Slow, deliberate, analytical | "Write a marketing strategy" → Think carefully | GPT/Gemini — text generation |
System One Model Definition
📖 System One models are a class of AI models built to make fast, structured decisions that software can use directly. A System One model evaluates a state and returns typed answers and probabilities.
How It's Trained
Jev uses Reinforcement Learning for Calibrated Decisions (RLCD) — a training approach that optimizes for producing well-calibrated probability scores (when Jev says 0.95, it really means 95% confident, not just a rough guess).
Traditional LLM Training:
Objective: Generate the NEXT TOKEN that best continues the text
Output: Free-form text (any shape, any length)
Jev (RLCD) Training:
Objective: Produce CALIBRATED PROBABILITIES for structured questions
Output: Fixed-shape JSON with confidence scores
3. How Jev Works — State + Questions
Every Jev call follows the same simple pattern: you send state (the context) and questions about that state.
The API Request Format
{
"model": "jev-latest",
"state": "Hi, I've been trying to connect my Stripe account for 3 days and it keeps failing. I'm losing sales. Please help ASAP.",
"questions": {
"is_urgent": {
"type": "noul",
"instructions": "The message conveys urgency or time-sensitivity"
}
}
}
The API Response
{
"is_urgent": {
"type": "noul",
"noul": 0.999
}
}
That's it. 0.999 = 99.9% probability that the message is urgent. Your code uses this number directly — no text parsing needed.
4. The Three Question Types
Jev supports three types of structured questions, each designed for a different decision pattern:
4a. Noul (Yes/No)
"Is this statement true?" → Returns probability (0.0 to 1.0)
# Noul = Boolean probability
{
"is_urgent": {
"type": "noul",
"instructions": "The message conveys urgency"
}
}
# Response: { "noul": 0.999 } ← 99.9% yes
💡 Analogy: Like a lie detector that gives you a confidence percentage instead of just "true" or "false".
Use cases: Spam detection, urgency flagging, content safety checks, prompt injection detection.
4b. Choice (Pick One from Options)
"Which category does this belong to?" → Returns probability for EACH option
{
"department": {
"type": "choice",
"instructions": "Which team should handle this ticket?",
"options": ["billing", "engineering", "sales", "hr"]
}
}
# Response:
# { "choice": "engineering", "probabilities": {"billing": 0.02, "engineering": 0.91, "sales": 0.05, "hr": 0.02} }
💡 Analogy: Like asking 100 experts to vote on which category something belongs to, and getting the vote distribution back.
Use cases: Intent classification, model routing, agent selection, query categorization.
4c. Score (Rate on a Scale)
"Rate this on a scale" → Returns continuous score between ordered levels
{
"severity": {
"type": "score",
"instructions": "How severe is this issue?",
"levels": ["low", "medium", "high", "critical"]
}
}
# Response:
# { "score": 0.87, "level": "high" }
💡 Analogy: Like asking a doctor "how sick is this patient?" and getting a precise number on a severity scale, not just "pretty sick."
Use cases: Risk scoring, quality assessment, sentiment intensity, priority ranking.
5. Multiple Questions in One Request
One of Jev's killer features: you can ask multiple questions about the same state in one API call. All questions are evaluated in parallel, so adding more questions barely changes latency.
{
"model": "jev-latest",
"state": "Customer: I was charged $499 twice for the same order. This is ridiculous. Fix it NOW or I'm filing a chargeback.",
"questions": {
"is_urgent": {
"type": "noul",
"instructions": "Does this need immediate attention?"
},
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"options": ["billing", "engineering", "sales", "support"]
},
"sentiment": {
"type": "score",
"instructions": "How negative is the customer sentiment?",
"levels": ["positive", "neutral", "frustrated", "angry"]
}
}
}
One call → Three answers → ~3ms total.
Compare this to using an LLM:
- 3 separate LLM calls ≈ 3000ms and ~$0.03
- 1 Jev call with 3 questions ≈ 3ms and ~$0.00003
6. Using Jev with LangChain
Installation
pip install langchain-typesafe
Setting Up
import os
os.environ["TYPESAFE_API_KEY"] = "your-api-key-here"
Basic Classification with TypeSafeClassifier
from langchain_typesafe import Noul, Choice, Score, TypeSafeClassifier
# Create the classifier (like creating a ChatOpenAI instance)
classifier = TypeSafeClassifier()
# Classify a support ticket
response = classifier.invoke({
"state": (
"The deploy failed twice and customers are seeing 500s. "
"Can someone look now?"
),
"questions": {
"urgent": Noul(
instructions="Does this need attention right now?"
),
},
})
# Use the result directly — no text parsing!
urgency = response.nouls["urgent"].noul # 0.999
if urgency > 0.8:
print("🚨 URGENT! Routing to on-call engineer...")
💡 Key Difference from ChatOpenAI: With
ChatOpenAI.invoke(), you get a text string you have to parse. WithTypeSafeClassifier.invoke(), you get typed Python objects with probability scores you can use directly inifstatements.
Multi-Question Example
from langchain_typesafe import Noul, Choice, Score, TypeSafeClassifier
classifier = TypeSafeClassifier()
result = classifier.invoke({
"state": "My payment of $2,400 was deducted but order shows cancelled. Need refund ASAP.",
"questions": {
"urgent": Noul(instructions="Needs immediate attention?"),
"team": Choice(
instructions="Which team should handle this?",
options=["billing", "engineering", "support", "sales"]
),
"anger_level": Score(
instructions="How frustrated is the customer?",
levels=["calm", "concerned", "frustrated", "furious"]
),
},
})
print(f"Urgency: {result.nouls['urgent'].noul:.1%}") # 99.8%
print(f"Team: {result.choices['team'].choice}") # "billing"
print(f"Anger Level: {result.scores['anger_level'].level}") # "frustrated"
7. Real-World Use Cases with LLM Agents
7a. Model Routing (Use Cheap Model vs Expensive Model)
Problem: Every query going to GPT-4 is expensive. Simple lookups ("what's the PTO policy?") don't need the same model as complex debugging tasks.
Solution: Jev classifies the query difficulty in ~2ms, then routes to the appropriate model:
from langchain_typesafe.experimental.middleware import (
ModelChoice,
ModelRouterMiddleware,
)
router = ModelRouterMiddleware(
choices={
"fast": ModelChoice(
model="openai:gpt-4o-mini",
criteria="Direct lookups, extraction, and localized changes.",
),
"powerful": ModelChoice(
model="openai:gpt-4o",
criteria="Architecture decisions and high-stakes analysis.",
),
},
instructions="Choose the least costly model that can complete the task.",
)
Without Jev (every query → GPT-4):
100 queries × $0.03 = $3.00
With Jev routing (80 simple → GPT-4o-mini, 20 complex → GPT-4):
80 × $0.002 + 20 × $0.03 + 100 × $0.00003 = $0.763
────────────────────────────────────────────────
💰 75% COST REDUCTION
7b. Agent Guardrails / Auto Mode (Tool Risk Gating)
Problem: AI agents can be tricked into running dangerous commands (e.g., rm -rf /, database drops, unauthorized API calls).
Solution: Before every tool execution, Jev classifies whether the action is risky:
from langchain_typesafe.experimental.middleware import AutoModeMiddleware
# Creates a guardrail that checks tool calls before execution
guardrail = AutoModeMiddleware(tools=["bash", "database_query"])
# Agent now auto-blocks risky tool calls
agent = create_agent("openai:gpt-4o", middleware=[guardrail])
Agent wants to run: rm -rf /tmp/user_data
↓
Jev evaluates in 2ms: { "is_dangerous": { "noul": 0.997 } }
↓
BLOCKED! Human approval required before execution.
💡 Connection to Your Capstone: This is exactly what the HITL (Human-in-the-Loop) gate does in Milestone 6's
tool_agent.py— but instead of using regex rules or an LLM call for the check, Jev does it in 2ms with calibrated confidence scores.
7c. Email Triage at Scale
Problem: A company receives 10,000+ emails daily. Using an LLM to classify each one costs ~$100/day and takes hours.
Solution:
classifier = TypeSafeClassifier()
for email in incoming_emails:
result = classifier.invoke({
"state": email.body,
"questions": {
"is_spam": Noul(instructions="Is this unsolicited marketing or spam?"),
"department": Choice(
instructions="Route to correct department",
options=["sales", "support", "legal", "hr", "engineering"]
),
"priority": Score(
instructions="How urgently does this need a response?",
levels=["low", "medium", "high", "critical"]
),
},
})
if result.nouls["is_spam"].noul > 0.9:
archive(email)
else:
route_to(result.choices["department"].choice, priority=result.scores["priority"].level)
10,000 emails/day:
LLM approach: 10,000 × $0.01 × 3 questions = $300/day, ~8 hours
Jev approach: 10,000 × $0.00003 × 1 call = $0.30/day, ~30 seconds
7d. Support Ticket Classification & Routing
# Classify support ticket for the supervisor agent
ticket = "Error E-4501 keeps appearing when I try to export reports. Blocking my quarterly review."
result = classifier.invoke({
"state": ticket,
"questions": {
"agent_type": Choice(
instructions="Which specialized agent should handle this?",
options=["rag_agent", "tool_agent", "reasoning_agent"]
),
"needs_human": Noul(
instructions="Does this require human escalation?"
),
},
})
# Result: { "agent_type": "rag_agent" (0.88), "needs_human": 0.12 }
# → Route to RAG agent, no human escalation needed
8. Where Jev Fits in the Agent Loop
Traditional Agent Loop (ALL LLM):
┌─────────────────────────────────────────────────────┐
│ User Query │
│ ↓ │
│ LLM: Classify intent (500ms, $0.01) ←slow │
│ ↓ │
│ LLM: Choose tool (500ms, $0.01) ←slow │
│ ↓ │
│ Execute tool (varies) │
│ ↓ │
│ LLM: Check if safe (500ms, $0.01) ←slow │
│ ↓ │
│ LLM: Format response (800ms, $0.02) │
│ ↓ │
│ Return to user Total: ~2.3s, ~$0.05 │
└─────────────────────────────────────────────────────┘
Optimized Agent Loop (Jev + LLM):
┌─────────────────────────────────────────────────────┐
│ User Query │
│ ↓ │
│ JEV: Classify intent + risk (3ms, $0.00003) ←⚡ │
│ ↓ │
│ JEV: Choose tool + model (3ms, $0.00003) ←⚡ │
│ ↓ │
│ Execute tool (varies) │
│ ↓ │
│ LLM: Generate response (800ms, $0.02) │
│ ↓ │
│ Return to user Total: ~0.8s, ~$0.02 │
└─────────────────────────────────────────────────────┘
💡 Rule of Thumb: Use Jev for decisions (classify, route, gate, score). Use LLMs for generation (write, explain, reason, synthesize).
9. Jev vs LLM Structured Output — When to Use Which?
| Aspect | Jev (System One) | LLM .with_structured_output()
|
|---|---|---|
| Speed | ~2-5ms | ~500-2000ms |
| Cost | ~$0.00003/call | ~$0.01-0.03/call |
| Output | Typed probabilities | Parsed JSON (from text) |
| Confidence | Calibrated (0.95 = really 95%) | Uncalibrated (varies wildly) |
| Text generation | ❌ Cannot generate text | ✅ Full text generation |
| Complex reasoning | ❌ Not designed for it | ✅ Chain-of-thought, analysis |
| Parallel questions | ✅ Multiple questions, same latency | ❌ Each question = separate call |
| Best for | Classification, routing, gating | Writing, explaining, reasoning |
Decision Flowchart
Is the task "decide/classify" or "generate/write"?
│
├── DECIDE/CLASSIFY → Use Jev
│ ├── "Is this urgent?" → Noul
│ ├── "Which department?" → Choice
│ ├── "How risky (low/med/high)?" → Score
│ └── "Route to which model?" → Choice
│
└── GENERATE/WRITE → Use LLM
├── "Write a response to this email"
├── "Explain why error E-4501 happens"
├── "Analyze Q3 vs Q4 revenue trends"
└── "Summarize these 10 documents"
10. Quick Reference
Setup Cheat Sheet
# Install
pip install langchain-typesafe
# Set API Key
export TYPESAFE_API_KEY="your-key-here"
Question Type Cheat Sheet
| Type | Question Pattern | Returns | Example |
|---|---|---|---|
| Noul | "Is this [X]?" | Probability (0.0–1.0) | Is this spam? → 0.97
|
| Choice | "Which [X]?" | Selected option + all probabilities | Which dept? → "billing"
|
| Score | "How [X]?" | Continuous score + level | How urgent? → 0.85, "high"
|
Cost Comparison
| Operation | LLM Cost | Jev Cost | Savings |
|---|---|---|---|
| 1 classification | ~$0.01 | ~$0.00003 | 333x cheaper |
| 100 classifications | ~$1.00 | ~$0.003 | 333x cheaper |
| 10,000 email triage | ~$100 | ~$0.30 | 333x cheaper |
Links & Resources
| Resource | URL |
|---|---|
| TypeSafe AI Docs | docs.typesafe.ai |
| LangChain Integration | langchain-typesafe docs |
| TypeSafe Blog (Intro) | typesafe.ai/blog |
| LangChain Blog (Harness) | langchain.com/blog |
| TypeSafe Quickstart | docs.typesafe.ai/quickstart |
Top comments (0)