Skip to content

Commit

Permalink
remove safety_settings for groq
Browse files Browse the repository at this point in the history
  • Loading branch information
SmartManoj committed Sep 18, 2024
1 parent 609b9f6 commit 8fd630b
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions openhands/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,31 @@ def __init__(
logger.info(f'Setting OllamaConfig.num_ctx to {total}')

# This only seems to work with Google as the provider, not with OpenRouter!
gemini_safety_settings = (
[
{
'category': 'HARM_CATEGORY_HARASSMENT',
'threshold': 'BLOCK_NONE',
},
{
'category': 'HARM_CATEGORY_HATE_SPEECH',
'threshold': 'BLOCK_NONE',
},
{
'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
'threshold': 'BLOCK_NONE',
},
{
'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
'threshold': 'BLOCK_NONE',
},
]
if self.config.model.lower().startswith('gemini')
else None
)
gemini_safety_settings = [
{
'category': 'HARM_CATEGORY_HARASSMENT',
'threshold': 'BLOCK_NONE',
},
{
'category': 'HARM_CATEGORY_HATE_SPEECH',
'threshold': 'BLOCK_NONE',
},
{
'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
'threshold': 'BLOCK_NONE',
},
{
'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
'threshold': 'BLOCK_NONE',
},
]

if self.config.model.lower().startswith('gemini'):
kwargs = {
'safety_settings': gemini_safety_settings,
}
else:
kwargs = {}

self.completion_unwrapped = partial(
litellm_completion,
Expand All @@ -179,7 +182,7 @@ def __init__(
temperature=self.config.temperature,
top_p=self.config.top_p,
caching=self.config.enable_cache,
safety_settings=gemini_safety_settings,
**kwargs,
)

if self.vision_is_active():
Expand Down

0 comments on commit 8fd630b

Please sign in to comment.