शुरू करेंमुफ़्त में शुरू करें

Text-to-Cypher चेन बनाना

आपने अपने खुद के Cypher क्वेरी लिखी हैं, तो अब LLMs से उन्हें जेनरेट कराने की कोशिश करें! नैचुरल लैंग्वेज में दी गई यूज़र क्वेरी से Cypher क्वेरी बनाना, text-to-Cypher Graph RAG वर्कफ़्लो का एक अहम हिस्सा है.

आप पिछले अभ्यास वाले उसी डेटाबेस पर काम कर रहे हैं, जिसमें लोगों, कंपनियों के नोड्स और WORKS_FOR रिलेशनशिप हैं, जो graph के रूप में उपलब्ध है.

यह अभ्यास पाठ्यक्रम का हिस्सा है

LangChain और Neo4j के साथ Graph RAG

पाठ्यक्रम देखें

अभ्यास निर्देश

  • partial_variables डिक्शनरी को अपडेट कर के ग्राफ़ स्कीमा को प्रॉम्प्ट में इंसर्ट करें.
  • prompt, llm का उपयोग करते हुए और स्ट्रिंग में पार्स करते हुए text-to-Cypher चेन बनाइए.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

prompt = ChatPromptTemplate.from_messages([
    SystemMessagePromptTemplate.from_template(""" 
		You are an expert Neo4j developer. Use the following database schema to write a Cypher statement to answer the user's question. Only generate the Cypher statement, no pre-amble. Do not return any Markdown.
	Schema: 
    {schema}
    
	Question: {question}""", 
	# Update the partial_variables dictionary
    partial_variables={"schema": graph.____})
])

# Create the text-to-Cypher chain
text_to_cypher_chain = ____ | ____ | StrOutputParser()
cypher = text_to_cypher_chain.invoke({"question": "Where does Jo Cornelissen work?"})
print(cypher)
कोड संपादित करें और चलाएँ