Open Stat-Up-YuChen opened 1 month ago
I get the same error. @Coding-Crashkurse Can you perhaps specify the version of the packages used so that I can fix them?
Hi @tae898 I meet same error, and below is the package list
['Package Version', '------------------------- --------------', 'aiohappyeyeballs 2.4.0', 'aiohttp 3.10.5', 'aiosignal 1.3.1', 'annotated-types 0.7.0', 'anyio 4.4.0', 'argon2-cffi 23.1.0', 'argon2-cffi-bindings 21.2.0', 'arrow 1.3.0', 'asttokens 2.4.1', 'async-lru 2.0.4', 'async-timeout 4.0.3', 'attrs 24.2.0', 'babel 2.16.0', 'beautifulsoup4 4.12.3', 'bleach 6.1.0', 'certifi 2024.8.30', 'cffi 1.17.1', 'charset-normalizer 3.3.2', 'colorama 0.4.6', 'comm 0.2.2', 'dataclasses-json 0.6.7', 'debugpy 1.8.5', 'decorator 5.1.1', 'defusedxml 0.7.1', 'distro 1.9.0', 'exceptiongroup 1.2.2', 'executing 2.1.0', 'fastjsonschema 2.20.0', 'fqdn 1.5.1', 'frozenlist 1.4.1', 'greenlet 3.1.0', 'h11 0.14.0', 'httpcore 1.0.5', 'httpx 0.27.2', 'idna 3.8', 'ipykernel 6.29.5', 'ipython 8.27.0', 'ipywidgets 8.1.5', 'isoduration 20.11.0', 'jedi 0.19.1', 'Jinja2 3.1.4', 'jiter 0.5.0', 'json_repair 0.29.2', 'json5 0.9.25', 'jsonpatch 1.33', 'jsonpointer 3.0.0', 'jsonschema 4.23.0', 'jsonschema-specifications 2023.12.1', 'jupyter_client 8.6.2', 'jupyter_core 5.7.2', 'jupyter-events 0.10.0', 'jupyter-lsp 2.2.5', 'jupyter_server 2.14.2', 'jupyter_server_terminals 0.5.3', 'jupyterlab 4.2.5', 'jupyterlab_pygments 0.3.0', 'jupyterlab_server 2.27.3', 'jupyterlab_widgets 3.0.13', 'langchain 0.2.16', 'langchain-community 0.2.16', 'langchain-core 0.2.39', 'langchain-experimental 0.0.65', 'langchain-ollama 0.1.3', 'langchain-openai 0.1.23', 'langchain-text-splitters 0.2.4', 'langsmith 0.1.118', 'MarkupSafe 2.1.5', 'marshmallow 3.22.0', 'matplotlib-inline 0.1.7', 'mistune 3.0.2', 'multidict 6.1.0', 'mypy-extensions 1.0.0', 'nbclient 0.10.0', 'nbconvert 7.16.4', 'nbformat 5.10.4', 'neo4j 5.24.0', 'nest-asyncio 1.6.0', 'notebook 7.2.2', 'notebook_shim 0.2.4', 'numpy 1.26.4', 'ollama 0.3.3', 'openai 1.44.1', 'orjson 3.10.7', 'overrides 7.7.0', 'packaging 24.1', 'pandocfilters 1.5.1', 'parso 0.8.4', 'pip 24.2', 'platformdirs 4.3.2', 'prometheus_client 0.20.0', 'prompt_toolkit 3.0.47', 'psutil 6.0.0', 'pure_eval 0.2.3', 'pycparser 2.22', 'pydantic 2.9.1', 'pydantic_core 2.23.3', 'Pygments 2.18.0', 'python-dateutil 2.9.0.post0', 'python-dotenv 1.0.1', 'python-json-logger 2.0.7', 'pytz 2024.2', 'pywin32 306', 'pywinpty 2.0.13', 'PyYAML 6.0.2', 'pyzmq 26.2.0', 'referencing 0.35.1', 'regex 2024.9.11', 'requests 2.32.3', 'rfc3339-validator 0.1.4', 'rfc3986-validator 0.1.1', 'rpds-py 0.20.0', 'Send2Trash 1.8.3', 'setuptools 65.5.0', 'six 1.16.0', 'sniffio 1.3.1', 'soupsieve 2.6', 'SQLAlchemy 2.0.34', 'stack-data 0.6.3', 'tenacity 8.5.0', 'terminado 0.18.1', 'tiktoken 0.7.0', 'tinycss2 1.3.0', 'tomli 2.0.1', 'tornado 6.4.1', 'tqdm 4.66.5', 'traitlets 5.14.3', 'types-python-dateutil 2.9.0.20240906', 'typing_extensions 4.12.2', 'typing-inspect 0.9.0', 'uri-template 1.3.0', 'urllib3 2.2.3', 'wcwidth 0.2.13', 'webcolors 24.8.0', 'webencodings 0.5.1', 'websocket-client 1.8.0', 'widgetsnbextension 4.0.13', 'yarl 1.11.1', 'yfiles_jupyter_graphs 1.8.1']
I made this fix to llm.py in graph_transformers and it seems to work
def _format_nodes(nodes: List[Node]) -> List[Node]:
return [
Node(
id=el.id.title() if isinstance(el.id, str) else el.id,
type=el.type.capitalize() if el.type else "Unknown", # Default to "Unknown" if type is None
properties=el.properties,
)
for el in nodes
]
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)