export async function embedNChunks(
args: { n: number; documentId?: string, timeoutMs?: number },
opts: ContextOptions
): Promise<number> {
const chunksToEmbed = await opts.db
.select()
.from(chunks)
.where(
and(
// not embedded yet
isNull(chunks.embedding),
// ----------------------
// PART THAT DOESN'T WORK
or(
isNull(args.documentId), // doesn't compile - not a column
eq(chunks.documentId, args.documentId)
),
// ----------------------
// bootleg job runner system - if no embedding 15s after last attempt,
// pick up with next job cycle
or(
isNull(chunks.embeddedAt),
lt(
chunks.embeddedAt,
new Date(Date.now() - (args.timeoutMs ?? DEFAULT_TIMEOUT_MS))
)
)
)
)
.limit(args.n);
...
export async function embedNChunks(
args: { n: number; documentId?: string, timeoutMs?: number },
opts: ContextOptions
): Promise<number> {
const chunksToEmbed = await opts.db
.select()
.from(chunks)
.where(
and(
// not embedded yet
isNull(chunks.embedding),
// ----------------------
// PART THAT DOESN'T WORK
or(
isNull(args.documentId), // doesn't compile - not a column
eq(chunks.documentId, args.documentId)
),
// ----------------------
// bootleg job runner system - if no embedding 15s after last attempt,
// pick up with next job cycle
or(
isNull(chunks.embeddedAt),
lt(
chunks.embeddedAt,
new Date(Date.now() - (args.timeoutMs ?? DEFAULT_TIMEOUT_MS))
)
)
)
)
.limit(args.n);
...