149 gemini
Using Gemini and EE Genie for automatic code generation
The source code is adapted from the ee_genie.ipynb notebook at https://bit.ly/3YEm7B6. Credit to the original author Simon Ilyushchenko.
Please note that this feature experimental. Using the Gemini API may incur charges. Please checkout the pricing here.
Installation¶
Uncomment the following line to uninstall the existing geemap package.
# %pip uninstall geemap -y
Uncomment the second line to install the development version of geemap.
# %pip install -U git+https://github.com/gee-community/geemap.git geedim
Pre-requisites¶
To use this new feature, you need two things:
- Earth Engine access
- Generative AI API key
You need a Google Cloud Project to associate your requests with. Use these instructions and set GOOGLE_PROJECT_ID
or EE_PROJECT_ID
notebook secret to your project id.
Next you need to get an Generative AI API key here.
To save this key in the notebook, click on the key icon in Colab on the left-hand side and add your key as a secret with the name GOOGLE_API_KEY
. Make sure the value has no newlines.
Alternatively, uncomment the following code block to set API keys if you have not set them as notebook secrets.
# import os
# os.environ["EE_PROJECT_ID"] = "YOUR-PROJECT-ID"
# os.environ["GOOGLE_API_KEY"] = "YOUR-GOOGLE-API-KEY"
Use Genie¶
from geemap.ai import Genie
For a list of available Gemini models, see https://bit.ly/4fKfXW7.
Genie(
gemini_model="gemini-1.5-flash",
target_score=0.8,
widget_height="600px",
)