mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-24 04:14:55 +00:00
- docsgpt api binds 127.0.0.1 by default, like gunicorn and uvicorn do; --host 0.0.0.0 exposes it. The docs say so. - The embedded Milvus and LanceDB defaults derive from the data home, so they follow DOCSGPT_HOME like the faiss indexes and uploads do. A checkout run from its root and the Docker image resolve to the same paths as before. - The docs and the pyproject comment describe the CPU torch install as two steps (torch and torchvision from the PyTorch CPU index first, then the docling extra): pip picks the highest version across indexes, so --extra-index-url only yields the CPU build while that index keeps pace with PyPI. - AGENTS.md separates DOCSGPT_HOME (moves the data home) from DOCSGPT_ENV_FILE (selects the .env file); the docs example uses a password placeholder.
63 lines
2.4 KiB
Python
63 lines
2.4 KiB
Python
"""Data home and .env discovery (docsgpt.core.paths)."""
|
|
|
|
from pathlib import Path
|
|
|
|
from docsgpt.core import paths
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
class TestHomeDir:
|
|
def test_the_checkout_wins_over_cwd(self, monkeypatch, tmp_path):
|
|
monkeypatch.delenv(paths.HOME_ENV, raising=False)
|
|
monkeypatch.chdir(tmp_path)
|
|
assert paths.checkout_root() == REPO_ROOT
|
|
assert paths.home_dir() == REPO_ROOT
|
|
|
|
def test_the_env_var_wins(self, monkeypatch, tmp_path):
|
|
monkeypatch.setenv(paths.HOME_ENV, str(tmp_path))
|
|
assert paths.home_dir() == tmp_path.resolve()
|
|
|
|
def test_an_installed_package_falls_back_to_cwd(self, monkeypatch, tmp_path):
|
|
monkeypatch.delenv(paths.HOME_ENV, raising=False)
|
|
monkeypatch.setattr(paths, "checkout_root", lambda: None)
|
|
monkeypatch.chdir(tmp_path)
|
|
assert paths.home_dir() == Path.cwd()
|
|
|
|
|
|
class TestEnvFile:
|
|
def test_default_is_dot_env_in_the_home(self, monkeypatch, tmp_path):
|
|
monkeypatch.delenv(paths.ENV_FILE_ENV, raising=False)
|
|
monkeypatch.setenv(paths.HOME_ENV, str(tmp_path))
|
|
assert paths.env_file() == tmp_path.resolve() / ".env"
|
|
|
|
def test_the_env_var_wins(self, monkeypatch, tmp_path):
|
|
monkeypatch.setenv(paths.ENV_FILE_ENV, str(tmp_path / "custom.env"))
|
|
assert paths.env_file() == tmp_path / "custom.env"
|
|
|
|
|
|
class TestSettingsFollowTheHome:
|
|
def test_embedded_vector_stores_default_under_the_home(self, monkeypatch, tmp_path):
|
|
from docsgpt.core.settings import Settings
|
|
|
|
monkeypatch.setenv(paths.HOME_ENV, str(tmp_path))
|
|
monkeypatch.delenv("MILVUS_URI", raising=False)
|
|
monkeypatch.delenv("LANCEDB_PATH", raising=False)
|
|
fresh = Settings(_env_file=None)
|
|
assert fresh.MILVUS_URI == str(tmp_path.resolve() / "milvus_local.db")
|
|
assert fresh.LANCEDB_PATH == str(tmp_path.resolve() / "data" / "lancedb")
|
|
|
|
def test_env_overrides_still_win(self, monkeypatch, tmp_path):
|
|
from docsgpt.core.settings import Settings
|
|
|
|
monkeypatch.setenv(paths.HOME_ENV, str(tmp_path))
|
|
monkeypatch.setenv("LANCEDB_PATH", "/srv/lancedb")
|
|
assert Settings(_env_file=None).LANCEDB_PATH == "/srv/lancedb"
|
|
|
|
|
|
class TestPackageDir:
|
|
def test_holds_the_shipped_data(self):
|
|
assert paths.package_dir().name == "docsgpt"
|
|
assert (paths.package_dir() / "alembic.ini").is_file()
|
|
assert (paths.package_dir() / "prompts" / "chat_reduce_prompt.txt").is_file()
|