feat: dynamic model selection for Gemini Flash, Pro, and Gemma#16
feat: dynamic model selection for Gemini Flash, Pro, and Gemma#16SISIR-REDDY wants to merge 1 commit intoAOSSIE-Org:mainfrom
Conversation
Closes AOSSIE-Org#8 - Add GeminiModel enum with three options: Gemini 2.0 Flash (default), Gemini 1.5 Pro, and Gemma 3 27B; each carries a modelId, displayName, and a short description shown in the picker - Update ChatbotService to hold a selectedModel field and build the API URL from it at call time; model can be changed at any point between recordings - Add hasValidApiKey guard and structured error extraction (mirrors the approach in AOSSIE-Org#13) while keeping this PR independently reviewable - Add a tune icon button in the header row of TranscriptionScreen that opens a PopupMenuButton listing all three models with their descriptions - Status text updates to show the active model name during processing
📝 WalkthroughWalkthroughThe changes introduce dynamic model selection to the DocPilot application, enabling users to choose between three AI models (Gemini 2.0 Flash, Gemini 1.5 Pro, and Gemma 3 27B) through a UI dropdown. The backend API integration is updated to use the selected model and includes improved request/response handling with validation and error logging. Changes
Sequence DiagramsequenceDiagram
participant User as User/UI
participant App as main.dart
participant Service as ChatbotService
participant API as Gemini API
User->>App: Selects model from dropdown
App->>Service: Update selectedModel
Service-->>App: selectedModel changed
App-->>User: UI reflects new model selection
User->>App: Sends chat message
App->>Service: Call getGeminiResponse()
Service->>Service: Validate hasValidApiKey
Service->>API: POST with selectedModel.modelId<br/>generationConfig, contents
API-->>Service: Response with candidates
Service->>Service: Parse candidates[0].content.parts[0].text<br/>with defensive checks
Service-->>App: Return formatted response text
App-->>User: Display response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/main.dart (1)
437-446: Inconsistent status messaging—consider including the model name here as well.Line 340 displays the selected model name ("Processing with Gemini 2.0 Flash..."), but this status indicator at line 443 still uses the generic "Generating content with Gemini..." text. For consistency, consider using the model's
displayNamehere too.♻️ Suggested fix
Text( _isRecording ? 'Recording in progress' : _isTranscribing ? 'Processing audio...' : _isProcessing - ? 'Generating content with Gemini...' + ? 'Generating content with ${_chatbotService.selectedModel.displayName}...' : _transcription.isEmpty ? 'Press the microphone button to start' : 'Ready to view results',🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/main.dart` around lines 437 - 446, The status text branch that shows 'Generating content with Gemini...' uses a hardcoded label; update that branch to include the currently selected model's displayName (same source used for line 340), e.g., replace the literal 'Generating content with Gemini...' with a formatted string that inserts the model display name (referencing the state variable/property that holds the selected model, and the existing flags _isRecording, _isTranscribing, _isProcessing, _transcription to find the branch). Ensure the replacement uses the same property (e.g., selectedModel.displayName or the existing variable used for "Processing with Gemini 2.0 Flash...") so the status becomes 'Generating content with {displayName}...' and stays consistent with the other status message.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/main.dart`:
- Around line 437-446: The status text branch that shows 'Generating content
with Gemini...' uses a hardcoded label; update that branch to include the
currently selected model's displayName (same source used for line 340), e.g.,
replace the literal 'Generating content with Gemini...' with a formatted string
that inserts the model display name (referencing the state variable/property
that holds the selected model, and the existing flags _isRecording,
_isTranscribing, _isProcessing, _transcription to find the branch). Ensure the
replacement uses the same property (e.g., selectedModel.displayName or the
existing variable used for "Processing with Gemini 2.0 Flash...") so the status
becomes 'Generating content with {displayName}...' and stays consistent with the
other status message.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 455ea401-5655-4c56-88ba-c9f0fd780aee
📒 Files selected for processing (2)
lib/main.dartlib/services/chatbot_service.dart
|
Please resolve the merge conflicts before review. Your PR will only be reviewed by a maintainer after all conflicts have been resolved. 📺 Watch this video to understand why conflicts occur and how to resolve them: |
|
Hey @SharkyBytes I went through this PR and it is duplicate of PR #9. It does not have a POW as well. I don't think it is needed so you can close it. |
Closes #8
Problem
ChatbotServicehad the Gemini model hardcoded asgemini-2.0-flash. Users with more complex medical notes had no way to use a more capable model, and there was no path to try Gemma's open-weight models.Changes
lib/services/chatbot_service.dartAdded a
GeminiModelenum with three entries:flash(default)gemini-2.0-flashprogemini-1.5-progemmagemma-3-27b-itEach entry carries a
modelId(used in the API URL), adisplayName(shown in the UI), and a shortdescription(shown as a subtitle in the picker).ChatbotServicenow holds aselectedModelfield (defaults toflash) that is used when building the API URL. It can be changed at any time between recordings.Added
hasValidApiKeyguard and structured Gemini error extraction while staying independently reviewable from fix: prevent RenderFlex overflow on small screens and improve API key validation #13.lib/main.dartPopupMenuButton(tune icon) to the right of the "DocPilot" title. Tapping it shows the three models with their descriptions. Selecting one updates_chatbotService.selectedModelviasetState.How it works
The model picker is in the app bar area so it is always accessible. The selected model persists for the lifetime of the app session and is used for all Gemini calls (summary and prescription) until changed.
Summary by CodeRabbit
New Features
Improvements