# The solution of challege in Neo4j & LLM Fundamentals

**URL:** https://community.neo4j.com/t/the-solution-of-challege-in-neo4j-llm-fundamentals/71327
**Category:** Graph Academy
**Created:** [November 6, 2024, 7:23am UTC](https://community.neo4j.com/t/the-solution-of-challege-in-neo4j-llm-fundamentals/71327 "2024-11-06T07:23:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![chishu.amenomori](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/chishu.amenomori/32/33225_2.png) [@chishu.amenomori](https://community.neo4j.com/u/chishu.amenomori)
#### Post date: [November 6, 2024, 7:23am UTC](https://community.neo4j.com/t/the-solution-of-challege-in-neo4j-llm-fundamentals/71327/1 "2024-11-06T07:23:08Z")

</div>

Very good tutorial!  
However, the current answer does not use the dialogue history. The get\_memory function is defined, so an answer using this would be better.

In this page (Adding the Neo4j Vector Retriever - [Neo4j & LLM Fundamentals](https://graphacademy.neo4j.com/courses/llm-fundamentals/))

Like this,

```python
prompt = ChatPromptTemplate.from_messages(
    [
        (
            "system",
            "You are a movie expert. You find movies from a genre or plot.",
        ),
        MessagesPlaceholder(variable_name="chat_history"),
        ("human", "{input}"),
    ]
)

```

Sorry if the dialogue history can be kept without using MessagesPlaceholder.

---

<div class="post-metadata">

### Author: ![martin.ohanlon](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/martin.ohanlon/32/35829_2.png) [@martin.ohanlon](https://community.neo4j.com/u/martin.ohanlon)
#### Post date: [November 6, 2024, 8:49am UTC](https://community.neo4j.com/t/the-solution-of-challege-in-neo4j-llm-fundamentals/71327/2 "2024-11-06T08:49:53Z")

</div>

Hi Chishu,

Welcome to the Neo4j community 🙂

In this example the message history is managed by the agent.

```auto
chat_agent = RunnableWithMessageHistory(
    agent_executor,
    get_memory,
    input_messages_key="input",
    history_messages_key="chat_history",
)

```

The agent rephrases questions and responses for the individual tool including adding additional context.

However... you could give individual tools their own message history, which they would use in generating responses. It is worth noting though that the tools message history would contain the rephrased question from the agent, not the original conversation history with the user.

I hope this helps,

Martin
