rosemariafontana commited on
Commit
ef76503
·
verified ·
1 Parent(s): 024da2b

Update process_data.py

Browse files
Files changed (1) hide show
  1. process_data.py +1 -16
process_data.py CHANGED
@@ -46,9 +46,6 @@ def generate_json(input_data, parameters):
46
  response_format=FarmActivities,
47
  )
48
 
49
- if 'error' in farm_info_response:
50
- raise ValueError(f"API error: {interactions_response['error']['message']}")
51
-
52
  farm_generated_json = farm_info_response.choices[0].message.parsed
53
 
54
 
@@ -65,9 +62,6 @@ def generate_json(input_data, parameters):
65
  ],
66
  response_format=Interactions,
67
  )
68
-
69
- if 'error' in interactions_response:
70
- raise ValueError(f"API error: {interactions_response['error']['message']}")
71
 
72
  interactions_generated_json = interactions_response.choices[0].message.parsed
73
 
@@ -85,9 +79,6 @@ def generate_json(input_data, parameters):
85
  response_format=Trial,
86
  )
87
 
88
- if 'error' in trial_response:
89
- raise ValueError(f"API error: {trial_response['error']['message']}")
90
-
91
  trial_generated_json = trial_response.choices[0].message.parsed
92
 
93
  print("TRIALS JSON: ")
@@ -175,14 +166,8 @@ def generate_json_pieces(specification, model_version, additional_json_creation_
175
  print(combined_json) # debugging
176
 
177
  pretty_json = combined_json.json()
178
-
179
- if 'error' in response:
180
- raise ValueError(f"API error: {response['error']['message']}")
181
 
182
  return pretty_json
183
-
184
- except ValidationError as e:
185
- return {"error": str(e)}
186
  except Exception as e:
187
  return {"error": "Failed to generate valid JSON. " + str(e)}
188
 
@@ -222,7 +207,7 @@ def pre_processing(input_data, parameters):
222
  ]
223
  )
224
 
225
- response_text = response['choices'][0]['message']['content']
226
  partially_processed_input = json.loads(response_text)
227
  input_text = partially_processed_input
228
 
 
46
  response_format=FarmActivities,
47
  )
48
 
 
 
 
49
  farm_generated_json = farm_info_response.choices[0].message.parsed
50
 
51
 
 
62
  ],
63
  response_format=Interactions,
64
  )
 
 
 
65
 
66
  interactions_generated_json = interactions_response.choices[0].message.parsed
67
 
 
79
  response_format=Trial,
80
  )
81
 
 
 
 
82
  trial_generated_json = trial_response.choices[0].message.parsed
83
 
84
  print("TRIALS JSON: ")
 
166
  print(combined_json) # debugging
167
 
168
  pretty_json = combined_json.json()
 
 
 
169
 
170
  return pretty_json
 
 
 
171
  except Exception as e:
172
  return {"error": "Failed to generate valid JSON. " + str(e)}
173
 
 
207
  ]
208
  )
209
 
210
+ response_text = response.choices[0].message.content
211
  partially_processed_input = json.loads(response_text)
212
  input_text = partially_processed_input
213