Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Llama Index
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
Llama Index
Commits
48a286ab
Unverified
Commit
48a286ab
authored
1 year ago
by
Logan
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Ensure load and search tool spec loads documents (#11733)
parent
0ae69d46
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llama-index-core/llama_index/core/tools/tool_spec/load_and_search/base.py
+14
-1
14 additions, 1 deletion
.../llama_index/core/tools/tool_spec/load_and_search/base.py
with
14 additions
and
1 deletion
llama-index-core/llama_index/core/tools/tool_spec/load_and_search/base.py
+
14
−
1
View file @
48a286ab
...
@@ -4,12 +4,12 @@ Tool that wraps any data loader, and is able to load data on-demand.
...
@@ -4,12 +4,12 @@ Tool that wraps any data loader, and is able to load data on-demand.
"""
"""
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Type
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Type
from
llama_index.core.bridge.pydantic
import
BaseModel
from
llama_index.core.bridge.pydantic
import
BaseModel
from
llama_index.core.indices.base
import
BaseIndex
from
llama_index.core.indices.base
import
BaseIndex
from
llama_index.core.indices.vector_store
import
VectorStoreIndex
from
llama_index.core.indices.vector_store
import
VectorStoreIndex
from
llama_index.core.schema
import
Document
from
llama_index.core.tools.function_tool
import
FunctionTool
from
llama_index.core.tools.function_tool
import
FunctionTool
from
llama_index.core.tools.tool_spec.base
import
SPEC_FUNCTION_TYPE
,
BaseToolSpec
from
llama_index.core.tools.tool_spec.base
import
SPEC_FUNCTION_TYPE
,
BaseToolSpec
from
llama_index.core.tools.types
import
ToolMetadata
from
llama_index.core.tools.types
import
ToolMetadata
...
@@ -123,6 +123,19 @@ class LoadAndSearchToolSpec(BaseToolSpec):
...
@@ -123,6 +123,19 @@ class LoadAndSearchToolSpec(BaseToolSpec):
def
load
(
self
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
Any
:
def
load
(
self
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
Any
:
# Call the wrapped tool and save the result in the index
# Call the wrapped tool and save the result in the index
docs
=
self
.
_tool
(
*
args
,
**
kwargs
).
raw_output
docs
=
self
.
_tool
(
*
args
,
**
kwargs
).
raw_output
# convert to Document if necessary
if
isinstance
(
docs
,
list
):
for
i
,
doc
in
enumerate
(
docs
):
if
not
isinstance
(
doc
,
Document
):
docs
[
i
]
=
Document
(
text
=
str
(
doc
))
elif
isinstance
(
docs
,
str
):
docs
=
[
Document
(
text
=
docs
)]
elif
isinstance
(
docs
,
Document
):
docs
=
[
docs
]
else
:
doc
=
[
Document
(
text
=
str
(
docs
))]
if
self
.
_index
:
if
self
.
_index
:
for
doc
in
docs
:
for
doc
in
docs
:
self
.
_index
.
insert
(
doc
,
**
self
.
_index_kwargs
)
self
.
_index
.
insert
(
doc
,
**
self
.
_index_kwargs
)
...
...
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