-
Notifications
You must be signed in to change notification settings - Fork 0
Switch AI integration from OpenAI to Gemini. #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8171c91 to
f9c1a97
Compare
f9c1a97 to
0236d19
Compare
- Introduce `GeminiApiService` for handling Gemini API requests.
- Create `KtorClientProvider` to manage the Ktor `HttpClient` and `Json` instances.
- Implement `GeminiPromptBuilder` to construct API request prompts and bodies.
- Add `GeminiJsonParser` for extracting and cleaning JSON from API responses.
- Move data models `CodeExample`, `Section`, and `Syntax` to separate files.
- Remove unused OpenAI-related data classes from `KotlinTopicDetails.kt`.
- Update `DetailRepository` to use the new `GeminiApiService`.
c690580 to
dad3e5a
Compare
RajashekarRaju
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have applied below changes :
Previously, GeminiApiService was an object, which will it hard to mock or replace for testing.
Now it’s provided as a DI singleton and injected into DetailRepository, improving testability.
Replaced the KtorClientProvider singleton with proper DI managed instances of HttpClient and Json. This ensures a consistent configuration and allows us to reuse or override these components in other environments.
DetailRepository now takes GeminiApiService as a constructor parameter. This decouples the repository from hardcoded services and aligns it with clean architecture best practices.
DI definitions have been cleanly separated into type-based modules:
httpClientModulefor Ktor HttpClient and JSONapiModulefor API servicesrepositoryModulefor data repositoriesviewModelModulefor ViewModels
This makes the setup modular, easier to reason about, avoids clutter in a single DI file.
...tlin/com/developersbreach/kotlindictionarymultiplatform/core/network/api/GeminiApiService.kt
Show resolved
Hide resolved
...om/developersbreach/kotlindictionarymultiplatform/data/detail/repository/DetailRepository.kt
Show resolved
Hide resolved
RajashekarRaju
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move data classes CodeExample, Section, Syntax into KotlinTopicDetails itself, this sort of granularity for separation of each data class into own file is is unnecessary here and adds extra overhead in navigating the codebase.
Since these classes are tightly coupled to KotlinTopicDetails and not reused elsewhere, keeping them grouped within the same file improves readability and makes the model easier to maintain as a single unit of domain logic.
…nTopicDetails.kt`.
…s as complete in README.
No description provided.