Skip to content

Commit be3e280

Browse files
authored
Updates references to SimpleNodeParser to SentenceSplitter. (#1129)
1 parent 2afcbe6 commit be3e280

File tree

16 files changed

+47
-51
lines changed

16 files changed

+47
-51
lines changed

apps/docs/docs/modules/ingestion_pipeline/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
MetadataMode,
1717
OpenAIEmbedding,
1818
TitleExtractor,
19-
SimpleNodeParser,
19+
SentenceSplitter,
2020
} from "llamaindex";
2121

2222
async function main() {
@@ -29,7 +29,7 @@ async function main() {
2929
const document = new Document({ text: essay, id_: path });
3030
const pipeline = new IngestionPipeline({
3131
transformations: [
32-
new SimpleNodeParser({ chunkSize: 1024, chunkOverlap: 20 }),
32+
new SentenceSplitter({ chunkSize: 1024, chunkOverlap: 20 }),
3333
new TitleExtractor(),
3434
new OpenAIEmbedding(),
3535
],
@@ -62,7 +62,7 @@ import {
6262
MetadataMode,
6363
OpenAIEmbedding,
6464
TitleExtractor,
65-
SimpleNodeParser,
65+
SentenceSplitter,
6666
QdrantVectorStore,
6767
VectorStoreIndex,
6868
} from "llamaindex";
@@ -81,7 +81,7 @@ async function main() {
8181
const document = new Document({ text: essay, id_: path });
8282
const pipeline = new IngestionPipeline({
8383
transformations: [
84-
new SimpleNodeParser({ chunkSize: 1024, chunkOverlap: 20 }),
84+
new SentenceSplitter({ chunkSize: 1024, chunkOverlap: 20 }),
8585
new TitleExtractor(),
8686
new OpenAIEmbedding(),
8787
],

apps/docs/docs/modules/ingestion_pipeline/transformations.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A transformation is something that takes a list of nodes as an input, and return
44

55
Currently, the following components are Transformation objects:
66

7-
- [SimpleNodeParser](../../api/classes/SimpleNodeParser.md)
7+
- [SentenceSplitter](../../api/classes/SentenceSplitter.md)
88
- [MetadataExtractor](../documents_and_nodes/metadata_extraction.md)
99
- [Embeddings](../embeddings/index.md)
1010

@@ -13,10 +13,10 @@ Currently, the following components are Transformation objects:
1313
While transformations are best used with with an IngestionPipeline, they can also be used directly.
1414

1515
```ts
16-
import { SimpleNodeParser, TitleExtractor, Document } from "llamaindex";
16+
import { SentenceSplitter, TitleExtractor, Document } from "llamaindex";
1717

1818
async function main() {
19-
let nodes = new SimpleNodeParser().getNodesFromDocuments([
19+
let nodes = new SentenceSplitter().getNodesFromDocuments([
2020
new Document({ text: "I am 10 years old. John is 20 years old." }),
2121
]);
2222

@@ -34,15 +34,15 @@ main().catch(console.error);
3434

3535
## Custom Transformations
3636

37-
You can implement any transformation yourself by implementing the `TransformerComponent`.
37+
You can implement any transformation yourself by implementing the `TransformComponent`.
3838

39-
The following custom transformation will remove any special characters or punctutaion in text.
39+
The following custom transformation will remove any special characters or punctutation in text.
4040

4141
```ts
42-
import { TransformerComponent, Node } from "llamaindex";
42+
import { TransformComponent, TextNode } from "llamaindex";
4343

44-
class RemoveSpecialCharacters extends TransformerComponent {
45-
async transform(nodes: Node[]): Promise<Node[]> {
44+
export class RemoveSpecialCharacters extends TransformComponent {
45+
async transform(nodes: TextNode[]): Promise<TextNode[]> {
4646
for (const node of nodes) {
4747
node.text = node.text.replace(/[^\w\s]/gi, "");
4848
}

apps/docs/docs/modules/node_parser.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ sidebar_position: 4
77
The `NodeParser` in LlamaIndex is responsible for splitting `Document` objects into more manageable `Node` objects. When you call `.fromDocuments()`, the `NodeParser` from the `Settings` is used to do this automatically for you. Alternatively, you can use it to split documents ahead of time.
88

99
```typescript
10-
import { Document, SimpleNodeParser } from "llamaindex";
10+
import { Document, SentenceSplitter } from "llamaindex";
1111

12-
const nodeParser = new SimpleNodeParser();
12+
const nodeParser = new SentenceSplitter();
1313

1414
Settings.nodeParser = nodeParser;
1515
```
@@ -93,6 +93,5 @@ The output metadata will be something like:
9393
9494
## API Reference
9595
96-
- [SimpleNodeParser](../api/classes/SimpleNodeParser.md)
9796
- [SentenceSplitter](../api/classes/SentenceSplitter.md)
9897
- [MarkdownNodeParser](../api/classes/MarkdownNodeParser.md)

apps/docs/docs/modules/query_engines/router_query_engine.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
OpenAI,
1616
RouterQueryEngine,
1717
SimpleDirectoryReader,
18-
SimpleNodeParser,
18+
SentenceSplitter,
1919
SummaryIndex,
2020
VectorStoreIndex,
2121
Settings,
@@ -34,11 +34,11 @@ const documents = await new SimpleDirectoryReader().loadData({
3434

3535
## Service Context
3636

37-
Next, we need to define some basic rules and parse the documents into nodes. We will use the `SimpleNodeParser` to parse the documents into nodes and `Settings` to define the rules (eg. LLM API key, chunk size, etc.):
37+
Next, we need to define some basic rules and parse the documents into nodes. We will use the `SentenceSplitter` to parse the documents into nodes and `Settings` to define the rules (eg. LLM API key, chunk size, etc.):
3838

3939
```ts
4040
Settings.llm = new OpenAI();
41-
Settings.nodeParser = new SimpleNodeParser({
41+
Settings.nodeParser = new SentenceSplitter({
4242
chunkSize: 1024,
4343
});
4444
```
@@ -104,14 +104,14 @@ import {
104104
OpenAI,
105105
RouterQueryEngine,
106106
SimpleDirectoryReader,
107-
SimpleNodeParser,
107+
SentenceSplitter,
108108
SummaryIndex,
109109
VectorStoreIndex,
110110
Settings,
111111
} from "llamaindex";
112112

113113
Settings.llm = new OpenAI();
114-
Settings.nodeParser = new SimpleNodeParser({
114+
Settings.nodeParser = new SentenceSplitter({
115115
chunkSize: 1024,
116116
});
117117

examples/agent/multi_document_agent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
OpenAI,
77
OpenAIAgent,
88
QueryEngineTool,
9+
SentenceSplitter,
910
Settings,
10-
SimpleNodeParser,
1111
SimpleToolNodeMapping,
1212
SummaryIndex,
1313
VectorStoreIndex,
@@ -43,7 +43,7 @@ async function main() {
4343
for (const title of wikiTitles) {
4444
console.log(`Processing ${title}`);
4545

46-
const nodes = new SimpleNodeParser({
46+
const nodes = new SentenceSplitter({
4747
chunkSize: 200,
4848
chunkOverlap: 20,
4949
}).getNodesFromDocuments([countryDocs[title]]);

examples/extractors/keywordExtractor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import {
22
Document,
33
KeywordExtractor,
44
OpenAI,
5-
SimpleNodeParser,
5+
SentenceSplitter,
66
} from "llamaindex";
77

88
(async () => {
99
const openaiLLM = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0 });
1010

11-
const nodeParser = new SimpleNodeParser();
11+
const nodeParser = new SentenceSplitter();
1212

1313
const nodes = nodeParser.getNodesFromDocuments([
1414
new Document({ text: "banana apple orange pear peach watermelon" }),

examples/extractors/questionsAnsweredExtractor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import {
22
Document,
33
OpenAI,
44
QuestionsAnsweredExtractor,
5-
SimpleNodeParser,
5+
SentenceSplitter,
66
} from "llamaindex";
77

88
(async () => {
99
const openaiLLM = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0 });
1010

11-
const nodeParser = new SimpleNodeParser();
11+
const nodeParser = new SentenceSplitter();
1212

1313
const nodes = nodeParser.getNodesFromDocuments([
1414
new Document({

examples/extractors/summaryExtractor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {
22
Document,
33
OpenAI,
4-
SimpleNodeParser,
4+
SentenceSplitter,
55
SummaryExtractor,
66
} from "llamaindex";
77

88
(async () => {
99
const openaiLLM = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0 });
1010

11-
const nodeParser = new SimpleNodeParser();
11+
const nodeParser = new SentenceSplitter();
1212

1313
const nodes = nodeParser.getNodesFromDocuments([
1414
new Document({

examples/extractors/titleExtractor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Document, OpenAI, SimpleNodeParser, TitleExtractor } from "llamaindex";
1+
import { Document, OpenAI, SentenceSplitter, TitleExtractor } from "llamaindex";
22

33
import essay from "../essay";
44

55
(async () => {
66
const openaiLLM = new OpenAI({ model: "gpt-3.5-turbo-0125", temperature: 0 });
77

8-
const nodeParser = new SimpleNodeParser({});
8+
const nodeParser = new SentenceSplitter({});
99

1010
const nodes = nodeParser.getNodesFromDocuments([
1111
new Document({

examples/jupyter/nodeparser.ipynb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
"metadata": {},
88
"outputs": [],
99
"source": [
10-
"import {\n",
11-
" Document,\n",
12-
" SimpleNodeParser\n",
13-
"} from \"npm:llamaindex\";"
10+
"import { Document, SentenceSplitter } from \"npm:llamaindex\";"
1411
]
1512
},
1613
{
@@ -45,7 +42,7 @@
4542
}
4643
],
4744
"source": [
48-
"const nodeParser = new SimpleNodeParser();\n",
45+
"const nodeParser = new SentenceSplitter();\n",
4946
"const nodes = nodeParser.getNodesFromDocuments([\n",
5047
" new Document({ text: \"I am 10 years old. John is 20 years old.\" }),\n",
5148
"]);\n",

0 commit comments

Comments
 (0)