mirror of
https://github.com/hwchase17/langchain
synced 2024-10-31 15:20:26 +00:00
4abe85be57
Co-authored-by: Wrick Talukdar <wrick.talukdar@gmail.com> Co-authored-by: Anjan Biswas <anjanavb@amazon.com> Co-authored-by: Jha <nikjha@amazon.com> Co-authored-by: Lucky-Lance <77819606+Lucky-Lance@users.noreply.github.com> Co-authored-by: 陆徐东 <luxudong@MacBook-Pro.local>
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
from typing import List, Union
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class ModerationPiiConfig(BaseModel):
|
|
threshold: float = 0.5
|
|
"""Threshold for PII confidence score, defaults to 0.5 i.e. 50%"""
|
|
|
|
labels: List[str] = []
|
|
"""
|
|
List of PII Universal Labels.
|
|
Defaults to `list[]`
|
|
"""
|
|
|
|
redact: bool = False
|
|
"""Whether to perform redaction of detected PII entities"""
|
|
|
|
mask_character: str = "*"
|
|
"""Redaction mask character in case redact=True, defaults to asterisk (*)"""
|
|
|
|
|
|
class ModerationToxicityConfig(BaseModel):
|
|
threshold: float = 0.5
|
|
"""Threshold for Toxic label confidence score, defaults to 0.5 i.e. 50%"""
|
|
|
|
labels: List[str] = []
|
|
"""List of toxic labels, defaults to `list[]`"""
|
|
|
|
|
|
class ModerationIntentConfig(BaseModel):
|
|
threshold: float = 0.5
|
|
"""
|
|
Threshold for Intent classification
|
|
confidence score, defaults to 0.5 i.e. 50%
|
|
"""
|
|
|
|
|
|
class BaseModerationConfig(BaseModel):
|
|
filters: List[
|
|
Union[ModerationPiiConfig, ModerationToxicityConfig, ModerationIntentConfig]
|
|
] = [
|
|
ModerationPiiConfig(),
|
|
ModerationToxicityConfig(),
|
|
ModerationIntentConfig(),
|
|
]
|
|
"""
|
|
Filters applied to the moderation chain, defaults to
|
|
`[ModerationPiiConfig(), ModerationToxicityConfig(),
|
|
ModerationIntentConfig()]`
|
|
"""
|