Repository navigation
langchain tool for yes no decisions
You can give a LangChain agent local yes/no decisions by wrapping one HTTP call to jev serve
in a function and decorating it with @tool, but for checks that must always run, call the same
function directly in your code instead of letting the agent decide whether to use it. A tool is
something the chat model chooses to call; a guardrail, a routing decision or a stop condition
should not depend on that choice. The function is the same in both cases: text and question in,
P(yes) out, no text generated by the local model and nothing to parse.
That split is the real design decision on this page. LangChain makes it easy to hand a model a list of tools, and it is tempting to hand it every capability that way. For a decision you already know you want on every step, a plain function call is deterministic: it runs, you get a number, your code compares it with a threshold.
This page is the plain function, the tool wrapper and its description, the deterministic pattern, and what to watch for. The code is a minimal sketch to adapt; LangChain facts are from its documentation, fetched 2026-09-29, and only the documented jev API is used.
import requests
JEV = "http://127.0.0.1:8017/v1/systemone"
session = requests.Session()
def p_yes(text: str, question: str) -> float:
body = {"model": "jev-latest", "state": text,
"questions": {"q": {"type": "noul", "instructions": question}}}
r = session.post(JEV, json=body, timeout=(3.05, 10))
r.raise_for_status()
return r.json()["answers"]["q"]["noul"]This is all the integration needs. If you have several questions about the same text, send them in one request with one key each: the text is read once, and on the reference laptop three questions take about 66 ms together against 49 ms for one alone. Timeouts, retries and error handling for this call are on a Python client for local LLM decisions.
LangChain's docs define a tool with the @tool decorator from langchain.tools. Two rules from
those docs shape the wrapper: "the function's docstring becomes the tool's description that helps
the model understand when to use it", and "type hints are required as they define the tool's
input schema".
from langchain.tools import tool
@tool
def text_says(text: str, question: str) -> str:
"""Probability (0 to 1) that the answer to a yes/no question about the given text is yes.
Use it to check what a text states. The question must be in English, ask one thing,
and be answerable from the text alone. It cannot do arithmetic or look anything up."""
return f"{p_yes(text, question):.2f}"The tool is passed to an agent the way the docs show, create_agent(model, tools=[...]). The
docstring is doing real work here: it is the only thing the chat model knows about the tool, so
it states the limits. A large model that thinks the tool can check a sum will ask it to, and a
small local model is weak at exactly that: on the fraud-points task, where a score is added up
from six rules, jevos-v4 got 0.50 right against 0.69 for the hosted Jev.
Most useful local decisions are not things an agent should opt into. They are fixed points in your pipeline:
draft = generate_reply(ticket) # your LLM step
if p_yes(draft, "Does the reply promise the customer a refund?") > 0.5:
send_to_human(ticket, draft) # never auto-send a refund promise
else:
send(draft)The check runs on every draft, costs no tokens on the paid model, takes a fraction of a second locally, and its threshold is in your code where a reviewer can see it. The same shape covers the patterns on gating AI agent tool calls with yes/no checks (before a refund or delete tool runs) and stop conditions for AI agents ("is the task complete?"). A router that sends only doubtful cases to a large model is on a model cascade: small model first, large model on doubt.
| Situation | Use |
|---|---|
| The check must run every time (safety, policy, routing) | plain function in the chain |
| The agent may need to verify a fact in a document it is reading | tool |
| The result decides who sees an output | plain function, plus a human band |
| You want the agent to explore what a long text says | tool, with one question per call |
A tool call also puts the local model's answer into the chat model's context as text, where it becomes one more thing the large model may reinterpret. When your code reads the float directly, the number means exactly what it says.
- jevos answers yes/no, multiple-choice and (early) score questions in English and nothing else. It is not a chat model and cannot be used as the agent's main model in LangChain.
- The probability is only as good as the question. Questions the model has to compute, dates and sums, lean toward yes; that measurement was taken on the first jevos and is on why a small LLM says yes when the answer is no.
- A yes/no check is a filter, not a security boundary. An agent that can call dangerous tools needs permissions in the tools themselves, with the check as one layer on top.
Is there a LangChain integration package for jevos? No. A decorated function around one HTTP call is all it takes.
Can I use jevos as the LLM in a LangChain agent? No. It generates no text; it only returns probabilities for yes/no, choice and score questions.
Why return a string from the tool? The docs' examples return strings, and the chat model reads the result as text. In your own code, use the float from the plain function.
Is the tool deterministic? The call and your threshold are. Whether an agent calls the tool is up to the chat model, which is why fixed checks belong in code.
How fast is one call? About 28 ms for a short request and 130 ms for a long one on an Intel Core Ultra 7 255H with 16 threads.
See also: AI agent guardrails with yes/no questions, replacing chat LLM calls with yes/no questions and reducing LLM cost with local yes/no decisions.
- Request shape and endpoint: the jev README. Latencies: the README, measured with jevos-v3, which has the same size and speed as jevos-v4. Accuracy: the README's six-task table for jevos-v4.
-
LangChain tools: the
@tooldecorator, docstrings as descriptions, type hints as schema, andcreate_agent(model, tools=[...]), fetched 2026-09-29.
From the notes of jev, a yes/no decision model that runs on a laptop CPU. The best place for a check you always want is a line of code, not a tool on a menu.
- Ask a local LLM a yes/no question and get P(yes)
- Zero-shot text classification with yes/no questions
- LLM policy decisions: put the rule in the question
- LLM as a judge on a CPU
- What is a decision model in AI?
- AI decision making with probabilities and thresholds
- Why a small LLM says yes when the answer is no
- Small LLMs and arithmetic in yes/no questions
- Our held-out benchmark said 0.855, new questions said 0.757
- Does an LLM know when a fact is missing?
- Snake AI: a local model vs a cloud API
- jevos vs Jev vs Laya for yes/no decisions
- An open-source alternative to Jev for yes/no decisions
- jevos vs the OpenAI API for yes/no classification
- jevos vs Ollama for yes/no decisions
- jevos vs bart-large-mnli for zero-shot classification
- A yes/no LLM vs a fine-tuned BERT classifier
- jevos vs SetFit: zero-shot vs few-shot classification
- jevos vs Llama Guard for content safety checks
- jev serve vs llama.cpp server for classification
- jevos vs LM Studio: a decision server, not a chat app
- Local vs hosted LLM decisions: latency, cost, privacy
- A yes/no LLM vs a business rules engine
- LLM decisions vs keyword rules and regex
- An open-source alternative to Microsoft-Decision-1
- Decision engine vs decision model
- The fastest AI model for yes/no decisions
- What makes a local LLM fast on a CPU
- Why one forward pass beats generating an answer
- Prefill vs decode: where LLM latency comes from
- Why LLM latency grows with the length of the text
- Why a hosted LLM API cannot answer in 50 ms
- Many questions about one text: why the extra ones are cheap
- CPU or GPU for a small LLM
- Latency budgets: where a 200 ms model fits
- Measuring LLM latency: median, p90 and warm-up
- Q4_K_M vs Q8_0: speed and size for a small model
- Throughput vs latency for a decision server
- OpenVINO for LLM inference on a CPU
- INT8 weight quantization explained
- What P(yes) means, and what it does not
- LLM calibration explained with yes/no answers
- Expected calibration error (ECE), explained
- Temperature scaling for LLM probabilities
- Platt scaling for a yes/no model
- Reading a reliability diagram
- How to choose a threshold for P(yes)
- Thresholds when a wrong yes costs more than a wrong no
- Human in the loop AI with a review band
- Precision and recall at a P(yes) threshold
- Base rates: why a 0.9 yes can still be wrong often
- Combining yes/no answers with AND, OR and NOT
- Logits, log-odds and P(yes)
- LLM confidence scores: probabilities vs self-reports
- How to write yes/no questions an LLM answers well
- Negation in yes/no questions for an LLM
- One condition per question: splitting compound questions
- Ask whether the text says it at all
- Scores as yes/no thresholds: is it at least high?
- Sending JSON as the text: designing the state
- Why wording changes an LLM's answer, and how to test it
- Mainly about: questions for messages with several topics
- Yes/no questions about tone and emotion
- Asking about intent: what does the writer want?
- Yes/no questions about long documents
- Using an English-only LLM with other languages
- Multi-class text classification with a choice question
- Content moderation with a local LLM
- A Discord moderation bot with a local LLM
- Spam detection with yes/no questions
- Review moderation with a local LLM
- Email triage with a local LLM
- Support ticket routing with yes/no questions
- Urgency detection in customer messages
- Sentiment analysis with yes/no questions
- Intent detection with a local LLM
- Lead qualification with yes/no questions
- Fraud case triage with a local LLM
- Phishing email screening with a local LLM
- Log and alert triage with a local LLM
- Checking text for personal data with yes/no questions
- Prompt injection screening with a small model
- Document classification with a local LLM
- Product categorization with yes/no questions
- Contract clause detection with a local LLM
- Refund request triage with a local LLM
- Detecting cancellation intent in customer messages
- Reranking search results with yes/no questions
- RAG evaluation with yes/no questions
- RAG faithfulness check with a local LLM
- Hallucination detection with a local LLM
- LLM regression tests in CI with yes/no checks
- Rubric design for an LLM judge
- Pairwise comparison with a yes/no judge
- LLM judge bias and how to control it
- Evaluation metrics for yes/no classifiers
- Building a yes/no test set for your own data
- Accuracy by kind of question: why one number hides failures
- Generating test questions with answers computed by code
- Benchmark contamination and truly held-out tests
- An LLM router with yes/no questions
- A model cascade: small model first, large model on doubt
- Semantic routing vs yes/no questions
- Gating AI agent tool calls with yes/no checks
- AI agent guardrails with yes/no questions
- Stop conditions for AI agents
- Logging LLM decisions for audit
- Reducing LLM cost with local yes/no decisions
- Replacing chat LLM calls with yes/no questions
- Structured output vs a probability
- A Python client for local LLM decisions
- Calling a local LLM decision server from JavaScript
- Local LLM yes/no decisions in n8n
- A Slack bot that uses local LLM decisions
- Home Assistant automations with local LLM decisions
- A LangChain tool for local yes/no decisions
- Batch decisions from files with jev decide
- Running LLM yes/no checks in GitHub Actions
- Securing a local LLM server with an API key
- curl examples for a local LLM decision API
- Self-hosted AI for decisions
- A private LLM for text classification
- On-premise LLM for business decisions
- GDPR and automated decision-making with an LLM
- Offline AI for decisions: no network needed
- Edge AI decisions on a CPU
- Run an LLM locally without a GPU
- Small language models explained
- When a small model is enough, and when it is not
- An LLM on a laptop: what it can do in real time
- What is GGUF, for someone deploying a classifier
- GGUF quantization types explained: Q4_K_M, Q8_0 and others
- GGUF vs safetensors
- llama.cpp vs Ollama for a classification service
- llama-cpp-python vs calling llama.cpp through ctypes
- llama.cpp on Windows without compiling
- Running llama.cpp CPU only
- Using llama.cpp prebuilt binaries instead of building
- Download a GGUF model from Hugging Face