Skip to content

Conversation

@Sang-it
Copy link
Member

@Sang-it Sang-it commented Jan 22, 2026

No description provided.

@Sang-it Sang-it marked this pull request as ready for review January 22, 2026 05:19
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 22, 2026

Greptile Summary

Refactored the umem_ai library by extracting model initialization logic from lib.rs into a dedicated model_impl module with separate files for each model type.

  • Moved LanguageModel::get_model(), EmbeddingModel::get_model(), and RerankingModel::get_model() implementations along with their static OnceCell instances into model_impl/language_model.rs, model_impl/embedding_model.rs, and model_impl/reranking_model.rs respectively
  • Created model_impl/mod.rs to organize and re-export all model implementations
  • Updated lib.rs to import and re-export the model_impl module via pub use model_impl::*
  • The public API remains unchanged - all models are still accessible through the same paths

This is a clean code organization refactoring that improves maintainability by separating concerns without altering functionality or breaking existing consumers.

Confidence Score: 5/5

  • This PR is safe to merge with no risk - it's a straightforward refactoring that moves code without changing behavior.
  • This is a pure code organization refactoring with no logic changes. The exact same implementation code was moved from lib.rs into dedicated module files, and the public API is preserved through re-exports. All existing consumers will continue to work identically.
  • No files require special attention

Important Files Changed

Filename Overview
crates/umem_ai/src/lib.rs Removed get_model() implementations and static OnceCell declarations, moving them to separate module files. Added model_impl module and re-export.
crates/umem_ai/src/model_impl/mod.rs New module file that organizes and re-exports the three model implementation modules.
crates/umem_ai/src/model_impl/language_model.rs Extracted LanguageModel::get_model() implementation and static LANGUAGE_MODEL into dedicated file.
crates/umem_ai/src/model_impl/embedding_model.rs Extracted EmbeddingModel::get_model() implementation and static EMBEDDING_MODEL into dedicated file.
crates/umem_ai/src/model_impl/reranking_model.rs Extracted RerankingModel::get_model() implementation and static RERANKING_MODEL into dedicated file.

Sequence Diagram

sequenceDiagram
    participant Client
    participant ModelImpl as model_impl module
    participant LM as LanguageModel
    participant EM as EmbeddingModel
    participant RM as RerankingModel
    participant Config as CONFIG
    participant Provider as AIProvider
    
    Note over Client,Provider: Before: All logic in lib.rs
    Note over Client,Provider: After: Split into model_impl/* files
    
    Client->>LM: LanguageModel::get_model()
    activate LM
    LM->>LM: Check LANGUAGE_MODEL OnceCell
    alt Not initialized
        LM->>Config: Read language_model config
        Config-->>LM: Provider config (OpenAI or AmazonBedrock)
        LM->>Provider: Build provider (OpenAI/Bedrock)
        Provider-->>LM: Arc<AIProvider>
        LM->>LM: Create Arc<LanguageModel>
        LM->>LM: Store in LANGUAGE_MODEL OnceCell
    end
    LM-->>Client: Arc<LanguageModel>
    deactivate LM
    
    Client->>EM: EmbeddingModel::get_model()
    activate EM
    EM->>EM: Check EMBEDDING_MODEL OnceCell
    alt Not initialized
        EM->>Config: Read embedding_model config
        Config-->>EM: Provider config
        EM->>Provider: Build provider
        Provider-->>EM: Arc<AIProvider>
        EM->>EM: Create Arc<EmbeddingModel>
        EM->>EM: Store in EMBEDDING_MODEL OnceCell
    end
    EM-->>Client: Arc<EmbeddingModel>
    deactivate EM
    
    Client->>RM: RerankingModel::get_model()
    activate RM
    RM->>RM: Check RERANKING_MODEL OnceCell
    alt Not initialized
        RM->>Config: Read reranking_model config
        Config-->>RM: Provider config
        RM->>Provider: Build provider
        Provider-->>RM: Arc<AIProvider>
        RM->>RM: Create Arc<RerankingModel>
        RM->>RM: Store in RERANKING_MODEL OnceCell
    end
    RM-->>Client: Arc<RerankingModel>
    deactivate RM
Loading

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 22, 2026

Greptile's behavior is changing!

From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

@vidurkhanal vidurkhanal merged commit 79edbd9 into main Jan 22, 2026
2 checks passed
@vidurkhanal vidurkhanal deleted the feat/switch-embed branch January 22, 2026 05:22
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.

3 participants