正在加载完整 README。 以下为已保存的摘录。
This repository contains code for StatGPT backend, which implements APIs and main logic of the StatGPT application.
More information about StatGPT and its architecture can be found in
the documentation repository.
Application is written in Python 3.11 and uses the following main technologies:查看完整 README ↗This repository contains code for StatGPT backend, which implements APIs and main logic of the StatGPT application.
More information about StatGPT and its architecture can be found in the documentation repository.
Application is written in Python 3.11 and uses the following main technologies:
| Technology | Purpose |
|---|---|
| AI DIAL SDK | SDK for building applications on top of AI DIAL platform |
| FastAPI | Web framework for API development |
| SQLAlchemy | ORM for database operations |
| LangChain | LLM application framework |
| Pydantic | Data validation and settings |
| sdmx1 | SDMX data handling and provider connections |
statgpt/admin — backend of the administrator part which allows the user to add and update data.statgpt/common — common code used in the statgpt.admin and statgpt.app applications.statgpt/app — main application that generates response using LLMs and based on data prepared by statgpt.admin.statgpt/cli — command-line interface (CLI) for managing various aspects of StatGPT.tests - unit and integration tests.docker - Dockerfiles for building docker images.The applications are configured using environment variables. The environment variables are described in the following files:
make is in the PATH (run which make).Direct installation:
brew install [email protected]python3 or python3.11 is in the PATH and works properly (run python3.11 --version).Alternative: use pyenv:
pyenv allows to manage different python versions on the same machinepyenv install 3.11
pyenv local 3.11 # use Python 3.11 for the current project
Recommended way - system-wide, independent of any particular python venv:
poetry is in the PATH and works properly (run poetry --version).Since Docker Desktop requires a paid license for commercial use, you can use one of the following alternatives:
Required for localization commands (make extract_messages, make update_messages, make compile_messages):
brew install gettextsudo apt install gettextchoco install gettextVerify installation: which xgettext msgmerge msgfmt
Create python virtual environment, using poetry:
make init_venv
If you see the following error: Skipping virtualenv creation, as specified in config file., it means venv was not
created because poetry is configured not to create a new virtual environment. You can fix this:
poetry config --local virtualenvs.create true (local config)poetry config virtualenvs.create true (global config)python -m venv .venvFor Mac / Linux:
source .venv/bin/activate
For Windows:
.venv/Scripts/Activate
The following will install basic and dev dependencies:
make install_dev
.env file in the root of the projectYou can copy the template file and fill values for secrets manually:
cp .env.template .env
The Environment variables section provides links to pages with detailed information about environment variables.
dial/core/config/config.json file by running python scriptNot implemented yet, TODO: create a script that generates config based on .env variables
Run the DIAL using docker compose:
docker compose up -d
Apply alembic migrations:
make db_migrate
Run Admin backend (if you want to initialize or update data):
make statgpt_admin
Run StatGPT application:
make statgpt_app
Initialize sample content (optional):
# Run CLI and initialize sample client
make statgpt_cli
Then in the CLI:
statgpt> content init --client-id sample -y
statgpt> channel reindex -c statgpt-sample --mode all
Wait till reindexing is finished (check status using channel status command in CLI). After that run deduplication:
statgpt> channel deduplicate -c statgpt-sample
See CLI documentation for more commands.
The main application includes an MCP server that exposes the SupremeAgent's tools to external MCP clients (Claude Code, Cursor, etc.).
See MCP Server setup instructions for details.
The Admin application includes an optional MCP (Model Context Protocol) server for dataset onboarding assistance. It provides tools and prompts for coding agents such as Cursor and Claude Code.
Note: This feature is optional and disabled by default. It requires installing additional dependencies and enabling via environment variable.
See MCP setup instructions for details.
make format
make lint
To automatically apply black and isort on each commit, enable PreCommit Hooks:
make install_pre_commit_hooks
This command will set up the git hook scripts.
alembic migration:(!) It is critical to note that autogenerate is not intended to be perfect. It is always necessary to manually review and correct the candidate migrations that autogenerate produces.
(!) After creating a new migration, it is necessary to update the ALEMBIC_TARGET_VERSION in the
statgpt/common/config/version.py file to the new version.
make db_autogenerate MESSAGE="Your message"
or:
alembic -c alembic.ini revision --autogenerate -m "Your message"
alembic migrationmake db_downgrade
The project uses GNU gettext for internationalizing dataset formatters. Use these commands when working with translations:
Workflow:
Extract translatable strings - Run after adding/modifying strings marked with _() in formatter code:
make extract_messages
This creates/updates the locales/dataset.pot template file.
Review changes to locales/dataset.pot file - check git diff.
There should be no unexpected changes (removals, additions) -
they sometimes happen on Windows platforms.
Update translation files - Run to sync .po files with the new template:
make update_messages
This updates en/LC_MESSAGES/dataset.po and uk/LC_MESSAGES/dataset.po with new strings.
Fill missing translations in .po files. Either manually or using coding agent.
Compile translations - Run after translating strings in .po files to generate binary .mo files:
make compile_messages
Or use the shorthand: make locales
Note: All commands require GNU gettext to be installed (see Prerequisites).
Run all tests (unit and integration):
make test
Run only unit tests:
make test_unit
Run only integration tests:
make test_integration
⚠️ WARNING: Integration tests require a database and Elasticsearch instance.
Consider using separate test instances instead of the ones from docker-compose.yml
because tests truncate tables during execution, which may result in DATA LOSS.
Configure TEST_DATABASE_* environment variables accordingly.
See Common environment variables for details.