“Capital of France?”,
“Read foo.py”,
“Type hint for a list of dicts”,
“Lowercase: HELLO”,
“One-sentence summary of REST”,
“Refactor a callback chain into async/await with proper error handling”,
“Design a sharded multi-region key-value store with linearizable reads”,
“Analyze the asymptotic complexity of this code and prove the bound rigorously”,
“Debug why our gRPC stream stalls when the client TCP window saturates”,
“Compare and contrast B-trees and LSM-trees for write-heavy workloads”,
]
corre = []
cliente = OpenAI(base_url=f”http://localhost:{PORT}/v1″, api_key=”local”) para p en la carga de trabajo: t0 = time.time() intente: r = client.chat.completions.create( model=”auto”, mensajes=[{“role”: “user”, “content”: p}]max_tokens=140, ) uso = getattr(r, “uso”, Ninguno) ejecuta.append({ “prompt”: p[:55]”model”: r.model, “latency_s”: round(time.time() – t0, 2), “in_tok”: getattr(usage, “prompt_tokens”, 0) si el uso es 0, “out_tok”: getattr(usage, “completion_tokens”, 0) si el uso es 0, }) excepto excepción como e: run.append({“prompt”: p[:55]”modelo”: “ERROR”, “latency_s”: Ninguno, “in_tok”: 0, “out_tok”: 0, “error”: str(e)[:80]}) rdf = pd.DataFrame(runs) print(rdf.to_string(index=False)) PRECIO = { “flash”: {“in”: 0.30 / 1e6, “out”: 2.50 / 1e6}, “pro”: {“in”: 1.25 / 1e6, “out”: 10.0 / 1e6}, } def price_for(model_str, in_t, out_t): m = (model_str o “”).lower() tier = “flash” si “flash” en m else “pro” devuelve in_t * PRECIO[tier][“in”] + salida_t * PRECIO[tier][“out”]
costo_enrutado = suma(precio_para(r[“model”]r.[“in_tok”]r.[“out_tok”]) para r en ejecuciones) cost_no_route = sum(price_for(“gemini-2.5-pro”, r[“in_tok”]r.[“out_tok”]) para r en ejecuciones) print(f”\n[10] Costo (enrutamiento de NadirClaw): ${cost_routed:.6f}”) print(f” Costo (línea de base siempre Pro): ${cost_no_route:.6f}”) if cost_no_route > 0: print(f” Ahorro estimado en esta ejecución: ” f”{(1 – cost_routed/cost_no_route) * 100:.1f}%”) print(“\n[11] `nadirclaw report` (analiza el registro de solicitudes JSONL):”) rep = subprocess.run([“nadirclaw”, “report”]capture_output=Verdadero, texto=Verdadero, tiempo de espera=60) print(rep.stdout o rep.stderr) si proxy_alive(): print(“\n[12] Deteniendo el proxy…”) intente: if hasattr(os, “killpg”): os.killpg(os.getpgid(server_proc.pid), signal.SIGTERM) else: server_proc.terminate() server_proc.wait(timeout=10) excepto Excepción: intente: server_proc.kill() excepto Excepción: pase print(” ✓ proxy detenido.”) print(“\nHecho. 🎉”)