निकाले गए बातचीत तथ्यों का उपयोग
अब अपने structured outputs वाले LLM को लागू करने का समय! पिछले अभ्यास में आपने जो llm_with_output बनाया था, वह अभी भी उपलब्ध है, और इस LLM के लिए प्रॉम्प्ट टेम्पलेट पहले से दिया गया है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
LangChain और Neo4j के साथ Graph RAG
अभ्यास निर्देश
- दिए गए चैट प्रॉम्प्ट टेम्पलेट को structured output वाले LLM (
llm_with_output) में पाइप करें. - दिए गए user और session ID पर चेन को invoke करें, और
historyसे messages पास करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
chain = ChatPromptTemplate.from_messages([
SystemMessagePromptTemplate.from_template("""
You are talking to {user}, the user of the application.
Any facts in the first person relate to {user}.
The Session ID is {session_id}.
Extract the facts from the conversation and return them in the format of object, subject, predicate.
"""),
# Pipe the chat prompt template into the LLM with structured output
MessagesPlaceholder(variable_name="history")
]) | ____
# Invoke the chain, passing it the messages from the history
chain.invoke({"user": USER, "session_id": SESSION_ID, "history": ____})