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
057ee146
Unverified
Commit
057ee146
authored
3 months ago
by
Thuc Pham
Committed by
GitHub
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: add start command for stackblitz (#1577)
parent
4a831b19
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
examples/package.json
+2
-1
2 additions, 1 deletion
examples/package.json
examples/starter.ts
+11
-5
11 additions, 5 deletions
examples/starter.ts
with
13 additions
and
6 deletions
examples/package.json
+
2
−
1
View file @
057ee146
...
...
@@ -33,7 +33,8 @@
"typescript"
:
"^5.7.2"
},
"scripts"
:
{
"lint"
:
"eslint ."
"lint"
:
"eslint ."
,
"start"
:
"tsx ./starter.ts"
},
"stackblitz"
:
{
"startCommand"
:
"npm start"
...
...
This diff is collapsed.
Click to expand it.
examples/starter.ts
+
11
−
5
View file @
057ee146
import
{
SimpleDirectoryReader
,
VectorStoreIndex
}
from
"
llamaindex
"
;
import
{
Document
,
VectorStoreIndex
}
from
"
llamaindex
"
;
import
fs
from
"
node:fs/promises
"
;
import
{
createInterface
}
from
"
node:readline/promises
"
;
async
function
main
()
{
const
reader
=
new
SimpleDirectoryReader
();
const
path
=
"
node_modules/llamaindex/examples/abramov.txt
"
;
const
essay
=
await
fs
.
readFile
(
path
,
"
utf-8
"
);
const
document
=
new
Document
({
text
:
essay
,
id_
:
path
});
const
documents
=
await
reader
.
loadData
(
"
./data
"
);
const
index
=
await
VectorStoreIndex
.
fromDocuments
(
documents
);
const
index
=
await
VectorStoreIndex
.
fromDocuments
([
document
]);
const
queryEngine
=
index
.
asQueryEngine
();
const
rl
=
createInterface
({
input
:
process
.
stdin
,
output
:
process
.
stdout
});
console
.
log
(
"
Try asking a question about the essay: https://github.com/run-llama/LlamaIndexTS/blob/main/packages/llamaindex/examples/abramov.txt
"
,
"
\n
Example: When did the author graduate from high school?
"
,
"
\n
==============================
\n
"
,
);
while
(
true
)
{
const
query
=
await
rl
.
question
(
"
Query:
"
);
const
response
=
await
queryEngine
.
query
({
...
...
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