Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when converting docs to graph #8

Open
cakshat opened this issue Sep 27, 2024 · 1 comment
Open

Error when converting docs to graph #8

cakshat opened this issue Sep 27, 2024 · 1 comment

Comments

@cakshat
Copy link

cakshat commented Sep 27, 2024

I am getting the following error when I am running the graph_documents = llm_transformer.convert_to_graph_documents(documents) line.

[/home/archaudh/anaconda3/envs/graphrag-tutorial/lib/python3.10/site-packages/IPython/core/interactiveshell.py:3577](https://file+.vscode-resource.vscode-cdn.net/home/archaudh/anaconda3/envs/graphrag-tutorial/lib/python3.10/site-packages/IPython/core/interactiveshell.py:3577): LangChainDeprecationWarning: As of langchain-core 0.3.0, LangChain uses pydantic v2 internally. The langchain_core.pydantic_v1 module was a compatibility shim for pydantic v1, and should no longer be used. Please update the code to import from Pydantic directly.

For example, replace imports like: `from langchain_core.pydantic_v1 import BaseModel`
with: `from pydantic import BaseModel`
or the v1 compatibility namespace if you are working in a code base that has not been fully upgraded to pydantic 2 yet. 	from pydantic.v1 import BaseModel

  exec(code_obj, self.user_global_ns, self.user_ns)
True
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[5], 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 [~/anaconda3/envs/graphrag-tutorial/lib/python3.10/site-packages/langchain_experimental/graph_transformers/llm.py:809](https://file+.vscode-resource.vscode-cdn.net/home/archaudh/research/GraphRAG-with-Llama-3.1/~/anaconda3/envs/graphrag-tutorial/lib/python3.10/site-packages/langchain_experimental/graph_transformers/llm.py:809), in LLMGraphTransformer.convert_to_graph_documents(self, documents, config)
    797 def convert_to_graph_documents(
    798     self, documents: Sequence[Document], config: Optional[RunnableConfig] = None
    799 ) -> List[GraphDocument]:
    800     """Convert a sequence of documents into graph documents.
    801 
    802     Args:
   (...)
    807         Sequence[GraphDocument]: The transformed documents as graphs.
    808     """
--> 809     return [self.process_response(document, config) for document in documents]

File [~/anaconda3/envs/graphrag-tutorial/lib/python3.10/site-packages/langchain_experimental/graph_transformers/llm.py:809](https://file+.vscode-resource.vscode-cdn.net/home/archaudh/research/GraphRAG-with-Llama-3.1/~/anaconda3/envs/graphrag-tutorial/lib/python3.10/site-packages/langchain_experimental/graph_transformers/llm.py:809), in (.0)
    797 def convert_to_graph_documents(
    798     self, documents: Sequence[Document], config: Optional[RunnableConfig] = None
    799 ) -> List[GraphDocument]:
    800     """Convert a sequence of documents into graph documents.
    801 
    802     Args:
   (...)
    807         Sequence[GraphDocument]: The transformed documents as graphs.
    808     """
--> 809     return [self.process_response(document, config) for document in documents]

File [~/anaconda3/envs/graphrag-tutorial/lib/python3.10/site-packages/langchain_experimental/graph_transformers/llm.py:754](https://file+.vscode-resource.vscode-cdn.net/home/archaudh/research/GraphRAG-with-Llama-3.1/~/anaconda3/envs/graphrag-tutorial/lib/python3.10/site-packages/langchain_experimental/graph_transformers/llm.py:754), in LLMGraphTransformer.process_response(self, document, config)
    750     parsed_json = [parsed_json]
    751 for rel in parsed_json:
    752     # Check if mandatory properties are there
    753     if (
--> 754         not rel.get("head")
    755         or not rel.get("tail")
    756         or not rel.get("relation")
    757     ):
    758         continue
    759     # Nodes need to be deduplicated using a set
    760     # Use default Node label for nodes if `missing`
AttributeError: 'list' object has no attribute 'get'
@kellerfabian
Copy link

same here. @cakshat did you find a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants