Experiment¶
- class opik.api_objects.experiment.experiment.Experiment(id: str, name: str | None, dataset_name: str, rest_client: OpikApi, prompts: List[Prompt] | None = None)¶
Bases:
object
- __init__(id: str, name: str | None, dataset_name: str, rest_client: OpikApi, prompts: List[Prompt] | None = None) None ¶
- property id: str¶
- property dataset_id: str¶
- property dataset_name: str¶
- property name: str¶
- insert(experiment_items_references: List[ExperimentItemReferences]) None ¶
Creates a new experiment item by linking the existing trace and dataset item.
- Parameters:
experiment_items_references – The list of ExperimentItemReferences objects, containing trace id and dataset item id to link together into experiment item.
- Returns:
None
- get_items(max_results: int | None = None, truncate: bool = False) List[ExperimentItemContent] ¶
Retrieves and returns a list of experiment items by streaming from the backend in batches, with an option to truncate the results for each batch.
This method streams experiment items from a backend service in chunks up to the specified max_results or until the available items are exhausted. It handles batch-wise retrieval and parsing, ensuring the client receives a list of ExperimentItemContent objects, while respecting the constraints on maximum retrieval size from the backend. If truncation is enabled, the backend may return truncated details for each item.
- Parameters:
max_results – Maximum number of experiment items to retrieve.
truncate – Whether to truncate the items returned by the backend.