@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/cli.js
CHANGED
|
@@ -1949,6 +1949,17 @@ var BatchStore = class {
|
|
|
1949
1949
|
const entries = await readDirQueued(this.dir);
|
|
1950
1950
|
return entries.filter((d) => d.isDirectory()).map((d) => d.name).sort();
|
|
1951
1951
|
}
|
|
1952
|
+
/**
|
|
1953
|
+
* Stream requests from JSONL one line at a time (memory-efficient).
|
|
1954
|
+
*/
|
|
1955
|
+
async *streamRequests(id) {
|
|
1956
|
+
const p = joinPath(this.batchDir(id), "requests.jsonl");
|
|
1957
|
+
if (!await fileExistsQueued(p)) return;
|
|
1958
|
+
const raw = await readFileQueued(p, "utf8");
|
|
1959
|
+
for (const line of raw.split("\n")) {
|
|
1960
|
+
if (line.trim()) yield JSON.parse(line);
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1952
1963
|
/**
|
|
1953
1964
|
* Check if a batch exists.
|
|
1954
1965
|
*/
|
|
@@ -2013,7 +2024,7 @@ var BatchManager = class {
|
|
|
2013
2024
|
this.processNativeBatch(id, request, native.adapter).catch(() => {
|
|
2014
2025
|
});
|
|
2015
2026
|
} else {
|
|
2016
|
-
this.processConcurrentBatch(id, request).catch(() => {
|
|
2027
|
+
this.processConcurrentBatch(id, request.model, request.options).catch(() => {
|
|
2017
2028
|
});
|
|
2018
2029
|
}
|
|
2019
2030
|
return batch;
|
|
@@ -2193,28 +2204,28 @@ var BatchManager = class {
|
|
|
2193
2204
|
}
|
|
2194
2205
|
/**
|
|
2195
2206
|
* Process batch requests concurrently (fallback path).
|
|
2207
|
+
* Streams requests from disk to avoid holding them all in memory.
|
|
2196
2208
|
*/
|
|
2197
|
-
async processConcurrentBatch(batchId,
|
|
2209
|
+
async processConcurrentBatch(batchId, model, options) {
|
|
2198
2210
|
const batch = await this.store.getMeta(batchId);
|
|
2199
2211
|
if (!batch) return;
|
|
2200
2212
|
batch.status = "processing";
|
|
2201
2213
|
await this.store.updateMeta(batch);
|
|
2202
|
-
const items = request.requests;
|
|
2203
2214
|
const active = /* @__PURE__ */ new Set();
|
|
2204
2215
|
const processItem = async (item) => {
|
|
2205
2216
|
const current = await this.store.getMeta(batchId);
|
|
2206
2217
|
if (current?.status === "cancelled") return;
|
|
2207
2218
|
const chatRequest = {
|
|
2208
|
-
model
|
|
2219
|
+
model,
|
|
2209
2220
|
messages: item.messages,
|
|
2210
|
-
max_tokens: item.max_tokens ??
|
|
2211
|
-
temperature: item.temperature ??
|
|
2212
|
-
top_p: item.top_p ??
|
|
2213
|
-
top_k: item.top_k ??
|
|
2214
|
-
stop: item.stop ??
|
|
2215
|
-
response_format: item.response_format ??
|
|
2216
|
-
tools: item.tools ??
|
|
2217
|
-
tool_choice: item.tool_choice ??
|
|
2221
|
+
max_tokens: item.max_tokens ?? options?.max_tokens,
|
|
2222
|
+
temperature: item.temperature ?? options?.temperature,
|
|
2223
|
+
top_p: item.top_p ?? options?.top_p,
|
|
2224
|
+
top_k: item.top_k ?? options?.top_k,
|
|
2225
|
+
stop: item.stop ?? options?.stop,
|
|
2226
|
+
response_format: item.response_format ?? options?.response_format,
|
|
2227
|
+
tools: item.tools ?? options?.tools,
|
|
2228
|
+
tool_choice: item.tool_choice ?? options?.tool_choice
|
|
2218
2229
|
};
|
|
2219
2230
|
let result;
|
|
2220
2231
|
try {
|
|
@@ -2245,7 +2256,7 @@ var BatchManager = class {
|
|
|
2245
2256
|
await this.store.updateMeta(meta);
|
|
2246
2257
|
}
|
|
2247
2258
|
};
|
|
2248
|
-
for (const item of
|
|
2259
|
+
for await (const item of this.store.streamRequests(batchId)) {
|
|
2249
2260
|
const current = await this.store.getMeta(batchId);
|
|
2250
2261
|
if (current?.status === "cancelled") break;
|
|
2251
2262
|
if (active.size >= this.concurrencyLimit) {
|