Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(gpt4all): discover existing model directory (#30) - #222

Merged
himanshu231204 merged 2 commits into
OpenAgentHQ:mainfrom
Deepnar:fix/gpt4all-model-directory
Sep 1, 2026
Merged

fix(gpt4all): discover existing model directory (#30)#222
himanshu231204 merged 2 commits into
OpenAgentHQ:mainfrom
Deepnar:fix/gpt4all-model-directory

Conversation

@Deepnar

@Deepnar Deepnar commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds configurable discovery of models already present in a GPT4All models directory for issue #30.

Changes

  • Add gpt4all_models_dir configuration with MODELDOCK_GPT4ALL_MODELS_DIR environment support.
  • Forward the configured directory through ModelManager and RuntimeRegistry to Gpt4AllRuntime.
  • Register top-level .gguf and .bin files as installed ModelRef values without downloading or loading models.
  • Keep missing directories safe and leave GPT4All download/inference behavior for later runtime work.

Testing

  • .venv/bin/pytest -q tests/unit/test_gpt4all_runtime.py tests/unit/test_config.py — 27 passed
  • .venv/bin/pytest -q tests/unit — 499 passed
  • .venv/bin/ruff check src tests — passed
  • .venv/bin/ruff format --check src tests — passed
  • .venv/bin/mypy src — passed for 79 source files
  • .venv/bin/bandit -r src — no issues identified
  • Repository pre-commit wrapper was also run; its existing notebook Ruff failure and isolated mypy dependency errors are unrelated to this patch. Direct venv gates above pass.

Checklist

  • Branch named per Git Workflow (fix/gpt4all-model-directory)
  • Not developed on main
  • Code follows AGENT.md coding standards
  • domain/ and ports/ stay pure
  • Tests cover supported files and missing directories
  • No download or inference behavior added
  • No secrets or generated artifacts included

Closes #30.

Copy link
Copy Markdown
Member

CI is red on all Windows jobs (py3.9–py3.12) in tests/unit/test_gpt4all_runtime.py::test_list_installed_registers_supported_model_files:

AssertionError: assert ['legacy-mode...-3-mini.Q4_0'] == ['Phi-3-mini....legacy-model']
At index 0 diff: 'legacy-model' != 'Phi-3-mini.Q4_0'

Root cause: list_installed() in src/modeldock/adapters/runtimes/gpt4all.py does for path in sorted(self._models_dir.iterdir()), which sorts Path objects directly. pathlib.PureWindowsPath comparison is case-insensitive (it case-folds before comparing), so on Windows "legacy-model.bin" sorts before "Phi-3-mini.Q4_0.gguf" (l < p case-folded), while on POSIX the comparison is case-sensitive ('P' < 'l' in ASCII), giving the opposite order. That's why Linux/macOS jobs pass and Windows fails.

Fix: sort by the plain string name instead of the Path object, e.g.:

for path in sorted(self._models_dir.iterdir(), key=lambda p: p.name):

That keeps ordering consistent (case-sensitive, platform-independent) across OSes. Once that's in, CI should go green on Windows too.


Generated by Claude Code

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).


Graphify review — findings

Implements GPT4All local model discovery: Gpt4AllRuntime now scans its _models_dir (defaulting to ~/.cache/gpt4all), reports availability based on the directory's existence, and returns a ModelRef for each top-level .gguf/.bin file, while downloads and loads still raise RuntimeUnavailableError. Adds a gpt4all_models_dir setting wired through env/TOML config and threaded from ModelManager into RuntimeRegistry.get via a new models_dir argument that sets _models_dir on runtimes that expose it.

No blocking issues surfaced. 4 lower-confidence candidates did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 224 functions depend on the 137 functions this change touches.

Health — this change adds coupling hotspots:

  • new: ModelManager — 32 callers, 23 callees
  • new: Settings — 29 callers, 3 callees
  • new: load_settings() — 14 callers, 6 callees
  • new: _manager() — 21 callers, 3 callees
  • new: _manager() — 10 callers, 3 callees
  • new: Gpt4AllRuntime — 3 callers, 5 callees
  • new: _register_builtins() — 1 callers, 6 callees

Verification — 224 functions in the blast radius were not formally verified this run (proofs are advisory here).

Health delta baseline: last indexed commit 5a9ff06 (diverged from this PR's base — delta is approximate).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 224 function(s) in the blast radius were not formally verified this run

· 2 grounded finding(s) anchored inline below; 5 more finding(s) on lines outside this diff (see the check run).

Comment thread src/modeldock/adapters/runtimes/gpt4all.py
Comment thread src/modeldock/common/config.py
@himanshu231204
himanshu231204 merged commit 50084a7 into OpenAgentHQ:main Sep 1, 2026
16 checks passed
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🎉 Congratulations @Deepnar!

Your pull request has been successfully merged into main. 🚀

Thank you for contributing to OpenAgentHQ and helping improve the project.

We truly appreciate your contribution and hope to see you back with more amazing PRs!

Happy Open Sourcing! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPT4All: embed local model path config

2 participants