Hello,
I have being trying with no success to use a tuned model with Gemini API. I have followed all guides to:
- set up the OAuth 2.0 Client ID
- Consent screen with scopes ( for example …/auth/generative-language.tuning )
- Storing the credential for use
Unfotunately I keep getting the message : “exc
google.api_core.exceptions.PermissionDenied: 403 You do not have permission to access tuned model tunedModels/mymodel”
Bellows is the code
import os
import google.generativeai as genai
from dotenv import load_dotenv
load_dotenv()
load_dotenv(dotenv_path=r"C:\Users\REPRO SANDRO\Documents\AI PROJECTS\GEN AI\.env") # Use the correct path to your .env file
credentials_path = os.getenv("GOOGLE_APPLICATION_CREDENTIALS")
# Configure the API key for the Google Generative AI
genai.configure(api_key="mykey", transport="grpc")
# Configuration for text generation
generation_config = {
"temperature": 0.9,
"top_p": 0.95,
"top_k": 64,
"max_output_tokens": 1024,
"response_mime_type": "text/plain",
}
# Create a GenerativeModel instance
model = genai.GenerativeModel(
model_name="tunedModels/custom-interact-sentiment-analysis-zn037",
generation_config=generation_config,
)
# Start a chat session
chat_session = model.start_chat(enable_automatic_function_calling=True)
# Send a message to the chat session including the file URI
response = chat_session.send_message(f"Fazer análise de sentimento no seguinte texto: 'Visita relacionamento, Jaque ainda não quebrou parceria com seu laboratório parceiro do RS Precision'. Apenas classifique positivo, neutro, ou negativo, nenhuma explicação é necessária.")
# Print the response
print(response.text)
Would be the scopes a problem ? What am i missing ?
Thanks in advance