Migrate from deprecated gemini-1.5-flash and @google/generative-ai to current packages #40
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.
Migration from deprecated packages to current ones
This PR migrates from deprecated packages to their current replacements:
gemini-1.5-flash→gemini-2.5-flash@google/generative-ai→@google/genaiMigration Plan
@google/genaipackage API structure@google/generative-aiwith@google/genai@google/generative-aito@google/genaiGoogleGenerativeAIwithGoogleGenAIgenAI.getGenerativeModel()toai.models.generateContent()gemini-1.5-flashtogemini-2.5-flashhttpOptions.baseUrlapp/actions/chatActions.ts(fromresult.response.text()toresult.text)app/actions/questionExample.ts(fromresult.response.text()toresult.text)paramsvariable for better maintainabilityFiles modified:
package.json- Updated dependency from@google/generative-aito@google/genaiapp/actions/gemini.ts- Complete API migration to new package with extracted parametersapp/actions/questionExample.ts- Updated response handling for new APIapp/actions/chatActions.ts- Updated response handling for new APIKey changes:
@google/generative-aiv0.24.1 to current@google/genaiv1.21.0gemini-1.5-flashtogemini-2.5-flashnew GoogleGenerativeAI().getGenerativeModel().generateContent()new GoogleGenAI().models.generateContent()result.response.text()result.text(with proper null checks)httpOptions.baseUrlfor the proxy fallbackmodelandcontentsinto a reusableparamsvariable, similar to the originalModelParamspattern, making it easier to modify parameters and reducing code duplicationAll TypeScript compilation, linting, and build processes pass successfully.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.