Update process_data.py
Browse files- process_data.py +7 -6
process_data.py
CHANGED
|
@@ -15,17 +15,18 @@ os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
|
|
| 15 |
client = OpenAI()
|
| 16 |
|
| 17 |
|
| 18 |
-
def generate_json(input_data,
|
| 19 |
"""
|
| 20 |
Function to prompt OpenAI API to generate structured JSON output.
|
| 21 |
"""
|
| 22 |
|
| 23 |
input_text = input_data["input_text"]
|
|
|
|
| 24 |
|
| 25 |
farm_prompt = "Extract the farm information."
|
| 26 |
interactions_prompt = "Extract the interactions information."
|
| 27 |
trial_prompt = "Extract the trial information."
|
| 28 |
-
|
| 29 |
if input_data["input_context"]:
|
| 30 |
farm_prompt = input_data["input_context"] + farm_prompt
|
| 31 |
interactions_prompt = input_data["input_context"] + interactions_prompt
|
|
@@ -240,10 +241,10 @@ def pre_processing(input_data, parameters):
|
|
| 240 |
def process_specifications(input_data, parameters):
|
| 241 |
# here is where parsing and other things will happen before
|
| 242 |
if parameters["pre_prompt"] == True:
|
| 243 |
-
|
| 244 |
-
return generate_json(
|
| 245 |
else:
|
| 246 |
-
return generate_json(input_data
|
| 247 |
|
| 248 |
|
| 249 |
def parse_survey_stack_parameters(data):
|
|
@@ -317,7 +318,7 @@ def parse_survey_stack_parameters(data):
|
|
| 317 |
processed_data["summary_pre_prompt"] = None
|
| 318 |
processed_data["conversation_pre_prompt"] = None
|
| 319 |
processed_data["example_pre_prompt"] = None
|
| 320 |
-
processed_data["chaining"] =
|
| 321 |
processed_data["combined_pre_prompt"] = None
|
| 322 |
|
| 323 |
except Exception as e:
|
|
|
|
| 15 |
client = OpenAI()
|
| 16 |
|
| 17 |
|
| 18 |
+
def generate_json(input_data, parameters):
|
| 19 |
"""
|
| 20 |
Function to prompt OpenAI API to generate structured JSON output.
|
| 21 |
"""
|
| 22 |
|
| 23 |
input_text = input_data["input_text"]
|
| 24 |
+
model_version = parameters["model_version"]
|
| 25 |
|
| 26 |
farm_prompt = "Extract the farm information."
|
| 27 |
interactions_prompt = "Extract the interactions information."
|
| 28 |
trial_prompt = "Extract the trial information."
|
| 29 |
+
|
| 30 |
if input_data["input_context"]:
|
| 31 |
farm_prompt = input_data["input_context"] + farm_prompt
|
| 32 |
interactions_prompt = input_data["input_context"] + interactions_prompt
|
|
|
|
| 241 |
def process_specifications(input_data, parameters):
|
| 242 |
# here is where parsing and other things will happen before
|
| 243 |
if parameters["pre_prompt"] == True:
|
| 244 |
+
processed_input = pre_processing(input_data, parameters)
|
| 245 |
+
return generate_json(processed_input, parameters)
|
| 246 |
else:
|
| 247 |
+
return generate_json(input_data, parameters)
|
| 248 |
|
| 249 |
|
| 250 |
def parse_survey_stack_parameters(data):
|
|
|
|
| 318 |
processed_data["summary_pre_prompt"] = None
|
| 319 |
processed_data["conversation_pre_prompt"] = None
|
| 320 |
processed_data["example_pre_prompt"] = None
|
| 321 |
+
processed_data["chaining"] = False
|
| 322 |
processed_data["combined_pre_prompt"] = None
|
| 323 |
|
| 324 |
except Exception as e:
|