File size: 4,331 Bytes
53d5fc6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""Example conversations for the 30.11 model card: real tool execution through the Studio server (same harness as live_eval), greedy decoding.
The 16 prompts were fixed before the model was run on them and every transcript is kept unedited.   python card_examples.py CKPT OUT.json"""
import json
import os
import sys
from datetime import date
from pathlib import Path

import torch
from tokenizers import Tokenizer

import live_eval as L
from chatfmt import Fmt
from model_io import load

W = L.WEB
DOC = {"service_agreement.pdf": ["SERVICE AGREEMENT no. 7/2026\nClient: Golden Ear Bakery, 3 Mill Street, Torun.\nSubject: servicing of 4 convection ovens.",
                                 "4. Flat fee: PLN 1,250 net per month.\n5. Payment term: 14 days from delivery of the invoice.",
                                 "7. Fixed term of 24 months. 8. Notice period: 2 months."]}
GROUP = [{"author": "Ola", "timestamp": "2026-11-27T09:00:00", "text": "I will finish the slides by Monday."},
         {"author": "Bartek", "timestamp": "2026-11-27T09:02:00", "text": "I will order the brochures by Friday."},
         {"author": "Iza", "timestamp": "2026-11-27T09:05:00", "text": "Wrap-up meeting on Wednesday at 15:30, room 2."}]
S = [
    ("chat", "Who are you", W + ["calculator"], "Hi! What's your name and who made you?", "en", {}),
    ("chat", "Writing, no tool needed", W + ["calculator", "get_weather"], "Write two short slogans for a small flower shop.", "en", {}),
    ("chat", "Polish to English", W + ["calculator"], "Przetłumacz na angielski: „Prosimy o potwierdzenie terminu dostawy do czwartku.”", "pl", {}),
    ("chat", "One-sentence explanation", W + ["calculator"], "Explain in one sentence what an API is.", "en", {}),
    ("tools", "Live exchange rate and maths", ["get_exchange_rate", "calculator", "web_search"], "How much is 40 euros in zlotys at today's NBP rate?", "en", {}),
    ("tools", "Weather right now, in Polish", ["get_weather", "web_search"], "Jaka jest teraz pogoda w Zakopanem?", "pl", {}),
    ("tools", "Exact percentage", ["calculator", "convert_units"], "What is 18% of 2450?", "en", {}),
    ("tools", "Live web search", W + ["calculator"], "Search the web and tell me which city hosted the 1964 Summer Olympics.", "en", {}),
    ("work", "Question about a document", ["search_document", "read_document", "web_search"], "What is the monthly fee and the notice period in my service agreement?", "en", {"docs": DOC}),
    ("work", "Saving a note", ["save_note", "create_table", "web_search"], "Save a note: pick up the parcel, call the accountant, buy printer ink.", "en", {}),
    ("work", "Reply to a client, in Polish", W + ["calculator"], "Klient pyta, kiedy dostanie fakturę. Napisz krótką, uprzejmą odpowiedź, że wyślemy ją jutro.", "pl", {}),
    ("work", "Comparing two offers", ["calculator", "web_search"], "Shop A: 15 chairs at 89 each. Shop B: 15 chairs at 95 each with a 10% discount. Which is cheaper and by how much?", "en", {}),
    ("hard", "Missing information", ["calculator", "convert_units", "web_search"], "Calculate my loan instalment.", "en", {}),
    ("hard", "Dead link", W + ["calculator"], "Read https://en.wikipedia.org/wiki/Royal_Castle_xyz_missing and tell me in which city the Royal Castle in Poland stands.", "en", {}),
    ("hard", "Group chat recap", ["search_messages", "create_table"], "@Slayer who is responsible for what, and by when?", "en", {"group": GROUP, "name": "Ola"}),
    ("hard", "Arithmetic without a tool", [], "What is 17 times 23?", "en", {}),
]

if __name__ == "__main__":
    f = Fmt(Tokenizer.from_file(os.environ["SLAYER_TOKENIZER"]))
    model, _, _ = load(sys.argv[1], device="cuda", dtype=torch.bfloat16)
    model.eval()
    today, out = date.today().isoformat(), []
    for g, t, tools, user, lang, ex in S:
        r = L.run_case(model, f, {"id": t, "lang": lang, "tools": tools, "user": user, "check": {}, **ex}, "http://127.0.0.1:5200", today)
        out.append({"group": g, "title": t, "lang": lang, "user": user, "tools": tools, "calls": r["trace"], "final": r["final"], "ckpt": sys.argv[1], "date": today})
        print(t, "|", [c["call"]["name"] for c in r["trace"]], "|", repr(r["final"][:260]), flush=True)
    Path(sys.argv[2]).write_text(json.dumps(out, ensure_ascii=False, indent=1), encoding="utf-8")