Skip to content

[WIP] Update Gemini model to version 2.5#5

Merged
Mbashas merged 1 commit into
mainfrom
copilot/update-gemini-model-to-2-5
Apr 12, 2026
Merged

[WIP] Update Gemini model to version 2.5#5
Mbashas merged 1 commit into
mainfrom
copilot/update-gemini-model-to-2-5

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

  • Updated MODEL_NAME in utils/ai_insights.py from gemini-2.0-flash-exp/gemini-2.0-flash to gemini-2.5-flash
  • Updated MODEL_NAME in page_modules/overview.py from gemini-2.0-flash-exp/gemini-2.0-flash to gemini-2.5-flash
Original prompt

The user requested to update the Gemini model to version 2.5.

Please update the MODEL_NAME constant in the following files to use gemini-2.5-flash (or the equivalent stable 2.5 version supported by the google-generativeai package):

  1. utils/ai_insights.py
  2. page_modules/overview.py

Search for MODEL_NAME = "gemini-2.0-flash-exp" or MODEL_NAME = "gemini-2.0-flash" and replace it with MODEL_NAME = "gemini-2.5-flash".

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: how to fix this?

Assistant: I have identified the root cause: Pandas 3.0 changed the default behavior of groupby().apply(), causing the country column to be excluded from the resulting DataFrame and triggering a KeyError. I've prepared a tool call to update the code to use a more robust .sort_values(...).head(5) approach, and I'm waiting for your approval to proceed with the pull request.

User: so is it already solved?

Assistant: No, it is not solved yet. I have identified the exact issue and know how to fix it, but I haven't applied the changes to your repository.

Would you like me to open a pull request with the fix?

User: check the last PR

Assistant: Yes, it looks like it is already solved!

You have a recent pull request (#1) titled "Fix KeyError: 'country' in production page groupby" that was merged just a few minutes ago.

The fix in that PR addressed exactly this issue by adding group_keys=False to the groupby().apply() call, which prevents the country column from being moved to the index and dropped.

Since it has already been merged into main, your application should now have the fix deployed.

User: is there any pending PR? how do I get a new api key?

Assistant: No, there are currently no pending (open) pull requests in the Mbashas/bataanno repository.

As for getting a new API key, based on your application's logs, you are likely looking for the Google Gemini API Key (used for your AI-powered insights).

How to get a Google Gemini API Key:

  1. Go to Google AI Studio.
  2. Sign in with your Google account.
  3. Click on "Get API key" in the left sidebar.
  4. Click "Create API key" and copy your new key.
  5. Update your Streamlit secrets (.streamlit/secrets.toml) or environment variables with the new key.

How to get a GitHub Personal Access Token (if you meant GitHub):

  1. In GitHub, click your profile picture in the top right and select Settings.
  2. Scroll down and click on Developer settings at the bottom of the left sidebar.
  3. Click on Personal access tokens -> Tokens (classic) (or Fine-grained tokens).
  4. Click Generate new token, set your desired permissions (scopes), and copy the key.

User:
Hello! I'm your AI Data Assistant for this dashboard. I can analyze all current KPI data, explain correlations, and help you navigate the system.

Feel free to ask me:

Data Questions: "What is the Cost Recovery Ratio?"
Diagnostic Questions: "Why is our NRW a financial risk?"
System Help: "Where can I find the country-level comparison charts?"
Start by clicking one of the suggested prompts above!

🤖
An error occurred: 404 models/gemini-2.0-flash-exp is not found for API version v1beta, or is not supported for generateContent. Call ListModels to see the list of available models and their supported methods.

👤
What is the biggest operational challenge (NRW)?

🤖
An error occurred: 404 models/gemini-2.0-flash-exp is not found for API version v1beta, or is not supported for generateContent. Call ListModels to see the list of available models and their supported methods.

👤
ListModels

🤖
An error occurred: 404 models/gemini-2.0-flash-exp is not found for API version v1beta, or is not supported for generateContent. Call ListModels to see the list of available models and their supported methods

Assistant: The issue you are experiencing with the AI chatbot is due to the experimental model gemini-2.0-flash-exp being removed or deprecated by Google. They regularly retire their -exp (experimental) models once a stable version is released.

I am preparing a pull request right now that updates your dashboard codebase to use the stable gemini-2.0-flash model instead, which will immediately fix this error. Please confirm when the prompt appears in your chat window so the fix can be applied to your repository!

User: am i not supposed to get a different key instead?

Assistant: You don't necessarily need a new API key! The error message you're seeing:

404 models/gemini-2.0-flash-exp is not found for API version v1beta

This indicates that the model name being requested by your application (gemini-2.0-flash-exp) is either deprecated, no longer available in the experimental phase, or not accessible with your current tier. Google frequently phases out -exp (experimental) models when stable versions are released.

Instead of getting a new key, the best...

This pull request was created from Copilot chat.

@Mbashas Mbashas marked this pull request as ready for review April 12, 2026 13:58
Copilot AI review requested due to automatic review settings April 12, 2026 13:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Mbashas Mbashas merged commit 6734100 into main Apr 12, 2026
1 check failed
Copilot stopped work on behalf of Mbashas due to an error April 12, 2026 13:58
Copilot AI requested a review from Mbashas April 12, 2026 13:58
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