-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharena.py
60 lines (45 loc) · 1.96 KB
/
arena.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from main import *
import csv
import pandas as pd
def json2csv(data):
# Extract the list of people
# create a pandas DataFrame from the dictionary
df = pd.DataFrame.from_dict(data, orient='index')
# reset the index of the DataFrame to create a new column for the index values
df = df.reset_index()
# rename the 'index' column to 'number'
df = df.rename(columns={'index': 'number'})
# save the DataFrame to a CSV file
df.to_csv('output.csv', index=False)
def synthesize_town():
data = {"people": []}
assistant_content = """
You are an AI bot that helps generate synethic identities for democracy testing.
"""
prompt = """
Here is an example identity for a citizen:
{
"name": "Alice Johnson",
"gender": "female",
"age": 35,
"political_leaning": "liberal",
"marital_status": "married",
"education": "bachelor's degree",
"occupation": "software engineer",
"income": 80000,
"religion": "Christian",
"ethnicity": "Asian American",
"nationality": "United States"
}
Generate a new identity and make sure it is different, offering a new perspective of a citizen of Praxis. Look at the following JSON for people already in the city, make sure you generate people that represent new viewpoints and backgrounds.
""" + json.dumps(data) + """
Only output the JSON, do not edit the JSON fields.
"""
messages = [
{"role": "system", "content": assistant_content},
{"role": "user", "content": prompt}
]
#calls = ['gpt4', 'mistral-tiny', 'mistral-small', 'mistral-medium', 'mistral-large']
calls = ['mistral-tiny']
x = combined_calls(calls, messages, prompt, data, times=15)
json2csv(x)