Comece agoraComece grátis

Usando fatos extraídos da conversa

Agora é hora de aplicar seu LLM com saídas estruturadas! O llm_with_output que você criou no exercício anterior ainda está disponível, e o template de prompt para esse LLM já foi fornecido.

Este exercicio faz parte do curso

Graph RAG com LangChain e Neo4j

Ver curso

Instruções do exercicio

  • Faça o pipe do template de prompt de chat fornecido para o LLM com saída estruturada (llm_with_output).
  • Invoque a cadeia com o usuário e o ID de sessão fornecidos, passando as mensagens do histórico (history).

exercicio interativo prático

Tente este exercicio completando este código de exemplo.

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": ____})
Editar e Executar Código