Spaces:
Build error
Build error
Commit
·
116c5b3
1
Parent(s):
dcb081c
Import and use additional HarmCategory and HarmBlockThreshold models to remove filter
Browse files- guardrails_models.py +12 -2
guardrails_models.py
CHANGED
|
@@ -3,7 +3,12 @@ import random
|
|
| 3 |
from typing import List, Optional
|
| 4 |
|
| 5 |
import openai
|
| 6 |
-
from google.generativeai.types import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
from langchain_community.chat_models import ChatAnyscale
|
| 8 |
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
|
| 9 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
|
@@ -383,7 +388,12 @@ def gemini_pro_nemoguardrails(
|
|
| 383 |
temperature=temperature,
|
| 384 |
max_retries=6,
|
| 385 |
metadata={"top_p": top_p, "max_output_tokens": max_output_tokens},
|
| 386 |
-
safety_settings={
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
),
|
| 388 |
)
|
| 389 |
completion = rails.generate(messages=messages)
|
|
|
|
| 3 |
from typing import List, Optional
|
| 4 |
|
| 5 |
import openai
|
| 6 |
+
from google.generativeai.types import (
|
| 7 |
+
BlockedPromptException,
|
| 8 |
+
StopCandidateException,
|
| 9 |
+
HarmCategory,
|
| 10 |
+
HarmBlockThreshold,
|
| 11 |
+
)
|
| 12 |
from langchain_community.chat_models import ChatAnyscale
|
| 13 |
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
|
| 14 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
|
|
|
| 388 |
temperature=temperature,
|
| 389 |
max_retries=6,
|
| 390 |
metadata={"top_p": top_p, "max_output_tokens": max_output_tokens},
|
| 391 |
+
safety_settings={
|
| 392 |
+
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
|
| 393 |
+
HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
|
| 394 |
+
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
|
| 395 |
+
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
|
| 396 |
+
},
|
| 397 |
),
|
| 398 |
)
|
| 399 |
completion = rails.generate(messages=messages)
|