Typing Module

Field Metadata for python’s t.Annotate.

Supported Types

Here we have the supported types and meta-types.

The API supports the following column types:

  • number: Numeric values
  • longText: Text content
  • select: Single selection from predefined options
  • date: Date values
  • multiSelect: Multiple selections from predefined options
  • checkbox: Boolean values
  • url: url fields
  • custom: Custom column types with specific behavior

Each column type has specific settings that can be configured through the settings object.


source

ColumnType

 ColumnType (value, names=None, module=None, qualname=None, type=None,
             start=1)

Column types supported by the Ragas API.


source

FieldMeta

 FieldMeta (type, required=True, id:Optional[str]=None,
            settings:Optional[dict]=None)

Base metadata for field type annotations.


source

Number

 Number (min_value:Optional[float]=None, max_value:Optional[float]=None,
         required:bool=True, id:Optional[str]=None)

Number field metadata.


source

Text

 Text (max_length:int=1000, required:bool=True, id:Optional[str]=None)

Text field metadata.


source

Url

 Url (required:bool=True, id:Optional[str]=None)

Url field metadata.


source

get_colors_for_options

 get_colors_for_options (options, color_names=None)

*Assign colors to options from the COLOR_MAP.

Args: options: List of option names color_names: Optional list of specific color names to use from COLOR_MAP If None, colors will be assigned in order from COLOR_MAP

Returns: List of option objects with name, value, and color properties*


source

Select

 Select (options:Optional[List[str]]=None, required:bool=True,
         colors:Optional[List[str]]=None)

Select field metadata.


source

MultiSelect

 MultiSelect (options:Optional[List[str]]=None, required:bool=True)

MultiSelect field metadata.


source

Checkbox

 Checkbox (required:bool=True)

Checkbox field metadata.


source

Date

 Date (include_time:bool=False, required:bool=True)

Date field metadata.


source

Custom

 Custom (custom_type:str='', required:bool=True)

Custom field metadata.

ModelConverter


source

ModelConverter

 ModelConverter ()

Convert Pydantic models to Ragas API columns and rows.


source

infer_metric_result_type

 infer_metric_result_type (field_value)

Infer field type from a MetricResult instance.


source

infer_field_type

 infer_field_type (annotation, field_info)

Infer field type from Python type annotation.


source

ModelConverter.model_to_columns

 ModelConverter.model_to_columns (model_class)

Convert a Pydantic model class to Ragas API column definitions.

class TestModel(BaseModel):
    tags: t.Literal["test", "test2"]
    tags_with_colors: t.Annotated[t.Literal["test", "test2"], Select(colors=["red", "blue"])]
    url: t.Annotated[str, Url()]
    score: MetricResult
ModelConverter.model_to_columns(TestModel)
[{'id': 'tags',
  'name': 'tags',
  'type': 'select',
  'settings': {'width': 255,
   'isVisible': True,
   'isEditable': True,
   'options': [{'name': 'test', 'value': 'test', 'color': 'hsl(0, 85%, 60%)'},
    {'name': 'test2', 'value': 'test2', 'color': 'hsl(30, 85%, 60%)'}],
   'position': 0}},
 {'id': 'tags_with_colors',
  'name': 'tags_with_colors',
  'type': 'select',
  'settings': {'width': 255,
   'isVisible': True,
   'isEditable': True,
   'options': [{'name': 'test', 'value': 'test', 'color': 'hsl(0, 85%, 60%)'},
    {'name': 'test2', 'value': 'test2', 'color': 'hsl(210, 85%, 60%)'}],
   'position': 1}},
 {'id': 'url',
  'name': 'url',
  'type': 'url',
  'settings': {'width': 255,
   'isVisible': True,
   'isEditable': True,
   'position': 2}},
 {'id': 'score',
  'name': 'score',
  'type': 'longText',
  'settings': {'width': 255,
   'isVisible': True,
   'isEditable': True,
   'max_length': 1000,
   'position': 3}},
 {'id': 'score_reason',
  'name': 'score_reason',
  'type': 'longText',
  'settings': {'width': 255,
   'isVisible': True,
   'isEditable': True,
   'max_length': 1000,
   'position': 4},
  'editable': True}]

source

ModelConverter.instance_to_row

 ModelConverter.instance_to_row (instance, model_class=None)

Convert a Pydantic model instance to a Ragas API row.


source

ModelConverter.instances_to_rows

 ModelConverter.instances_to_rows (instances, model_class=None)

Convert multiple Pydantic model instances to Ragas API rows.