mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 19:58:27 +00:00
Centralize date/time formatting utilities (#11831)
This commit is contained in:
@@ -59,7 +59,9 @@ function getVoyageHeaders(
|
||||
}
|
||||
|
||||
function splitVoyageBatchRequests(requests: VoyageBatchRequest[]): VoyageBatchRequest[][] {
|
||||
if (requests.length <= VOYAGE_BATCH_MAX_REQUESTS) return [requests];
|
||||
if (requests.length <= VOYAGE_BATCH_MAX_REQUESTS) {
|
||||
return [requests];
|
||||
}
|
||||
const groups: VoyageBatchRequest[][] = [];
|
||||
for (let i = 0; i < requests.length; i += VOYAGE_BATCH_MAX_REQUESTS) {
|
||||
groups.push(requests.slice(i, i + VOYAGE_BATCH_MAX_REQUESTS));
|
||||
@@ -170,7 +172,9 @@ async function readVoyageBatchError(params: {
|
||||
throw new Error(`voyage batch error file content failed: ${res.status} ${text}`);
|
||||
}
|
||||
const text = await res.text();
|
||||
if (!text.trim()) return undefined;
|
||||
if (!text.trim()) {
|
||||
return undefined;
|
||||
}
|
||||
const lines = text
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
@@ -246,7 +250,9 @@ export async function runVoyageEmbeddingBatches(params: {
|
||||
concurrency: number;
|
||||
debug?: (message: string, data?: Record<string, unknown>) => void;
|
||||
}): Promise<Map<string, number[]>> {
|
||||
if (params.requests.length === 0) return new Map();
|
||||
if (params.requests.length === 0) {
|
||||
return new Map();
|
||||
}
|
||||
const groups = splitVoyageBatchRequests(params.requests);
|
||||
const byCustomId = new Map<string, number[]>();
|
||||
|
||||
@@ -307,15 +313,19 @@ export async function runVoyageEmbeddingBatches(params: {
|
||||
|
||||
if (contentRes.body) {
|
||||
const reader = createInterface({
|
||||
input: Readable.fromWeb(contentRes.body as any),
|
||||
input: Readable.fromWeb(contentRes.body as unknown as import("stream/web").ReadableStream),
|
||||
terminal: false,
|
||||
});
|
||||
|
||||
for await (const rawLine of reader) {
|
||||
if (!rawLine.trim()) continue;
|
||||
if (!rawLine.trim()) {
|
||||
continue;
|
||||
}
|
||||
const line = JSON.parse(rawLine) as VoyageBatchOutputLine;
|
||||
const customId = line.custom_id;
|
||||
if (!customId) continue;
|
||||
if (!customId) {
|
||||
continue;
|
||||
}
|
||||
remaining.delete(customId);
|
||||
if (line.error?.message) {
|
||||
errors.push(`${customId}: ${line.error.message}`);
|
||||
|
||||
Reference in New Issue
Block a user