fix: pRetry not working with CommonJS

This commit is contained in:
Marcus Schiesser
2025-05-22 15:13:38 +07:00
parent ed497727b1
commit 76ff23dc48
3 changed files with 15 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@llamaindex/cloud": patch
---
Fix pRetry not working with CommonJS
+9 -1
View File
@@ -1,5 +1,13 @@
import { LlamaParseReader } from "@llamaindex/cloud";
import { VectorStoreIndex } from "llamaindex";
import { openai, OpenAIEmbedding } from "@llamaindex/openai";
import { Settings, VectorStoreIndex } from "llamaindex";
Settings.llm = openai({
model: "gpt-4.1",
});
Settings.embedModel = new OpenAIEmbedding({
model: "text-embedding-3-small",
});
async function main() {
// Load PDF using LlamaParse
+1 -1
View File
@@ -2,7 +2,6 @@
import { type Client, createClient, createConfig } from "@hey-api/client-fetch";
import { Document, FileReader } from "@llamaindex/core/schema";
import { fs, getEnv, path } from "@llamaindex/env";
import pRetry from "p-retry";
import {
type BodyUploadFileApiParsingUploadPost,
type FailPageMode,
@@ -391,6 +390,7 @@ export class LlamaParseReader extends FileReader {
): Promise<any> {
let tries = 0;
let currentInterval = this.checkInterval;
const { default: pRetry } = await import("p-retry");
while (true) {
await sleep(currentInterval * 1000);