Log prompt/generation speed of every LLM call in the Prefect log
llama.content() returns the message text and prints llama-server's timings (prompt tokens + t/s, generated tokens + t/s); used by shots and report/memory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d9ec9c5b01
commit
bc16b01232
+1
-1
@@ -40,7 +40,7 @@ def chat(system, user, max_tokens, retries=2):
|
||||
if e.code != 400: raise
|
||||
body.pop("response_format", None)
|
||||
r = _open(urllib.request.Request(API, json.dumps(body).encode(), {"Content-Type": "application/json"}), timeout=1800)
|
||||
t = json.load(r)["choices"][0]["message"]["content"]
|
||||
t = llama.content(json.load(r), f"report ({max_tokens} max)")
|
||||
t = re.sub(r"<think>.*?</think>", "", t, flags=re.S)
|
||||
d = json.loads(t[t.find("{"):t.rfind("}") + 1])
|
||||
if isinstance(d, dict): return d
|
||||
|
||||
Reference in New Issue
Block a user