以下是创建服务账户和启用API的代码示例和步骤:
错误:
AttributeError Traceback (most recent call last)<ipython-input-20-ee7d7add68db> in <cell line: 8>() 6 7 # Make the request----> 8 create_corpus_response = retriever_service_client.create_corpus(create_corpus_request) 9 10 # Set the `corpus_resource_name` for subsequent sections.2 frames/usr/local/lib/python3.10/dist-packages/google/ai/generativelanguage_v1beta/services/retriever_service/client.py in _compare_universes(client_universe, credentials) 514 """ 515 if credentials:--> 516 credentials_universe = credentials.universe_domain 517 if client_universe != credentials_universe: 518 default_universe = RetrieverServiceClient._DEFAULT_UNIVERSEAttributeError: 'Credentials' object has no attribute 'universe_domain'
回答:
您可以尝试升级Google Auth,看起来某些版本存在一些问题:
pip install --upgrade google-auth
参考问题:https://github.com/googleapis/google-cloud-python/issues/12254