rosemariafontana commited on
Commit
ef3a845
·
verified ·
1 Parent(s): 42db456

Update process_data.py

Browse files
Files changed (1) hide show
  1. process_data.py +13 -11
process_data.py CHANGED
@@ -197,7 +197,7 @@ def generate_json_pieces(input_data, parameters):
197
 
198
  print("FIELD JSON: ")
199
  print(field_generated_json) # debugging
200
- farm_pretty_json = field_generated_json.json()
201
 
202
 
203
  plant_response = client.beta.chat.completions.parse(
@@ -264,19 +264,21 @@ def generate_json_pieces(input_data, parameters):
264
  print(yield_generated_json) # debugging
265
  yield_pretty_json = yield_generated_json.json()
266
 
 
 
 
 
 
 
267
 
268
- #combined_json = field_response.choices[0].message.parsed.copy()
269
- #combined_json["plantings"] = plant_response.choices[0].message.parsed
270
- #combined_json["plantings"]["logs"] = log_response.choices[0].message.parsed
271
- #combined_json["plantings"]["soil"] = soil_response.choices[0].message.parsed
272
- #combined_json["plantings"]["yield"] = yield_response.choices[0].message.parsed
273
-
274
- #print(combined_json) # debugging
275
 
276
- #pretty_json = combined_json.json()
277
 
278
- # this is a hack because i need to make the other two schemas still
279
- return pretty_json, pretty_json, pretty_json
280
  except Exception as e:
281
  return {"error": "Failed to generate valid JSON. " + str(e)}
282
 
 
197
 
198
  print("FIELD JSON: ")
199
  print(field_generated_json) # debugging
200
+ field_pretty_json = field_generated_json.json()
201
 
202
 
203
  plant_response = client.beta.chat.completions.parse(
 
264
  print(yield_generated_json) # debugging
265
  yield_pretty_json = yield_generated_json.json()
266
 
267
+ plantings = {
268
+ **plant_pretty_json,
269
+ "logs": log_pretty_json,
270
+ "soil": soil_pretty_json,
271
+ "yield_": yield_pretty_json
272
+ }
273
 
274
+ farm_activities = {
275
+ **field_pretty_json,
276
+ "plantings": plantings
277
+ }
 
 
 
278
 
279
+ final_pretty_json = farm_activities.json()
280
 
281
+ return final_pretty_json, final_pretty_json, final_pretty_json
 
282
  except Exception as e:
283
  return {"error": "Failed to generate valid JSON. " + str(e)}
284