Base Classes

pydantic model ibm_watsonx_gov.entities.base_classes.BaseConfiguration

Bases: BaseModel

Show JSON schema
{
   "title": "BaseConfiguration",
   "type": "object",
   "properties": {
      "record_id_field": {
         "default": "record_id",
         "description": "The record identifier field name.",
         "examples": [
            "record_id"
         ],
         "title": "Record id field",
         "type": "string"
      },
      "record_timestamp_field": {
         "default": "record_timestamp",
         "description": "The record timestamp field name.",
         "examples": [
            "record_timestamp"
         ],
         "title": "Record timestamp field",
         "type": "string"
      }
   }
}

Config:
  • arbitrary_types_allowed: bool = True

Fields:
field record_id_field: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='record_id', title='Record id field', description='The record identifier field name.', examples=['record_id'])] = 'record_id'

The record identifier field name.

field record_timestamp_field: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='record_timestamp', title='Record timestamp field', description='The record timestamp field name.', examples=['record_timestamp'])] = 'record_timestamp'

The record timestamp field name.

pydantic model ibm_watsonx_gov.entities.base_classes.BaseMetric

Bases: BaseModel

Show JSON schema
{
   "title": "BaseMetric",
   "type": "object",
   "properties": {
      "name": {
         "description": "The name of the metric",
         "title": "Metric Name",
         "type": "string"
      }
   },
   "required": [
      "name"
   ]
}

Fields:
field name: Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Metric Name', description='The name of the metric', frozen=True)] [Required]

The name of the metric

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

property id
pydantic model ibm_watsonx_gov.entities.base_classes.BaseMetricGroup

Bases: BaseModel

Show JSON schema
{
   "title": "BaseMetricGroup",
   "type": "object",
   "properties": {
      "name": {
         "description": "The name of the metric group",
         "title": "Name",
         "type": "string"
      }
   },
   "required": [
      "name"
   ]
}

Fields:
field name: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='The name of the metric group')] [Required]

The name of the metric group

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

property metrics: list[BaseMetric]
pydantic model ibm_watsonx_gov.entities.base_classes.BaseMetricResult

Bases: BaseModel

Show JSON schema
{
   "title": "BaseMetricResult",
   "type": "object",
   "properties": {
      "name": {
         "description": "The name of the metric.",
         "examples": [
            "answer_correctness",
            "context_relevance"
         ],
         "title": "Name",
         "type": "string"
      },
      "method": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The method used to compute this metric result.",
         "examples": [
            "token_recall"
         ],
         "title": "Method"
      },
      "provider": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The provider used to compute this metric result.",
         "title": "Provider"
      },
      "value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "description": "The metric value.",
         "title": "Value"
      },
      "errors": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/Error"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The list of error messages",
         "title": "Errors"
      },
      "additional_info": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The additional information about the metric result.",
         "title": "Additional Info"
      },
      "group": {
         "anyOf": [
            {
               "$ref": "#/$defs/MetricGroup"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The metric group"
      },
      "thresholds": {
         "default": [],
         "description": "The metric thresholds",
         "items": {
            "$ref": "#/$defs/MetricThreshold"
         },
         "title": "Thresholds",
         "type": "array"
      }
   },
   "$defs": {
      "Error": {
         "properties": {
            "code": {
               "description": "The error code",
               "title": "Code",
               "type": "string"
            },
            "message_en": {
               "description": "The error message in English.",
               "title": "Message En",
               "type": "string"
            },
            "parameters": {
               "default": [],
               "description": "The list of parameters to construct the message in a different locale.",
               "items": {},
               "title": "Parameters",
               "type": "array"
            }
         },
         "required": [
            "code",
            "message_en"
         ],
         "title": "Error",
         "type": "object"
      },
      "MetricGroup": {
         "enum": [
            "retrieval_quality",
            "answer_quality",
            "content_safety",
            "performance",
            "usage",
            "tool_call_quality",
            "readability"
         ],
         "title": "MetricGroup",
         "type": "string"
      },
      "MetricThreshold": {
         "description": "The class that defines the threshold for a metric.",
         "properties": {
            "type": {
               "description": "Threshold type. One of 'lower_limit', 'upper_limit'",
               "enum": [
                  "lower_limit",
                  "upper_limit"
               ],
               "title": "Type",
               "type": "string"
            },
            "value": {
               "default": 0,
               "description": "The value of metric threshold",
               "title": "Threshold value",
               "type": "number"
            }
         },
         "required": [
            "type"
         ],
         "title": "MetricThreshold",
         "type": "object"
      }
   },
   "required": [
      "name",
      "value"
   ]
}

Config:
  • arbitrary_types_allowed: bool = True

  • use_enum_values: bool = True

Fields:
field additional_info: Annotated[dict | None, FieldInfo(annotation=NoneType, required=False, default=None, description='The additional information about the metric result.')] = None

The additional information about the metric result.

field errors: Annotated[list[Error] | None, FieldInfo(annotation=NoneType, required=False, default=None, description='The list of error messages')] = None

The list of error messages

field group: Annotated[MetricGroup | None, FieldInfo(annotation=NoneType, required=False, default=None, description='The metric group')] = None

The metric group

field method: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='The method used to compute this metric result.', examples=['token_recall'])] = None

The method used to compute this metric result.

field name: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='The name of the metric.', examples=['answer_correctness', 'context_relevance'])] [Required]

The name of the metric.

field provider: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='The provider used to compute this metric result.')] = None

The provider used to compute this metric result.

field thresholds: Annotated[list[MetricThreshold], FieldInfo(annotation=NoneType, required=False, default=[], description='The metric thresholds')] = []

The metric thresholds

field value: Annotated[float | str | bool | None, FieldInfo(annotation=NoneType, required=True, description='The metric value.')] [Required]

The metric value.

pydantic model ibm_watsonx_gov.entities.base_classes.Error

Bases: BaseModel

Show JSON schema
{
   "title": "Error",
   "type": "object",
   "properties": {
      "code": {
         "description": "The error code",
         "title": "Code",
         "type": "string"
      },
      "message_en": {
         "description": "The error message in English.",
         "title": "Message En",
         "type": "string"
      },
      "parameters": {
         "default": [],
         "description": "The list of parameters to construct the message in a different locale.",
         "items": {},
         "title": "Parameters",
         "type": "array"
      }
   },
   "required": [
      "code",
      "message_en"
   ]
}

Fields:
field code: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='The error code')] [Required]

The error code

field message_en: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='The error message in English.')] [Required]

The error message in English.

field parameters: Annotated[list[Any], FieldInfo(annotation=NoneType, required=False, default=[], description='The list of parameters to construct the message in a different locale.')] = []

The list of parameters to construct the message in a different locale.