页面简介
Design AI-powered software by keeping code in control and giving Jev narrow, structured decisions.
正文摘录
Jev is TypeSafe’s model for building AI-powered software, not agents. It does not generate code or choose its own next action. It provides AI primitives that embed into software, so code remains in control while the model handles common-sense judgments over unstructured data. Summary: build a normal software workflow and insert Jev only where AI is needed. Keep control flow, deterministic rules, and side effects in code. Break broad judgments into narrow, typed questions with explicit instructions and criteria. Give each question only the context it needs. Use probabilities and confidence to act, ask for review, or escalate. Ask independent questions together, then compose their answers in code. Three software architectures TypeSafe is designed for building AI-powered software, where code owns the workflow and AI handles narrow, structured decisions. Traditional software LLM agents AI-powered softwareTraditional code is a complex decision tree made from simple software primitives. Because each primitive is reliable, developers can compose them into higher-level abstractions.An agent processes instructions and chooses its next step. This works well when a person is monitoring the process, but every loop introduces another opportunity to go off the rails.Code handles deterministic work and owns the control flow. The model appears only where the system needs programmable common sense or needs to interpret unstructured data. Each AI task is kept atomic and constrained. What makes Jev composable StructuredJev is type-safe by construction. Decisions and probabilities conform to the structured software types and JSON schema your code expects, so it never has to recover a value from generated prose.ParallelQuestions are evaluated independently and in parallel. One primitive’s result does not become hidden context that changes another primitive’s result.ComparableOutputs are sortable and can drive smart if statements, thresholds, and comparisons.FastMost calls complete in about 100 ms. Jev is fast enough for real-time request paths and user interfaces.Calibrated confidenceRLCD communicates uncertainty through calibrated probabilities instead of tending toward overconfidence.Self-consistentJev is designed to return stable answers across repeated evaluations. See the self-consistency cookbook. Because every output is constrained to the supplied options, the model returns a full probability distribution over those options rather than inventing a value outside the schema. TypeSafe’s target is a greater than 100× intelligence-to-speed-and-cost ratio; the underlying bet is that cheaper intelligence will create much more demand. Design a System One workflow 1Use code when you canKeep deterministic work in code. It is reliable and cheap. Avoid agent while loops when a software workflow can express the same behavior.Example: keep deterministic rules in codedays_overdue = (today - invoice.due_date).days if days_overdue > 30: route_to_collections(invoice) Browse the System One patterns for bounded ways to compose model decisions with code.2Decompose the input stateInclude only the context relevant to the current questions. This helps the model avoid distractions and context rot. Do not rely on knowledge stored in model weights when current information can come from your own knowledge base.Example: send only relevant context3Use structure in the input stateUse nested JSON for the state and questions fields. Point questions at specific values when that removes ambiguity, and include the backtick characters around each path inside the question.Example: reference a nested valueUse a backticked dot-and-index path to point a question at a specific nested value, such as support.tickets[0].message.4Decompose the questionsAsk the most explicit, narrow, specific, atomic questions you can. Break down complex or ill-defined questions into separate questions that each evaluate one property.This is probably the most important concept in this guide. Broad questions hide several judgments behind one answer. Atomic questions expose those judgments so you can inspect, tune, and combine them in code.Example: decompose spam detectionExample: verify a tool-call trace5Use structure in the questionsKeep questions short. instructions and criteria are usually strings, and for a short, unambiguous question a string is all you need. They can also be objects or arrays. Put the question in one field and the data that guides the question in the others.Structure helps in these situations: The question needs context or examples. A long sentence of background information or a list of example inputs belongs in named fields next to the question, where your code can add to them or swap them without rewriting the question. Part of the question comes from your code. When a value comes from a database, put it in its own field instead of splicing it into a string template. Several questions have similar instructions. A request takes one state and can include multiple questions. Adding supplementary data can help make questions distinct. Example: reference a record from your codeThis Noul question compares a resume in the state against a record from a candidate database. The record goes into potential_duplicate as it is, and the question refers to it by name.The “potential_duplicate” data sourced from code can change over time. The “question” references it using backticks.The descriptions inside criteria can be objects too. For a Choice question, each option’s description can be an object that says what the option covers, what belongs to a different option, and a few examples. Use the same field names across options so the model can compare them directly.Example: define contrastive Choice criteriaEach question type’s page has a worked example: Noul compares one resume against several candidate records, one question per record, with the questions built in code. Choice describes two easily confused options with what each covers, what it’s not for, and examples. Score gives each level a description and example situations. The structured-data-extraction cascade cookbook shows the shared-wording case, asking the same battery of questions about every field of an extracted record.A short, unambiguous question or criterion can remain a string. Add structure when it separates guidance that would otherwise blur together. For the full set of places structure is accepted, see Advanced: structure.6Ask a lot of questionsAsk many narrow, independent questions about the same state in one request. This is how you maximize effectiveness and intelligence per dollar with the API: questions run in parallel, and code can combine their signals without adding serial model round trips.See the Speculative fan-out pattern and Parallel questions cookbook.7Combine question outputs in code (or feed into a classical ML model)Combine independent answers with deterministic rules or weighted sums. For learned composition, use the probabilities as features in a downstream classical machine-learning model.Example: combine signals with a weighted scoreanswers = response.answers # Combine independent signals into one application-specific score. quality = ( 0.4 * answers["answers_request"].noul + 0.4 * answers["citations_are_supported"].noul + 0.2 * (1 - answers["contradicts_context"].noul) ) Composite scoring shows how to preserve individual judgments while combining them. If you do not have labels for a downstream model, use an ensemble of expensive reasoning models to generate them; the AutoResearch cookbook shows how to train a classical model on Jev outputs.8Route on uncertaintyMake code take different actions for confident and unconfident answers. Escalate uncertain cases to a person or a more expensive reasoning model. Test thresholds by plotting confidence against accuracy on your data. For a Noul, a good starting point is 0.7 for yes and 0.3 for no; see Reading a Noul.Example: route by confidenceanswer = response.answers["card_help_topic"] if answer.confidence < 0.8: route_to_human_review(ticket) else: route_to_handler(answer.choice, ticket) See Confidence and Routing by probability for choosing thresholds and matching them to the risk of each action. Decomposition does not require more round trips. Questions over the same state run in parallel. Putting it all together This support-ticket workflow keeps deterministic work in code, sends only relevant structured context, evaluates many atomic questions in one request, and composes the answers with explicit confidence thresholds. triage_ticket.pyfrom typesafe_sdk import Choice, Noul, NoulCriteria, Score, TypeSafeClient def triage_ticket(ticket, customer): # Handle deterministic states without calling a model. if ticket["status"] == "closed": return "no_action" open_orders = [ order for order in customer["orders"] if order["status"] != "delivered" ] # Include only the structured context needed by the questions below. state = { "ticket": { "message": ticket["message"], "sender": ticket["sender"], "links": ticket["links"], }, "customer": { "plan": customer["plan"], "open_orders": open_orders, }, "policy": { "sensitive_credentials": ["password", "security code", "API key"], }, } # Ask structured, atomic questions together so they run in parallel. questions = { "topic": Choice( instructions={ "question": "Which team should handle `ticket.message`?", "focus": "Classify the customer's primary request.", }, criteria={ "billing": { "what": "Charges, invoices, refunds, or subscriptions", "not_for": "Order tracking or account access", "examples": ["I was charged twice", "Where is my refund?"], }, "orders": { "what": "Order status, delivery, cancellation, or returns", "not_for": "Charges or account access", "examples": ["Where is my order?", "Cancel my shipment"], }, "account": { "what": "Login, profile, permissions, or security", "not_for": "Charges or order tracking", "examples": ["Reset my password", "I cannot sign in"], }, }, ), "requests_credentials": Noul(