Files
privateGPT/Makefile
Javier Martinez cd8ca2214a feat: resumable chat worker + tool worker + async tokenizer (#2298)
* fix: avoid to block the loop

* fix: blocks in expansion

* fix: remove maximum concurrent users

...

* fix: multiplexer

* fix: readers

* fix: more fixes

...

* fix: impl

* feat: tool scheduler

* feat: add adaptative

* feat: add chat worker

* fix: max

* feat: add chat/tools workers

* fix: mypy

* feat: add generic scheduler

* fix: get result

* feat: do serializable the tool executor

* fix: tools

* fix: config

* fix: config

* fix: args

* fix: config

* fix: serializer

* Revert "fix: blocks in expansion"

This reverts commit a2110f94a8.

* fix: unify all logic

* feat: add ingestion scheduler

* fix: settings

* fix: config

* feat: add arq worker to chat

* fix: arq worker

* fix: add nest

* fix: mypy

* fix: await

* fix: script stress

* fix: tokenizer

* fix: chat scheduler

* fix: mypy

* fix: add async tokenizer

* fix: improve condense

* fix: tool scheduler

* feat: add initial real async chat worker

* fix: mypy

* fix: do resumable local executor

...

...

...

fix: revert usleess changes

fix: remove parent chat job

fix: refactor

fix: loop

ref: rename models

fix: chat engine

fix: mypy

...

...

...

fix: fix deps

* fix: tests

* fix: tests

* ...

* fix: stream

* fix: config

* fix: scheduler

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Handle PGPT_WORKER_MODE=celery in health check worker status

* fix: cancel

* fix: arch

* fix: test ingestion

* fix: deserialization of chat messages

* fix: broken results

* fix: mypy

* fix: test

* fix: config

* fix: remove arq tool worker

* fix: output cls

* fix: preserve early resumable tool callbacks

* fix: preserve async tool result order

* refactor: address worker PR review comments

* fix: mypy

* test: colocate ARQ chat enqueue coverage

* fix: remove redis from tests

* test: isolate chat mocks and cancellation timing

* fix: tests

(cherry picked from commit 218b599c66)

# Conflicts:
#	tests/server/chat/anthropic/test_anthropic_client.py
#	tests/server/chat/anthropic/test_langchain_anthropic.py
#	tests/server/chat/test_chat_knowledge_revamp.py
#	tests/server/chat/test_chat_routes.py
#	tests/server/chat/test_chat_routes_skills_integration.py

* fix: tests

(cherry picked from commit fc5ec0f72a)

* fix: ruff

* fix: test

* fix: worker config

(cherry picked from commit 1371c275a1)

* fix: principal

* test: remove flaky chat cancellation assertion

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-07-15 12:12:45 +02:00

135 lines
4.5 KiB
Makefile

# Any args passed to the make script, use with $(call args, default_value)
args = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}`
AUTO_DISCOVER_ARGS ?=
WORKER_ARGS ?=
PROD_DIST_DIR ?= .dist
PROD_PYTHON ?= .venv/bin/python
PROD_BINARY ?= .venv/bin/private-gpt
PROD_ARGS ?= serve
PROD_UV_CACHE_DIR ?= .uv-cache
TEST_PGPT_HOME ?= $(CURDIR)
TEST_LOCAL_DATA_DIR ?= $(TEST_PGPT_HOME)/local_data/tests
WIPE_PGPT_HOME := $(if $(PGPT_HOME),$(PGPT_HOME),$(HOME)/.local/share/private-gpt)
WIPE_LOCAL_DATA_DIR := $(WIPE_PGPT_HOME)/local_data
.PHONY: test test-coverage black ruff format mypy check auto-discover-models update-openapi-spec run dev-windows dev prod-run api-docs docs ingest wipe celery flower celery-worker arq-worker chat-worker tools-worker
########################################################################################################################
# Quality checks
########################################################################################################################
test:
rm -rf "$(TEST_LOCAL_DATA_DIR)"/*
PGPT_HOME=$(TEST_PGPT_HOME) PYTHONPATH=. uv run pytest tests
test-coverage:
rm -rf "$(TEST_LOCAL_DATA_DIR)"/*
PGPT_HOME=$(TEST_PGPT_HOME) PYTHONPATH=. uv run pytest tests --cov private_gpt --cov-report term --cov-report=html --cov-report xml --junit-xml=tests-results.xml
black:
uv run black . --check
ruff:
uv run ruff check private_gpt tests scripts
format:
uv run black .
uv run ruff check private_gpt tests scripts --fix
mypy:
@if ! uv run dmypy status >/dev/null 2>&1; then \
echo "Starting mypy daemon..."; \
uv run dmypy start; \
fi
uv run dmypy check private_gpt scripts
check:
make format
make mypy
auto-discover-models:
uv run python scripts/auto_discover_models.py $(AUTO_DISCOVER_ARGS)
update-openapi-spec:
uv run python scripts/update_claude_openapi.py
########################################################################################################################
# Run
########################################################################################################################
run:
uv run private-gpt serve
dev-windows:
uv run private-gpt serve --reload
dev:
PYTHONUNBUFFERED=1 uv run private-gpt serve --reload --host 0.0.0.0 --port 8080
prod-run:
rm -rf $(PROD_DIST_DIR)
mkdir -p $(PROD_DIST_DIR)
UV_CACHE_DIR=$(PROD_UV_CACHE_DIR) uv build --out-dir $(PROD_DIST_DIR)
@if [ ! -x "$(PROD_PYTHON)" ]; then \
echo "Python interpreter not found at $(PROD_PYTHON). Create the project venv first."; \
exit 1; \
fi
@wheel="$$(ls -t $(PROD_DIST_DIR)/private_gpt-*.whl 2>/dev/null | head -n 1)"; \
if [ -z "$$wheel" ]; then \
echo "No built wheel found in $(PROD_DIST_DIR)."; \
exit 1; \
fi; \
UV_CACHE_DIR=$(PROD_UV_CACHE_DIR) uv pip install --python $(PROD_PYTHON) --force-reinstall --no-deps "$$wheel"; \
$(PROD_BINARY) $(PROD_ARGS)
########################################################################################################################
# Misc
########################################################################################################################
api-docs:
PGPT_PROFILES=mock uv run python scripts/extract_openapi.py private_gpt.main:app --out fern/openapi/openapi.json
docs:
cd fern && npx fern-api@latest docs check && npx fern-api@latest docs dev
ingest:
@uv run python scripts/ingest_folder.py $(call args)
wipe:
@mkdir -p "$(WIPE_LOCAL_DATA_DIR)"
@find "$(WIPE_LOCAL_DATA_DIR)" -mindepth 1 ! -name '.gitignore' -exec rm -rf {} +
########################################################################################################################
# Celery
########################################################################################################################
celery:
PGPT_WORKER_MODE=celery ./scripts/worker_entrypoint $(WORKER_ARGS)
flower:
PGPT_WORKER_MODE=flower ./scripts/worker_entrypoint $(WORKER_ARGS)
celery-worker:
PGPT_WORKER_MODE=celery ./scripts/worker_entrypoint $(WORKER_ARGS)
arq-worker:
PGPT_WORKER_MODE=arq ./scripts/worker_entrypoint $(WORKER_ARGS)
chat-worker:
PGPT_WORKER_MODE=arq \
PGPT_WORKER_APP_MODULE=private_gpt \
PGPT_ARQ_QUEUE=chat \
PGPT_ARQ_TASK_PACKAGES=private_gpt.arq.tasks.chat \
PGPT_STATEFUL_WORKER_TYPE=chat \
PGPT_WORKER_WARM_PROFILE=chat \
./scripts/worker_entrypoint $(WORKER_ARGS)
tools-worker:
PGPT_WORKER_MODE=celery \
PGPT_WORKER_APP_MODULE=private_gpt \
PGPT_CELERY_QUEUES=tools \
PGPT_CELERY_TASK_PACKAGES=private_gpt.celery.tasks.tools \
PGPT_STATEFUL_WORKER_TYPE=tools \
PGPT_WORKER_WARM_PROFILE=tools \
./scripts/worker_entrypoint $(WORKER_ARGS)