Black November

ATÉ 50% OFF

TÁ ACABANDO!

0 dias

0 horas

0 min

0 seg

1
resposta

[Bug] Na Imersão Dev Agentes de IA Google o código com erros dependencies

Imersão Agentes de IA - Alura + Google Gemini

Estou refazendo a Imersão Agentes de IA - Alura + Google Gemini e mesmo seguindo passo a passo todas as aulas o código está apresentando erros, com o código disponível na pagina "feito pelos instrutores" ocorre os mesmos erros.
Projeto dos Instrutores

segue abaixo

Aula 01

!pip install -q --upgrade langchain langchain-google-genai google-generativeai

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
opentelemetry-proto 1.37.0 requires protobuf<7.0,>=5.0, but you have protobuf 4.25.8 which is incompatible.
ydf 0.13.0 requires protobuf<7.0.0,>=5.29.1, but you have protobuf 4.25.8 which is incompatible.

**Importação da API Key

from google.colab import userdata
from langchain_google_genai import ChatGoogleGenerativeAI**

GOOGLE_API_KEY = userdata.get('GEMINI_API_KEY')**

ERRO:
ModuleNotFoundError Traceback (most recent call last)
/tmp/ipython-input-3109593305.py in <cell line: 0>()
1 from google.colab import userdata
----> 2 from langchain_google_genai import ChatGoogleGenerativeAI
3
4 GOOGLE_API_KEY = userdata.get('GEMINI_API_KEY')

/usr/local/lib/python3.12/dist-packages/langchain_google_genai/chat_models.py in
40 )
41 from langchain_core.outputs import ChatGeneration, ChatGenerationChunk, ChatResult
---> 42 from langchain_core.pydantic_v1 import Field, root_validator
43 from langchain_core.utils import get_from_dict_or_env
44 from tenacity import (

ModuleNotFoundError: No module named 'langchain_core.pydantic_v1'


NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.

ERRO AO FAZER A Importação da API Key ![erro ao executar o codigo Importação da API Key

POR FAVOR! como resolver essa falha ?

Matricule-se agora e aproveite até 50% OFF

O maior desconto do ano para você evoluir com a maior escola de tecnologia

QUERO APROVEITAR
1 resposta

Olá, Evandro!

Podemos tentar resolver seguindo os seguintes passos:

  1. Atualizar o protobuf: O erro indica um conflito de versão do protobuf. Tente atualizar para uma versão compatível com as dependências exigidas:

    !pip install protobuf==5.0.0
    
  2. Instalar o langchain_core: O erro ModuleNotFoundError sugere que o módulo langchain_core está ausente. Tente instalar ou atualizar esse pacote:

    !pip install langchain-core
    
  3. Reinstalar as bibliotecas:

    Às vezes, reinstalar as bibliotecas pode resolver problemas de dependência:

    !pip uninstall langchain langchain-google-genai google-generativeai -y
    !pip install langchain langchain-google-genai google-generativeai
    
  4. Verificar a API Key: Certifique-se de que a chave da API está corretamente configurada no Colab. Você pode verificar se a chave foi carregada corretamente:

    GOOGLE_API_KEY = userdata.get('GEMINI_API_KEY')
    print(GOOGLE_API_KEY)  # Verifique se a chave está correta
    

Após essas etapas, tente executar novamente o seu código. Espero ter ajudado e bons estudos!