-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: asChatEngine function for index (#1640)
- Loading branch information
Showing
10 changed files
with
146 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@llamaindex/core": patch | ||
"llamaindex": patch | ||
--- | ||
|
||
feat: asChatEngine function for index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Document, KeywordTableIndex } from "llamaindex"; | ||
import essay from "../essay"; | ||
|
||
async function main() { | ||
const document = new Document({ text: essay }); | ||
const index = await KeywordTableIndex.fromDocuments([document]); | ||
const chatEngine = index.asChatEngine(); | ||
|
||
const response = await chatEngine.chat({ | ||
message: "What is Harsh Mistress?", | ||
}); | ||
console.log(response.message.content); | ||
} | ||
|
||
main().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Document, SummaryIndex, SummaryRetrieverMode } from "llamaindex"; | ||
import essay from "../essay"; | ||
|
||
async function main() { | ||
const document = new Document({ text: essay }); | ||
const index = await SummaryIndex.fromDocuments([document]); | ||
const chatEngine = index.asChatEngine({ | ||
mode: SummaryRetrieverMode.LLM, | ||
}); | ||
|
||
const response = await chatEngine.chat({ | ||
message: "Summary about the author", | ||
}); | ||
console.log(response.message.content); | ||
} | ||
|
||
main().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Document, VectorStoreIndex } from "llamaindex"; | ||
import essay from "../essay"; | ||
|
||
async function main() { | ||
const document = new Document({ text: essay }); | ||
const index = await VectorStoreIndex.fromDocuments([document]); | ||
const chatEngine = index.asChatEngine({ similarityTopK: 5 }); | ||
|
||
const response = await chatEngine.chat({ | ||
message: "What did I work on in February 2021?", | ||
}); | ||
console.log(response.message.content); | ||
} | ||
|
||
main().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters