OUTPUT #1003 | 3621 karakter | 82 satır
========== YENİ KOMUT | 23.09.2026 02:20:35 ==========
plugins/jev-decider/__init__.py <<'PY'
import json, os, time, urllib.request
from datetime root@213-238-170-219:/home/hermes# cat > /home/hermes/.hermes/plugins/jev-decider/__init__.py <<'PY'
> import json, os, time, urllib.request
> from datetime import datetime, timezone
> from pathlib import Path
> from typing import Any, Optional
>
> API="https://api.typesafe.ai/v1/systemone"
> LOG=Path("/home/hermes/.hermes/logs/jev-shadow.jsonl")
>
> def _route(model: str) -> str:
> m=(model or "").lower()
> if "luna" in m: return "luna"
> return "sol"
>
> def _on_pre_llm_call(
> session_id: str="",
> turn_id: str="",
> user_message: str="",
> model: str="",
> platform: str="",
> **_: Any,
> ) -> Optional[dict]:
> key=os.getenv("TYPESAFE_API_KEY","").strip()
> if not key or not user_message.strip():
> return None
> body={
> "model":"jev-latest",
> "state":{"user_message":user_message[:6000]},
> "questions":{
> "model_route":{
> "type":"choice",
> "instructions":"Choose the least expensive Hermes model sufficient for this request. Prefer Luna only for simple, low-risk work not requiring deep reasoning, complex coding, high-stakes judgment, or long-context synthesis.",
> "criteria":{
> "luna":"Simple, low-risk request suitable for a fast inexpensive auxiliary model.",
> "sol":"Complex reasoning, coding, long-context synthesis, high-stakes judgment, or work where stronger reasoning materially matters."
> }
> }
> }
> }
> started=time.monotonic()
> rec={
> "ts":datetime.now(timezone.utc).isoformat(),
> "mode":"shadow",
> "session_id":session_id,
> "turn_id":turn_id,
> "platform":platform,
> "actual_model":model,
> "actual_route":_route(model),
> }
> try:
> req=urllib.request.Request(API,data=json.dumps(body).encode(),headers={"Authorization":f"Bearer {key}","Content-Type":"application/json"},method="POST")
> with urllib.request.urlopen(req,timeout=4) as r:
> d=json.load(r)
> a=d["answers"]["model_route"]
> rec.update({
> "jev_model":d.get("model"),
> "jev_choice":a.get("choice"),
> "confidence":a.get("confidence"),
> "probabilities":a.get("probabilities"),
> "agreement":a.get("choice")==rec["actual_route"],
> "latency_ms":round((time.monotonic()-started)*1000),
> "usage":d.get("usage",{}),
> "status":"pass",
> })
> except Exception as e:
> rec.update({"status":"fail","error":type(e).__name__,"latency_ms":round((time.monotonic()-started)*1000)})
> LOG.parent.mkdir(parents=True,exist_ok=True)
> with LOG.open("a",encoding="utf-8") as f:
> f.write(json.dumps(rec,ensure_ascii=False,separators=(",",":"))+"\n")
> return None
>
> def register(ctx) -> None:
> ctx.register_hook("pre_llm_call", _on_pre_llm_call)
> PY
rmes /home/hermes/.hermes/plugins/jev-decider && /homeroot@213-238-170-219:/home/hermes# chown -R hermes:hermes /home/hermes/.hermes/plugins/jev-decider && /home/hermes/.hermes/hermes-agent/venv/bin/python -m py_compile /home/hermes/.hermes/plugins/jev-decider/__init__.py && echo 'JEV_SHADOW_PLUGIN=CREATED'
JEV_SHADOW_PLUGIN=CREATED
root@213-238-170-219:/home/hermes#