I get the following error stack when running the jupyter notebook cell with the line
graph_documents = llm_transformer.convert_to_graph_documents(documents)
The stack is as follows
`{
"name": "KeyError",
"message": "'head'",
"stack": "---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[10], line 8
5 llm = ChatOpenAI(temperature=0, model="gpt-4o-mini")
6 llm_transformer = LLMGraphTransformer(llm=llm)
----> 8 graph_documents = llm_transformer.convert_to_graph_documents(documents)
File ~/work/repo/GraphRAG-with-Llama-3.1/.venv/lib/python3.11/site-packages/langchain_experimental/graph_transformers/llm.py:782, in LLMGraphTransformer.convert_to_graph_documents(self, documents, config)
770 def convert_to_graph_documents(
771 self, documents: Sequence[Document], config: Optional[RunnableConfig] = None
772 ) -> List[GraphDocument]:
773 """Convert a sequence of documents into graph documents.
774
775 Args:
(...)
780 Sequence[GraphDocument]: The transformed documents as graphs.
781 """
--> 782 return [self.process_response(document, config) for document in documents]
File ~/work/repo/GraphRAG-with-Llama-3.1/.venv/lib/python3.11/site-packages/langchain_experimental/graph_transformers/llm.py:782, in (.0)
770 def convert_to_graph_documents(
771 self, documents: Sequence[Document], config: Optional[RunnableConfig] = None
772 ) -> List[GraphDocument]:
773 """Convert a sequence of documents into graph documents.
774
775 Args:
(...)
780 Sequence[GraphDocument]: The transformed documents as graphs.
781 """
--> 782 return [self.process_response(document, config) for document in documents]
File ~/work/repo/GraphRAG-with-Llama-3.1/.venv/lib/python3.11/site-packages/langchain_experimental/graph_transformers/llm.py:734, in LLMGraphTransformer.process_response(self, document, config)
731 parsed_json = self.json_repair.loads(raw_schema)
732 for rel in parsed_json:
733 # Nodes need to be deduplicated using a set
--> 734 nodes_set.add((rel["head"], rel["head_type"]))
735 nodes_set.add((rel["tail"], rel["tail_type"]))
737 source_node = Node(id=rel["head"], type=rel["head_type"])
KeyError: 'head'"
}`
I get the following error stack when running the jupyter notebook cell with the line
graph_documents = llm_transformer.convert_to_graph_documents(documents)The stack is as follows
`{
"name": "KeyError",
"message": "'head'",
"stack": "---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[10], line 8
5 llm = ChatOpenAI(temperature=0, model="gpt-4o-mini")
6 llm_transformer = LLMGraphTransformer(llm=llm)
----> 8 graph_documents = llm_transformer.convert_to_graph_documents(documents)
File ~/work/repo/GraphRAG-with-Llama-3.1/.venv/lib/python3.11/site-packages/langchain_experimental/graph_transformers/llm.py:782, in LLMGraphTransformer.convert_to_graph_documents(self, documents, config)
770 def convert_to_graph_documents(
771 self, documents: Sequence[Document], config: Optional[RunnableConfig] = None
772 ) -> List[GraphDocument]:
773 """Convert a sequence of documents into graph documents.
774
775 Args:
(...)
780 Sequence[GraphDocument]: The transformed documents as graphs.
781 """
--> 782 return [self.process_response(document, config) for document in documents]
File ~/work/repo/GraphRAG-with-Llama-3.1/.venv/lib/python3.11/site-packages/langchain_experimental/graph_transformers/llm.py:782, in (.0)
770 def convert_to_graph_documents(
771 self, documents: Sequence[Document], config: Optional[RunnableConfig] = None
772 ) -> List[GraphDocument]:
773 """Convert a sequence of documents into graph documents.
774
775 Args:
(...)
780 Sequence[GraphDocument]: The transformed documents as graphs.
781 """
--> 782 return [self.process_response(document, config) for document in documents]
File ~/work/repo/GraphRAG-with-Llama-3.1/.venv/lib/python3.11/site-packages/langchain_experimental/graph_transformers/llm.py:734, in LLMGraphTransformer.process_response(self, document, config)
731 parsed_json = self.json_repair.loads(raw_schema)
732 for rel in parsed_json:
733 # Nodes need to be deduplicated using a set
--> 734 nodes_set.add((rel["head"], rel["head_type"]))
735 nodes_set.add((rel["tail"], rel["tail_type"]))
737 source_node = Node(id=rel["head"], type=rel["head_type"])
KeyError: 'head'"
}`