Skip to content

Commit

Permalink
Remove legacy data struct and drop _v2 suffix. (run-llama#1878)
Browse files Browse the repository at this point in the history
* wip

* remove v2

* wip

* docs

* wip

* docs
  • Loading branch information
Disiok authored May 2, 2023
1 parent 9e92ce0 commit 1dc7cab
Show file tree
Hide file tree
Showing 85 changed files with 250 additions and 693 deletions.
9 changes: 7 additions & 2 deletions docs/guides/primer/usage_pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ nodes = parser.get_nodes_from_documents(documents)
You can also choose to construct Node objects manually and skip the first section. For instance,

```python
from llama_index.data_structs.node_v2 import Node, DocumentRelationship
from llama_index.data_structs.node import Node, DocumentRelationship

node1 = Node(text="<text_chunk>", doc_id="<node_id>")
node2 = Node(text="<text_chunk>", doc_id="<node_id>")
Expand Down Expand Up @@ -263,6 +263,7 @@ from llama_index import (
)
from llama_index.retrievers import VectorIndexRetriever
from llama_index.query_engine import RetrieverQueryEngine
from llama_index.indices.postprocessor import SimilarityPostprocessor

# build index
index = GPTVectorStoreIndex.from_documents(documents)
Expand All @@ -276,7 +277,7 @@ retriever = VectorIndexRetriever(
# configure response synthesizer
response_synthesizer = ResponseSynthesizer.from_args(
node_postprocessors=[
SimilarityPostprocessor(required_keywords=['hello'])
SimilarityPostprocessor(similarity_cutoff=0.7)
]
)

Expand All @@ -285,6 +286,10 @@ query_engine = RetrieverQueryEngine(
retriever=retriever,
response_synthesizer=response_synthesizer,
)

# query
response = query_engine.query("What did the author do growing up?")
print(response)
```
You may also add your own retrieval, response synthesis, and overall query logic, by implementing the corresponding interfaces.

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/node.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Node
=================

.. automodule:: llama_index.data_structs.node_v2
.. automodule:: llama_index.data_structs.node
:members:
:inherited-members:
:exclude-members: NodeType, ImageNode, IndexNode
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/suo/dev/llama_index/llama_index/data_structs/node_v2.py:176: UserWarning: .source_text is deprecated, use .node.get_text() instead\n",
"/Users/suo/dev/llama_index/llama_index/data_structs/node.py:176: UserWarning: .source_text is deprecated, use .node.get_text() instead\n",
" warnings.warn(\".source_text is deprecated, use .node.get_text() instead\")\n"
]
}
Expand Down
6 changes: 3 additions & 3 deletions llama_index/data_structs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""Init file."""

from llama_index.data_structs.data_structs_v2 import (
from llama_index.data_structs.data_structs import (
IndexDict,
IndexGraph,
IndexList,
KeywordTable,
)
from llama_index.data_structs.node_v2 import Node, NodeWithScore
from llama_index.data_structs.table_v2 import StructDatapoint
from llama_index.data_structs.node import Node, NodeWithScore
from llama_index.data_structs.table import StructDatapoint

__all__ = [
"Node",
Expand Down
Loading

0 comments on commit 1dc7cab

Please sign in to comment.