|
from hundred_system_prompts import * |
|
import inspect |
|
import json |
|
|
|
def convert_triplets_to_json(triplets, json_file_path): |
|
json_data = [] |
|
for prompt, probe, func in triplets: |
|
|
|
source = inspect.getsource(func) |
|
|
|
|
|
last_comma_index = source.rfind(',') |
|
|
|
lambda_start = source.find('lambda') |
|
lambda_source = source[lambda_start:last_comma_index-1] |
|
|
|
json_data.append({"prompt": prompt, "probe": probe, "function": lambda_source}) |
|
|
|
|
|
with open(json_file_path, 'w', encoding='utf-8') as file: |
|
json.dump(json_data, file, ensure_ascii=False, indent=4) |
|
|
|
print(f"JSON file created at: {json_file_path}") |
|
|
|
|
|
convert_triplets_to_json(system_prompts, 'hundred_system_prompts.json') |