rosemariafontana commited on
Commit
05f03c4
·
verified ·
1 Parent(s): 443fc96

Update process_data.py

Browse files
Files changed (1) hide show
  1. process_data.py +22 -20
process_data.py CHANGED
@@ -42,10 +42,10 @@ def generate_json(input_data, parameters):
42
  interactions_prompt = "Extract the interactions information."
43
  trial_prompt = "Extract the trial information."
44
 
45
- if input_data["input_context"]:
46
- farm_prompt = input_data["input_context"] + farm_prompt
47
- interactions_prompt = input_data["input_context"] + interactions_prompt
48
- trial_prompt = input_data["input_context"] + trial_prompt
49
 
50
 
51
  try:
@@ -166,11 +166,12 @@ def generate_json_pieces(input_data, parameters):
166
  # figure out what happens when there's
167
  # chaining, pre-prompts, context, etc ....
168
 
169
- if input_data["input_context"]:
170
- field_prompt = input_data["input_text_pieces"]["field_data_input"] + field_prompt
171
- # farm_prompt = input_data["input_text_pieces"]["field_data_input"] + farm_prompt
172
- # farm_prompt = input_data["input_text_pieces"]["field_data_input"] + farm_prompt
173
- # farm_prompt = input_data["input_text_pieces"]["field_data_input"] + farm_prompt
 
174
 
175
  try:
176
  # Call OpenAI API to generate structured output based on prompt
@@ -255,7 +256,7 @@ def pre_processing(input_data, parameters):
255
 
256
  Returns:
257
  (dict) input_data
258
- input_data["input_context"] = (bool) whether the input text should be used as context or not
259
  input_data["input_text"] = (str) input text
260
  """
261
  if input_data["stepwise_json_creation"] == "stepwisejsoncreation":
@@ -275,9 +276,10 @@ def pre_processing(input_data, parameters):
275
  input_data["input_text_pieces"]["pre_processed_pieces"][text_label] = response_text
276
  else:
277
  # Add in here the other schemas (interactions and trials)
278
- input_context = f"You are processing farm activity data. Here's important context of the data {parameters['combined_prompt']}. With this context in mind, "
279
- input_data["input_context"] = input_context
280
- return input_data
 
281
 
282
 
283
  if input_data["stepwise_json_creation"] == "singlejsoncreation":
@@ -317,13 +319,13 @@ def pre_processing(input_data, parameters):
317
  except Exception as e:
318
  print(f"Failed to parse response as JSON. Error was: {e}")
319
 
320
- input_data["input_context"] = False
321
- input_data["input_text"] = input_text
322
- return input_data
323
  else:
324
- input_context = f"You are processing farm activity, interactions, and trial data. Here's important context of the data {parameters['combined_prompt']}. With this context in mind, "
325
- input_data["input_context"] = input_context
326
- return input_data
327
 
328
 
329
 
@@ -366,7 +368,7 @@ def process_specifications(input_data, parameters):
366
  return generate_json_pieces(processed_input, parameters)
367
  elif input_data["stepwise_json_creation"][0] == "singlejsoncreation":
368
  print("You are elifing into single json creation")
369
- input_data["input_context"] = False
370
  if parameters["pre_prompt"] == True:
371
  print("You are preprocessing now")
372
  processed_input = pre_processing(input_data, parameters)
 
42
  interactions_prompt = "Extract the interactions information."
43
  trial_prompt = "Extract the trial information."
44
 
45
+ if parameters["combined_pre_prompt"]:
46
+ farm_prompt = parameters["combined_pre_prompt"] + farm_prompt
47
+ interactions_prompt = parameters["combined_pre_prompt"] + interactions_prompt
48
+ trial_prompt = parameters["combined_pre_prompt"] + trial_prompt
49
 
50
 
51
  try:
 
166
  # figure out what happens when there's
167
  # chaining, pre-prompts, context, etc ....
168
 
169
+ if parameters["combined_pre_prompt"]:
170
+ field_prompt = parameters["combined_pre_prompt"] + field_prompt
171
+ plant_prompt = parameters["combined_pre_prompt"] + plant_prompt
172
+ log_prompt = parameters["combined_pre_prompt"] + log_prompt
173
+ soil_prompt = parameters["combined_pre_prompt"] + soil_prompt
174
+ yield_prompt = parameters["combined_pre_prompt"] + yield_prompt
175
 
176
  try:
177
  # Call OpenAI API to generate structured output based on prompt
 
256
 
257
  Returns:
258
  (dict) input_data
259
+ input_data["input_context"] = (str) the text which should be used as context or "EMPTY" to indicate there is no context
260
  input_data["input_text"] = (str) input text
261
  """
262
  if input_data["stepwise_json_creation"] == "stepwisejsoncreation":
 
276
  input_data["input_text_pieces"]["pre_processed_pieces"][text_label] = response_text
277
  else:
278
  # Add in here the other schemas (interactions and trials)
279
+ #if parameters['combined_prompt']:
280
+ # input_context = f"You are processing farm activity data. Here's important context of the data {parameters['combined_pre_prompt']}. With this context in mind, "
281
+ # input_data["input_context"] = input_context
282
+ # return input_data
283
 
284
 
285
  if input_data["stepwise_json_creation"] == "singlejsoncreation":
 
319
  except Exception as e:
320
  print(f"Failed to parse response as JSON. Error was: {e}")
321
 
322
+ #input_data["input_context"] = "EMPTY"
323
+ #input_data["input_text"] = input_text
324
+ #return input_data
325
  else:
326
+ #input_context = f"You are processing farm activity, interactions, and trial data. Here's important context of the data {parameters['combined_pre_prompt']}. With this context in mind, "
327
+ #input_data["input_context"] = input_context
328
+ #return input_data
329
 
330
 
331
 
 
368
  return generate_json_pieces(processed_input, parameters)
369
  elif input_data["stepwise_json_creation"][0] == "singlejsoncreation":
370
  print("You are elifing into single json creation")
371
+ #input_data["input_context"] = "EMPTY"
372
  if parameters["pre_prompt"] == True:
373
  print("You are preprocessing now")
374
  processed_input = pre_processing(input_data, parameters)