Integration
Jev with LangChain
There is no langchain-typesafe package, and this page is not going to pretend otherwise. What there is instead is a clean answer about where a decision model belongs in a chain — and it turns out not to be the model slot.
Why there is no model adapter, and why that is fine
LangChain's LLM and BaseChatModel interfaces are contracts to turn messages into text. Every downstream piece — output parsers, streaming, the tool-calling loop, the memory abstractions — assumes tokens come out the other end.
Jev generates no tokens. It takes a state plus a map of named questions and returns typed answers: a chosen option with a probability for every alternative, a rubric score, or a bare 0–1 probability. Forcing that into a chat-model wrapper means serialising a distribution into a string so that an output parser can turn it back into a distribution. That is a lossy round trip in service of a type signature.
The three places it actually belongs
In front
Route the input. Which chain, which model, which prompt — decided in 0.4s for a fraction of a cent before any expensive call happens.
Behind
Guard the output. Score it, check it against a policy, decide whether it ships or goes back. Cheap enough to run on every response.
Alongside
As a tool the agent can call when it needs a judgement rather than a paragraph of reasoning about a judgement.
A router, as a Runnable
The highest-value one. A branch in front of the chain costs $0.000021 at a 500-token state and decides which of your expensive paths runs at all:
from langchain_core.runnables import RunnableLambda, RunnableBranch
from typesafe_sdk import Choice, TypeSafeClient
jev = TypeSafeClient()
def classify(inputs: dict) -> dict:
"""Attach an intent and a confidence. Adds a field; changes nothing else."""
answer = jev.system_one(
model="jev-latest",
state=inputs["question"],
questions={
"intent": Choice(
instructions="What is the user asking for?",
criteria={
"factual": "A specific fact that lives in the knowledge base",
"creative": "Drafting, rewriting or brainstorming",
"troubleshoot": "Something is broken and they want it fixed",
},
)
},
).answers["intent"]
return {**inputs, "intent": answer.choice, "confidence": answer.confidence}
route = RunnableLambda(classify) | RunnableBranch(
# Low confidence never picks a specialist path — it goes to the general one.
(lambda x: x["confidence"] < 0.6, general_chain),
(lambda x: x["intent"] == "factual", rag_chain),
(lambda x: x["intent"] == "troubleshoot", support_chain),
creative_chain,
)As a tool an agent can call
The other shape worth having. Note the docstring is doing real work: it is what the agent reads to decide whether to call this at all.
from langchain_core.tools import tool
from typesafe_sdk import Noul
@tool
def check_policy(text: str, policy: str) -> dict:
"""Judge whether some text satisfies a policy.
Returns a probability between 0 and 1, not a verdict — 0.5 means genuinely
uncertain, and the caller decides what threshold matters.
"""
answer = jev.system_one(
model="jev-latest",
state={"text": text, "policy": policy},
questions={"ok": Noul(instructions="Does the text satisfy the policy as written?")},
).answers["ok"]
return {"satisfies_policy": answer.noul}Three things that will trip you up
- Do not put a chain's whole scratchpad in the state. Accuracy falls as the state fills with material unrelated to the decision — the vendor documents this directly. Pass the question, not the conversation.
- Ask several questions in one call, not several calls. The state is ingested once and every question is evaluated against it in parallel, so five questions cost what one costs. A chain that calls Jev three times in a row is usually one call written badly.
- Do not carry a threshold between primitives. A 0.6 tuned on a Noul does not mean the same thing on a Choice; the vendor publishes an example where the two disagree sharply on the same question.
Common questions
Is there a LangChain integration for Jev?
Not as of this page's last check. There is no first-party package from TypeSafe and none in awesome-jev's integrations category. The community has built SDKs for Go, Swift, Elixir, Scala and PHP, but no chain-framework adapter.
Can I use Jev as a LangChain LLM or ChatModel?
No, and you should not want to. Those interfaces are contracts to return text from messages. Jev returns a decision from a state and named questions, and it generates no tokens at all — wrapping it in BaseChatModel means inventing a text representation of a probability distribution, then parsing it back.
Where does Jev fit in a chain then?
As a router in front of the chain, as a guardrail after it, or as a tool the agent can call. All three are plain Runnables, which is a smaller and more honest surface than a model adapter.
If a real package appears, this page should say so — awesome-jev is where it would show up first.