From fe08d0451b9174cd501d5681b5d6d994d1eb8b79 Mon Sep 17 00:00:00 2001 From: Marcus Schiesser <mail@marcusschiesser.de> Date: Wed, 9 Oct 2024 11:39:55 +0700 Subject: [PATCH] fix: llamacloud retrieval with multiple pipelines (#1309) --- .changeset/proud-lies-brush.md | 5 +++++ .../src/cloud/LlamaCloudRetriever.ts | 18 ++---------------- packages/llamaindex/src/cloud/utils.ts | 4 ++-- 3 files changed, 9 insertions(+), 18 deletions(-) create mode 100644 .changeset/proud-lies-brush.md diff --git a/.changeset/proud-lies-brush.md b/.changeset/proud-lies-brush.md new file mode 100644 index 000000000..c3364c42d --- /dev/null +++ b/.changeset/proud-lies-brush.md @@ -0,0 +1,5 @@ +--- +"llamaindex": patch +--- + +Fix LlamaCloud retrieval with multiple pipelines diff --git a/packages/llamaindex/src/cloud/LlamaCloudRetriever.ts b/packages/llamaindex/src/cloud/LlamaCloudRetriever.ts index 54f18fb86..d2a659504 100644 --- a/packages/llamaindex/src/cloud/LlamaCloudRetriever.ts +++ b/packages/llamaindex/src/cloud/LlamaCloudRetriever.ts @@ -61,7 +61,7 @@ export class LlamaCloudRetriever extends BaseRetriever { await PipelinesService.searchPipelinesApiV1PipelinesGet({ query: { project_id: await getProjectId(this.projectName, this.organizationId), - project_name: this.pipelineName, + pipeline_name: this.pipelineName, }, throwOnError: true, }); @@ -72,25 +72,11 @@ export class LlamaCloudRetriever extends BaseRetriever { ); } - const { data: pipeline } = - await PipelinesService.getPipelineApiV1PipelinesPipelineIdGet({ - path: { - pipeline_id: pipelines[0]!.id, - }, - throwOnError: true, - }); - - if (!pipeline) { - throw new Error( - `No pipeline found with name ${this.pipelineName} in project ${this.projectName}`, - ); - } - const { data: results } = await PipelinesService.runSearchApiV1PipelinesPipelineIdRetrievePost({ throwOnError: true, path: { - pipeline_id: pipeline.id, + pipeline_id: pipelines[0]!.id, }, body: { ...this.retrieveParams, diff --git a/packages/llamaindex/src/cloud/utils.ts b/packages/llamaindex/src/cloud/utils.ts index c5fdcbb3e..bbaadd854 100644 --- a/packages/llamaindex/src/cloud/utils.ts +++ b/packages/llamaindex/src/cloud/utils.ts @@ -40,9 +40,9 @@ export async function getProjectId( ): Promise<string> { const { data: projects } = await ProjectsService.listProjectsApiV1ProjectsGet( { - path: { + query: { project_name: projectName, - organization_id: organizationId, + organization_id: organizationId ?? null, }, throwOnError: true, }, -- GitLab