Skip to content
Snippets Groups Projects
Commit d1aa3b79 authored by Yi Ding's avatar Yi Ding
Browse files

more changes for the summary index

parent e4af7b3a
No related branches found
No related tags found
No related merge requests found
import { import {
Document, Document,
ListRetrieverMode,
SimpleNodeParser, SimpleNodeParser,
SummaryIndex, SummaryIndex,
SummaryRetrieverMode,
serviceContextFromDefaults, serviceContextFromDefaults,
} from "llamaindex"; } from "llamaindex";
import essay from "./essay"; import essay from "./essay";
...@@ -18,7 +18,7 @@ async function main() { ...@@ -18,7 +18,7 @@ async function main() {
serviceContext, serviceContext,
}); });
const queryEngine = index.asQueryEngine({ const queryEngine = index.asQueryEngine({
retriever: index.asRetriever({ mode: ListRetrieverMode.LLM }), retriever: index.asRetriever({ mode: SummaryRetrieverMode.LLM }),
}); });
const response = await queryEngine.query( const response = await queryEngine.query(
"What did the author do growing up?", "What did the author do growing up?",
......
import { import {
Document, Document,
ListRetrieverMode,
SimpleNodeParser, SimpleNodeParser,
SummaryIndex,
SummaryRetrieverMode,
serviceContextFromDefaults, serviceContextFromDefaults,
} from "llamaindex"; } from "llamaindex";
import essay from "./essay"; import essay from "./essay";
...@@ -13,9 +14,11 @@ async function main() { ...@@ -13,9 +14,11 @@ async function main() {
}), }),
}); });
const document = new Document({ text: essay, id_: "essay" }); 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({ const queryEngine = index.asQueryEngine({
retriever: index.asRetriever({ mode: ListRetrieverMode.LLM }), retriever: index.asRetriever({ mode: SummaryRetrieverMode.LLM }),
}); });
const response = await queryEngine.query( const response = await queryEngine.query(
"What did the author do growing up?", "What did the author do growing up?",
......
...@@ -254,3 +254,4 @@ export class SummaryIndex extends BaseIndex<IndexList> { ...@@ -254,3 +254,4 @@ export class SummaryIndex extends BaseIndex<IndexList> {
// Legacy // Legacy
export type ListIndex = SummaryIndex; export type ListIndex = SummaryIndex;
export type ListRetrieverMode = SummaryRetrieverMode;
export { export { SummaryIndex, SummaryRetrieverMode } from "./SummaryIndex";
SummaryRetrieverMode as ListRetrieverMode, export type { ListIndex, ListRetrieverMode } from "./SummaryIndex";
SummaryIndex,
} from "./SummaryIndex";
export type { ListIndex } from "./SummaryIndex";
export { export {
SummaryIndexLLMRetriever, SummaryIndexLLMRetriever,
SummaryIndexRetriever, SummaryIndexRetriever,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment