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

कन्वरसेशन हिस्ट्री से फैक्ट्स निकालना

अब अपनी कन्वरसेशन हिस्ट्री को अगले स्तर पर ले चलिए! आप कन्वरसेशन हिस्ट्री से फैक्ट्स को स्ट्रक्चर्ड तरीके से निकालने के लिए pydantic क्लासेस परिभाषित करेंगे.

यह कोर्स के अगले और अंतिम अभ्यास की बुनियाद रखेगा, जहाँ आप वास्तव में एक्सट्रैक्शन करेंगे.

ज़रूरी pydantic क्लासेस पहले ही इम्पोर्ट की जा चुकी हैं, और एक llm भी परिभाषित किया जा चुका है.

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

LangChain और Neo4j के साथ Graph RAG

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

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

  • कन्वरसेशन से फैक्ट्स निकालने के लिए एक pydantic ConversationFact क्लास परिभाषित करें; इसमें object, subject, relationship, और session_id फ़ील्ड शामिल हों, जो दी गई विवरणों से मेल खाते हों.
  • ConversationFact ऑब्जेक्ट्स की लिस्ट बनाने के लिए एक pydantic ConversationFacts क्लास परिभाषित करें.
  • दिए गए llm से स्ट्रक्चर्ड आउटपुट फ़ॉर्मेट को बाइंड करें.

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

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

# Define the ConversationFact with the correct fields
class ____(____):
    """
    A class that holds the facts from a conversation in a format of object, subject, predicate.

    For example, if the conversation includes the fact that the user likes ice creamthe facts would be:
    - object: "Adam"
    - subject: "ice cream"
    - relationship: "LIKES"
    The class also includes a session ID to identify the conversation.
    """
    ____: str = Field(description="The session ID of the conversation.")
    ____: str = Field(description="The object of the fact. For example, 'Adam' ")
    ____: str = Field(description="The subject of the fact. For example, 'Ice cream'")
    ____: str = Field(description="The relationship between the object and the subject.  This should be a single word verb in upper case. For example, 'LIKES' or 'OWNS'")

# Define a ConversationFacts class for creating lists of ConversationFact objects
class ____(____):
    """A class that holds a list of ConversationFact objects."""
    facts: list[____] = Field(description="A list of ConversationFact objects.")

# Bind the output to the llm provided
llm_with_output = llm.____(____) 
कोड संपादित करें और चलाएँ