agent_studio.utils.json_utils
#
Module Contents#
Functions#
|
Reads lines from a .jsonl file between start_idx and end_idx. |
|
Adds a list of dictionaries to a .jsonl file. |
|
Reads a dictionary from a .json file. |
|
Prints a dictionary in a formatted way. |
|
Exports the trajectory data to a .jsonl file. |
|
|
|
- agent_studio.utils.json_utils.read_jsonl(file_path: str, start_idx: int = 0, end_idx: int | None = None) list [source]#
Reads lines from a .jsonl file between start_idx and end_idx.
- Parameters:
file_path (str) – Path to the .jsonl file
start_idx (int, optional) – The starting index of lines to read
end_idx (int | None, optional) – The ending index of lines to read
- Returns:
- A list of dictionaries, each dictionary is a line from
the .jsonl file
- Return type:
list[dict]
- agent_studio.utils.json_utils.add_jsonl(data: list, file_path: str, mode='a')[source]#
Adds a list of dictionaries to a .jsonl file.
- Parameters:
data (list[dict]) – A list of json objects to add to the file
file_path (str) – Path to the .jsonl file
- agent_studio.utils.json_utils.read_json(file_path: str) dict [source]#
Reads a dictionary from a .json file.
- Parameters:
file_path (str) – Path to the .json file
- Returns:
The dictionary read from the file
- Return type:
dict
- agent_studio.utils.json_utils.format_json(data: dict, indent=4, sort_keys=False)[source]#
Prints a dictionary in a formatted way.
- Parameters:
data (dict) – The dictionary to print
- agent_studio.utils.json_utils.export_trajectories(self_eval_results: dict | None, task_config: dict, trajectory: list, record_path: str, score: float | None, feedback: str | None, token_count: int | None, video_meta: dict | None = None, jsonl_name: str = 'results.jsonl') None [source]#
Exports the trajectory data to a .jsonl file.