Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support organization id in llamacloud index #1123

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions packages/llamaindex/src/cloud/LlamaCloudIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,46 @@ export class LlamaCloudIndex {
await this.waitForPipelineIngestion(verbose, raiseOnError);
}

private async getPipelineId(
name: string,
projectName: string,
public async getPipelineId(
name?: string,
projectName?: string,
): Promise<string> {
const pipelines = await PipelinesService.searchPipelinesApiV1PipelinesGet({
projectName,
pipelineName: name,
projectName: projectName ?? this.params.projectName,
thucpn marked this conversation as resolved.
Show resolved Hide resolved
pipelineName: name ?? this.params.name,
});

return pipelines[0].id;
}

public async getProjectId(
organizationId?: string,
projectName?: string,
): Promise<string> {
const projects = await ProjectsService.listProjectsApiV1ProjectsGet({
organizationId: organizationId ?? this.params.organizationId,
projectName: projectName ?? this.params.projectName,
});

if (projects.length === 0) {
throw new Error(
`Unknown project name ${this.params.projectName}. Please confirm a managed project with this name exists.`,
);
} else if (projects.length > 1) {
throw new Error(
`Multiple projects found with name ${this.params.projectName}. Please specify organization_id.`,
);
}

const project = projects[0];

if (!project.id) {
throw new Error(`No project found with name ${this.params.projectName}`);
}

return project.id;
}

static async fromDocuments(
params: {
documents: Document[];
Expand All @@ -168,6 +196,7 @@ export class LlamaCloudIndex {
});

const project = await ProjectsService.upsertProjectApiV1ProjectsPut({
organizationId: params.organizationId,
requestBody: {
name: params.projectName ?? "default",
},
Expand Down
1 change: 1 addition & 0 deletions packages/llamaindex/src/cloud/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export type ClientParams = { apiKey?: string; baseUrl?: string };
export type CloudConstructorParams = {
name: string;
projectName: string;
organizationId?: string;
serviceContext?: ServiceContext;
} & ClientParams;