I am trying to run the PALM API Python Example:
<
import pprint
import google.generativeai as palm
API_KEY ='XXXXXXXXXXXXXXXXXXXXXXX'
palm.configure(api_key = API_KEY)
model = 'models/text-bison-001'
prompt = """
You are an expert at solving word problems.
Solve the following problem:
I have three houses, each with three cats.
each cat owns 4 mittens, and a hat. Each mitten was
knit from 7m of yarn, each hat from 4m.
How much yarn was needed to make all the items?
Think about it step by step, and show your work.
"""
completion = palm.generate_text(
model=model,
prompt=prompt,
temperature=0,
# The maximum length of the response
max_output_tokens=800,
)
print(completion.result)
i>
I keep getting the following error message:
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS
I have doubled checked the APi-Key and have enabled it. The code is similar to 2 examples found with googe search.
Solved! Go to Solution.
I finally got it working on a different computer. I suspected that there was something corrupt in one of the modules. Created a req.txt file containing the following modules:
cachetools-5.3.1 google-ai-generativelanguage-0.2.0 google-api-core-2.11.1 google-auth-2.22.0 google-generativeai-0.1.0 googleapis-common-protos-1.59.1 grpcio-1.56.2 grpcio-status-1.56.2 proto-plus-1.22.3 protobuf-4.23.4 pyasn1-0.5.0 pyasn1-modules-0.3.0 rsa-4.9
Ran:
pip uninstall -y -r reqs.txt
pip install google-generativeai
It is now working as expected