Note that text chunking is avoided due to Diffbot's character limit per API request.from langchain.document_loaders import WikipediaLoaderquery = "Warren Buffett"raw_documents = WikipediaLoader(query=query).load()graph_documents = diffbot_nlp.convert_to_graph_documents(raw_documents)Loading the data into a knowledge graph‚ÄãYou will need to have a running Neo4j instance. One option is to create a free Neo4j database instance in their Aura cloud service. You can also run the database locally using the Neo4j Desktop application, or running a docker container. You can run a local docker container by running the executing the following script:docker run \    --name neo4j \    -p 7474:7474 -p 7687:7687 \    -d \    -e NEO4J_AUTH=neo4j/pleaseletmein \    -e NEO4J_PLUGINS=\[\"apoc\"\]  \    neo4j:latestIf you are using the docker container, you need to wait a couple of second for the database to start.from langchain.graphs import Neo4jGraphurl="bolt://localhost:7687"username="neo4j"password="pleaseletmein"graph = Neo4jGraph(    url=url,    username=username,     password=password)The GraphDocuments can be loaded into a knowledge graph using the add_graph_documents method.graph.add_graph_documents(graph_documents)Refresh graph schema information‚ÄãIf the schema of database changes, you can refresh the schema information needed to generate Cypher statementsgraph.refresh_schema()Querying the graph‚ÄãWe can now use the graph cypher QA chain to ask question of the graph. It is advisable to use gpt-4 to construct Cypher queries to get the best experience.from langchain.chains import GraphCypherQAChainfrom langchain.chat_models import ChatOpenAIchain = GraphCypherQAChain.from_llm(    cypher_llm=ChatOpenAI(temperature=0, model_name="gpt-4"),    qa_llm=ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo"),    graph=graph, verbose=True,    )chain.run("Which university did Warren Buffett attend?")            > Entering new GraphCypherQAChain chain...    Generated Cypher:    MATCH
Open In Colab
Open In Colab ->: Note that text chunking is avoided due to Diffbot's character limit per API request.from langchain.document_loaders import WikipediaLoaderquery = "Warren Buffett"raw_documents = WikipediaLoader(query=query).load()graph_documents = diffbot_nlp.convert_to_graph_documents(raw_documents)Loading the data into a knowledge graph‚ÄãYou will need to have a running Neo4j instance. One option is to create a free Neo4j database instance in their Aura cloud service. You can also run the database locally using the Neo4j Desktop application, or running a docker container. You can run a local docker container by running the executing the following script:docker run \    --name neo4j \    -p 7474:7474 -p 7687:7687 \    -d \    -e NEO4J_AUTH=neo4j/pleaseletmein \    -e NEO4J_PLUGINS=\[\"apoc\"\]  \    neo4j:latestIf you are using the docker container, you need to wait a couple of second for the database to start.from langchain.graphs import Neo4jGraphurl="bolt://localhost:7687"username="neo4j"password="pleaseletmein"graph = Neo4jGraph(    url=url,    username=username,     password=password)The GraphDocuments can be loaded into a knowledge graph using the add_graph_documents method.graph.add_graph_documents(graph_documents)Refresh graph schema information‚ÄãIf the schema of database changes, you can refresh the schema information needed to generate Cypher statementsgraph.refresh_schema()Querying the graph‚ÄãWe can now use the graph cypher QA chain to ask question of the graph. It is advisable to use gpt-4 to construct Cypher queries to get the best experience.from langchain.chains import GraphCypherQAChainfrom langchain.chat_models import ChatOpenAIchain = GraphCypherQAChain.from_llm(    cypher_llm=ChatOpenAI(temperature=0, model_name="gpt-4"),    qa_llm=ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo"),    graph=graph, verbose=True,    )chain.run("Which university did Warren Buffett attend?")            > Entering new GraphCypherQAChain chain...    Generated Cypher:    MATCH