BaşlayınÜcretsiz başlayın

Çıkarılan konuşma olgularını kullanma

Şimdi yapılandırılmış çıktılarla LLM'ini uygulama zamanı! Bir önceki egzersizde oluşturduğun llm_with_output hâlâ kullanılabilir durumda ve bu LLM için istem şablonu zaten sağlandı.

Bu egzersiz, kursun bir parçasıdır

LangChain ve Neo4j ile Graph RAG

Kursa Göz Atın

Egzersiz talimatları

  • Verilen sohbet istem şablonunu, yapılandırılmış çıktılı LLM'e (llm_with_output) pipe et.
  • Sağlanan kullanıcı ve oturum kimliği üzerinde zinciri çağır; bunu yaparken geçmişten (history) gelen mesajları ilet.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

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": ____})
Kodu Düzenle ve Çalıştır