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
99d2421b
Unverified
Commit
99d2421b
authored
1 year ago
by
Andrei Fajardo
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Delete txtai.py from chatgpt-plugin-reader package directory (#10601)
parent
c6caa133
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-integrations/readers/llama-index-readers-chatgpt-plugin/llama_index/readers/txtai.py
+0
-76
0 additions, 76 deletions
...index-readers-chatgpt-plugin/llama_index/readers/txtai.py
with
0 additions
and
76 deletions
llama-index-integrations/readers/llama-index-readers-chatgpt-plugin/llama_index/readers/txtai.py
deleted
100644 → 0
+
0
−
76
View file @
c6caa133
"""
txtai reader.
"""
from
typing
import
Any
,
Dict
,
List
import
numpy
as
np
from
llama_index.readers.base
import
BaseReader
from
llama_index.schema
import
Document
class
TxtaiReader
(
BaseReader
):
"""
txtai reader.
Retrieves documents through an existing in-memory txtai index.
These documents can then be used in a downstream LlamaIndex data structure.
If you wish use txtai itself as an index to to organize documents,
insert documents, and perform queries on them, please use VectorStoreIndex
with TxtaiVectorStore.
Args:
txtai_index (txtai.ann.ANN): A txtai Index object (required)
"""
def
__init__
(
self
,
index
:
Any
):
"""
Initialize with parameters.
"""
import_err_msg
=
"""
`txtai` package not found. For instructions on
how to install `txtai` please visit
https://neuml.github.io/txtai/install/
"""
try
:
import
txtai
# noqa
except
ImportError
:
raise
ImportError
(
import_err_msg
)
self
.
_index
=
index
def
load_data
(
self
,
query
:
np
.
ndarray
,
id_to_text_map
:
Dict
[
str
,
str
],
k
:
int
=
4
,
separate_documents
:
bool
=
True
,
)
->
List
[
Document
]:
"""
Load data from txtai index.
Args:
query (np.ndarray): A 2D numpy array of query vectors.
id_to_text_map (Dict[str, str]): A map from ID
'
s to text.
k (int): Number of nearest neighbors to retrieve. Defaults to 4.
separate_documents (Optional[bool]): Whether to return separate
documents. Defaults to True.
Returns:
List[Document]: A list of documents.
"""
search_result
=
self
.
_index
.
search
(
query
,
k
)
documents
=
[]
for
query_result
in
search_result
:
for
doc_id
,
_
in
query_result
:
doc_id
=
str
(
doc_id
)
if
doc_id
not
in
id_to_text_map
:
raise
ValueError
(
f
"
Document ID
{
doc_id
}
not found in id_to_text_map.
"
)
text
=
id_to_text_map
[
doc_id
]
documents
.
append
(
Document
(
text
=
text
))
if
not
separate_documents
:
# join all documents into one
text_list
=
[
doc
.
get_content
()
for
doc
in
documents
]
text
=
"
\n\n
"
.
join
(
text_list
)
documents
=
[
Document
(
text
=
text
)]
return
documents
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