-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CachedContent.create() gives "403 You do not have permission to access the File" error for Video files. #617
Comments
Hi @tobyperrett Could you share the sample code you're working with? This will help us reproduce the issue you've described. Thanks |
Hi, I'm facing this issue as well. The sample code used and the error message are shown below. # Source: https://ai.google.dev/gemini-api/docs/caching?lang=python#generate-content
import getpass
import os
import google.generativeai as genai
from google.generativeai import caching
import datetime
import time
# Get your API key from https://aistudio.google.com/app/apikey
# and access your API key as an environment variable.
# To authenticate from a Colab, see
# https://github.com/google-gemini/cookbook/blob/main/quickstarts/Authentication.ipynb
genai.configure(api_key=getpass.getpass('Gemini API_KEY: '))
# Download video file
#!curl -O https://storage.googleapis.com/generativeai-downloads/data/Sherlock_Jr_FullMovie.mp4
path_to_video_file = 'Sherlock_Jr_FullMovie.mp4'
# Upload the video using the Files API
video_file = genai.upload_file(path=path_to_video_file)
# Wait for the file to finish processing
while video_file.state.name == 'PROCESSING':
print('Waiting for video to be processed.')
time.sleep(2)
video_file = genai.get_file(video_file.name)
print(f'Video processing complete: {video_file.uri}')
# Create a cache with a 5 minute TTL
cache = caching.CachedContent.create(
model='models/gemini-1.5-flash-001',
display_name='sherlock jr movie', # used to identify the cache
system_instruction=(
'You are an expert video analyzer, and your job is to answer '
'the user\'s query based on the video file you have access to.'
),
contents=[video_file],
ttl=datetime.timedelta(minutes=5),
)
# Construct a GenerativeModel which uses the created cache.
model = genai.GenerativeModel.from_cached_content(cached_content=cache)
# Query the model
response = model.generate_content([(
'Introduce different characters in the movie by describing '
'their personality, looks, and names. Also list the timestamps '
'they were introduced for the first time.')])
print(response.usage_metadata)
# The output should look something like this:
#
# prompt_token_count: 696219
# cached_content_token_count: 696190
# candidates_token_count: 214
# total_token_count: 696433
print(response.text) Output:
The output is the same if I switch to Flash 002. |
The sample code from https://ai.google.dev/gemini-api/docs/caching?lang=python#generate-content posted by barun-saha above fails. In addition to the flash models they tried, it has been failing for pro-001 and pro-002 for me. |
I'm getting same error. It was working fine, a day before. But all of a sudden, it throws this. I couldn't get a solution anywhere. So i decided to create a issue and just found out it is the first one here. Someone please look into this. Thanks for opening this up @tobyperrett |
@tobyperrett is it resolved for you? |
No, still broken. |
It is somehow resolved now. idk what has been tweaked. |
The cache creation appears to work, but now I get a different error when querying the model created with cached content:
|
Confirmed, video files + caching are intermittently failing for me too, Colab to reproduce: https://colab.research.google.com/drive/1aqtluHSMhVKDzW96upKcE2oZYwpXMQqo |
Description of the bug:
When I try to create a caching.CachedContent.create(), I get a "403 You do not have permission to access the File XXXX" error. I've checked and the model runs fine if I don't cache. The file does exist and is marked as "ACTIVE".
Actual vs expected behavior:
It was working a couple of days ago.
Any other information you'd like to share?
No response
The text was updated successfully, but these errors were encountered: