Aan de slagGa gratis aan de slag

Chaining, Graph RAG style!

Now to bring everything together to create a Graph RAG QA chain! You've been provided with the same graph you've worked with throughout this chapter (with some potential variation in the specific nodes and relationships), and you'll connect this with another LLM to generate the Cypher query and return the natural language response.

Deze oefening maakt deel uit van de cursus

Retrieval Augmented Generation (RAG) with LangChain

Cursus bekijken

Oefeninstructies

  • Create a Graph Cypher QA chain using an OpenAI chat model and the graph you've created previously.
  • Invoke the chain with the input provided.
  • Extract and print the result text from the result.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Create the Graph Cypher QA chain
graph_qa_chain = ____.____(
    ____=ChatOpenAI(api_key="", temperature=0), ____, verbose=True
)

# Invoke the chain with the input provided
result = ____({"query": "Who discovered the element Radium?"})

# Print the result text
print(f"Final answer: {result['____']}")
Code bewerken en uitvoeren