Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Explicar células de código com a ajuda do Gemini
Este documento descreve como usar o Gemini no Colab Enterprise, um produto do portfólio do Gemini para Google Cloud, para ajudar você a explicar células de código em um notebook do Colab Enterprise.
Este documento é destinado a analistas, cientistas e desenvolvedores de dados que trabalham com o Colab Enterprise. É necessário saber como escrever código em um ambiente de notebook.
Visão geral
O Gemini no Colab Enterprise pode ajudar você a explicar células de código em um notebook do Colab Enterprise. Isso pode ser útil quando você está trabalhando
com o notebook de outra pessoa e quer entender rapidamente o que
o código faz. Ou talvez você precise se lembrar de como partes do notebook
funcionam depois de um longo período sem trabalhar nele.
Depois de receber uma explicação de uma célula de código, você pode navegar por todos os snippets de código incluídos e revisar as fontes. Você também pode usar a caixa de diálogo de chat Explicar código para discutir o código e fazer mais perguntas.
Para mais detalhes, consulte Explicar uma célula de código.
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
Enable the Vertex AI, Cloud AI Companion, Dataform, and Compute Engine APIs.
Para receber as permissões necessárias para usar o Gemini no Colab Enterprise, peça ao administrador para conceder a você os seguintes papéis do IAM no projeto:
No menu Região, selecione a região que contém o notebook.
Clique no notebook que você quer abrir.
No notebook, clique em uma célula de código que tenha código.
Clique em
sparkRecursos de IA
disponíveis e em Explicar código.
Uma caixa de diálogo de conversa Explicar código aparece com uma explicação do seu código.
Leia a explicação, navegue pelos exemplos de snippets de código e revise as fontes. Use essa caixa de diálogo para discutir o código e
fazer perguntas complementares.
Para fechar a caixa de diálogo Explicar código, clique em
closeFechar.
Desativar o Gemini no Colab Enterprise
Para desativar o Gemini no Colab Enterprise em um
Google Cloud projeto, um administrador precisa desativar a
API Gemini para Google Cloud. Consulte
Como desativar serviços.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-01 UTC."],[],[],null,["# Explain code cells with Gemini assistance\n=========================================\n\n|\n| **Preview**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis document describes how you can use\nGemini in Colab Enterprise, which is a product\nin the [Gemini for Google Cloud](/gemini/docs/overview) portfolio,\nto help you explain code cells in a Colab Enterprise notebook.\n\nLearn [how and when Gemini\nfor Google Cloud uses your data](/gemini/docs/discover/data-governance).\n\nThis document is intended for data analysts, data scientists, and\ndata developers who work with Colab Enterprise. It assumes you have\nknowledge of how to write code in a notebook environment.\n\nOverview\n--------\n\nGemini in Colab Enterprise can help you explain code cells\nin a Colab Enterprise notebook. You might want to do this when you're working\nwith someone else's notebook and want to get a quick understanding of what\nthe code does. Or you might need to remind yourself how parts of your notebook\nwork after a long period of time without working on it.\n\nAfter you get an explanation of a code cell, you can browse any\nincluded code snippets and review the sources. You can also use the\n**Explain code** chat dialog to discuss the code and ask follow-up questions.\nFor more details, see [Explain a code cell](#explain).\n\nBefore you begin\n----------------\n\n| As an early-stage technology, Gemini for Google Cloud\n| products can generate output that seems plausible but is factually incorrect. We recommend that you\n| validate all output from Gemini for Google Cloud products before you use it.\n| For more information, see\n| [Gemini for Google Cloud and responsible AI](/gemini/docs/discover/responsible-ai).\n\n1. [Ensure that\n Gemini in Colab Enterprise is set up for your\n Google Cloud user account and project.](/gemini/docs/colab/set-up-gemini)\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n-\n\n\n Enable the Vertex AI, Cloud AI Companion, Dataform, and Compute Engine APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com, cloudaicompanion.googleapis.com, dataform.googleapis.com, compute.googleapis.com)\n\n-\n\n\n Enable the Vertex AI, Cloud AI Companion, Dataform, and Compute Engine APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com, cloudaicompanion.googleapis.com, dataform.googleapis.com, compute.googleapis.com)\n\n### Required roles\n\n\nTo get the permissions that\nyou need to use Gemini in Colab Enterprise,\n\nask your administrator to grant you the\nfollowing IAM roles on the project:\n\n- [Colab Enterprise User](/iam/docs/roles-permissions/aiplatform#aiplatform.colabEnterpriseUser) (`roles/aiplatform.colabEnterpriseUser`)\n- [Gemini for Google Cloud User](/iam/docs/roles-permissions/cloudaicompanion#cloudaicompanion.user) (`roles/cloudaicompanion.user`)\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYou might also be able to get\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n| One or more of the required roles includes the `dataform.repositories.list` permission. Users who are granted the `dataform.repositories.list` permission or the [Code Creator\n| (`roles/dataform.codeCreator`)](/iam/docs/understanding-roles#dataform.codeCreator) role in a project can list the names of code assets in that project by using the Dataform API or the Dataform command-line interface (CLI). Non-administrators using BigQuery Studio can only see code assets that they created or that were shared with them.\n\nExplain a code cell\n-------------------\n\nTo explain a code cell using Gemini for Google Cloud,\ndo the following:\n\n1. In the Google Cloud console, go to\n the Colab Enterprise **My notebooks** page.\n\n [Go to My notebooks](https://console.cloud.google.com/vertex-ai/colab/notebooks)\n2. In the **Region** menu, select the region that contains your notebook.\n\n3. Click the notebook that you want to open.\n\n4. In your notebook, click a code cell that has code in it.\n\n5. Click\n spark **Available\n AI features** , and then click **Explain code**.\n\n An **Explain code** chat dialog appears that includes\n an explanation of your code.\n6. Read through the explanation, browse the example code snippets,\n and review the sources. Use this chat dialog to discuss the code and\n ask follow-up questions.\n\n7. To close the **Explain code** dialog, click\n close **Close**.\n\nTurn off Gemini in Colab Enterprise\n-----------------------------------\n\n\nTo turn off Gemini in Colab Enterprise for a\nGoogle Cloud project, an administrator must turn off the\nGemini for Google Cloud API. See\n[Disabling services](/service-usage/docs/enable-disable#disabling).\n\n\nTo turn off Gemini in Colab Enterprise for a specific user, an\nadministrator needs to revoke the\n[Gemini for\nGoogle Cloud User](/iam/docs/understanding-roles#cloudaicompanion.user) (`roles/cloudaicompanion.user`) role for that user. See\n[Revoke\na single IAM role](/iam/docs/granting-changing-revoking-access#revoke-single-role).\n\nWhat's next\n-----------\n\n- Read the [Gemini for Google Cloud\n overview](/gemini/docs/overview).\n\n- For more ways to write and edit code with Gemini\n assistance, see the following:\n\n - [Chat about your notebook with Gemini](/colab/docs/chat)\n - [Use code completion and code generation](/colab/docs/use-code-completion)\n - [Explain and fix errors](/colab/docs/explain-errors)\n - [Use the Data Science Agent](/colab/docs/use-data-science-agent)\n- Learn [how Gemini for Google Cloud uses\n your data](/gemini/docs/discover/data-governance)."]]