Skip to content

Commit

Permalink
change constructor format
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheepsta300 committed Sep 28, 2024
1 parent f2514b2 commit a57b48f
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@ class AzureOpenAIContentSafetyChain(Chain):
"""Whether or not to error if bad content was found."""
input_key: str = "input" #: :meta private:
output_key: str = "output" #: :meta private:
content_safety_api_key: Optional[str] = None
content_safety_endpoint: Optional[str] = None

def __init__(
self,
*,
content_safety_key: Optional[str] = None,
content_safety_endpoint: Optional[str] = None,
) -> None:
content_safety_key = content_safety_key or os.environ["CONTENT_SAFETY_API_KEY"]
content_safety_endpoint = (
self.content_safety_key = content_safety_key or os.environ["CONTENT_SAFETY_API_KEY"]

Check failure on line 26 in libs/community/langchain_community/chains/azure_content_safety_chain.py

View workflow job for this annotation

GitHub Actions / cd libs/community / make lint #3.12

Ruff (E501)

langchain_community/chains/azure_content_safety_chain.py:26:89: E501 Line too long (92 > 88)

Check failure on line 26 in libs/community/langchain_community/chains/azure_content_safety_chain.py

View workflow job for this annotation

GitHub Actions / cd libs/community / make lint #3.9

Ruff (E501)

langchain_community/chains/azure_content_safety_chain.py:26:89: E501 Line too long (92 > 88)
self.content_safety_endpoint = (
content_safety_endpoint or os.environ["CONTENT_SAFETY_ENDPOINT"]
)
try:
import azure.ai.contentsafety as sdk
from azure.core.credentials import AzureKeyCredential

client = sdk.ContentSafetyClient(
self.client = sdk.ContentSafetyClient(
endpoint=content_safety_endpoint,
credential=AzureKeyCredential(content_safety_key),
)
Expand All @@ -43,11 +41,6 @@ def __init__(
"azure-ai-contentsafety is not installed. "
"Run `pip install azure-ai-contentsafety` to install."
)
super().__init__(
content_safety_key=content_safety_key,
content_safety_endpoint=content_safety_endpoint,
client=client,
)

@property
def input_keys(self) -> List[str]:
Expand Down

0 comments on commit a57b48f

Please sign in to comment.