型別安全 AI Jev 編碼指南:型別決策、校準信心與系統一模型的推測性扇出
In this tutorial, we work with Jev, TypeSafe AI’s first System One model, which does not generate text at all: we send it a piece of program state and a set of typed questions, and it returns choices, scores, and yes/no probabilities that our code can branch on directly.
We install the official Python SDK, make a first call that uses all three question primitives at once, and look at how the shape of the state changes what the model can know.
We then recompute the published confidence statistic from the returned probabilities, measure what batching ten questions into one call buys over ten separate calls, and build the patterns the API is designed for: confidence-gated routing, composite scoring with the weights kept in code, typed function calling, and counting done the way the model can actually do it.
We close with the production shape: Pydantic response models, an async client fanned out with asyncio, retry policies, typed errors, and a running ledger that prices the whole notebook.
Copy CodeCopiedUse a different Browserimport os import sys import json import time import asyncio import traceback import subprocess from getpass import getpass RESULTS = {} LEDGER = {"calls": 0, "inputtokens": 0, "outputtokens": 0} USDPERMILLIONINPUTTOKENS = 0.
042 # Jev list price; output tokens are free def banner(title): print("\n" + "=" 78) print(title) print("=" 78) def section(name): def wrap(fn): def run(a, kw): banner(name) try: out = fn(a, kw) RESULTS[name] = out if isinstance(out, str) else "ok" return out except Exception as e: RESULTS[name] = f"SKIPPED / FAILED -> {type(e).
name}: {e}" print(f"\n[!] {name} did not complete: {type(e).name}: {e}") traceback.printexc(limit=3) return None return run return wrap banner("0.Install the SDK, load the API key, list the models") subprocess.run([sys.executable, "-m", "pip", "install", "-q", "typesafe-sdk==0.7.
0"], check=True) import typesafesdk from typesafesdk import Choice, Noul, Score, TypeSafeClient def loadapikey(): key = os.environ.get("TYPESAFEAPIKEY", "").strip() if not key: try: from google.colab import userdata # Colab: key stored under the Secrets tab key = (userdata.
get("TYPESAFEAPIKEY") or "").strip() except Exception: key = "" return key or getpass("TypeSafe API key (console.typesafe.ai/keys): ").strip() os.environ["TYPESAFEAPIKEY"] = loadapikey() client = TypeSafeClient() # reads TYPESAFEAPIKEY, defaults to jev-latest print(f" typesafe-sdk {typesafesdk.
version} | Python {sys.version.split()[0]}") print(" models available to this key:") for m in client.models.list().models: print(f" {m.name:<14s} released {m.releasedate} {m.description}") def ask(state, questions, kw): """One System One call, timed, with its tokens added to the running ledger.
""" t0 = time.perfcounter() response = client.systemone(state, questions, kw) ms = (time.perfcounter() - t0) * 1e3 LEDGER["calls"] += 1 LEDGER["inputtokens"] += response.usage.inputtokens or 0 LEDGER["outputtokens"] += response.usage.
outputtokens or 0 return response, ms We install typesafe-sdk, pinned to the version this notebook was written against, and load the API key from the environment, from Colab’s Secrets tab, or from a hidden prompt, so it never appears in the notebook.
TypeSafeClient reads TYPESAFEAPIKEY on its own and defaults to the jev-latest alias; listing the models shows which names and pinned versions the key can use.
The small ask helper wraps systemone so that every call in the rest of the notebook is timed and its token usage lands in a ledger we total at the end.
Copy CodeCopiedUse a different BrowserTICKET = { "ticket": { "subject": "Duplicate charge", "messages": [ {"from": "customer", "text": "I was charged twice for order A-104.This is the second time " "this year.Please refund the duplicate today.
"}, {"from": "support", "text": "We are checking the charges."}, ], }, "order": {"id": "A-104", "charges": [{"amountusd": 49, "status": "captured"}, {"amountusd": 49, "status": "captured"}]}, "refundpolicy": "Duplicate charges are eligible for a full refund within 30 days.", } @section("1.
Three primitives, one call: Choice, Score, Noul") def threeprimitives(): response, ms = ask(TICKET, { "department": Choice( instructions="Which team should handle this ticket", criteria={"billing": "Payment, refund or subscription issues", "technical": "Bugs, outages or integration problems", "sales": "Pricing, plans or account upgrades"}, ), "frustration": Score( instructions="How frustrated the customer appears in ticket.
messages[0].
text", criteria=["Calm, just stating facts", "Frustrated but civil", "Very angry, strong language"], ), "refundrequested": Noul(instructions="The customer is explicitly asking for a refund"), "policysupports": Noul(instructions="The stated refundpolicy covers this situation"), }) dept = response.
choices["department"] print(f" department -> {dept.choice!r} confidence {dept.confidence:.3f}") print(f" probabilities {({k: round(v, 3) for k, v in dept.probabilities.items()})}") fr = response.scores["frustration"] print(f" frustration -> score {fr.score:.3f} on 0..{len(fr.
legend) - 1} confidence {fr.confidence:.3f}") for level, text in fr.legend.items(): print(f" {level}: p={fr.probabilities[level]:.3f} {text}") print(f" refundrequested -> noul {response.nouls['refundrequested'].noul:.3f}") print(f" policysupports -> noul {response.nouls['policysupports'].noul:.
3f}") print(f"\n answered by {response.model} in {ms:.0f} ms " f"input tokens {response.usage.inputtokens}, output tokens {response.usage.outputtokens}") return f"{dept.choice}, frustration {fr.score:.2f}, refund {response.nouls['refundrequested'].noul:.
2f}" threeprimitives() A System One request has two parts: state, which is any text, JSON object or array describing the situation, and a dictionary of named questions.
Choice selects one label from the criteria we define and returns a probability for every label; Score places the state on an ordered rubric and returns the probability-weighted level, so it can land between two levels; Noul returns a single probability that a statement is true.
The question names are ours and never reach the model, which is why the instructions carry the full meaning and can point at nested fields with backticked paths.
All four questions are evaluated in one request, in parallel and in isolation from one another, and the response reports the pinned model version that answered and the tokens it billed.Copy CodeCopiedUse a different Browser@section("2.
State is program state: the same question over a string and over named fields") def stateshapes(): question = {"eligible": Noul( instructions="The customer is eligible for a refund under the company's written policy", criteria={"true": "A policy is present and it covers the customer's situation", "false": "No policy is given, or the policy does not cover the situation"}, )} bare = "I was charged twice for order A-104.
Please refund the duplicate.
" aslist = [m["text"] for m in TICKET["ticket"]["messages"]] shapes = [("string: the message only", bare), ("array : the conversation", aslist), ("object: ticket + order + policy", TICKET)] print(f" {'state shape':<34s} {'noul':>6s} input tokens ms") seen = {} for label, state in shapes: response, ms = ask(state, question) seen[label] = response.
nouls["eligible"].noul print(f" {label:<34s} {seen[label]:6.3f} {response.usage.inputtokens:12d} {ms:5.0f}") print("\n Only the object carries the policy and the two captured charges; the question") print(" is identical in all three calls, so any movement comes from the state.
") return "noul by state shape: " + ", ".join(f"{v:.2f}" for v in seen.values()) state_shapes() State is the only thing the model knows, so we ask one question, whether the customer is eligible for a refund under the company’s written policy, over three shapes of state.
A bare string contains the complaint and nothing else; an array adds the conversation; the JS
Related
相關文章
衝刺狂歡日!抖音商城雙11高光品牌有哪些?
雙11大促進入最後衝刺期,品牌增長持續提速。11月7日,抖音商城雙11高光品牌TOP20正式出爐,覆蓋服飾穿搭、運動戶外、美妝個護、品質生活四大賽道,集中呈現大促開門紅至第二階段,各賽道標杆品牌的爆發表現。01運動戶外“輕戶外”生活方式加速普及,疊加秋冬出行場景增多,運動戶外賽道熱度持續攀升。Fila/斐樂、CAMEL/駱駝、adidas/阿迪達斯佔據運動戶外榜前三。
抖音商城「雙11現貨日」:以“現貨”確定性,撬動大促生意增量
今年抖音商城雙11好物節進入衝刺期,用戶對“下單後儘快收到”的確定性需求進一步放大。圍繞“48小時內發貨,晚必賠”,抖音商城在雙11期間升級「雙11現貨日」:一方面在商城頻道、專屬打標、獨立會場、直播間氛圍等用戶端核心場域集中透出,讓現貨商品更容易被識別和選擇;另一方面通過消費券、流量加碼、分層激勵和履約保障,把商家提前備貨、即時發貨的能力轉化為大促轉化效率。這次雙11現貨日的亮點不只在資源投入,更在於商家和達人把“現貨”做成了可感知的經營場景。
搶跑雙11開門紅,這些品牌如何憑“好貨與好策略”率先突圍?
2026年抖音商城雙11好物節開門紅階段已經打響,各行業品牌穩紮穩打、實現生意增長。在流量與銷量的雙重角逐中,打動消費者的不再侷限於價格。將優質的商品供給、豐富的內容生態、有競爭力的價格與穩定的履約服務相結合,同時善用智能工具提效,是品牌在雙11 實現增長的重要路徑。本文將拆解7大品牌在開門紅階段的高光表現,詳細分析他們如何通過精細化運營搶佔生意先機,為更多商家沉澱可複用的實戰經驗。百雀羚:“廠區直播+現貨現發”打爆開門紅,首日GMV同比增長2.5倍在分秒必爭的雙11大促中,“看得見的現貨”正成為打動消費者的關鍵。
外部專家開始核驗機器生成證明
Ad Skip to content OpenAI asks outside experts, including a Nobel laureate, to check proofs its AI produced in math, computer science, and physics Maximilian Schreiner View the LinkedIn Profile of Maximilian Schreiner Oct 27, 2026 Nano Banana Pro prompted by THE DECODER OpenAI says its internal models have disproved a central assumption in computer science and proved part of one of the Millennium Prize Problems, among other results.
何剛升任董事後首秀!甩出八款華為終端新品,詳解韜芯片黑科技
作者 | 楊京麗 編輯 | 李水青 10月28日報道,今日,華為發佈Pura90 Plus、暢享100系列、FreeClip 2耳夾耳機潮玩拼色版本、華為路由X2 Pro、華為全能充智能移動電源等多款新品,覆蓋多條產品線。 此次發佈會由華為董事、終端BG CEO何剛主持,這也是其升任華為董事後主持的首場發佈會。
2.3萬元起!首款觸屏MacBook來了,蘋果Logo重新發光點亮
作者 | 陳駿達 編輯 | 李水青 觸屏Mac,真的來了! 10月29日報道,今天凌晨1點,蘋果推出了其歷史上首款觸屏版Mac——搭載PROLED XDR顯示屏的MacBook Pro。 除了首次支持觸控之外,這款旗艦新品一口氣帶來了Mac產品線的多項“第一次”:首次引入iPhone上的靈動島,承載Spotlight、實時活動與Siri AI等功能;首次搭載雙層串聯OLED的PROLED XDR屏幕,峰值亮度達2000尼特。