This repository contains the complete codebase of The Agent's backend service.
The service covers for the majority of daily user-facing features, such as asking for advice, checking news, analyzing photos, generating new content, etc. Although the final product looks like a simple wrapper around the Large Language Model (LLM) technology, it's more than that – The Agent is a complex system or interconnected modules that integrate many services and APIs, and enables multiple access channels to provide a true virtual assistant experience.
See the rest of this document for a developer's overview and information on how to use it yourself.
This service currently powers several Telegram bots. For privacy reasons, we're not listing each bot here individually – but you can run the service locally on your machine and connect it to your own bot.
If you plan on contributing to this project in any way, please read and acknowledge the Contributing guide first.
Please also take note of the License.
Because the complete codebase is open-source, you can inspect and run the service yourself.
The project currently uses the following tech stack:
- Runtime: Python Interpreter
- Language: Python
- Framework: FastAPI (with Pydantic 2)
- Persistence: PostgreSQL (with SQL Alchemy)
- Build System: Custom (see
tools
and.github
directories) - Continuous Integration: GitHub Actions
- Continuous Deployment: Argo
- Distribution: Docker image (easiest managed using Kubernetes)
This project uses
pipenv
to manage dependencies and take care of the environment.
Using pipenv
, you can run pipenv install
in the root directory to set up your dependencies correctly.
To prepare the production server (less logging, more parallelism):
$ pipenv install
To prepare a development system, e.g. for testing and improvement purposes:
$ pipenv install --dev
After the dependencies have been installed, you can run pipenv shell
to get a new shell forked, in which the environment will be set up to easily run everything. Your Python version will be correct in there, and the dependencies will be available.
To exit the shell, simply run
deactivate
, followed byexit
if the shell hasn't closed automatically.
Exiting the shell will remove the environment, so you will need to run pipenv shell
again to get back to the correct environment.
Once the environment has been configured, you can run the main code.
You can use the pre-built scripts located in the tools
directory. Those are easy-to-use, single-shot Shell executables that require no developer setup.
To run the production mode:
$ ./tools/run_prod.sh
To run the development mode:
$ ./tools/run_dev.sh
And most importantly, to run all tests:
$ ./tools/run_tests.sh
Follow the command line instructions for more information during the execution of the scripts.
There are more tools in the same directory (especially useful around database migrations); feel free to explore those at your own pace when needed.
To emulate this behavior on Windows, you would need to inspect the scripts individually and mimic their behavior in the DOS environment... or open a Pull Request with a Windows-compatible version of the scripts!
This final product is also available as a Docker image.
For more information on how to run it using Docker, see the Dockerfile
and the Packages
section in the GitHub repository. There's also more information in the Docker directory.
Check out the license here.
For frontend and user interface details, see the web app repository.