Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LlamaIndexTS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
LlamaIndexTS
Commits
5a50ed2d
Commit
5a50ed2d
authored
1 year ago
by
Sourabh Desai
Browse files
Options
Downloads
Patches
Plain Diff
udpate ListIndex.fromDocuments method signature
parent
775be4da
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/simple/listIndex.ts
+16
-2
16 additions, 2 deletions
apps/simple/listIndex.ts
packages/core/src/index/list/ListIndex.ts
+6
-5
6 additions, 5 deletions
packages/core/src/index/list/ListIndex.ts
with
22 additions
and
7 deletions
apps/simple/listIndex.ts
+
16
−
2
View file @
5a50ed2d
import
{
Document
,
ListIndex
,
ListRetrieverMode
}
from
"
llamaindex
"
;
import
{
Document
,
ListIndex
,
ListRetrieverMode
,
serviceContextFromDefaults
,
SimpleNodeParser
,
}
from
"
llamaindex
"
;
import
essay
from
"
./essay
"
;
async
function
main
()
{
const
serviceContext
=
serviceContextFromDefaults
({
nodeParser
:
new
SimpleNodeParser
({
chunkSize
:
40
,
}),
});
const
document
=
new
Document
({
text
:
essay
});
const
index
=
await
ListIndex
.
fromDocuments
([
document
]);
const
index
=
await
ListIndex
.
fromDocuments
({
documents
:
[
document
],
serviceContext
,
});
const
queryEngine
=
index
.
asQueryEngine
(
ListRetrieverMode
.
LLM
);
const
response
=
await
queryEngine
.
aquery
(
"
What did the author do growing up?
"
...
...
This diff is collapsed.
Click to expand it.
packages/core/src/index/list/ListIndex.ts
+
6
−
5
View file @
5a50ed2d
...
...
@@ -74,11 +74,12 @@ export class ListIndex extends BaseIndex<IndexList> {
});
}
static
async
fromDocuments
(
documents
:
Document
[],
storageContext
?:
StorageContext
,
serviceContext
?:
ServiceContext
):
Promise
<
ListIndex
>
{
static
async
fromDocuments
(
args
:
{
documents
:
Document
[];
storageContext
?:
StorageContext
;
serviceContext
?:
ServiceContext
;
}):
Promise
<
ListIndex
>
{
let
{
documents
,
storageContext
,
serviceContext
}
=
args
;
storageContext
=
storageContext
??
(
await
storageContextFromDefaults
({}));
serviceContext
=
serviceContext
??
serviceContextFromDefaults
({});
const
docStore
=
storageContext
.
docStore
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment