Skip to content

Callbacks

rupsycho.callbacks.answer_saving_callbacks

Callback

Abstract base class for implementing custom callbacks for saving answers.

save_answer abstractmethod

save_answer(experiment, instruction_item_id, instruction_item, model_id, profile_id, random_seed, time, answer)

Method to be implemented by subclasses to save the answer.

Args: - experiment: The experiment instance (self) being processed. - instruction_item_id: The unique ID of the instruction item. - instruction_item: The instruction item being processed. - model_id: The identifier of the model used for generating the answer. - profile_id: The identifier of the demographic profile. - random_seed: The random seed used for generating the answer. - time: Seconds it took to generate the answer. - answer: The generated answer for the instruction item.

JSONLCallback

JSONLCallback(file_path='experiment_output.jsonl')

Callback implementation for saving answers to a JSONL file.

CSVCallback

CSVCallback(file_path='experiment_output.csv')

Callback implementation for saving answers to a CSV file.

PrintCallback

Callback implementation for printing answers to the screen.

PrintTableCallback

PrintTableCallback()

Callback implementation for printing answers in a fixed-width, table-like format without line breaks, restricting the question and answer to 100 characters each, and printing headers only once.