feat: OpenAI-compatible embedding provider + graceful degradation#1
Merged
feat: OpenAI-compatible embedding provider + graceful degradation#1
Conversation
…degradation Add OpenAICompatibleProvider that works with any OpenAI-compatible /v1/embeddings endpoint (Ollama, LM Studio, vLLM). Uses httpx (now a core dependency) with configurable base_url, model, and optional api_key. Auto-detection order: SentenceTransformers → OpenAI-compatible server (EMBEDDING_BASE_URL + EMBEDDING_MODEL env vars) → OpenAI API → None. When no embedder is available, the system runs in degraded mode instead of raising 501: believe uses exact-match dedup, explain falls back to exact claim match, search uses case-insensitive substring matching via new store.find_by_text() method. A warning is logged at init.
- Add mypy to dev deps and fix type errors in store.py (kuzu QueryResult union type) by introducing _query() and _next_row() typed helpers - Fix variable redefinition in memory.py believe() method - Add dict-payload and string-belief-id tests for working_memory commit to cover the two remaining uncovered lines (197, 242)
Add mypy step to the lint job in ci.yml. Move mypy from dependency-groups to the dev optional-dependency so it's installed by uv sync --extra dev.
…R0914 - Extract _get, _build_evidence_input, _apply_new_beliefs, _apply_revisions from commit_frame to reduce local variables from 18 to under 15 - Add mocked SentenceTransformerProvider tests for 100% coverage - Pylint score: 10.00/10
- Replace test_get_embedder_raises_when_none with test_degraded_mode_when_no_embedder (method was removed in degraded-mode refactor) - Change _build_evidence_input return annotation from "EvidenceInput" forward ref to Any to satisfy ruff F821
Dependency ReviewThe following issues were found:
License Issuespyproject.toml
OpenSSF Scorecard
Scanned Files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
httpx-based) supporting any/v1/embeddingsendpoint (Ollama, LM Studio, vLLM, etc.)working_memory.pyto extract commit_frame helpers (fixes pylint R0914)Changes
providers/embeddings/openai_compatible.py— new providermemory.py— auto-detect chain + degraded mode fallbackstore.py— text-match search when embeddings unavailableworking_memory.py— extracted helper methodsTest plan
uv run pytest tests/ -vpassesuv run mypy src/mnemebrain_core/ --ignore-missing-importspasses