Starter-kit to build constrained agents with Nextjs, FastAPI and Langchain
MIT License
AgentKit is a LangChain-based starter kit developed by BCG X to build Agent apps. Developers can use AgentKit to
Key advantages of the AgentKit toolkit include:
https://github.com/BCG-X-Official/agentkit/assets/103188952/8e86fd0e-24a5-4335-8dba-06f1cefa8dd9
The starter pack is based on the latest technologies for optimal performance, security and developer experience.
Note: this is a starter kit - for production deployments, we recommend adding enterprise-grade security functionalities. Especially when using LLMs, be aware of known risks like prompt injection (read more).
For a quick setup of AgentKit, use the steps below, where both the backend app and frontend app are run inside a Docker container. More elaborate setup instructions can be found in the documentation.
Clone the repository containing the source code for the backend and frontend apps.
Copy the frontend/.env.example
file in the frontend directory and change the name to .env
. Also, copy the .env.example
file in the root directory of the repository and change the name to .env
.
In the terminal, navigate to the root directory of the cloned repository. Build and start the Docker containers with the following command:
docker-compose -f docker-compose.yml up -d
Wait for the containers to build and start, which may take a few minutes depending on your system. Once the containers are up and running, you can access the apps in your browser at http://localhost.
docker-compose down --volumes
docker-compose.yml
with docker-compose-demo.yml
to run the appCheck out a more advanced demo build following the tutorial.
Find the hosted documentation here.
AgentKit attempts to solve the reliability issue of agents such as ReAct agents by constraining the potential routes the agent can take to a pre-configured sets of routes, or Action Plans. Since for many use cases the potential routes the agent can take are known, we can use our human domain expertise to steer the agent in the right direction, and reduce it going into unexpected directions or rabbit holes. This is achieved by combining a Meta Agent with Action Plans: A set of tools which are executed linearly and in parallel, similar to a Chain. The Meta Agent takes in the user prompt and outputs the most suited Action Plan to generate an answer. Note: implementing multiple Meta Agents is possible, generating a tree of possible routes.
To optimize user experience, the intermediary output of every step in the Action Plan can be shown to the user. For example, consider an Action Plan consisting of 2 toolsets: [[sql_tool, pdf_tool], [generate_summary_tool, visualize_tool]]
. In the first action step, information from a SQL database and a vector database with embedded PDFs are retrieved in parallel. The retrieved data and most relevant PDF are streamed to the UI as soon as the first action step finishes. In the second action step, the output from step 1 is passed to a tool that generates a text summary and a tool that creates a JSX visualization from the data, which is streamed to the UI to create the final answer.
For a high level overview of the routing flow and connection the UI, please see below diagram:
See optional feature documentation for more detailed info.
The project spun of a combination of different templates. One great inspiration is fastapi-alembic-sqlmodel-async, which provided the foundations for the FastAPI setup. Please check them out!
Great thanks to all the contributors: @kaikun213 @drivian @ielmansouri @mastersplinter @tanmaygupta9 @sofglide @harticode @edenbd @ben-howt @carelschw @gustafvh @casper321 @modvinden1 @valerie-jzr @ispoljari @martinthenext @rkdy
Please read CONTRIBUTING.md
for more details on how to contribute.
PRs are welcome ❤️