LoslegenKostenlos starten

Using extracted conversation facts

Now to apply your LLM with structured outputs! The llm_with_output you created in the previous exercise is still available, and the prompt template for this LLM has already been provided.

Diese Übung ist Teil des Kurses

<Kurs>Graph RAG with LangChain and Neo4j</Kurs>
Kurs ansehen

Übungsanweisungen

  • Pipe the chat prompt template provided into the LLM with structured output (llm_with_output).
  • Invoke the chain on the user and session ID provided, passing it the messages from the history (history).

Interaktive praktische Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

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": ____})
Code bearbeiten und ausführen