refactor(models): move model structs and errors into dedicated module#67
Merged
vidurkhanal merged 1 commit intomainfrom Jan 26, 2026
Merged
Conversation
- Extracted `LanguageModel`, `RerankingModel`, and `EmbeddingModel` structs and their error types from `lib.rs` into new files under `models/`. - Updated imports and usage throughout the codebase to reference the new `models` module. - Moved related trait definitions (`GeneratesText`, `GeneratesObject`, `Reranks`, `ReranksStructuredData`, `Embeds`) to their respective response generator modules. - Centralized `AIProvider` enum and its implementations in `providers/mod.rs` for better separation of concerns. - No functional changes; this is an internal code organization and modularization improvement.
Contributor
Greptile SummarySuccessfully refactored Key improvements:
The refactoring follows Rust module best practices and significantly improves code maintainability. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as Client Code
participant ModelImpl as model_impl/
participant Models as models/
participant Providers as providers/
participant ResponseGen as response_generators/
Note over Models: New Module Structure
Note over Models: language.rs, embedding.rs, reranking.rs
Client->>ModelImpl: get_model()
ModelImpl->>Models: LanguageModel::new()
Models->>Providers: AIProvider enum
Note over Providers: Centralized in providers/mod.rs
Client->>ResponseGen: generate_text(request)
ResponseGen->>Models: request.model (LanguageModel)
Models->>Providers: model.provider (AIProvider)
Providers->>Providers: do_generate_text()
Note over Providers: Matches on provider type
Providers-->>ResponseGen: GenerateTextResponse
ResponseGen-->>Client: Result
Note over ResponseGen: Traits moved to response_generators/
Note over ResponseGen: GeneratesText, GeneratesObject, Embeds, Reranks, ReranksStructuredData
|
Sang-it
approved these changes
Jan 26, 2026
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.
LanguageModel,RerankingModel, andEmbeddingModelstructs and their error types fromlib.rsinto new files undermodels/.modelsmodule.GeneratesText,GeneratesObject,Reranks,ReranksStructuredData,Embeds) to their respective response generator modules.AIProviderenum and its implementations inproviders/mod.rsfor better separation of concerns.