Looking for an agent to handle this for you? Check out DocAgent, which simplifies the RAG process by streamlining data retrieval and generation-making it faster and easier for you.
- Use an AG2 reference agent, DocAgent
- Add RAG capabilities to an agent
- Incorporate context into an agent’s system message (manually and automatically)
1. DocAgent
Use AG2’s reference agent, DocAgent, built specifically for RAG. It will take the hassle out of loading, parsing, storing, and querying documents/web pages.2. Add RAG capabilities to an agent
AG2 allows you to add capabilities to agents and an example of a capability is RAG using a graph database. It only takes two steps to do this:- Create the capability
- Add it to the agent
RAG Capability: Neo4j GraphRAG
Based on AG2’s base GraphRAG capability, this Neo4j GraphRAG capability allows the embedding and querying of information with a Neo4j graph database. See the Using Neo4j’s graph database with AG2 agents for Q&A notebook.RAG Capability: FalkorDB GraphRAG
Also based on AG2’s base GraphRAG capability, this capability uses a FalkorDB GraphRAG database. See the Trip planning with a FalkorDB GraphRAG agent using a Swarm notebook.If you need a capability for a different GraphRAG database, consider building a capability similar to these using our GraphRagCapability base class.
3. Incorporating context into an Agent’s system message
ConversableAgent has a number of hooks that get run before an agent replies. You can utilise theupdate_agent_state
hook to run a function that updates your agent’s system message with some context before it goes to the LLM.
Within the function use the ConversableAgent.update_system_message method to update the system message.
Let’s walk through a simple example where we take a list of files from the current directory, include it in an agent’s system message, and ask an LLM to analyze or explain the files.
We start with our imports, LLM configuration, and the system message template, which we’ll inject the file listing in to.
files_agent
about the files.