rosemariafontana commited on
Commit
5802390
·
verified ·
1 Parent(s): 632b9a9

Update script_for_automation.py

Browse files
Files changed (1) hide show
  1. script_for_automation.py +72 -32
script_for_automation.py CHANGED
@@ -12,8 +12,8 @@ from jsondiff import diff
12
  # First, get the gold standard JSONs from baserow
13
  # Next, get the recipe parameter list from the input folder
14
  # Iterate through the recipe parameter list one at a time
15
- # In the iteration, first fill out a surveystack submission
16
- # Next, save the surveystack submission ID
17
  # Use the iteration parameters to then get the three JSONs back from chatgpt
18
  # Compare the JSONs to the gold standard JSONs
19
  # Print out the differences in a .csv
@@ -76,20 +76,20 @@ def get_baserow_data():
76
  wally_squash_greg_summary_preprocessing = row.get("Post-Interview Summary")
77
 
78
  gold_standards = {
79
- "planting_gold_standards": {
80
- "liz_carrot": liz_carrot_plantings_gold_standard,
81
- "ben_soybean": ben_soybean_plantings_gold_standard,
82
- "wally_squash": wally_squash_plantings_gold_standard
83
  },
84
- "interactions_gold_standards": {
85
- "liz_carrot": liz_carrot_interactions_gold_standard,
86
- "ben_soybean": ben_soybean_interactions_gold_standard,
87
- "wally_squash": wally_squash_interactions_gold_standard
88
  },
89
- "trial_gold_standards": {
90
- "liz_carrot": liz_carrot_trials_gold_standard,
91
- "ben_soybean": ben_soybean_trials_gold_standard,
92
- "wally_squash": wally_squash_trials_gold_standard
93
  }
94
  }
95
 
@@ -99,23 +99,23 @@ def get_baserow_data():
99
  # wally_squash_trial = gold_standards["trial_gold_standards"]["wally_squash"]
100
 
101
  input_data = {
102
- "raw_interview": {
103
- "liz_carrot": liz_carrot_input_data_raw_interview,
104
- "ben_soybean": ben_soybean_input_data_raw_interview,
105
- "wally_squash": wally_squash_input_data_raw_interview
106
  },
107
- "otter_summary": {
108
- "liz_carrot": liz_carrot_otter_summary_preprocessing,
109
- "ben_soybean": ben_soybean_otter_summary_preprocessing,
110
- "wally_squash": wally_squash_otter_summary_preprocessing
111
  },
112
- "summary": {
113
- "liz_carrot": liz_carrot_greg_summary_preprocessing,
114
- "ben_soybean": ben_soybean_greg_summary_preprocessing,
115
- "wally_squash": wally_squash_greg_summary_preprocessing
116
  }
117
  }
118
-
119
  return gold_standards, input_data
120
 
121
  except requests.exceptions.RequestException as e:
@@ -183,7 +183,7 @@ def fill_out_survey(recipe_dict, input_data):
183
  "survey": survey_id,
184
  "data": {
185
  "inputstyle": "big-block-input-text",
186
- "onelonginputtext": recipe_dict["schema_processing_model"],
187
  "schema_prompt": {
188
  "firstschemaprompt": recipe_dict["plantings_and_fields_prompt"],
189
  "secondschemaprompt": recipe_dict["interactions_prompt"],
@@ -206,7 +206,7 @@ def fill_out_survey(recipe_dict, input_data):
206
  "survey": survey_id,
207
  "data": {
208
  "inputstyle": "big-block-input-text",
209
- "onelonginputtext": recipe_dict["schema_processing_model"],
210
  "schema_prompt": {
211
  "firstschemaprompt": recipe_dict["plantings_and_fields_prompt"],
212
  "secondschemaprompt": recipe_dict["interactions_prompt"],
@@ -219,12 +219,52 @@ def fill_out_survey(recipe_dict, input_data):
219
  }
220
  }
221
  }
222
-
223
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
 
225
- return "pumpkin"
226
 
227
  def drive_process():
228
  # this is to drive the processing process
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  return "banana"
230
 
 
12
  # First, get the gold standard JSONs from baserow
13
  # Next, get the recipe parameter list from the input folder
14
  # Iterate through the recipe parameter list one at a time
15
+ # In the iteration, first fill out a surveystack submission - is this possible with the current surveystack API?
16
+ # Next, save the surveystack submission ID (?)
17
  # Use the iteration parameters to then get the three JSONs back from chatgpt
18
  # Compare the JSONs to the gold standard JSONs
19
  # Print out the differences in a .csv
 
76
  wally_squash_greg_summary_preprocessing = row.get("Post-Interview Summary")
77
 
78
  gold_standards = {
79
+ "liz_carrot": {
80
+ "planting": liz_carrot_plantings_gold_standard,
81
+ "interactions": liz_carrot_interactions_gold_standard,
82
+ "trials": liz_carrot_trials_gold_standard,
83
  },
84
+ "ben_soybean": {
85
+ "planting": ben_soybean_plantings_gold_standard,
86
+ "interactions": ben_soybean_interactions_gold_standard,
87
+ "trials": ben_soybean_trials_gold_standard,
88
  },
89
+ "wally_squash": {
90
+ "planting": wally_squash_plantings_gold_standard,
91
+ "interactions": wally_squash_interactions_gold_standard,
92
+ "trials": wally_squash_trials_gold_standard,
93
  }
94
  }
95
 
 
99
  # wally_squash_trial = gold_standards["trial_gold_standards"]["wally_squash"]
100
 
101
  input_data = {
102
+ "liz_carrot": {
103
+ "raw_interview": liz_carrot_input_data_raw_interview,
104
+ "otter_summary": liz_carrot_otter_summary_preprocessing,
105
+ "greg_summary": liz_carrot_greg_summary_preprocessing
106
  },
107
+ "ben_soybean": {
108
+ "raw_interview": ben_soybean_input_data_raw_interview,
109
+ "otter_summary": ben_soybean_otter_summary_preprocessing,
110
+ "greg_summary": ben_soybean_greg_summary_preprocessing
111
  },
112
+ "wally_squash": {
113
+ "raw_interview": wally_squash_input_data_raw_interview,
114
+ "otter_summary": wally_squash_otter_summary_preprocessing,
115
+ "greg_summary": wally_squash_greg_summary_preprocessing
116
  }
117
  }
118
+
119
  return gold_standards, input_data
120
 
121
  except requests.exceptions.RequestException as e:
 
183
  "survey": survey_id,
184
  "data": {
185
  "inputstyle": "big-block-input-text",
186
+ "onelonginputtext": input_data,
187
  "schema_prompt": {
188
  "firstschemaprompt": recipe_dict["plantings_and_fields_prompt"],
189
  "secondschemaprompt": recipe_dict["interactions_prompt"],
 
206
  "survey": survey_id,
207
  "data": {
208
  "inputstyle": "big-block-input-text",
209
+ "onelonginputtext": input_data,
210
  "schema_prompt": {
211
  "firstschemaprompt": recipe_dict["plantings_and_fields_prompt"],
212
  "secondschemaprompt": recipe_dict["interactions_prompt"],
 
219
  }
220
  }
221
  }
222
+
223
+ headers = {
224
+ "Content-Type": "application/json",
225
+ }
226
+
227
+ try:
228
+ response = requests.post(base_url, headers=headers, data=json.dumps(submission_data))
229
+ response.raise_for_status()
230
+
231
+ if response.status_code == 200:
232
+ print("Submission successful to SurveyStack!")
233
+ print(response.json())
234
+ else:
235
+ print(f"Failed to submit: {response.status_code} - {response.text}")
236
+ except requests.exceptions.RequestException as e:
237
+ print(f"An error occurred while submitting the data: {e}")
238
 
 
239
 
240
  def drive_process():
241
  # this is to drive the processing process
242
+ gold_standards, input_data = get_baserow_data()
243
+ my_recipes = get_recipes()
244
+
245
+ # Input chunk structure
246
+ # "liz_carrot": {
247
+ # "raw_interview": liz_carrot_input_data_raw_interview,
248
+ # "otter_summary": liz_carrot_otter_summary_preprocessing,
249
+ # "greg_summary": liz_carrot_greg_summary_preprocessing
250
+ # },
251
+
252
+ for recipe_dict in my_recipes:
253
+ for key, input_chunks in input_data.items():
254
+ if recipe_dict["pre_processing_strategy"] == "Otter.ai Summary":
255
+ input_data = input_chunks["otter_summary"]
256
+ elif recipe_dict["pre_processing_strategy"] == "Greg Summary":
257
+ input_data = input_chunks["greg_summary"]
258
+ else:
259
+ input_data = input_chunks["raw_interview"]
260
+
261
+ fill_out_survey(recipe_dict, input_data)
262
+
263
+
264
+ # This is for after doing the stuff with chatgpt actually
265
+ gold_standard_dict = gold_standard[key]
266
+ difference = diff(gold_standard_dict, )
267
+
268
+
269
  return "banana"
270