google / generative-ai-docs

Documentation for Google's Gen AI site - including the Gemini API and Gemma
https://ai.google.dev
Apache License 2.0
1.5k stars 518 forks source link

google.api_core.exceptions.PermissionDenied: 403 #317

Closed zzj0402 closed 3 weeks ago

zzj0402 commented 4 months ago

Description of the bug:

Trying to use AI Studio locally with the Gemini tuned model with the following code:

"""
At the command line, only need to run once to install the package via pip:

$ pip install google-generativeai
"""

import google.generativeai as genai

genai.configure(api_key="YOUR_API_KEY")

# Set up the model
generation_config = {
  "temperature": 0.9,
  "top_p": 1,
  "top_k": 1,
  "max_output_tokens": 8192,
}

safety_settings = [
  {
    "category": "HARM_CATEGORY_HARASSMENT",
    "threshold": "BLOCK_MEDIUM_AND_ABOVE"
  },
  {
    "category": "HARM_CATEGORY_HATE_SPEECH",
    "threshold": "BLOCK_MEDIUM_AND_ABOVE"
  },
  {
    "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
    "threshold": "BLOCK_MEDIUM_AND_ABOVE"
  },
  {
    "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
    "threshold": "BLOCK_MEDIUM_AND_ABOVE"
  },
]

model = genai.GenerativeModel(model_name="tunedModels/sdfs-dfsf-sdfsadf",
                              generation_config=generation_config,
                              safety_settings=safety_settings)

prompt_parts = [
  BLABLABLA
]

response = model.generate_content(prompt_parts)
print(response.text)

Actual vs expected behavior:

Expect return a generated response but get:

envs\gemini\lib\site-packages\google\api_core\grpc_helpers.py", line 78, in error_remapped_callable
    raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.PermissionDenied: 403 You do not have permission to access tuned model tunedModels/sdfsdfasdfasdfa.

Any other information you'd like to share?

No response

rawsid11 commented 4 months ago

same error

singhniraj08 commented 3 months ago

@zzj0402, This repository is for issues related to website(https://ai.google.dev/) like documentation bugs or improvements. For issues related to AI Studio, we would suggest you to use "Send Feedback" option in AI Studio. Ref: Screenshot below. Thank you!

image

kohry commented 3 months ago

Same error here. I assume oauth is somewhat related to this issue, and I think people need some additional guidance. https://ai.google.dev/docs/oauth_quickstart

github-actions[bot] commented 2 months ago

Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.

hossain666 commented 2 months ago

""" At the command line, only need to run once to install the package via pip:

$ pip install google-generativeai """

import google.generativeai as genai

genai.configure(api_key="YOUR_API_KEY")

Set up the model

generation_config = { "temperature": 1, "top_p": 0.95, "top_k": 0, "max_output_tokens": 8192, }

safety_settings = [ { "category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE" }, { "category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_MEDIUM_AND_ABOVE" }, { "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "BLOCK_MEDIUM_AND_ABOVE" }, { "category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE" }, ]

model = genai.GenerativeModel(model_name="gemini-1.5-pro-latest", generation_config=generation_config, safety_settings=safety_settings)

convo = model.start_chat(history=[ ])

convo.send_message("YOUR_USER_INPUT") print(convo.last.text)

hossain666 commented 2 months ago

rbrisita:fix_doc

hossain666 commented 2 months ago

Reenvs\gemini\lib\site-packages\google\api_core\grpc_helpers.py", line 78, in error_remapped_callable raise exceptions.from_grpc_error(exc) from exc google.api_core.exceptions.PermissionDenied: 403 You do not have permission to access tuned model tunedModels/sdfsdfasdfasdfa.ference i

github-actions[bot] commented 2 months ago

Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.

harinaralasetty commented 1 month ago

This issue is still there, the code given in ai studio doesn't work with the ai studio api key.

Package versions: google-ai-generativelanguage==0.6.4 google-api-core==2.19.0 google-api-python-client==2.130.0 google-auth==2.29.0 google-auth-httplib2==0.2.0 google-generativeai==0.5.4 googleapis-common-protos==1.63.0 langchain-google-genai==1.0.5

Error: raise exceptions.from_grpc_error(exc) from exc google.api_core.exceptions.PermissionDenied: 403 You do not have permission to access tuned model tunedModels/nextnum-k7f103e3mv0y.

github-actions[bot] commented 1 month ago

Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.

github-actions[bot] commented 3 weeks ago

This issue was closed because it has been inactive for 28 days. Please post a new issue if you need further assistance. Thanks!