Код: Выделить всё
from langchain_core.documents import Document
text = """
Marie Curie, born in 1867, was a Polish and naturalised-French physicist and chemist who conducted pioneering research on radioactivity.
She was the first woman to win a Nobel Prize, the first person to win a Nobel Prize twice, and the only person to win a Nobel Prize in two scientific fields.
Her husband, Pierre Curie, was a co-winner of her first Nobel Prize, making them the first-ever married couple to win the Nobel Prize and launching the Curie family legacy of five Nobel Prizes.
She was, in 1906, the first woman to become a professor at the University of Paris.
"""
documents = [Document(page_content=text)]
graph_documents = llm_transformer.convert_to_graph_documents(documents)
print(f"Nodes:{graph_documents[0].nodes}")
print(f"Relationships:{graph_documents[0].relationships}")---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in ()
8 """
9 documents = [Document(page_content=text)]
---> 10 graph_documents = llm_transformer.convert_to_graph_documents(documents)
11 print(f"Nodes:{graph_documents[0].nodes}")
12 print(f"Relationships:{graph_documents[0].relationships}")
2 frames
/usr/local/lib/python3.10/dist-packages/langchain_experimental/graph_transformers/llm.py in process_response(self, document)
593 nodes_set = set()
594 relationships = []
--> 595 parsed_json = self.json_repair.loads(raw_schema.content)
596 for rel in parsed_json:
597 # Nodes need to be deduplicated using a set
AttributeError: 'str' object has no attribute 'content'
Я нашел аналогичную проблему на GitHub --https://github.com/langchain-ai/langchain/issues/21482
Подробнее здесь: https://stackoverflow.com/questions/785 ... eerror-str