From d1aa3b7982f0192e911d2f84b70e72ced9c9afc2 Mon Sep 17 00:00:00 2001 From: Yi Ding <yi.s.ding@gmail.com> Date: Tue, 29 Aug 2023 09:41:23 -0700 Subject: [PATCH] more changes for the summary index --- apps/simple/summaryIndex.ts | 4 ++-- examples/summaryIndex.ts | 9 ++++++--- packages/core/src/indices/summary/SummaryIndex.ts | 1 + packages/core/src/indices/summary/index.ts | 7 ++----- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/simple/summaryIndex.ts b/apps/simple/summaryIndex.ts index d3fe7736b..cc34e95d3 100644 --- a/apps/simple/summaryIndex.ts +++ b/apps/simple/summaryIndex.ts @@ -1,8 +1,8 @@ import { Document, - ListRetrieverMode, SimpleNodeParser, SummaryIndex, + SummaryRetrieverMode, serviceContextFromDefaults, } from "llamaindex"; import essay from "./essay"; @@ -18,7 +18,7 @@ async function main() { serviceContext, }); const queryEngine = index.asQueryEngine({ - retriever: index.asRetriever({ mode: ListRetrieverMode.LLM }), + retriever: index.asRetriever({ mode: SummaryRetrieverMode.LLM }), }); const response = await queryEngine.query( "What did the author do growing up?", diff --git a/examples/summaryIndex.ts b/examples/summaryIndex.ts index 9045d8ef5..cc34e95d3 100644 --- a/examples/summaryIndex.ts +++ b/examples/summaryIndex.ts @@ -1,7 +1,8 @@ import { Document, - ListRetrieverMode, SimpleNodeParser, + SummaryIndex, + SummaryRetrieverMode, serviceContextFromDefaults, } from "llamaindex"; import essay from "./essay"; @@ -13,9 +14,11 @@ async function main() { }), }); const document = new Document({ text: essay, id_: "essay" }); - const index = await ListIndex.fromDocuments([document], { serviceContext }); + const index = await SummaryIndex.fromDocuments([document], { + serviceContext, + }); const queryEngine = index.asQueryEngine({ - retriever: index.asRetriever({ mode: ListRetrieverMode.LLM }), + retriever: index.asRetriever({ mode: SummaryRetrieverMode.LLM }), }); const response = await queryEngine.query( "What did the author do growing up?", diff --git a/packages/core/src/indices/summary/SummaryIndex.ts b/packages/core/src/indices/summary/SummaryIndex.ts index fcf4e0326..39a8ec525 100644 --- a/packages/core/src/indices/summary/SummaryIndex.ts +++ b/packages/core/src/indices/summary/SummaryIndex.ts @@ -254,3 +254,4 @@ export class SummaryIndex extends BaseIndex<IndexList> { // Legacy export type ListIndex = SummaryIndex; +export type ListRetrieverMode = SummaryRetrieverMode; diff --git a/packages/core/src/indices/summary/index.ts b/packages/core/src/indices/summary/index.ts index b3f8dba2c..b6e0c7d5e 100644 --- a/packages/core/src/indices/summary/index.ts +++ b/packages/core/src/indices/summary/index.ts @@ -1,8 +1,5 @@ -export { - SummaryRetrieverMode as ListRetrieverMode, - SummaryIndex, -} from "./SummaryIndex"; -export type { ListIndex } from "./SummaryIndex"; +export { SummaryIndex, SummaryRetrieverMode } from "./SummaryIndex"; +export type { ListIndex, ListRetrieverMode } from "./SummaryIndex"; export { SummaryIndexLLMRetriever, SummaryIndexRetriever, -- GitLab