afnio.trainer#

class afnio.trainer.Trainer(*, max_epochs=None, enable_checkpointing=True, enable_progress_bar=True, enable_agent_summary=True, default_root_dir=None)[source]#

Bases: object

fit(agent, train_dataloader=None, val_dataloader=None, ckpt_path=None, llm_clients=[])[source]#

Runs the full optimization routine.

Parameters:
  • agent (Module) – AI agent (or flow) to fit.

  • train_dataloader (Union[Iterable[Any], DataLoader, None]) – An iterable or DataLoader specifying training samples.

  • val_dataloader (Union[Iterable[Any], DataLoader, None]) – An iterable or or DataLoader specifying validation samples.

  • ckpt_path (Union[str, Path, None]) – Path of the checkpoint from which training is resumed. Otherwise, if there is no checkpoint file at the path, an exception is raised.

  • llm_clients (Optional[List[BaseModel]]) – Optional list of LLM clients used during training. If provided this list is used to calculate the total cost of training (in USD).

Raises:

TypeError – If agent is not Module.

predict()[source]#
test(agent, test_dataloader=None, llm_clients=[])[source]#
validate(agent, val_dataloader=None, llm_clients=[])[source]#

Modules