Closed
Description
Description of the bug:
After uploading a file using the file API and calling the count_tokens
functions, I get the following error.
google.api_core.exceptions.PermissionDenied: 403 You do not have permission to access the File 8lqhztqcd6g1 or it may not exist
Here is my code:
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
genai.configure(api_key=GOOGLE_API_KEY)
model_name = "models/gemini-1.5-pro-latest"
model = genai.GenerativeModel(model_name)
audio_file_path = "./../data/audio_example.mp3"
audio_sample = genai.upload_file(audio_file_path)
model.count_tokens(audio_sample)
Additional info: For some reason, if I comment the model.count_tokens
call line, and run the following code, it works:
response = model.generate_content([
"Describe the following audio:",
audio_sample
])
print(response)
Actual vs expected behavior:
Return the number of tokens as shown in the notebook: https://github.com/google-gemini/cookbook/blob/main/quickstarts/Counting_Tokens.ipynb
Any other information you'd like to share?
No response