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
c47ed4e8
Commit
c47ed4e8
authored
4 days ago
by
thucpn
Browse files
Options
Downloads
Patches
Plain Diff
revert wiki (update in another PR)
parent
c6eee12e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
packages/tools/src/index.ts
+1
-1
1 addition, 1 deletion
packages/tools/src/index.ts
packages/tools/src/tools/wiki.ts
+5
-5
5 additions, 5 deletions
packages/tools/src/tools/wiki.ts
packages/tools/tests/wikipedia.test.ts
+3
-3
3 additions, 3 deletions
packages/tools/tests/wikipedia.test.ts
with
9 additions
and
9 deletions
packages/tools/src/index.ts
+
1
−
1
View file @
c47ed4e8
...
...
@@ -6,6 +6,6 @@ export * from "./tools/img-gen";
export
*
from
"
./tools/interpreter
"
;
export
*
from
"
./tools/openapi-action
"
;
export
*
from
"
./tools/weather
"
;
export
*
from
"
./tools/wiki
pedia
"
;
export
*
from
"
./tools/wiki
"
;
export
*
from
"
./tool-call
"
;
This diff is collapsed.
Click to expand it.
packages/tools/src/tools/wiki
pedia
.ts
→
packages/tools/src/tools/wiki.ts
+
5
−
5
View file @
c47ed4e8
import
{
tool
}
from
"
@llamaindex/core/tools
"
;
import
{
default
as
wiki
}
from
"
wikipedia
"
;
import
{
default
as
wiki
pedia
}
from
"
wikipedia
"
;
import
{
z
}
from
"
zod
"
;
export
type
WikiToolOutput
=
{
...
...
@@ -7,7 +7,7 @@ export type WikiToolOutput = {
content
:
string
;
};
export
const
wiki
pedia
=
()
=>
{
export
const
wiki
=
()
=>
{
return
tool
({
name
:
"
wikipedia
"
,
description
:
"
Use this function to search Wikipedia
"
,
...
...
@@ -16,11 +16,11 @@ export const wikipedia = () => {
lang
:
z
.
string
().
describe
(
"
The language to search in
"
).
default
(
"
en
"
),
}),
execute
:
async
({
query
,
lang
}):
Promise
<
WikiToolOutput
>
=>
{
wiki
.
setLang
(
lang
);
const
searchResult
=
await
wiki
.
search
(
query
);
wiki
pedia
.
setLang
(
lang
);
const
searchResult
=
await
wiki
pedia
.
search
(
query
);
const
pageTitle
=
searchResult
?.
results
[
0
]?.
title
;
if
(
!
pageTitle
)
return
{
title
:
"
No search results.
"
,
content
:
""
};
const
result
=
await
wiki
.
page
(
pageTitle
,
{
autoSuggest
:
false
});
const
result
=
await
wiki
pedia
.
page
(
pageTitle
,
{
autoSuggest
:
false
});
return
{
title
:
pageTitle
,
content
:
await
result
.
content
()
};
},
});
...
...
This diff is collapsed.
Click to expand it.
packages/tools/tests/wikipedia.test.ts
+
3
−
3
View file @
c47ed4e8
import
{
describe
,
expect
,
test
}
from
"
vitest
"
;
import
{
wiki
pedia
}
from
"
../src/tools/wiki
pedia
"
;
import
{
wiki
}
from
"
../src/tools/wiki
"
;
describe
(
"
Wikipedia Tool
"
,
()
=>
{
test
(
"
wiki tool returns content for valid query
"
,
async
()
=>
{
const
wiki
pedia
Tool
=
wiki
pedia
();
const
result
=
await
wiki
pedia
Tool
.
call
({
const
wikiTool
=
wiki
();
const
result
=
await
wikiTool
.
call
({
query
:
"
Albert Einstein
"
,
lang
:
"
en
"
,
});
...
...
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