Skip to content

Validation Error on graph_documents = llm_transformer.convert_to_graph_documents(documents) with Ollama LLM #5

Description

@Stat-Up-YuChen

ValidationError Traceback (most recent call last)
Cell In[6], line 10
7 llm = ChatOpenAI(temperature=0, model="gpt-4o-mini")
8 llm_transformer = LLMGraphTransformer(llm=llm)
---> 10 graph_documents = llm_transformer.convert_to_graph_documents(documents)

File ~/.cache/pypoetry/virtualenvs/graphrag-with-llama-3-1-QrOEH8Po-py3.12/lib/python3.12/site-packages/langchain_experimental/graph_transformers/llm.py:795, in LLMGraphTransformer.convert_to_graph_documents(self, documents, config)
783 def convert_to_graph_documents(
784 self, documents: Sequence[Document], config: Optional[RunnableConfig] = None
785 ) -> List[GraphDocument]:
786 """Convert a sequence of documents into graph documents.
787
788 Args:
(...)
793 Sequence[GraphDocument]: The transformed documents as graphs.
794 """
--> 795 return [self.process_response(document, config) for document in documents]

File ~/.cache/pypoetry/virtualenvs/graphrag-with-llama-3-1-QrOEH8Po-py3.12/lib/python3.12/site-packages/langchain_experimental/graph_transformers/llm.py:751, in LLMGraphTransformer.process_response(self, document, config)
748 nodes_set.add((rel["tail"], rel["tail_type"]))
750 source_node = Node(id=rel["head"], type=rel["head_type"])
--> 751 target_node = Node(id=rel["tail"], type=rel["tail_type"])
752 relationships.append(
753 Relationship(
754 source=source_node, target=target_node, type=rel["relation"]
755 )
756 )
757 # Create nodes list

File ~/.cache/pypoetry/virtualenvs/graphrag-with-llama-3-1-QrOEH8Po-py3.12/lib/python3.12/site-packages/langchain_core/load/serializable.py:113, in Serializable.init(self, *args, **kwargs)
111 def init(self, *args: Any, **kwargs: Any) -> None:
112 """"""
--> 113 super().init(*args, **kwargs)

File ~/.cache/pypoetry/virtualenvs/graphrag-with-llama-3-1-QrOEH8Po-py3.12/lib/python3.12/site-packages/pydantic/v1/main.py:341, in BaseModel.init(pydantic_self, **data)
339 values, fields_set, validation_error = validate_model(pydantic_self.class, data)
340 if validation_error:
--> 341 raise validation_error
342 try:
343 object_setattr(pydantic_self, 'dict', values)

ValidationError: 2 validation errors for Node
id
none is not an allowed value (type=type_error.none.not_allowed)
type
none is not an allowed value (type=type_error.none.not_allowed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions