You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great to have, in addition to the to_llama_index_nodes method to have a to_llama_index_document method on the openparse.schemas.ParsedDocument class that returns a valid llama_index.core.schema.Document object.
The text was updated successfully, but these errors were encountered:
Can you point me to documentation that explains how Nodes and Documents are related in llama_index? From what I understand a Document is just a parent Node.
This is the current implementation.
defto_llama_index_nodes(self):
try:
fromllama_index.core.schemaimportDocumentasLlamaIndexDocumentexceptImportErroraserr:
raiseImportError(
"llama_index is not installed. Please install it with `pip install llama-index`."
) fromerrli_doc=LlamaIndexDocument(
id_=self.id_,
metadata={
"file_name": self.filename,
"file_size": self.file_size,
"creation_date": self.creation_date.isoformat(),
"last_modified_date": self.last_modified_date.isoformat(),
},
excluded_embed_metadata_keys=[
"file_size",
"creation_date",
"last_modified_date",
],
excluded_llm_metadata_keys=[
"file_name",
"file_size",
"creation_date",
"last_modified_date",
],
)
li_nodes=self._nodes_to_llama_index(li_doc)
returnli_nodesdef_nodes_to_llama_index(self, llama_index_doc):
try:
fromllama_index.core.schemaimportNodeRelationshipexceptImportErroraserr:
raiseImportError(
"llama_index is not installed. Please install it with `pip install llama-index`."
) fromerrli_nodes= [node.to_llama_index() fornodeinsorted(self.nodes)]
foriinrange(len(li_nodes) -1):
li_nodes[i].relationships[NodeRelationship.NEXT] =li_nodes[
i+1
].as_related_node_info()
li_nodes[i+1].relationships[NodeRelationship.PREVIOUS] =li_nodes[
i
].as_related_node_info()
forli_nodeinli_nodes:
li_node.relationships[NodeRelationship.PARENT] = (
llama_index_doc.as_related_node_info()
) # NOTE: A DOC IS JUST A NODE?returnli_nodes
Description
It would be great to have, in addition to the
to_llama_index_nodes
method to have ato_llama_index_document
method on theopenparse.schemas.ParsedDocument
class that returns a validllama_index.core.schema.Document
object.The text was updated successfully, but these errors were encountered: