-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support adding pdfs as context
- Loading branch information
1 parent
4350067
commit b9cef53
Showing
7 changed files
with
205 additions
and
70 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* eslint-disable @typescript-eslint/no-magic-numbers */ | ||
import type { Index } from "@upstash/vector"; | ||
import { sleep } from "bun"; | ||
|
||
export const awaitUntilIndexed = async (client: Index, timeoutMillis = 10_000) => { | ||
const start = performance.now(); | ||
|
||
const getInfo = async () => { | ||
return await client.info(); | ||
}; | ||
|
||
do { | ||
const info = await getInfo(); | ||
if (info.pendingVectorCount === 0) { | ||
// OK, nothing more to index. | ||
return; | ||
} | ||
|
||
// Not indexed yet, sleep a bit and check again if the timeout is not passed. | ||
await sleep(1000); | ||
} while (performance.now() < start + timeoutMillis); | ||
|
||
throw new Error(`Indexing is not completed in ${timeoutMillis} ms.`); | ||
}; |