Невозможно настроить параметры безопасности в Gemini-Pro: google.api_core.Exceptions.InvalidArgument.Python

Программы на Python
Anonymous
Невозможно настроить параметры безопасности в Gemini-Pro: google.api_core.Exceptions.InvalidArgument.

Сообщение Anonymous »


The code below runs find but when I uncomment any of the safety settings it throws:

google.api_core.exceptions.InvalidArgument: 400 Request contains an invalid argument The reason I'm trying to customize the safety settings is because in a real scenario gemini-pro is throwing me an error: response was blocked. This happens when I'm trying to use it to generate SQL.
from vertexai.preview.generative_models import GenerativeModel from vertexai.preview import generative_models safety_config = { #generative_models.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: generative_models.HarmBlockThreshold.BLOCK_NONE, #generative_models.HarmCategory.HARM_CATEGORY_HARASSMENT: generative_models.HarmBlockThreshold.BLOCK_NONE, #generative_models.HarmCategory.HARM_CATEGORY_HATE_SPEECH: generative_models.HarmBlockThreshold.BLOCK_NONE, #generative_models.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: generative_models.HarmBlockThreshold.BLOCK_LOW_AND_ABOVE, #generative_models.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: generative_models.HarmBlockThreshold.BLOCK_NONE, #generative_models.HarmCategory.HARM_CATEGORY_UNSPECIFIED: generative_models.HarmBlockThreshold.BLOCK_NONE, } model = GenerativeModel( "gemini-pro", safety_settings=safety_config ) response = model.generate_content("What is the future of AI in one sentence?") print(response.text)

Источник: https://stackoverflow.com/questions/780 ... eptions-in

Вернуться в «Python»