Docs: Change to async llm graph transformer (#31126)

This commit is contained in:
Tomaz Bratanic 2025-05-06 18:53:57 +02:00 committed by GitHub
parent 703fce7972
commit 6b6750967a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -167,7 +167,7 @@
"She was, in 1906, the first woman to become a professor at the University of Paris.\n",
"\"\"\"\n",
"documents = [Document(page_content=text)]\n",
"graph_documents = llm_transformer.convert_to_graph_documents(documents)\n",
"graph_documents = await llm_transformer.aconvert_to_graph_documents(documents)\n",
"print(f\"Nodes:{graph_documents[0].nodes}\")\n",
"print(f\"Relationships:{graph_documents[0].relationships}\")"
]
@ -205,7 +205,7 @@
" allowed_nodes=[\"Person\", \"Country\", \"Organization\"],\n",
" allowed_relationships=[\"NATIONALITY\", \"LOCATED_IN\", \"WORKED_AT\", \"SPOUSE\"],\n",
")\n",
"graph_documents_filtered = llm_transformer_filtered.convert_to_graph_documents(\n",
"graph_documents_filtered = await llm_transformer_filtered.aconvert_to_graph_documents(\n",
" documents\n",
")\n",
"print(f\"Nodes:{graph_documents_filtered[0].nodes}\")\n",
@ -245,7 +245,9 @@
" allowed_nodes=[\"Person\", \"Country\", \"Organization\"],\n",
" allowed_relationships=allowed_relationships,\n",
")\n",
"graph_documents_filtered = llm_transformer_tuple.convert_to_graph_documents(documents)\n",
"graph_documents_filtered = await llm_transformer_tuple.aconvert_to_graph_documents(\n",
" documents\n",
")\n",
"print(f\"Nodes:{graph_documents_filtered[0].nodes}\")\n",
"print(f\"Relationships:{graph_documents_filtered[0].relationships}\")"
]
@ -289,7 +291,9 @@
" allowed_relationships=[\"NATIONALITY\", \"LOCATED_IN\", \"WORKED_AT\", \"SPOUSE\"],\n",
" node_properties=[\"born_year\"],\n",
")\n",
"graph_documents_props = llm_transformer_props.convert_to_graph_documents(documents)\n",
"graph_documents_props = await llm_transformer_props.aconvert_to_graph_documents(\n",
" documents\n",
")\n",
"print(f\"Nodes:{graph_documents_props[0].nodes}\")\n",
"print(f\"Relationships:{graph_documents_props[0].relationships}\")"
]