class TestModel(BaseModel):
"test", "test2"]
tags: t.Literal["test", "test2"], Select(colors=["red", "blue"])]
tags_with_colors: t.Annotated[t.Literal[str, Url()]
url: t.Annotated[ score: MetricResult
Typing Module
t.Annotate
.
Supported Types
Here we have the supported types and meta-types.
The API supports the following column types:
number
: Numeric valueslongText
: Text contentselect
: Single selection from predefined optionsdate
: Date valuesmultiSelect
: Multiple selections from predefined optionscheckbox
: Boolean valuesurl
: url fieldscustom
: Custom column types with specific behavior
Each column type has specific settings that can be configured through the settings
object.
ColumnType
ColumnType (value, names=None, module=None, qualname=None, type=None, start=1)
Column types supported by the Ragas API.
FieldMeta
FieldMeta (type, required=True, id:Optional[str]=None, settings:Optional[dict]=None)
Base metadata for field type annotations.
Number
Number (min_value:Optional[float]=None, max_value:Optional[float]=None, required:bool=True, id:Optional[str]=None)
Number field metadata.
Text
Text (max_length:int=1000, required:bool=True, id:Optional[str]=None)
Text field metadata.
Url
Url (required:bool=True, id:Optional[str]=None)
Url field metadata.
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*
Select
Select (options:Optional[List[str]]=None, required:bool=True, colors:Optional[List[str]]=None)
Select field metadata.
MultiSelect
MultiSelect (options:Optional[List[str]]=None, required:bool=True)
MultiSelect field metadata.
Checkbox
Checkbox (required:bool=True)
Checkbox field metadata.
Date
Date (include_time:bool=False, required:bool=True)
Date field metadata.
Custom
Custom (custom_type:str='', required:bool=True)
Custom field metadata.
ModelConverter
ModelConverter
ModelConverter ()
Convert Pydantic models to Ragas API columns and rows.
infer_metric_result_type
infer_metric_result_type (field_value)
Infer field type from a MetricResult instance.
infer_field_type
infer_field_type (annotation, field_info)
Infer field type from Python type annotation.
ModelConverter.model_to_columns
ModelConverter.model_to_columns (model_class)
Convert a Pydantic model class to Ragas API column definitions.
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}]
ModelConverter.instance_to_row
ModelConverter.instance_to_row (instance, model_class=None)
Convert a Pydantic model instance to a Ragas API row.
ModelConverter.instances_to_rows
ModelConverter.instances_to_rows (instances, model_class=None)
Convert multiple Pydantic model instances to Ragas API rows.