lightnode-sdk 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/add.js +123 -107
- package/package.json +1 -1
package/dist/add.js
CHANGED
|
@@ -1274,59 +1274,67 @@ export default function InferenceWeb3() {
|
|
|
1274
1274
|
}
|
|
1275
1275
|
|
|
1276
1276
|
return (
|
|
1277
|
-
<main
|
|
1278
|
-
<
|
|
1279
|
-
<
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
<div style={{ border: "1px solid #ddd", borderRadius: 8, padding: 12, margin: "12px 0", display: "flex", alignItems: "center", gap: 12 }}>
|
|
1289
|
-
<span>Connect a wallet to run inference.</span>
|
|
1290
|
-
<ConnectButton />
|
|
1277
|
+
<main className="mx-auto flex min-h-screen w-full max-w-2xl flex-col px-4 py-6">
|
|
1278
|
+
<header className="flex items-center justify-between gap-3 border-b border-border pb-4">
|
|
1279
|
+
<div className="min-w-0">
|
|
1280
|
+
<h1 className="text-base font-semibold text-foreground">Inference</h1>
|
|
1281
|
+
<p className="truncate text-xs text-muted-foreground">
|
|
1282
|
+
{network ? (
|
|
1283
|
+
<>Signed from your wallet on {network} · {feeLcai != null ? feeLcai + " LCAI" : "..."}/call + gas</>
|
|
1284
|
+
) : (
|
|
1285
|
+
"Connect a wallet on LightChain to start"
|
|
1286
|
+
)}
|
|
1287
|
+
</p>
|
|
1291
1288
|
</div>
|
|
1292
|
-
|
|
1289
|
+
<ConnectButton />
|
|
1290
|
+
</header>
|
|
1293
1291
|
|
|
1294
|
-
<
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
<textarea value={prompt} onChange={(e) => setPrompt(e.target.value)} rows={5}
|
|
1302
|
-
style={{ width: "100%", padding: 8, fontFamily: "monospace", fontSize: 12 }} />
|
|
1303
|
-
</label>
|
|
1304
|
-
<button type="button" onClick={() => run()} disabled={busy || !prompt.trim() || !address || !network}
|
|
1305
|
-
style={{ padding: "8px 16px", borderRadius: 8, cursor: busy ? "wait" : "pointer" }}>
|
|
1306
|
-
{busy ? (busyStage || "Running...") : "Run inference"}
|
|
1307
|
-
</button>
|
|
1292
|
+
<div className="flex flex-col gap-4 py-6">
|
|
1293
|
+
{!address && (
|
|
1294
|
+
<div className="flex items-center justify-between gap-3 rounded-xl border border-border bg-card px-4 py-3 text-sm text-muted-foreground">
|
|
1295
|
+
<span>Connect a wallet to run inference.</span>
|
|
1296
|
+
<ConnectButton />
|
|
1297
|
+
</div>
|
|
1298
|
+
)}
|
|
1308
1299
|
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
{
|
|
1312
|
-
|
|
1313
|
-
|
|
1300
|
+
<label className="flex flex-col gap-1.5">
|
|
1301
|
+
<span className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">System prompt</span>
|
|
1302
|
+
<textarea value={system} onChange={(e) => setSystem(e.target.value)} rows={2}
|
|
1303
|
+
className="resize-none rounded-xl border border-border bg-card px-3 py-2 font-mono text-xs text-foreground outline-none focus:ring-2 focus:ring-primary" />
|
|
1304
|
+
</label>
|
|
1305
|
+
<label className="flex flex-col gap-1.5">
|
|
1306
|
+
<span className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">Prompt</span>
|
|
1307
|
+
<textarea value={prompt} onChange={(e) => setPrompt(e.target.value)} rows={5}
|
|
1308
|
+
className="resize-none rounded-xl border border-border bg-card px-3 py-2 font-mono text-xs text-foreground outline-none focus:ring-2 focus:ring-primary" />
|
|
1309
|
+
</label>
|
|
1310
|
+
|
|
1311
|
+
<button type="button" onClick={() => run()} disabled={busy || !prompt.trim() || !address || !network}
|
|
1312
|
+
className="self-start rounded-xl bg-gradient-primary px-4 py-2 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40">
|
|
1313
|
+
{busy ? (busyStage || "Running...") : "Run inference"}
|
|
1314
|
+
</button>
|
|
1314
1315
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
<
|
|
1324
|
-
{result.
|
|
1325
|
-
|
|
1326
|
-
|
|
1316
|
+
{err && (
|
|
1317
|
+
<p className="rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">
|
|
1318
|
+
{err}
|
|
1319
|
+
</p>
|
|
1320
|
+
)}
|
|
1321
|
+
|
|
1322
|
+
{result && (
|
|
1323
|
+
<div className="rounded-2xl border border-border bg-card p-4">
|
|
1324
|
+
<div className="mb-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground">Answer</div>
|
|
1325
|
+
<pre className="m-0 whitespace-pre-wrap break-words font-sans text-sm text-foreground">{result.answer}</pre>
|
|
1326
|
+
<div className="mt-3 flex flex-wrap gap-3 text-xs text-muted-foreground">
|
|
1327
|
+
<span>elapsed {Math.round(result.elapsedMs / 1000)}s</span>
|
|
1328
|
+
<span>job #{result.jobId}</span>
|
|
1329
|
+
<a className="hover:text-foreground hover:underline" href={\`https://\${network}.lightscan.app/address/\${result.worker}\`} target="_blank" rel="noopener noreferrer">worker</a>
|
|
1330
|
+
<a className="hover:text-foreground hover:underline" href={\`https://\${network}.lightscan.app/tx/\${result.submitJob}\`} target="_blank" rel="noopener noreferrer">submitJob</a>
|
|
1331
|
+
{result.jobCompleted && (
|
|
1332
|
+
<a className="hover:text-foreground hover:underline" href={\`https://\${network}.lightscan.app/tx/\${result.jobCompleted}\`} target="_blank" rel="noopener noreferrer">jobCompleted</a>
|
|
1333
|
+
)}
|
|
1334
|
+
</div>
|
|
1327
1335
|
</div>
|
|
1328
|
-
|
|
1329
|
-
|
|
1336
|
+
)}
|
|
1337
|
+
</div>
|
|
1330
1338
|
</main>
|
|
1331
1339
|
);
|
|
1332
1340
|
}
|
|
@@ -1459,72 +1467,80 @@ Reply with STRICT JSON only, matching: { "passed": boolean, "confidence": 0-1, "
|
|
|
1459
1467
|
}
|
|
1460
1468
|
|
|
1461
1469
|
return (
|
|
1462
|
-
<main
|
|
1463
|
-
<
|
|
1464
|
-
<
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
<div style={{ border: "1px solid #ddd", borderRadius: 8, padding: 12, margin: "12px 0", display: "flex", alignItems: "center", gap: 12 }}>
|
|
1474
|
-
<span>Connect a wallet to submit.</span>
|
|
1475
|
-
<ConnectButton />
|
|
1470
|
+
<main className="mx-auto flex min-h-screen w-full max-w-2xl flex-col px-4 py-6">
|
|
1471
|
+
<header className="flex items-center justify-between gap-3 border-b border-border pb-4">
|
|
1472
|
+
<div className="min-w-0">
|
|
1473
|
+
<h1 className="text-base font-semibold text-foreground">AI Judge</h1>
|
|
1474
|
+
<p className="truncate text-xs text-muted-foreground">
|
|
1475
|
+
{network ? (
|
|
1476
|
+
<>Signed from your wallet on {network} · {feeLcai != null ? feeLcai + " LCAI" : "..."} + gas · verdict has on-chain proof</>
|
|
1477
|
+
) : (
|
|
1478
|
+
"Connect a wallet on LightChain to start"
|
|
1479
|
+
)}
|
|
1480
|
+
</p>
|
|
1476
1481
|
</div>
|
|
1477
|
-
|
|
1482
|
+
<ConnectButton />
|
|
1483
|
+
</header>
|
|
1478
1484
|
|
|
1479
|
-
<
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
<textarea value={evidence} onChange={(e) => setEvidence(e.target.value)} rows={5}
|
|
1487
|
-
style={{ width: "100%", padding: 8, fontFamily: "monospace", fontSize: 12 }} />
|
|
1488
|
-
</label>
|
|
1489
|
-
<button type="button" onClick={() => run()} disabled={busy || !criteria.trim() || !evidence.trim() || !address || !network}
|
|
1490
|
-
style={{ padding: "8px 16px", borderRadius: 8, cursor: busy ? "wait" : "pointer" }}>
|
|
1491
|
-
{busy ? (busyStage || "Judging...") : "Get AI verdict"}
|
|
1492
|
-
</button>
|
|
1485
|
+
<div className="flex flex-col gap-4 py-6">
|
|
1486
|
+
{!address && (
|
|
1487
|
+
<div className="flex items-center justify-between gap-3 rounded-xl border border-border bg-card px-4 py-3 text-sm text-muted-foreground">
|
|
1488
|
+
<span>Connect a wallet to submit.</span>
|
|
1489
|
+
<ConnectButton />
|
|
1490
|
+
</div>
|
|
1491
|
+
)}
|
|
1493
1492
|
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
{
|
|
1497
|
-
|
|
1498
|
-
|
|
1493
|
+
<label className="flex flex-col gap-1.5">
|
|
1494
|
+
<span className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">Criteria</span>
|
|
1495
|
+
<textarea value={criteria} onChange={(e) => setCriteria(e.target.value)} rows={2}
|
|
1496
|
+
className="resize-none rounded-xl border border-border bg-card px-3 py-2 font-mono text-xs text-foreground outline-none focus:ring-2 focus:ring-primary" />
|
|
1497
|
+
</label>
|
|
1498
|
+
<label className="flex flex-col gap-1.5">
|
|
1499
|
+
<span className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">Evidence (JSON)</span>
|
|
1500
|
+
<textarea value={evidence} onChange={(e) => setEvidence(e.target.value)} rows={5}
|
|
1501
|
+
className="resize-none rounded-xl border border-border bg-card px-3 py-2 font-mono text-xs text-foreground outline-none focus:ring-2 focus:ring-primary" />
|
|
1502
|
+
</label>
|
|
1503
|
+
|
|
1504
|
+
<button type="button" onClick={() => run()} disabled={busy || !criteria.trim() || !evidence.trim() || !address || !network}
|
|
1505
|
+
className="self-start rounded-xl bg-gradient-primary px-4 py-2 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40">
|
|
1506
|
+
{busy ? (busyStage || "Judging...") : "Get AI verdict"}
|
|
1507
|
+
</button>
|
|
1508
|
+
|
|
1509
|
+
{err && (
|
|
1510
|
+
<p className="rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">
|
|
1511
|
+
{err}
|
|
1512
|
+
</p>
|
|
1513
|
+
)}
|
|
1499
1514
|
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1515
|
+
{result && (
|
|
1516
|
+
<div className="rounded-2xl border border-border bg-card p-4">
|
|
1517
|
+
<div className="mb-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground">Verdict</div>
|
|
1518
|
+
{result.verdict ? (
|
|
1519
|
+
<div>
|
|
1520
|
+
<div className={"flex items-baseline gap-3 text-2xl font-semibold " + (result.verdict.passed ? "text-success" : "text-destructive")}>
|
|
1521
|
+
{result.verdict.passed ? "PASSED" : "FAILED"}
|
|
1522
|
+
<span className="text-sm font-normal text-muted-foreground">
|
|
1523
|
+
confidence {Math.round(result.verdict.confidence * 100)}%
|
|
1524
|
+
</span>
|
|
1525
|
+
</div>
|
|
1526
|
+
<p className="mt-2 text-sm text-foreground">{result.verdict.reason}</p>
|
|
1510
1527
|
</div>
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
{result.raw}
|
|
1516
|
-
</pre>
|
|
1517
|
-
)}
|
|
1518
|
-
<div style={{ marginTop: 12, fontSize: 12, color: "#666", display: "flex", gap: 12, flexWrap: "wrap" }}>
|
|
1519
|
-
<span>job #{result.jobId}</span>
|
|
1520
|
-
<a href={\`https://\${network}.lightscan.app/address/\${result.worker}\`} target="_blank" rel="noopener noreferrer">worker</a>
|
|
1521
|
-
<a href={\`https://\${network}.lightscan.app/tx/\${result.submitJob}\`} target="_blank" rel="noopener noreferrer">submitJob</a>
|
|
1522
|
-
{result.jobCompleted && (
|
|
1523
|
-
<a href={\`https://\${network}.lightscan.app/tx/\${result.jobCompleted}\`} target="_blank" rel="noopener noreferrer">jobCompleted</a>
|
|
1528
|
+
) : (
|
|
1529
|
+
<pre className="m-0 whitespace-pre-wrap break-words font-mono text-xs text-muted-foreground">
|
|
1530
|
+
{result.raw}
|
|
1531
|
+
</pre>
|
|
1524
1532
|
)}
|
|
1533
|
+
<div className="mt-3 flex flex-wrap gap-3 text-xs text-muted-foreground">
|
|
1534
|
+
<span>job #{result.jobId}</span>
|
|
1535
|
+
<a className="hover:text-foreground hover:underline" href={\`https://\${network}.lightscan.app/address/\${result.worker}\`} target="_blank" rel="noopener noreferrer">worker</a>
|
|
1536
|
+
<a className="hover:text-foreground hover:underline" href={\`https://\${network}.lightscan.app/tx/\${result.submitJob}\`} target="_blank" rel="noopener noreferrer">submitJob</a>
|
|
1537
|
+
{result.jobCompleted && (
|
|
1538
|
+
<a className="hover:text-foreground hover:underline" href={\`https://\${network}.lightscan.app/tx/\${result.jobCompleted}\`} target="_blank" rel="noopener noreferrer">jobCompleted</a>
|
|
1539
|
+
)}
|
|
1540
|
+
</div>
|
|
1525
1541
|
</div>
|
|
1526
|
-
|
|
1527
|
-
|
|
1542
|
+
)}
|
|
1543
|
+
</div>
|
|
1528
1544
|
</main>
|
|
1529
1545
|
);
|
|
1530
1546
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lightnode-sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Read-only TypeScript client for LightChain AI: workers, jobs, models, on-chain registration, and per-model network analytics. Independent, community-built (not an official LightChain package).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|