Datasets:

Modalities:
Text
Formats:
json
Languages:
English
Size:
< 1K
ArXiv:
Libraries:
Datasets
pandas
License:
File size: 1,018 Bytes
d6cf209
 
 
f9e51f9
d6cf209
 
 
 
f9e51f9
 
 
 
d6cf209
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from hundred_system_prompts import *
import inspect
import json
import random

def convert_triplets_to_json(triplets, json_file_path):
    json_data = []
    for prompt, probe, func in triplets:
        # If needed, change the probe to be random
        if probe == "random":
            probe = random.choice(random_probes)
        
        # Get the source of the function
        source = inspect.getsource(func)

        # Find the index of the last comma in the source
        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})

    # Write to the JSON file
    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}")

# Example usage:
convert_triplets_to_json(system_prompts, 'hundred_system_prompts.json')