Agent Architecture

Alright! Congratulations on making it this far!

Here is where we bring everything together into a single agent. Before jumping in let’s recap how the agent will work.

Tools

As you learned in Neo4j & LLM Fundamentals, the term Agent describes a callable interface that provides an LLM with access to a set of tools. These tools may access additional data sources, APIs, or functionality. The model is used to determine which of the tools to use to complete a task.

In this case, we have two tools suitable for distinct tasks.

  1. The Vector Retrieval Chain from Module 4 searches embeddings of movie plots to find movies based on a text input. For example, "recommend me a movie about a love story that ends in tragedy".

  2. For more complex queries, the Cypher Retrieval Chain from Module 5 will use the schema to generate a Cypher statement that answers a question. For example, "Who directed Toy Story?" or "What was the average user rating of La La Land?"

The LLM will use descriptions of these tools to decide which tool is most appropriate for performing the task.

These chains expect an object containing an input and rephrasedQuestion and return a string.

Memory

Our Agent will also be capable of simulating a real conversation by recalling the conversation history and rephrasing the current user input.

The agent must perform this step before the agent selecting which tool to use.

Process

Therefore, the agent chain should adhere to the following steps:

  1. A Runnable sequence receives the user’s input

  2. The sequence gets any recent conversation history from the database

  3. The history is used to re-phrase the input into a standalone question

  4. The standalone question is passed to the agent executor, which will select a tool, invoke it, and return a string response.

Ready?

Now we have covered the architecture, it’s time to build.

Click the button below to mark the lesson as read and to continue to the challenge.

Summary

In this lesson, we discussed the agent’s architecture and outlined how the agent will work.

In the next lesson, you will define the tools available to the agent.

Chatbot

Hi, I am an Educational Learning Assistant for Intelligent Network Exploration. You can call me E.L.A.I.N.E.

How can I help you today?