@probeo/anymodel 0.5.0 → 0.5.1
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/README.md +1 -0
- package/dist/cli.cjs +24 -13
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +24 -13
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +24 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +24 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2010,6 +2010,17 @@ var BatchStore = class {
|
|
|
2010
2010
|
const entries = await readDirQueued(this.dir);
|
|
2011
2011
|
return entries.filter((d) => d.isDirectory()).map((d) => d.name).sort();
|
|
2012
2012
|
}
|
|
2013
|
+
/**
|
|
2014
|
+
* Stream requests from JSONL one line at a time (memory-efficient).
|
|
2015
|
+
*/
|
|
2016
|
+
async *streamRequests(id) {
|
|
2017
|
+
const p = joinPath(this.batchDir(id), "requests.jsonl");
|
|
2018
|
+
if (!await fileExistsQueued(p)) return;
|
|
2019
|
+
const raw = await readFileQueued(p, "utf8");
|
|
2020
|
+
for (const line of raw.split("\n")) {
|
|
2021
|
+
if (line.trim()) yield JSON.parse(line);
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2013
2024
|
/**
|
|
2014
2025
|
* Check if a batch exists.
|
|
2015
2026
|
*/
|
|
@@ -2074,7 +2085,7 @@ var BatchManager = class {
|
|
|
2074
2085
|
this.processNativeBatch(id, request, native.adapter).catch(() => {
|
|
2075
2086
|
});
|
|
2076
2087
|
} else {
|
|
2077
|
-
this.processConcurrentBatch(id, request).catch(() => {
|
|
2088
|
+
this.processConcurrentBatch(id, request.model, request.options).catch(() => {
|
|
2078
2089
|
});
|
|
2079
2090
|
}
|
|
2080
2091
|
return batch;
|
|
@@ -2254,28 +2265,28 @@ var BatchManager = class {
|
|
|
2254
2265
|
}
|
|
2255
2266
|
/**
|
|
2256
2267
|
* Process batch requests concurrently (fallback path).
|
|
2268
|
+
* Streams requests from disk to avoid holding them all in memory.
|
|
2257
2269
|
*/
|
|
2258
|
-
async processConcurrentBatch(batchId,
|
|
2270
|
+
async processConcurrentBatch(batchId, model, options) {
|
|
2259
2271
|
const batch = await this.store.getMeta(batchId);
|
|
2260
2272
|
if (!batch) return;
|
|
2261
2273
|
batch.status = "processing";
|
|
2262
2274
|
await this.store.updateMeta(batch);
|
|
2263
|
-
const items = request.requests;
|
|
2264
2275
|
const active = /* @__PURE__ */ new Set();
|
|
2265
2276
|
const processItem = async (item) => {
|
|
2266
2277
|
const current = await this.store.getMeta(batchId);
|
|
2267
2278
|
if (current?.status === "cancelled") return;
|
|
2268
2279
|
const chatRequest = {
|
|
2269
|
-
model
|
|
2280
|
+
model,
|
|
2270
2281
|
messages: item.messages,
|
|
2271
|
-
max_tokens: item.max_tokens ??
|
|
2272
|
-
temperature: item.temperature ??
|
|
2273
|
-
top_p: item.top_p ??
|
|
2274
|
-
top_k: item.top_k ??
|
|
2275
|
-
stop: item.stop ??
|
|
2276
|
-
response_format: item.response_format ??
|
|
2277
|
-
tools: item.tools ??
|
|
2278
|
-
tool_choice: item.tool_choice ??
|
|
2282
|
+
max_tokens: item.max_tokens ?? options?.max_tokens,
|
|
2283
|
+
temperature: item.temperature ?? options?.temperature,
|
|
2284
|
+
top_p: item.top_p ?? options?.top_p,
|
|
2285
|
+
top_k: item.top_k ?? options?.top_k,
|
|
2286
|
+
stop: item.stop ?? options?.stop,
|
|
2287
|
+
response_format: item.response_format ?? options?.response_format,
|
|
2288
|
+
tools: item.tools ?? options?.tools,
|
|
2289
|
+
tool_choice: item.tool_choice ?? options?.tool_choice
|
|
2279
2290
|
};
|
|
2280
2291
|
let result;
|
|
2281
2292
|
try {
|
|
@@ -2306,7 +2317,7 @@ var BatchManager = class {
|
|
|
2306
2317
|
await this.store.updateMeta(meta);
|
|
2307
2318
|
}
|
|
2308
2319
|
};
|
|
2309
|
-
for (const item of
|
|
2320
|
+
for await (const item of this.store.streamRequests(batchId)) {
|
|
2310
2321
|
const current = await this.store.getMeta(batchId);
|
|
2311
2322
|
if (current?.status === "cancelled") break;
|
|
2312
2323
|
if (active.size >= this.concurrencyLimit) {
|