mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 21:29:11 +00:00
Improve safety settings for Gemini chat models
- Align remaining harm categories to only refuse in high harm scenarios as well - Handle response for new "negligible" harm probability as well
This commit is contained in:
@@ -52,6 +52,10 @@ SAFETY_SETTINGS = [
|
|||||||
category=gtypes.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
|
category=gtypes.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
|
||||||
threshold=gtypes.HarmBlockThreshold.BLOCK_ONLY_HIGH,
|
threshold=gtypes.HarmBlockThreshold.BLOCK_ONLY_HIGH,
|
||||||
),
|
),
|
||||||
|
gtypes.SafetySetting(
|
||||||
|
category=gtypes.HarmCategory.HARM_CATEGORY_CIVIC_INTEGRITY,
|
||||||
|
threshold=gtypes.HarmBlockThreshold.BLOCK_ONLY_HIGH,
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -246,6 +250,7 @@ def generate_safety_response(safety_ratings: list[gtypes.SafetyRating]):
|
|||||||
# Add a bit of variety to the discomfort level based on the safety rating probability
|
# Add a bit of variety to the discomfort level based on the safety rating probability
|
||||||
discomfort_level = {
|
discomfort_level = {
|
||||||
gtypes.HarmProbability.HARM_PROBABILITY_UNSPECIFIED: " ",
|
gtypes.HarmProbability.HARM_PROBABILITY_UNSPECIFIED: " ",
|
||||||
|
gtypes.HarmProbability.NEGLIGIBLE: "a little ",
|
||||||
gtypes.HarmProbability.LOW: "a bit ",
|
gtypes.HarmProbability.LOW: "a bit ",
|
||||||
gtypes.HarmProbability.MEDIUM: "moderately ",
|
gtypes.HarmProbability.MEDIUM: "moderately ",
|
||||||
gtypes.HarmProbability.HIGH: random.choice(["very ", "quite ", "fairly "]),
|
gtypes.HarmProbability.HIGH: random.choice(["very ", "quite ", "fairly "]),
|
||||||
|
|||||||
Reference in New Issue
Block a user