Update process_data.py
Browse files- process_data.py +44 -7
process_data.py
CHANGED
|
@@ -191,6 +191,14 @@ def generate_json_pieces(input_data, parameters):
|
|
| 191 |
],
|
| 192 |
response_format=FarmActivitiesLite,
|
| 193 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
plant_response = client.beta.chat.completions.parse(
|
| 196 |
model=model_version, # Use GPT model that supports structured output
|
|
@@ -201,6 +209,13 @@ def generate_json_pieces(input_data, parameters):
|
|
| 201 |
response_format=PlantingLite,
|
| 202 |
)
|
| 203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
log_response = client.beta.chat.completions.parse(
|
| 205 |
model=model_version, # Use GPT model that supports structured output
|
| 206 |
messages=[
|
|
@@ -210,6 +225,13 @@ def generate_json_pieces(input_data, parameters):
|
|
| 210 |
response_format=Log,
|
| 211 |
)
|
| 212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
soil_response = client.beta.chat.completions.parse(
|
| 214 |
model=model_version, # Use GPT model that supports structured output
|
| 215 |
messages=[
|
|
@@ -219,6 +241,13 @@ def generate_json_pieces(input_data, parameters):
|
|
| 219 |
response_format=Soil,
|
| 220 |
)
|
| 221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
yield_response = client.beta.chat.completions.parse(
|
| 223 |
model=model_version, # Use GPT model that supports structured output
|
| 224 |
messages=[
|
|
@@ -227,16 +256,24 @@ def generate_json_pieces(input_data, parameters):
|
|
| 227 |
],
|
| 228 |
response_format=Yield,
|
| 229 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
-
combined_json = field_response.choices[0].message.parsed.copy()
|
| 232 |
-
combined_json["plantings"] = plant_response.choices[0].message.parsed
|
| 233 |
-
combined_json["plantings"]["logs"] = log_response.choices[0].message.parsed
|
| 234 |
-
combined_json["plantings"]["soil"] = soil_response.choices[0].message.parsed
|
| 235 |
-
combined_json["plantings"]["yield"] = yield_response.choices[0].message.parsed
|
| 236 |
|
| 237 |
-
print(combined_json) # debugging
|
| 238 |
|
| 239 |
-
pretty_json = combined_json.json()
|
| 240 |
|
| 241 |
# this is a hack because i need to make the other two schemas still
|
| 242 |
return pretty_json, pretty_json, pretty_json
|
|
|
|
| 191 |
],
|
| 192 |
response_format=FarmActivitiesLite,
|
| 193 |
)
|
| 194 |
+
|
| 195 |
+
field_generated_json = field_response.choices[0].message.parsed
|
| 196 |
+
|
| 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(
|
| 204 |
model=model_version, # Use GPT model that supports structured output
|
|
|
|
| 209 |
response_format=PlantingLite,
|
| 210 |
)
|
| 211 |
|
| 212 |
+
plant_generated_json = plant_response.choices[0].message.parsed
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
print("PLANT JSON: ")
|
| 216 |
+
print(plant_generated_json) # debugging
|
| 217 |
+
plant_pretty_json = plant_generated_json.json()
|
| 218 |
+
|
| 219 |
log_response = client.beta.chat.completions.parse(
|
| 220 |
model=model_version, # Use GPT model that supports structured output
|
| 221 |
messages=[
|
|
|
|
| 225 |
response_format=Log,
|
| 226 |
)
|
| 227 |
|
| 228 |
+
log_generated_json = log_response.choices[0].message.parsed
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
print("LOG JSON: ")
|
| 232 |
+
print(log_generated_json) # debugging
|
| 233 |
+
log_pretty_json = log_generated_json.json()
|
| 234 |
+
|
| 235 |
soil_response = client.beta.chat.completions.parse(
|
| 236 |
model=model_version, # Use GPT model that supports structured output
|
| 237 |
messages=[
|
|
|
|
| 241 |
response_format=Soil,
|
| 242 |
)
|
| 243 |
|
| 244 |
+
soil_generated_json = soil_response.choices[0].message.parsed
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
print("SOIL JSON: ")
|
| 248 |
+
print(soil_generated_json) # debugging
|
| 249 |
+
soil_pretty_json = soil_generated_json.json()
|
| 250 |
+
|
| 251 |
yield_response = client.beta.chat.completions.parse(
|
| 252 |
model=model_version, # Use GPT model that supports structured output
|
| 253 |
messages=[
|
|
|
|
| 256 |
],
|
| 257 |
response_format=Yield,
|
| 258 |
)
|
| 259 |
+
|
| 260 |
+
yield_generated_json = yield_response.choices[0].message.parsed
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
print("YIELD JSON: ")
|
| 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
|