Spaces:
Running

File size: 5,270 Bytes
cbdf1db
061a21e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cbdf1db
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
53
54
55
56
57
58
59
60
61
62
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Reactive Labs task browser</title>
<style>
:root{--bg:#fff;--fg:#111;--mut:#666;--line:#e5e5e5;--card:#fafafa;--acc:#111}
@media (prefers-color-scheme:dark){:root{--bg:#0f0f10;--fg:#eee;--mut:#9a9a9a;--line:#2a2a2c;--card:#18181a;--acc:#eee}}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.5 system-ui,-apple-system,Segoe UI,sans-serif}
main{max-width:1100px;margin:0 auto;padding:24px 16px}
h1{font-size:22px;margin:0 0 4px}p.sub{color:var(--mut);margin:0 0 20px}
.sets{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:18px}
.sets button{border:1px solid var(--line);background:var(--card);color:var(--fg);padding:6px 10px;border-radius:6px;cursor:pointer;font:inherit;font-size:13px}
.sets button.on{background:var(--acc);color:var(--bg);border-color:var(--acc)}
.grp{width:100%;font-size:12px;color:var(--mut);margin-top:6px}
.hero img{width:100%;max-height:340px;object-fit:cover;object-position:top;border-radius:8px;border:1px solid var(--line)}
.meta{display:flex;flex-wrap:wrap;gap:16px;align-items:center;margin:12px 0}
code,pre{font:13px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace}
pre{background:var(--card);border:1px solid var(--line);border-radius:6px;padding:10px;overflow:auto;white-space:pre-wrap;word-break:break-word}
a{color:inherit}
.layout{display:grid;grid-template-columns:280px 1fr;gap:16px;margin-top:12px}
@media (max-width:760px){.layout{grid-template-columns:1fr}}
.list{border:1px solid var(--line);border-radius:8px;max-height:70vh;overflow:auto}
.list div{padding:8px 10px;border-bottom:1px solid var(--line);cursor:pointer}
.list div.on{background:var(--card);font-weight:600}
.list small{display:block;color:var(--mut);font-weight:400}
.tags span{display:inline-block;font-size:12px;border:1px solid var(--line);border-radius:4px;padding:0 6px;margin:0 4px 4px 0;color:var(--mut)}
details{margin-top:8px}
</style>
</head>
<body>
<main>
<h1>Reactive Labs task browser</h1>
<p class="sub">Every task in every dataset, with its instruction and the command to run it. Apache 2.0.</p>
<div class="sets" id="sets"></div>
<div id="view"></div>
</main>
<script>
const ORG="reactive-labs";let SETS=[],cur=null;
const el=(t,a={},...c)=>{const e=document.createElement(t);Object.assign(e,a);c.forEach(x=>e.append(x));return e};
async function rows(ds){let out=[],off=0;for(;;){const r=await fetch(`https://datasets-server.huggingface.co/rows?dataset=${ORG}/${ds}&config=default&split=test&offset=${off}&length=100`);if(!r.ok)throw new Error(r.status);const j=await r.json();out=out.concat(j.rows.map(x=>x.row));off+=100;if(off>=j.num_rows_total)break}return out}
function nav(){const s=document.getElementById("sets");s.innerHTML="";let g=null;for(const d of SETS){if(d.collection!==g){g=d.collection;s.append(el("div",{className:"grp",textContent:g}))}const b=el("button",{textContent:d.title,className:d.name===cur?"on":""});b.onclick=()=>{location.hash=d.name};s.append(b)}}
async function show(name){cur=name;nav();const d=SETS.find(x=>x.name===name)||SETS[0];cur=d.name;nav();const v=document.getElementById("view");v.innerHTML="";
 const url=`https://huggingface.co/datasets/${ORG}/${d.name}`;
 v.append(el("div",{className:"hero"},el("img",{src:`${url}/resolve/main/${d.media}`,alt:d.title,loading:"lazy"})));
 v.append(el("div",{className:"meta"},el("strong",{textContent:d.title}),el("a",{href:url,target:"_blank",textContent:"Hugging Face"}),el("a",{href:`https://hub.harborframework.com/datasets/${ORG}/${d.name}`,target:"_blank",textContent:"Harbor Hub"})));
 v.append(el("pre",{textContent:`harbor run -d ${ORG}/${d.name} -a <agent> -m <model>`}));
 const lay=el("div",{className:"layout"}),list=el("div",{className:"list",textContent:"Loading tasks…"}),det=el("div");lay.append(list,det);v.append(lay);
 let rs;try{rs=await rows(d.name)}catch(e){list.textContent="The task list could not be loaded. Open the dataset on Hugging Face.";return}
 list.innerHTML="";const pick=(r,i)=>{[...list.children].forEach((c,k)=>c.className=k===i?"on":"");const t=r.name.split("/")[1],kw=Array.isArray(r.keywords)?r.keywords:[];det.innerHTML="";
  det.append(el("h3",{textContent:t,style:"margin:0 0 4px"}),el("div",{textContent:r.description||"",style:"color:var(--mut)"}),el("div",{className:"tags"},...kw.map(k=>el("span",{textContent:k}))));
  det.append(el("pre",{textContent:`harbor run -d ${ORG}/${d.name} -i ${ORG}/${t} -a <agent> -m <model>`}));
  det.append(el("h4",{textContent:"Instruction",style:"margin:12px 0 4px"}),el("pre",{textContent:r.instruction||""}));
  const files=(r.files||[]).filter(f=>!/^(solution|tests)\//.test(f));const fd=el("details",{},el("summary",{textContent:`Files given to the agent (${files.length})`}),el("pre",{textContent:files.join("\n")}));det.append(fd)};
 rs.forEach((r,i)=>{const it=el("div",{},r.name.split("/")[1],el("small",{textContent:r.description||""}));it.onclick=()=>pick(r,i);list.append(it)});if(rs.length)pick(rs[0],0)}
fetch("datasets.json").then(r=>r.json()).then(j=>{SETS=j;show(location.hash.slice(1))});
addEventListener("hashchange",()=>show(location.hash.slice(1)));
</script>
</body>
</html>