google / generative-ai-go

Go SDK for Google Generative AI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can I only adjust 4 elements of safety settings for now?

KnightChaser opened this issue · comments

According to the official documentation, the type HarmCategory says These categories cover various kinds of harms that developers may wish to adjust. and it enumerates 11 categories like below.

// HarmCategory specifies the category of a rating.
//
// These categories cover various kinds of harms that developers
// may wish to adjust.
type HarmCategory int32

const (
	// HarmCategoryUnspecified means category is unspecified.
	HarmCategoryUnspecified HarmCategory = 0
	// HarmCategoryDerogatory means negative or harmful comments targeting identity and/or protected attribute.
	HarmCategoryDerogatory HarmCategory = 1
	// HarmCategoryToxicity means content that is rude, disrepspectful, or profane.
	HarmCategoryToxicity HarmCategory = 2
	// HarmCategoryViolence means describes scenarios depictng violence against an individual or group, or
	// general descriptions of gore.
	HarmCategoryViolence HarmCategory = 3
	// HarmCategorySexual means contains references to sexual acts or other lewd content.
	HarmCategorySexual HarmCategory = 4
	// HarmCategoryMedical means promotes unchecked medical advice.
	HarmCategoryMedical HarmCategory = 5
	// HarmCategoryDangerous means dangerous content that promotes, facilitates, or encourages harmful acts.
	HarmCategoryDangerous HarmCategory = 6
	// HarmCategoryHarassment means harasment content.
	HarmCategoryHarassment HarmCategory = 7
	// HarmCategoryHateSpeech means hate speech and content.
	HarmCategoryHateSpeech HarmCategory = 8
	// HarmCategorySexuallyExplicit means sexually explicit content.
	HarmCategorySexuallyExplicit HarmCategory = 9
	// HarmCategoryDangerousContent means dangerous content.
	HarmCategoryDangerousContent HarmCategory = 10
)

However, currently, I can only adjust 4 parameters among them as below, not corresponding to the annotation in the source code or an explanation of the SDK document, and I receive a 400 error if I add more adjustments for other defined categories in HarmCategory int32 like genai.HarmCategoryMedical. Can I get some explanation or advice about this? I wonder if I misunderstood about this feature.

model.SafetySettings = []*genai.SafetySetting{
		{
			Category:  genai.HarmCategoryDangerousContent,
			Threshold: genai.HarmBlockNone,
		},
		{
			Category:  genai.HarmCategoryHarassment,
			Threshold: genai.HarmBlockNone,
		},
		{
			Category:  genai.HarmCategoryHateSpeech,
			Threshold: genai.HarmBlockNone,
		},
		{
			Category:  genai.HarmCategorySexuallyExplicit,
			Threshold: genai.HarmBlockNone,
		},
	}

Thanks is advance!

Sorry for the late reply; yes, this sounds right. We'll be working on exposing additional adjustments. Which ones are you particularly interested in?

Well, I was just curious about the difference and the real code. I just wanted to turn everything on and off, just out of my curiosity... but currently I'm not working with Google's Gemini API in Go language. Thanks for reply.

We are encountering the same problem and, so far, we have only been able to set up 4 out of 11 safe settings.