feat(multimodal): FakeEmbeddingEngine + MemoryVectorStore (closes #147, #149)#186
Open
stevei101 wants to merge 3 commits into
Open
feat(multimodal): FakeEmbeddingEngine + MemoryVectorStore (closes #147, #149)#186stevei101 wants to merge 3 commits into
stevei101 wants to merge 3 commits into
Conversation
, #156) Introduces the multimodal RAG foundation under a new `multimodal` feature flag in graphrag-core. Types + async traits only; no backend impls yet — those land in follow-on PRs per meta-epic #182. Module layout (`graphrag-core/src/multimodal/`): - `types` — `ContentType`, `MultimodalContent`, `ContentSource` - `embedding` — `Embedding`, `EmbeddingMetadata`, `ModelInfo`, `EmbeddingEngine` trait, `EmbeddingError` - `store` — `SearchFilters`, `SearchResult`, `VectorStore` trait, `VectorStoreError` - `ingest` — `MultimodalIngestor` trait, `IngestError` - `search` — `CrossModalSearcher` trait, `SearchError` Closes #146, #148, #153, #156. Lays groundwork for #147, #149, #150, #151, #152, #154, #155, #157, #158, #159. Design notes: - Additive to the existing text-only `EmbeddingProvider` — text-only callers stay where they are. - `Embedding::vector` is `Vec<f32>` (not a const-generic length); backends report dimensionality via `ModelInfo`, callers validate per-store. - `VectorStore::search_by_type` and `_batch` methods ship with default impls so backends can override progressively. - `IngestError::UnsupportedMime` field renamed `source` → `origin` to avoid thiserror's implicit `#[source]` convention. - `ContentSource::DirectContent.data` → `bytes` to satisfy the workspace clippy `disallowed_names` rule (per AGENTS.md). - Each public type carries a doctest or unit test; `multimodal::*` tests: 12 lib + 2 doctests, all green. Refs meta-epic #182, TDD `docs/tdd-multimodal-and-service.md` phase 2.1. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Lands the in-memory test doubles for the multimodal seams introduced in PR #185. Both live in `graphrag-core/src/multimodal/fakes.rs` behind the existing `multimodal` feature flag. `FakeEmbeddingEngine` (#147): - Builder pattern with `new`, `with_fixed_vector`, `with_hash_seeded_vector`, `with_failure`, `with_delay` - `call_count()` and `reset_call_count()` for test assertions - Deterministic hash-seeded mode: identical inputs → identical vectors, distinct inputs → distinct vectors - Failure injection returns `EmbeddingError::LocalInference` - Latency injection via `tokio::time::sleep` for timeout/concurrency tests `MemoryVectorStore` (#149): - `new`, `with_capacity`, `stats() -> StoreStats` - Exact cosine similarity (O(n) per query) — fine at test sizes - Filter support: content type, date range, metadata tag equality, min score - Default `store_batch` + `search_by_type` inherited from the trait 10 unit tests covering both fakes + 1 doctest on the builder. All green. Refs meta-epic #182, TDD phase 3.1. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
FakeEmbeddingEngineandMemoryVectorStorein a newgraphrag-core/src/multimodal/fakes.rsmodule — closes Implement FakeEmbeddingEngine for Testing #147 + Implement In-Memory VectorStore for Testing #149.multimodalfeature flag.This PR is stacked on top of #185 (multimodal foundation). It references types that don't exist on
developyet. Either:develop; orThe branch is rebased onto
feat/multimodal-foundationlocally; once #185 lands, GitHub will auto-detect the rebase.What's inside
FakeEmbeddingEngine— #147new()with_fixed_vector(v)with_hash_seeded_vector(dim)with_failure(msg)EmbeddingError::LocalInferencewith_delay(d)tokio::time::sleepcall_count()/reset_call_count()MemoryVectorStore— #149new(),with_capacity(n)stats() -> StoreStatsVectorStoreimplFilter support: content type, date range, metadata tag equality, min score.
Test plan
cargo test -p graphrag-core --features multimodal --lib— 385/385 pass (10 new fakes tests + 12 foundation + 363 pre-existing)cargo test -p graphrag-core --features multimodal --doc multimodal::— 3/3 doctests passcargo clippy -p graphrag-core --features multimodal --all-targets -- -D warningscleanOption::map_ornotis_none_or(latter is 1.82+; project MSRV is 1.70)Refs
docs/tdd-multimodal-and-service.md🤖 Generated with Claude Code