whylogs_container.whylabs.container.policy package#
Submodules#
whylogs_container.whylabs.container.policy.hashable_dict module#
- class whylogs_container.whylabs.container.policy.hashable_dict.HashableDict#
Bases:
dict
[str
,Any
]- static from_dict(value: dict[str, Any]) HashableDict #
whylogs_container.whylabs.container.policy.normalized_scores module#
- class whylogs_container.whylabs.container.policy.normalized_scores.SensitivitySettings(low: float, medium: float, high: float, max: float, min: float, tags: str | None = None, check_str: Callable[[str | None, float], bool] | None = None, check_number: Callable[[int | float, float], bool] | None = None, upper_threshold: bool | None = False)#
Bases:
object
- check_number: Callable[[int | float, float], bool] | None = None#
- check_str: Callable[[str | None, float], bool] | None = None#
- get_threshold(sensitivity_level: str) float #
- high: float#
- low: float#
- max: float#
- medium: float#
- min: float#
- tags: str | None = None#
- upper_threshold: bool | None = False#
- whylogs_container.whylabs.container.policy.normalized_scores.calculate_rule_set_score(row: Mapping[str, float | int | str | None]) Tuple[int | None, Dict[str, int]] #
Calculate normalized scores for a set of metrics based on the thresholds defined in the thresholds dictionary.
- Returns:
The score for the rule set, and the scores for each individual metrics that went into that calculation, in
the same order as the input mapping (important).
- whylogs_container.whylabs.container.policy.normalized_scores.find_thresholds_for_metric(metric_name: str) SensitivitySettings | None #
- whylogs_container.whylabs.container.policy.normalized_scores.threshold_relative_score_normalization(metric_value: float | int, max_val: float, min_val: float, threshold: float, lower_threshold: bool = True) int #
whylogs_container.whylabs.container.policy.policy module#
- class whylogs_container.whylabs.container.policy.policy.CachedMetricCreator(metric_creator: Callable[[...], List[List[MetricCreator] | Callable[[], MetricCreator] | Callable[[], List[MetricCreator]] | Callable[[], SingleMetric | MultiMetric] | Callable[[], List[SingleMetric | MultiMetric]] | List[Callable[[], SingleMetric | MultiMetric]]] | Callable[[], List[MetricCreator] | Callable[[], MetricCreator] | Callable[[], List[MetricCreator]] | Callable[[], SingleMetric | MultiMetric] | Callable[[], List[SingleMetric | MultiMetric]] | List[Callable[[], SingleMetric | MultiMetric]]] | Callable[[], List[List[MetricCreator] | Callable[[], MetricCreator] | Callable[[], List[MetricCreator]] | Callable[[], SingleMetric | MultiMetric] | Callable[[], List[SingleMetric | MultiMetric]] | List[Callable[[], SingleMetric | MultiMetric]]]] | Callable[[], SingleMetric | MultiMetric] | Callable[[], List[SingleMetric | MultiMetric]] | List[Callable[[], SingleMetric | MultiMetric]]])#
Bases:
object
whylogs_container.whylabs.container.policy.policy_0_0_1 module#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.ActionOptions(*, block_message: str | None = None)#
Bases:
BaseModel
- block_message: str | None#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'block_message': FieldInfo(annotation=Union[str, NoneType], required=False)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class whylogs_container.whylabs.container.policy.policy_0_0_1.BadActorsRuleSet(*, ruleset: Literal['score.bad_actors'] = 'score.bad_actors', options: BadActorsRuleSetOptions)#
Bases:
MetaRulesetBaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=BadActorsRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['score.bad_actors'], required=False, default='score.bad_actors')}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: BadActorsRuleSetOptions#
- ruleset: Literal['score.bad_actors']#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.BadActorsRuleSetOptions(*, behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high'])#
Bases:
BaseModel
- behavior: Literal['observe', 'flag', 'block']#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'behavior': FieldInfo(annotation=Literal['observe', 'flag', 'block'], required=True), 'sensitivity': FieldInfo(annotation=Literal['low', 'medium', 'high'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- sensitivity: Literal['low', 'medium', 'high']#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.CallbackOptions(*, callback: str, options: Mapping[str, bool | str] | None = None)#
Bases:
BaseModel
- callback: str#
- classmethod hashable_dicts(it: Any)#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'callback': FieldInfo(annotation=str, required=True), 'options': FieldInfo(annotation=Union[Mapping[str, Union[bool, str]], NoneType], required=False)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: Mapping[str, bool | str] | None#
- to_langkit_options() LangkitOptions #
- class whylogs_container.whylabs.container.policy.policy_0_0_1.CostRuleSet(*, ruleset: Literal['score.cost'] = 'score.cost', options: CostRuleSetOptions)#
Bases:
MetaRulesetBaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=CostRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['score.cost'], required=False, default='score.cost')}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: CostRuleSetOptions#
- ruleset: Literal['score.cost']#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.CostRuleSetOptions(*, behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high'])#
Bases:
BaseModel
- behavior: Literal['observe', 'flag', 'block']#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'behavior': FieldInfo(annotation=Literal['observe', 'flag', 'block'], required=True), 'sensitivity': FieldInfo(annotation=Literal['low', 'medium', 'high'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- sensitivity: Literal['low', 'medium', 'high']#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.CustomerExperienceRuleSet(*, ruleset: Literal['score.customer_experience'] = 'score.customer_experience', options: CustomerExperienceRuleSetOptions)#
Bases:
MetaRulesetBaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=CustomerExperienceRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['score.customer_experience'], required=False, default='score.customer_experience')}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: CustomerExperienceRuleSetOptions#
- ruleset: Literal['score.customer_experience']#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.CustomerExperienceRuleSetOptions(*, behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high'])#
Bases:
BaseModel
- behavior: Literal['observe', 'flag', 'block']#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'behavior': FieldInfo(annotation=Literal['observe', 'flag', 'block'], required=True), 'sensitivity': FieldInfo(annotation=Literal['low', 'medium', 'high'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- sensitivity: Literal['low', 'medium', 'high']#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.LangkitMetric(*, metric: str, profile: bool | None = True, options: Mapping[str, float | int | str | bool | Tuple[float | int | str | bool, ...]] | Mapping[str, Mapping[str, float | int | str | bool | Tuple[float | int | str | bool, ...]]] | None = None, validation: ValidationOptions | None = None)#
Bases:
BaseModel
- classmethod hashable_dicts(it: Any)#
- metric: str#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'metric': FieldInfo(annotation=str, required=True), 'options': FieldInfo(annotation=Union[Mapping[str, Union[float, int, str, bool, Tuple[Union[float, int, str, bool], ...]]], Mapping[str, Mapping[str, Union[float, int, str, bool, Tuple[Union[float, int, str, bool], ...]]]], NoneType], required=False), 'profile': FieldInfo(annotation=Union[bool, NoneType], required=False, default=True), 'validation': FieldInfo(annotation=Union[ValidationOptions, NoneType], required=False)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: Mapping[str, float | int | str | bool | Tuple[float | int | str | bool, ...]] | Mapping[str, Mapping[str, float | int | str | bool | Tuple[float | int | str | bool, ...]]] | None#
- profile: bool | None#
If true, then this metric will be included in the whylogs profiles
- to_langkit_options() LangkitOptions #
- validation: ValidationOptions | None#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.MetaRulesetBaseModel#
Bases:
BaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class whylogs_container.whylabs.container.policy.policy_0_0_1.MisuseRuleSet(*, ruleset: Literal['score.misuse'] = 'score.misuse', options: MisuseRuleSetOptions)#
Bases:
MetaRulesetBaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=MisuseRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['score.misuse'], required=False, default='score.misuse')}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: MisuseRuleSetOptions#
- ruleset: Literal['score.misuse']#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.MisuseRuleSetOptions(*, behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high'], topics: Tuple[str, ...])#
Bases:
BaseModel
- behavior: Literal['observe', 'flag', 'block']#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'behavior': FieldInfo(annotation=Literal['observe', 'flag', 'block'], required=True), 'sensitivity': FieldInfo(annotation=Literal['low', 'medium', 'high'], required=True), 'topics': FieldInfo(annotation=Tuple[str, ...], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- sensitivity: Literal['low', 'medium', 'high']#
- topics: Tuple[str, ...]#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.Policy(*, whylabs_dataset_id: str, id: str, policy_version: int, schema_version: Literal['0.0.1'] = '0.0.1', metrics: Tuple[LangkitMetric, ...] | None = None, callbacks: Tuple[CallbackOptions, ...] | None = None, validators: Tuple[ValidatorOptions, ...] | None = None, rulesets: Tuple[MisuseRuleSet | BadActorsRuleSet | CustomerExperienceRuleSet | TruthfulnessRuleSet | CostRuleSet | PromptMisuseRuleSet | PromptBadActorsRuleSet | PromptCustomerExperienceRuleSet | PromptTruthfulnessRuleSet | PromptCostRuleSet | ResponseMisuseRuleSet | ResponseBadActorsRuleSet | ResponseCustomerExperienceRuleSet | ResponseTruthfulnessRuleSet | ResponseCostRuleSet, ...] | None = None, actions: ActionOptions | None = None)#
Bases:
BaseModel
- actions: ActionOptions | None#
- callbacks: Tuple[CallbackOptions, ...] | None#
- classmethod ensure_str(it: Any)#
Ensure that these fields are parsed as strings. The python yaml parser sometimes pickes ints or floats if these are defined as something like 1.
- get_rulesets() Sequence[PromptMisuseRuleSet | PromptBadActorsRuleSet | PromptCustomerExperienceRuleSet | PromptTruthfulnessRuleSet | PromptCostRuleSet | ResponseMisuseRuleSet | ResponseBadActorsRuleSet | ResponseCustomerExperienceRuleSet | ResponseTruthfulnessRuleSet | ResponseCostRuleSet] #
- id: str#
- metrics: Tuple[LangkitMetric, ...] | None#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'actions': FieldInfo(annotation=Union[ActionOptions, NoneType], required=False), 'callbacks': FieldInfo(annotation=Union[Tuple[CallbackOptions, ...], NoneType], required=False, default_factory=tuple), 'id': FieldInfo(annotation=str, required=True), 'metrics': FieldInfo(annotation=Union[Tuple[LangkitMetric, ...], NoneType], required=False, default_factory=tuple), 'policy_version': FieldInfo(annotation=int, required=True), 'rulesets': FieldInfo(annotation=Union[Tuple[Union[MisuseRuleSet, BadActorsRuleSet, CustomerExperienceRuleSet, TruthfulnessRuleSet, CostRuleSet, PromptMisuseRuleSet, PromptBadActorsRuleSet, PromptCustomerExperienceRuleSet, PromptTruthfulnessRuleSet, PromptCostRuleSet, ResponseMisuseRuleSet, ResponseBadActorsRuleSet, ResponseCustomerExperienceRuleSet, ResponseTruthfulnessRuleSet, ResponseCostRuleSet], ...], NoneType], required=False, default_factory=tuple), 'schema_version': FieldInfo(annotation=Literal['0.0.1'], required=False, default='0.0.1'), 'validators': FieldInfo(annotation=Union[Tuple[ValidatorOptions, ...], NoneType], required=False, default_factory=tuple), 'whylabs_dataset_id': FieldInfo(annotation=str, required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- policy_version: int#
- rulesets: Tuple[MisuseRuleSet | BadActorsRuleSet | CustomerExperienceRuleSet | TruthfulnessRuleSet | CostRuleSet | PromptMisuseRuleSet | PromptBadActorsRuleSet | PromptCustomerExperienceRuleSet | PromptTruthfulnessRuleSet | PromptCostRuleSet | ResponseMisuseRuleSet | ResponseBadActorsRuleSet | ResponseCustomerExperienceRuleSet | ResponseTruthfulnessRuleSet | ResponseCostRuleSet, ...] | None#
- schema_version: Literal['0.0.1']#
- to_langkit_options() LangkitOptions #
- validators: Tuple[ValidatorOptions, ...] | None#
- whylabs_dataset_id: str#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.PromptBadActorsRuleSet(*, ruleset: Literal['prompt.score.bad_actors'], options: BadActorsRuleSetOptions)#
Bases:
BaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=BadActorsRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['prompt.score.bad_actors'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: BadActorsRuleSetOptions#
- ruleset: Literal['prompt.score.bad_actors']#
- to_langkit_options() LangkitOptions #
- class whylogs_container.whylabs.container.policy.policy_0_0_1.PromptCostRuleSet(*, ruleset: Literal['prompt.score.cost'], options: CostRuleSetOptions)#
Bases:
BaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=CostRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['prompt.score.cost'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: CostRuleSetOptions#
- ruleset: Literal['prompt.score.cost']#
- to_langkit_options() LangkitOptions #
- class whylogs_container.whylabs.container.policy.policy_0_0_1.PromptCustomerExperienceRuleSet(*, ruleset: Literal['prompt.score.customer_experience'] = 'prompt.score.customer_experience', options: CustomerExperienceRuleSetOptions)#
Bases:
BaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=CustomerExperienceRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['prompt.score.customer_experience'], required=False, default='prompt.score.customer_experience')}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: CustomerExperienceRuleSetOptions#
- ruleset: Literal['prompt.score.customer_experience']#
- to_langkit_options() LangkitOptions #
- class whylogs_container.whylabs.container.policy.policy_0_0_1.PromptMisuseRuleSet(*, ruleset: Literal['prompt.score.misuse'], options: MisuseRuleSetOptions)#
Bases:
BaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=MisuseRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['prompt.score.misuse'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: MisuseRuleSetOptions#
- ruleset: Literal['prompt.score.misuse']#
- to_langkit_options() LangkitOptions #
- class whylogs_container.whylabs.container.policy.policy_0_0_1.PromptTruthfulnessRuleSet(*, ruleset: Literal['prompt.score.truthfulness'], options: TruthfulnessRuleSetOptions)#
Bases:
BaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=TruthfulnessRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['prompt.score.truthfulness'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: TruthfulnessRuleSetOptions#
- ruleset: Literal['prompt.score.truthfulness']#
- to_langkit_options() LangkitOptions #
- class whylogs_container.whylabs.container.policy.policy_0_0_1.ResponseBadActorsRuleSet(*, ruleset: Literal['response.score.bad_actors'], options: BadActorsRuleSetOptions)#
Bases:
BaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=BadActorsRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['response.score.bad_actors'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: BadActorsRuleSetOptions#
- ruleset: Literal['response.score.bad_actors']#
- to_langkit_options() LangkitOptions #
- class whylogs_container.whylabs.container.policy.policy_0_0_1.ResponseCostRuleSet(*, ruleset: Literal['response.score.cost'], options: CostRuleSetOptions)#
Bases:
BaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=CostRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['response.score.cost'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: CostRuleSetOptions#
- ruleset: Literal['response.score.cost']#
- to_langkit_options() LangkitOptions #
- class whylogs_container.whylabs.container.policy.policy_0_0_1.ResponseCustomerExperienceRuleSet(*, ruleset: Literal['response.score.customer_experience'] = 'response.score.customer_experience', options: CustomerExperienceRuleSetOptions)#
Bases:
BaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=CustomerExperienceRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['response.score.customer_experience'], required=False, default='response.score.customer_experience')}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: CustomerExperienceRuleSetOptions#
- ruleset: Literal['response.score.customer_experience']#
- to_langkit_options() LangkitOptions #
- class whylogs_container.whylabs.container.policy.policy_0_0_1.ResponseMisuseRuleSet(*, ruleset: Literal['response.score.misuse'], options: MisuseRuleSetOptions)#
Bases:
BaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=MisuseRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['response.score.misuse'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: MisuseRuleSetOptions#
- ruleset: Literal['response.score.misuse']#
- to_langkit_options() LangkitOptions #
- class whylogs_container.whylabs.container.policy.policy_0_0_1.ResponseTruthfulnessRuleSet(*, ruleset: Literal['response.score.truthfulness'], options: TruthfulnessRuleSetOptions)#
Bases:
BaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=TruthfulnessRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['response.score.truthfulness'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: TruthfulnessRuleSetOptions#
- ruleset: Literal['response.score.truthfulness']#
- to_langkit_options() LangkitOptions #
- class whylogs_container.whylabs.container.policy.policy_0_0_1.TruthfulnessRuleSet(*, ruleset: Literal['score.truthfulness'] = 'score.truthfulness', options: TruthfulnessRuleSetOptions)#
Bases:
MetaRulesetBaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=TruthfulnessRuleSetOptions, required=True), 'ruleset': FieldInfo(annotation=Literal['score.truthfulness'], required=False, default='score.truthfulness')}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: TruthfulnessRuleSetOptions#
- ruleset: Literal['score.truthfulness']#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.TruthfulnessRuleSetOptions(*, behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high'], rag_enabled: bool, hallucinations_enabled: bool)#
Bases:
BaseModel
- behavior: Literal['observe', 'flag', 'block']#
- hallucinations_enabled: bool#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'behavior': FieldInfo(annotation=Literal['observe', 'flag', 'block'], required=True), 'hallucinations_enabled': FieldInfo(annotation=bool, required=True), 'rag_enabled': FieldInfo(annotation=bool, required=True), 'sensitivity': FieldInfo(annotation=Literal['low', 'medium', 'high'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- rag_enabled: bool#
- sensitivity: Literal['low', 'medium', 'high']#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.ValidationOptions(*, upper_threshold: float | None = None, upper_threshold_inclusive: float | None = None, lower_threshold: float | None = None, lower_threshold_inclusive: float | None = None, one_of: Tuple[str | float | int, ...] | None = None, none_of: Tuple[str | float | int, ...] | None = None, must_be_non_none: bool | None = None, must_be_none: bool | None = None)#
Bases:
BaseModel
- lower_threshold: float | None#
- lower_threshold_inclusive: float | None#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'lower_threshold': FieldInfo(annotation=Union[float, NoneType], required=False), 'lower_threshold_inclusive': FieldInfo(annotation=Union[float, NoneType], required=False), 'must_be_non_none': FieldInfo(annotation=Union[bool, NoneType], required=False), 'must_be_none': FieldInfo(annotation=Union[bool, NoneType], required=False), 'none_of': FieldInfo(annotation=Union[Tuple[Union[str, float, int], ...], NoneType], required=False), 'one_of': FieldInfo(annotation=Union[Tuple[Union[str, float, int], ...], NoneType], required=False), 'upper_threshold': FieldInfo(annotation=Union[float, NoneType], required=False), 'upper_threshold_inclusive': FieldInfo(annotation=Union[float, NoneType], required=False)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- must_be_non_none: bool | None#
- must_be_none: bool | None#
- none_of: Tuple[str | float | int, ...] | None#
- one_of: Tuple[str | float | int, ...] | None#
- upper_threshold: float | None#
- upper_threshold_inclusive: float | None#
- class whylogs_container.whylabs.container.policy.policy_0_0_1.ValidatorOptions(*, validator: Literal['constraint', 'multi_column_constraint', 'presets.recommended'], options: ConstraintValidatorOptions | MultiColumnConstraintValidatorOptions | None = None)#
Bases:
BaseModel
- classmethod hashable_dicts(it: Any)#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'options': FieldInfo(annotation=Union[ConstraintValidatorOptions, MultiColumnConstraintValidatorOptions, NoneType], required=False), 'validator': FieldInfo(annotation=Literal['constraint', 'multi_column_constraint', 'presets.recommended'], required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- options: ConstraintValidatorOptions | MultiColumnConstraintValidatorOptions | None#
- to_langkit_options() LangkitOptions #
- validator: Literal['constraint', 'multi_column_constraint', 'presets.recommended']#
- whylogs_container.whylabs.container.policy.policy_0_0_1.combine_langkit_options(l1: LangkitOptions, l2: LangkitOptions) LangkitOptions #
- whylogs_container.whylabs.container.policy.policy_0_0_1.validator_to_langkit_options(validator: str, options: ValidatorOptions | None) LangkitOptions #
whylogs_container.whylabs.container.policy.ruleset module#
- class whylogs_container.whylabs.container.policy.ruleset.RulesetLibrary#
Bases:
object
- static prompt_bad_actors(behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high']) LangkitOptions #
- static prompt_cost(behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high']) LangkitOptions #
- static prompt_customer_experience(behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high']) LangkitOptions #
- static prompt_misuse(behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high'], topics: List[str]) LangkitOptions #
- static prompt_truthfulness(behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high'], rag_enabled: bool, hallucinations_enabled: bool) LangkitOptions #
- static response_bad_actors(behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high']) LangkitOptions #
- static response_cost(behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high']) LangkitOptions #
- static response_customer_experience(behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high']) LangkitOptions #
- static response_misuse(behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high'], topics: List[str]) LangkitOptions #
- static response_truthfulness(behavior: Literal['observe', 'flag', 'block'], sensitivity: Literal['low', 'medium', 'high'], rag_enabled: bool, hallucinations_enabled: bool) LangkitOptions #
whylogs_container.whylabs.container.policy.scores module#
- whylogs_container.whylabs.container.policy.scores.get_score_workflow(rulesets: Sequence[PromptMisuseRuleSet | PromptBadActorsRuleSet | PromptCustomerExperienceRuleSet | PromptTruthfulnessRuleSet | PromptCostRuleSet | ResponseMisuseRuleSet | ResponseBadActorsRuleSet | ResponseCustomerExperienceRuleSet | ResponseTruthfulnessRuleSet | ResponseCostRuleSet]) Workflow #
Module contents#
- class whylogs_container.whylabs.container.policy.Policy(*, whylabs_dataset_id: str, id: str, policy_version: int, schema_version: Literal['0.0.1'] = '0.0.1', metrics: Tuple[LangkitMetric, ...] | None = None, callbacks: Tuple[CallbackOptions, ...] | None = None, validators: Tuple[ValidatorOptions, ...] | None = None, rulesets: Tuple[MisuseRuleSet | BadActorsRuleSet | CustomerExperienceRuleSet | TruthfulnessRuleSet | CostRuleSet | PromptMisuseRuleSet | PromptBadActorsRuleSet | PromptCustomerExperienceRuleSet | PromptTruthfulnessRuleSet | PromptCostRuleSet | ResponseMisuseRuleSet | ResponseBadActorsRuleSet | ResponseCustomerExperienceRuleSet | ResponseTruthfulnessRuleSet | ResponseCostRuleSet, ...] | None = None, actions: ActionOptions | None = None)#
Bases:
BaseModel
- actions: ActionOptions | None#
- callbacks: Tuple[CallbackOptions, ...] | None#
- classmethod ensure_str(it: Any)#
Ensure that these fields are parsed as strings. The python yaml parser sometimes pickes ints or floats if these are defined as something like 1.
- get_rulesets() Sequence[PromptMisuseRuleSet | PromptBadActorsRuleSet | PromptCustomerExperienceRuleSet | PromptTruthfulnessRuleSet | PromptCostRuleSet | ResponseMisuseRuleSet | ResponseBadActorsRuleSet | ResponseCustomerExperienceRuleSet | ResponseTruthfulnessRuleSet | ResponseCostRuleSet] #
- id: str#
- metrics: Tuple[LangkitMetric, ...] | None#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'actions': FieldInfo(annotation=Union[ActionOptions, NoneType], required=False), 'callbacks': FieldInfo(annotation=Union[Tuple[CallbackOptions, ...], NoneType], required=False, default_factory=tuple), 'id': FieldInfo(annotation=str, required=True), 'metrics': FieldInfo(annotation=Union[Tuple[LangkitMetric, ...], NoneType], required=False, default_factory=tuple), 'policy_version': FieldInfo(annotation=int, required=True), 'rulesets': FieldInfo(annotation=Union[Tuple[Union[MisuseRuleSet, BadActorsRuleSet, CustomerExperienceRuleSet, TruthfulnessRuleSet, CostRuleSet, PromptMisuseRuleSet, PromptBadActorsRuleSet, PromptCustomerExperienceRuleSet, PromptTruthfulnessRuleSet, PromptCostRuleSet, ResponseMisuseRuleSet, ResponseBadActorsRuleSet, ResponseCustomerExperienceRuleSet, ResponseTruthfulnessRuleSet, ResponseCostRuleSet], ...], NoneType], required=False, default_factory=tuple), 'schema_version': FieldInfo(annotation=Literal['0.0.1'], required=False, default='0.0.1'), 'validators': FieldInfo(annotation=Union[Tuple[ValidatorOptions, ...], NoneType], required=False, default_factory=tuple), 'whylabs_dataset_id': FieldInfo(annotation=str, required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- policy_version: int#
- rulesets: Tuple[MisuseRuleSet | BadActorsRuleSet | CustomerExperienceRuleSet | TruthfulnessRuleSet | CostRuleSet | PromptMisuseRuleSet | PromptBadActorsRuleSet | PromptCustomerExperienceRuleSet | PromptTruthfulnessRuleSet | PromptCostRuleSet | ResponseMisuseRuleSet | ResponseBadActorsRuleSet | ResponseCustomerExperienceRuleSet | ResponseTruthfulnessRuleSet | ResponseCostRuleSet, ...] | None#
- schema_version: Literal['0.0.1']#
- to_langkit_options() LangkitOptions #
- validators: Tuple[ValidatorOptions, ...] | None#
- whylabs_dataset_id: str#