@antseed/node 0.2.145 → 0.2.147
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/buyer-identity-context.d.ts +2 -2
- package/dist/buyer-identity-context.d.ts.map +1 -1
- package/dist/health/model-health-checker.d.ts +10 -0
- package/dist/health/model-health-checker.d.ts.map +1 -1
- package/dist/health/model-health-checker.js +67 -1
- package/dist/health/model-health-checker.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/seller-provider.d.ts +42 -0
- package/dist/interfaces/seller-provider.d.ts.map +1 -1
- package/dist/node.d.ts +18 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +24 -2
- package/dist/node.js.map +1 -1
- package/dist/routing/seller-health.d.ts +177 -0
- package/dist/routing/seller-health.d.ts.map +1 -0
- package/dist/routing/seller-health.js +380 -0
- package/dist/routing/seller-health.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive seller selection for automatic routing.
|
|
3
|
+
*
|
|
4
|
+
* Each buyer learns, from its own traffic, how every seller serves every
|
|
5
|
+
* model: how often requests succeed, how soon the answer starts and how fast
|
|
6
|
+
* it streams. Observations fade with a half-life, so a seller that blipped
|
|
7
|
+
* once barely moves and a seller that fixed itself recovers as soon as it
|
|
8
|
+
* serves again — no timers. Trust stays a gate applied before this: every
|
|
9
|
+
* seller the buyer has not used starts from the same prior, so with no
|
|
10
|
+
* observations the order is plain price order.
|
|
11
|
+
*
|
|
12
|
+
* Sellers are ranked by expected cost of one successful answer: price plus the
|
|
13
|
+
* value of the time it takes, divided by the chance it succeeds. Traffic is
|
|
14
|
+
* spread across sellers that are close to the best instead of all going to
|
|
15
|
+
* one, and a small share probes sellers the buyer has not heard from lately,
|
|
16
|
+
* so failover always has fresh data and recovered sellers are noticed.
|
|
17
|
+
*
|
|
18
|
+
* Nothing here talks to anyone: it is local state plus public metadata.
|
|
19
|
+
*/
|
|
20
|
+
/** Observations lose half their weight every 15 minutes. */
|
|
21
|
+
export const SELLER_HEALTH_HALF_LIFE_MS = 15 * 60_000;
|
|
22
|
+
/** Chance of success assumed for a seller the buyer has not used. */
|
|
23
|
+
export const SELLER_SUCCESS_PRIOR = 0.8;
|
|
24
|
+
/** The prior counts as this many observations. */
|
|
25
|
+
export const SELLER_HEALTH_PRIOR_WEIGHT = 2;
|
|
26
|
+
/** Value of one second of waiting, in USD. Makes a seller 15 s slower worth ~$0.003 more per request. */
|
|
27
|
+
export const DEFAULT_TIME_VALUE_USD_PER_SECOND = 0.0002;
|
|
28
|
+
/** Sellers within this fraction of the best expected cost share the traffic. */
|
|
29
|
+
export const SELLER_SPREAD_TOLERANCE = 0.3;
|
|
30
|
+
/** Share of requests that probe a seller the buyer has no recent data on. */
|
|
31
|
+
export const SELLER_EXPLORATION_RATE = 0.05;
|
|
32
|
+
/** A seller not observed for this long is due for a probe. */
|
|
33
|
+
export const SELLER_STALE_AFTER_MS = 10 * 60_000;
|
|
34
|
+
/**
|
|
35
|
+
* Extra wait counted for a seller the buyer has no open payment channel with:
|
|
36
|
+
* the first request has to reserve funds on-chain before it is served.
|
|
37
|
+
*/
|
|
38
|
+
export const NEW_RESERVE_SECONDS = 5;
|
|
39
|
+
/** Below this chance of success a seller is tried only after every healthier one. */
|
|
40
|
+
export const UNHEALTHY_SUCCESS_PROBABILITY = 0.5;
|
|
41
|
+
/** Weight of a seller's record on its other models, for a model with no data of its own. */
|
|
42
|
+
const SELLER_WIDE_WEIGHT = 0.5;
|
|
43
|
+
const DEFAULT_FIRST_TOKEN_MS = 4_000;
|
|
44
|
+
const DEFAULT_TOKENS_PER_SECOND = 50;
|
|
45
|
+
const LATENCY_EMA_ALPHA = 0.3;
|
|
46
|
+
const MIN_THROUGHPUT_TOKENS = 20;
|
|
47
|
+
const MAX_ENTRIES = 2_048;
|
|
48
|
+
/** Entries not observed for a day carry no weight worth keeping. */
|
|
49
|
+
const RETENTION_MS = 24 * 60 * 60_000;
|
|
50
|
+
function emptyStats(now) {
|
|
51
|
+
return {
|
|
52
|
+
successes: 0,
|
|
53
|
+
failures: 0,
|
|
54
|
+
decayedAt: now,
|
|
55
|
+
firstTokenMs: null,
|
|
56
|
+
tokensPerSecond: null,
|
|
57
|
+
lastSuccessAt: 0,
|
|
58
|
+
lastFailureAt: 0,
|
|
59
|
+
lastFailureReason: null,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function ema(previous, sample) {
|
|
63
|
+
return previous === null ? sample : previous * (1 - LATENCY_EMA_ALPHA) + sample * LATENCY_EMA_ALPHA;
|
|
64
|
+
}
|
|
65
|
+
function finiteNonNegative(value) {
|
|
66
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
67
|
+
}
|
|
68
|
+
export function sellerHealthKey(peerId, serviceId) {
|
|
69
|
+
return `${peerId.trim().toLowerCase().replace(/^0x/, '')}|${(serviceId ?? '').trim().toLowerCase()}`;
|
|
70
|
+
}
|
|
71
|
+
/** What one buyer has observed of every seller and model it used. */
|
|
72
|
+
export class SellerHealthBook {
|
|
73
|
+
_halfLifeMs;
|
|
74
|
+
_entries = new Map();
|
|
75
|
+
constructor(_halfLifeMs = SELLER_HEALTH_HALF_LIFE_MS) {
|
|
76
|
+
this._halfLifeMs = _halfLifeMs;
|
|
77
|
+
}
|
|
78
|
+
_decayed(stats, now) {
|
|
79
|
+
const elapsed = now - stats.decayedAt;
|
|
80
|
+
if (elapsed <= 0)
|
|
81
|
+
return stats;
|
|
82
|
+
const factor = 0.5 ** (elapsed / this._halfLifeMs);
|
|
83
|
+
return { ...stats, successes: stats.successes * factor, failures: stats.failures * factor, decayedAt: now };
|
|
84
|
+
}
|
|
85
|
+
_update(peerId, serviceId, now, apply) {
|
|
86
|
+
const key = sellerHealthKey(peerId, serviceId);
|
|
87
|
+
const current = this._entries.get(key);
|
|
88
|
+
this._entries.delete(key);
|
|
89
|
+
this._entries.set(key, apply(current ? this._decayed(current, now) : emptyStats(now)));
|
|
90
|
+
if (this._entries.size > MAX_ENTRIES) {
|
|
91
|
+
const oldest = this._entries.keys().next().value;
|
|
92
|
+
if (oldest !== undefined)
|
|
93
|
+
this._entries.delete(oldest);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
recordSuccess(peerId, serviceId, now, timing) {
|
|
97
|
+
this._update(peerId, serviceId, now, (stats) => {
|
|
98
|
+
const next = { ...stats, successes: stats.successes + 1, lastSuccessAt: now };
|
|
99
|
+
if (!timing || !finiteNonNegative(timing.firstTokenMs))
|
|
100
|
+
return next;
|
|
101
|
+
const outputTokens = timing.outputTokens ?? 0;
|
|
102
|
+
if (timing.streamed) {
|
|
103
|
+
next.firstTokenMs = ema(stats.firstTokenMs, timing.firstTokenMs);
|
|
104
|
+
if (outputTokens >= MIN_THROUGHPUT_TOKENS && finiteNonNegative(timing.streamMs) && timing.streamMs > 0) {
|
|
105
|
+
next.tokensPerSecond = ema(stats.tokensPerSecond, outputTokens / (timing.streamMs / 1000));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// Only the whole duration is known: take out the generation time at
|
|
110
|
+
// the speed seen so far to estimate when the answer would have started.
|
|
111
|
+
const tokensPerSecond = stats.tokensPerSecond ?? DEFAULT_TOKENS_PER_SECOND;
|
|
112
|
+
next.firstTokenMs = ema(stats.firstTokenMs, Math.max(0, timing.firstTokenMs - (outputTokens / tokensPerSecond) * 1000));
|
|
113
|
+
}
|
|
114
|
+
return next;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/** `weight` lets a failure that can only be the seller's (a forged receipt) count for more than one. */
|
|
118
|
+
recordFailure(peerId, serviceId, now, reason, weight = 1) {
|
|
119
|
+
this._update(peerId, serviceId, now, (stats) => ({
|
|
120
|
+
...stats,
|
|
121
|
+
failures: stats.failures + Math.max(0, weight),
|
|
122
|
+
lastFailureAt: now,
|
|
123
|
+
lastFailureReason: reason,
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
/** A failure that applies to every model the seller serves (e.g. a forged receipt) when the model is unknown. */
|
|
127
|
+
recordSellerFailure(peerId, now, reason, weight = 1) {
|
|
128
|
+
const prefix = sellerHealthKey(peerId, null);
|
|
129
|
+
let matched = false;
|
|
130
|
+
for (const key of [...this._entries.keys()]) {
|
|
131
|
+
if (!key.startsWith(prefix))
|
|
132
|
+
continue;
|
|
133
|
+
const [, serviceId] = key.split('|');
|
|
134
|
+
this.recordFailure(peerId, serviceId ?? null, now, reason, weight);
|
|
135
|
+
matched = true;
|
|
136
|
+
}
|
|
137
|
+
if (!matched)
|
|
138
|
+
this.recordFailure(peerId, null, now, reason, weight);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Decayed view of one seller's model. For a model the buyer has not used
|
|
142
|
+
* with this seller yet, what it saw on the seller's other models counts at
|
|
143
|
+
* half weight: a seller rejecting every request on one model usually does
|
|
144
|
+
* on the next. Speed is per model and is not carried over.
|
|
145
|
+
*/
|
|
146
|
+
stats(peerId, serviceId, now) {
|
|
147
|
+
const exact = this._entries.get(sellerHealthKey(peerId, serviceId));
|
|
148
|
+
if (exact)
|
|
149
|
+
return this._decayed(exact, now);
|
|
150
|
+
const prefix = sellerHealthKey(peerId, null);
|
|
151
|
+
let sellerWide = null;
|
|
152
|
+
for (const [key, entry] of this._entries) {
|
|
153
|
+
if (!key.startsWith(prefix))
|
|
154
|
+
continue;
|
|
155
|
+
const decayed = this._decayed(entry, now);
|
|
156
|
+
sellerWide ??= { ...emptyStats(now) };
|
|
157
|
+
sellerWide.successes += decayed.successes * SELLER_WIDE_WEIGHT;
|
|
158
|
+
sellerWide.failures += decayed.failures * SELLER_WIDE_WEIGHT;
|
|
159
|
+
if (decayed.lastSuccessAt > sellerWide.lastSuccessAt)
|
|
160
|
+
sellerWide.lastSuccessAt = decayed.lastSuccessAt;
|
|
161
|
+
if (decayed.lastFailureAt > sellerWide.lastFailureAt) {
|
|
162
|
+
sellerWide.lastFailureAt = decayed.lastFailureAt;
|
|
163
|
+
sellerWide.lastFailureReason = decayed.lastFailureReason;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return sellerWide;
|
|
167
|
+
}
|
|
168
|
+
entries(now) {
|
|
169
|
+
return [...this._entries.entries()].map(([key, stats]) => {
|
|
170
|
+
const [peerId, serviceId] = key.split('|');
|
|
171
|
+
return { peerId: peerId, serviceId: serviceId || null, stats: this._decayed(stats, now) };
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/** Forget a seller entirely, e.g. when an operator asks to give it another chance. */
|
|
175
|
+
forget(peerId) {
|
|
176
|
+
const prefix = sellerHealthKey(peerId, null);
|
|
177
|
+
for (const key of [...this._entries.keys()])
|
|
178
|
+
if (key.startsWith(prefix))
|
|
179
|
+
this._entries.delete(key);
|
|
180
|
+
}
|
|
181
|
+
serialize(now) {
|
|
182
|
+
return [...this._entries.entries()]
|
|
183
|
+
.filter(([, stats]) => now - Math.max(stats.lastSuccessAt, stats.lastFailureAt) < RETENTION_MS)
|
|
184
|
+
.map(([key, stats]) => [key, this._decayed(stats, now)]);
|
|
185
|
+
}
|
|
186
|
+
/** Restore persisted entries, dropping anything malformed or from the future. */
|
|
187
|
+
static parse(raw, now, halfLifeMs = SELLER_HEALTH_HALF_LIFE_MS) {
|
|
188
|
+
const book = new SellerHealthBook(halfLifeMs);
|
|
189
|
+
if (!Array.isArray(raw))
|
|
190
|
+
return book;
|
|
191
|
+
for (const item of raw.slice(-MAX_ENTRIES)) {
|
|
192
|
+
if (!Array.isArray(item) || typeof item[0] !== 'string' || !item[0].includes('|'))
|
|
193
|
+
continue;
|
|
194
|
+
const value = item[1];
|
|
195
|
+
if (!value || typeof value !== 'object')
|
|
196
|
+
continue;
|
|
197
|
+
const decayedAt = finiteNonNegative(value.decayedAt) ? Math.min(value.decayedAt, now) : now;
|
|
198
|
+
const lastSuccessAt = finiteNonNegative(value.lastSuccessAt) ? Math.min(value.lastSuccessAt, now) : 0;
|
|
199
|
+
const lastFailureAt = finiteNonNegative(value.lastFailureAt) ? Math.min(value.lastFailureAt, now) : 0;
|
|
200
|
+
if (now - Math.max(lastSuccessAt, lastFailureAt) >= RETENTION_MS)
|
|
201
|
+
continue;
|
|
202
|
+
book._entries.set(item[0], {
|
|
203
|
+
successes: finiteNonNegative(value.successes) ? Math.min(value.successes, 1e6) : 0,
|
|
204
|
+
failures: finiteNonNegative(value.failures) ? Math.min(value.failures, 1e6) : 0,
|
|
205
|
+
decayedAt,
|
|
206
|
+
firstTokenMs: finiteNonNegative(value.firstTokenMs) ? value.firstTokenMs : null,
|
|
207
|
+
tokensPerSecond: finiteNonNegative(value.tokensPerSecond) && value.tokensPerSecond > 0 ? value.tokensPerSecond : null,
|
|
208
|
+
lastSuccessAt,
|
|
209
|
+
lastFailureAt,
|
|
210
|
+
lastFailureReason: typeof value.lastFailureReason === 'string' ? value.lastFailureReason.slice(0, 200) : null,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
return book;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
export function successProbability(stats, prior = SELLER_SUCCESS_PRIOR) {
|
|
217
|
+
const successes = stats?.successes ?? 0;
|
|
218
|
+
const failures = stats?.failures ?? 0;
|
|
219
|
+
return (successes + SELLER_HEALTH_PRIOR_WEIGHT * prior) / (successes + failures + SELLER_HEALTH_PRIOR_WEIGHT);
|
|
220
|
+
}
|
|
221
|
+
function median(values) {
|
|
222
|
+
if (values.length === 0)
|
|
223
|
+
return null;
|
|
224
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
225
|
+
const middle = Math.floor(sorted.length / 2);
|
|
226
|
+
return sorted.length % 2 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
|
|
227
|
+
}
|
|
228
|
+
/** Typical speed among sellers the buyer has measured, used for sellers it has not. */
|
|
229
|
+
export function networkSpeed(stats) {
|
|
230
|
+
return {
|
|
231
|
+
firstTokenMs: median(stats.flatMap((entry) => entry?.firstTokenMs != null ? [entry.firstTokenMs] : [])) ?? DEFAULT_FIRST_TOKEN_MS,
|
|
232
|
+
tokensPerSecond: median(stats.flatMap((entry) => entry?.tokensPerSecond != null ? [entry.tokensPerSecond] : [])) ?? DEFAULT_TOKENS_PER_SECOND,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
export function scoreAdaptiveRoute(input, stats, shape, network, now, timeValueUsdPerSecond = DEFAULT_TIME_VALUE_USD_PER_SECOND) {
|
|
236
|
+
const probability = successProbability(stats);
|
|
237
|
+
const firstTokenMs = stats?.firstTokenMs ?? network.firstTokenMs;
|
|
238
|
+
const tokensPerSecond = stats?.tokensPerSecond ?? network.tokensPerSecond;
|
|
239
|
+
const expectedSeconds = firstTokenMs / 1000 + shape.outputTokens / Math.max(1, tokensPerSecond)
|
|
240
|
+
+ (input.channelOpen === false ? NEW_RESERVE_SECONDS : 0);
|
|
241
|
+
const expectedPriceUsd = finiteNonNegative(input.requestUsd)
|
|
242
|
+
? input.requestUsd
|
|
243
|
+
: input.inputUsdPerMillion !== null && input.outputUsdPerMillion !== null
|
|
244
|
+
? (shape.inputTokens * input.inputUsdPerMillion + shape.outputTokens * input.outputUsdPerMillion) / 1_000_000
|
|
245
|
+
: null;
|
|
246
|
+
// Sellers with no advertised price rank after priced ones (see the ordering);
|
|
247
|
+
// among themselves, count them at a dollar per million tokens.
|
|
248
|
+
const pricePart = expectedPriceUsd ?? (shape.inputTokens + shape.outputTokens) / 1_000_000;
|
|
249
|
+
const lastObservedAt = Math.max(stats?.lastSuccessAt ?? 0, stats?.lastFailureAt ?? 0);
|
|
250
|
+
return {
|
|
251
|
+
successProbability: probability,
|
|
252
|
+
expectedSeconds,
|
|
253
|
+
expectedPriceUsd,
|
|
254
|
+
score: (pricePart + timeValueUsdPerSecond * expectedSeconds) / Math.max(probability, 0.01),
|
|
255
|
+
unhealthy: probability < UNHEALTHY_SUCCESS_PROBABILITY,
|
|
256
|
+
stale: now - lastObservedAt >= SELLER_STALE_AFTER_MS,
|
|
257
|
+
stats,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Order candidates for one request. Ready, healthy sellers come first: one is
|
|
262
|
+
* drawn from those within `spreadTolerance` of the best expected cost,
|
|
263
|
+
* weighted toward the cheapest; the rest follow by expected cost. Unhealthy
|
|
264
|
+
* sellers follow, then sellers cooling down. With `explorationRate`, a seller
|
|
265
|
+
* the buyer has no recent data on goes first instead, with the usual order
|
|
266
|
+
* behind it as the fallback.
|
|
267
|
+
*/
|
|
268
|
+
export function orderAdaptiveRoutes(candidates, input, book, shape, options) {
|
|
269
|
+
const { now } = options;
|
|
270
|
+
const random = options.random ?? Math.random;
|
|
271
|
+
const tolerance = options.spreadTolerance ?? SELLER_SPREAD_TOLERANCE;
|
|
272
|
+
const explorationRate = options.explorationRate ?? SELLER_EXPLORATION_RATE;
|
|
273
|
+
const inputs = new Map(candidates.map((candidate) => [candidate, input(candidate)]));
|
|
274
|
+
const stats = new Map(candidates.map((candidate) => {
|
|
275
|
+
const { peerId, serviceId } = inputs.get(candidate);
|
|
276
|
+
return [candidate, book.stats(peerId, serviceId, now)];
|
|
277
|
+
}));
|
|
278
|
+
const network = networkSpeed([...stats.values()]);
|
|
279
|
+
const scores = new Map(candidates.map((candidate) => [
|
|
280
|
+
candidate,
|
|
281
|
+
scoreAdaptiveRoute(inputs.get(candidate), stats.get(candidate), shape, network, now, options.timeValueUsdPerSecond),
|
|
282
|
+
]));
|
|
283
|
+
// Priced sellers first, then by expected cost; ties keep the incoming order.
|
|
284
|
+
const position = new Map(candidates.map((candidate, index) => [candidate, index]));
|
|
285
|
+
const byScore = (a, b) => Number(scores.get(a).expectedPriceUsd === null) - Number(scores.get(b).expectedPriceUsd === null)
|
|
286
|
+
|| scores.get(a).score - scores.get(b).score
|
|
287
|
+
|| position.get(a) - position.get(b);
|
|
288
|
+
const cooling = candidates.filter((candidate) => inputs.get(candidate).coolingDown).sort(byScore);
|
|
289
|
+
const ready = candidates.filter((candidate) => !inputs.get(candidate).coolingDown);
|
|
290
|
+
const saturated = (candidate) => inputs.get(candidate).saturated === true;
|
|
291
|
+
const healthy = ready.filter((candidate) => !scores.get(candidate).unhealthy)
|
|
292
|
+
.sort((a, b) => Number(saturated(a)) - Number(saturated(b)) || byScore(a, b));
|
|
293
|
+
const unhealthy = ready.filter((candidate) => scores.get(candidate).unhealthy).sort(byScore);
|
|
294
|
+
const leader = healthy[0];
|
|
295
|
+
const best = leader ? scores.get(leader).score : null;
|
|
296
|
+
const leaderPriced = leader ? scores.get(leader).expectedPriceUsd !== null : false;
|
|
297
|
+
let pool = best === null ? [] : healthy.filter((candidate) => scores.get(candidate).score <= best * (1 + tolerance)
|
|
298
|
+
&& (scores.get(candidate).expectedPriceUsd !== null) === leaderPriced
|
|
299
|
+
&& saturated(candidate) === saturated(leader));
|
|
300
|
+
// Spreading must not open payment channels for its own sake: share traffic
|
|
301
|
+
// among sellers the buyer already pays, and only reserve on a new seller
|
|
302
|
+
// when it is the best choice outright (or failover needs it).
|
|
303
|
+
const channelOpen = (candidate) => inputs.get(candidate).channelOpen;
|
|
304
|
+
if (pool.some((candidate) => channelOpen(candidate) === false)) {
|
|
305
|
+
const open = pool.filter((candidate) => channelOpen(candidate) !== false);
|
|
306
|
+
pool = open.length > 0 ? open : pool.slice(0, 1);
|
|
307
|
+
}
|
|
308
|
+
let ordered = [...healthy, ...unhealthy, ...cooling];
|
|
309
|
+
if (pool.length > 0) {
|
|
310
|
+
// Weight 1/score²: twice as expensive gets a quarter of the traffic. The
|
|
311
|
+
// pool may no longer hold the leader (it needed a new channel), so even a
|
|
312
|
+
// single remaining seller goes first.
|
|
313
|
+
const weights = pool.map((candidate) => 1 / Math.max(scores.get(candidate).score, 1e-9) ** 2);
|
|
314
|
+
const picked = pool.length === 1
|
|
315
|
+
? pool[0]
|
|
316
|
+
: options.affinityKey
|
|
317
|
+
? rendezvousPick(pool, weights, (candidate) => inputs.get(candidate).peerId, options.affinityKey)
|
|
318
|
+
: weightedPick(pool, weights, random());
|
|
319
|
+
ordered = [picked, ...ordered.filter((candidate) => candidate !== picked)];
|
|
320
|
+
}
|
|
321
|
+
let explored = null;
|
|
322
|
+
// Probes are separate requests, never a turn of an ongoing conversation
|
|
323
|
+
// (that would move it off its cached seller), never open a channel, and
|
|
324
|
+
// never go to a seller already at its concurrency limit.
|
|
325
|
+
if (pool.length > 0 && !options.affinityKey && explorationRate > 0 && random() < explorationRate) {
|
|
326
|
+
explored = ready.filter((candidate) => !pool.includes(candidate) && scores.get(candidate).stale
|
|
327
|
+
&& channelOpen(candidate) !== false && !saturated(candidate)).sort(byScore)[0] ?? null;
|
|
328
|
+
if (explored)
|
|
329
|
+
ordered = [explored, ...ordered.filter((candidate) => candidate !== explored)];
|
|
330
|
+
}
|
|
331
|
+
return { ordered, scores, pool, explored };
|
|
332
|
+
}
|
|
333
|
+
function weightedPick(pool, weights, draw) {
|
|
334
|
+
let remaining = draw * weights.reduce((sum, weight) => sum + weight, 0);
|
|
335
|
+
for (const [index, weight] of weights.entries()) {
|
|
336
|
+
remaining -= weight;
|
|
337
|
+
if (remaining < 0)
|
|
338
|
+
return pool[index];
|
|
339
|
+
}
|
|
340
|
+
return pool[pool.length - 1];
|
|
341
|
+
}
|
|
342
|
+
/** FNV-1a over the key and seller, mapped to (0, 1]. */
|
|
343
|
+
function stableUnit(text) {
|
|
344
|
+
let hash = 0x811c9dc5;
|
|
345
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
346
|
+
hash ^= text.charCodeAt(index);
|
|
347
|
+
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
348
|
+
}
|
|
349
|
+
return (hash + 1) / 0x1_0000_0001;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Weighted rendezvous hashing: each conversation maps to one seller, with
|
|
353
|
+
* sellers' shares proportional to their weights. When the pool changes, only
|
|
354
|
+
* the conversations of a seller that left (or the share a newcomer takes)
|
|
355
|
+
* move; everyone else stays where their cache is.
|
|
356
|
+
*/
|
|
357
|
+
function rendezvousPick(pool, weights, peerId, key) {
|
|
358
|
+
let best = pool[0];
|
|
359
|
+
let bestScore = Number.NEGATIVE_INFINITY;
|
|
360
|
+
for (const [index, candidate] of pool.entries()) {
|
|
361
|
+
const score = Math.log(stableUnit(`${key}|${peerId(candidate)}`)) / weights[index];
|
|
362
|
+
if (score > bestScore) {
|
|
363
|
+
bestScore = score;
|
|
364
|
+
best = candidate;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return best;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* How long to wait for a seller to start answering before trying the next
|
|
371
|
+
* one: four times what it usually takes, never under 30 s or over 2 min.
|
|
372
|
+
* Null when the buyer has too little data on the seller to judge.
|
|
373
|
+
*/
|
|
374
|
+
export function adaptiveFirstTokenTimeoutMs(stats, expectedOutputTokens, streamed) {
|
|
375
|
+
if (!stats || stats.firstTokenMs === null || stats.successes < 2)
|
|
376
|
+
return null;
|
|
377
|
+
const generationMs = streamed ? 0 : (expectedOutputTokens / (stats.tokensPerSecond ?? DEFAULT_TOKENS_PER_SECOND)) * 1000;
|
|
378
|
+
return Math.round(Math.min(120_000, Math.max(30_000, 4 * (stats.firstTokenMs + generationMs))));
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=seller-health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seller-health.js","sourceRoot":"","sources":["../../src/routing/seller-health.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,GAAG,MAAM,CAAA;AACrD,qEAAqE;AACrE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAA;AACvC,kDAAkD;AAClD,MAAM,CAAC,MAAM,0BAA0B,GAAG,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MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAE,CAAA;QACnF,IAAI,KAAK,GAAG,SAAS,EAAE,CAAC;YAAC,SAAS,GAAG,KAAK,CAAC;YAAC,IAAI,GAAG,SAAS,CAAA;QAAC,CAAC;IAChE,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAA+B,EAAE,oBAA4B,EAAE,QAAiB;IAC1H,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,YAAY,KAAK,IAAI,IAAI,KAAK,CAAC,SAAS,GAAG,CAAC;QAAE,OAAO,IAAI,CAAA;IAC7E,MAAM,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,GAAG,CAAC,KAAK,CAAC,eAAe,IAAI,yBAAyB,CAAC,CAAC,GAAG,IAAI,CAAA;IACxH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AACjG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antseed/node",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.147",
|
|
4
4
|
"description": "Antseed Network protocol SDK — P2P inference marketplace",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"node-datachannel": "^0.7.0",
|
|
71
71
|
"tokenx": "^1.3.0",
|
|
72
72
|
"@antseed/api-adapter": "0.1.53",
|
|
73
|
-
"@antseed/
|
|
74
|
-
"@antseed/
|
|
73
|
+
"@antseed/protocol": "0.1.10",
|
|
74
|
+
"@antseed/buyer-core": "0.1.23"
|
|
75
75
|
},
|
|
76
76
|
"optionalDependencies": {
|
|
77
77
|
"keytar": "^7.9.0"
|