rosemariafontana commited on
Commit
cb0109e
·
verified ·
1 Parent(s): ec69e62

temp comment out

Browse files
Files changed (1) hide show
  1. app.py +38 -37
app.py CHANGED
@@ -139,42 +139,42 @@ def generate_json(specification, model_version):
139
 
140
  try:
141
  # Call OpenAI API to generate structured output based on prompt
142
- farm_info_response = client.beta.chat.completions.parse(
143
- model=model_version, # Use GPT model that supports structured output
144
- messages=[
145
- {"role": "system", "content": "Extract the farm information."},
146
- {"role": "user", "content": specification}
147
- ],
148
- response_format=FarmActivities,
149
- )
150
-
151
- if 'error' in farm_info_response:
152
- raise ValueError(f"API error: {interactions_response['error']['message']}")
153
 
154
- farm_generated_json = farm_info_response.choices[0].message.parsed
155
- print("FARM JSON: ")
156
- print(farm_generated_json) # debugging
157
-
158
- farm_pretty_json = farm_generated_json.json()
159
-
160
- interactions_response = client.beta.chat.completions.parse(
161
- model=model_version, # Use GPT model that supports structured output
162
- messages=[
163
- {"role": "system", "content": "Extract the interactions information."},
164
- {"role": "user", "content": specification}
165
- ],
166
- response_format=Interactions,
167
- )
168
-
169
- if 'error' in interactions_response:
170
- raise ValueError(f"API error: {interactions_response['error']['message']}")
171
 
172
- interactions_generated_json = interactions_response.choices[0].message.parsed
173
 
174
- print("INTERACTIONS JSON: ")
175
- print(interactions_generated_json) # debugging 2
176
 
177
- interactions_pretty_json = interactions_generated_json.json()
178
 
179
 
180
  trial_response = client.beta.chat.completions.parse(
@@ -196,8 +196,8 @@ def generate_json(specification, model_version):
196
 
197
  trial_pretty_json = trial_generated_json.json()
198
 
199
-
200
- return [farm_pretty_json, interactions_pretty_json, trial_pretty_json]
201
 
202
  except ValidationError as e:
203
  return {"error": str(e)}
@@ -315,8 +315,8 @@ with gr.Blocks() as demo:
315
 
316
  with gr.Row():
317
  farm_output_box = gr.Textbox(label="Fields and Activities Output Data")
318
- interactions_output_box = gr.Textbox(label="Interactions Output Data")
319
- trials_output_box = gr.Textbox(label="Trials Output Data")
320
 
321
  def update_visibility(radio, additional_options):
322
  value = radio
@@ -341,7 +341,8 @@ with gr.Blocks() as demo:
341
  submit_button.click(
342
  fn=process_specifications,
343
  inputs=[data_input, model_version_input, json_creation_input, additional_json_creation_options, field_data_input, planting_data_input, logs_data_input, soil_data_input, yield_data_input],
344
- outputs=[farm_output_box, interactions_output_box, trials_output_box]
 
345
  )
346
 
347
  clear_button = gr.ClearButton(components=[data_input, model_version_input, json_creation_input, additional_json_creation_options, field_data_input, planting_data_input, logs_data_input, soil_data_input, yield_data_input])
 
139
 
140
  try:
141
  # Call OpenAI API to generate structured output based on prompt
142
+ #farm_info_response = client.beta.chat.completions.parse(
143
+ # model=model_version, # Use GPT model that supports structured output
144
+ # messages=[
145
+ # {"role": "system", "content": "Extract the farm information."},
146
+ # {"role": "user", "content": specification}
147
+ # ],
148
+ # response_format=FarmActivities,
149
+ #)
150
+
151
+ #if 'error' in farm_info_response:
152
+ # raise ValueError(f"API error: {interactions_response['error']['message']}")
153
 
154
+ #farm_generated_json = farm_info_response.choices[0].message.parsed
155
+ #print("FARM JSON: ")
156
+ #print(farm_generated_json) # debugging
157
+
158
+ #farm_pretty_json = farm_generated_json.json()
159
+
160
+ #interactions_response = client.beta.chat.completions.parse(
161
+ # model=model_version, # Use GPT model that supports structured output
162
+ # messages=[
163
+ # {"role": "system", "content": "Extract the interactions information."},
164
+ # {"role": "user", "content": specification}
165
+ # ],
166
+ # response_format=Interactions,
167
+ #)
168
+
169
+ #if 'error' in interactions_response:
170
+ # raise ValueError(f"API error: {interactions_response['error']['message']}")
171
 
172
+ #interactions_generated_json = interactions_response.choices[0].message.parsed
173
 
174
+ #print("INTERACTIONS JSON: ")
175
+ #print(interactions_generated_json) # debugging 2
176
 
177
+ #interactions_pretty_json = interactions_generated_json.json()
178
 
179
 
180
  trial_response = client.beta.chat.completions.parse(
 
196
 
197
  trial_pretty_json = trial_generated_json.json()
198
 
199
+ return trial_pretty_json
200
+ #return [farm_pretty_json, interactions_pretty_json, trial_pretty_json]
201
 
202
  except ValidationError as e:
203
  return {"error": str(e)}
 
315
 
316
  with gr.Row():
317
  farm_output_box = gr.Textbox(label="Fields and Activities Output Data")
318
+ #interactions_output_box = gr.Textbox(label="Interactions Output Data")
319
+ #trials_output_box = gr.Textbox(label="Trials Output Data")
320
 
321
  def update_visibility(radio, additional_options):
322
  value = radio
 
341
  submit_button.click(
342
  fn=process_specifications,
343
  inputs=[data_input, model_version_input, json_creation_input, additional_json_creation_options, field_data_input, planting_data_input, logs_data_input, soil_data_input, yield_data_input],
344
+ outputs=[farm_output_box]
345
+ #outputs=[farm_output_box, interactions_output_box, trials_output_box]
346
  )
347
 
348
  clear_button = gr.ClearButton(components=[data_input, model_version_input, json_creation_input, additional_json_creation_options, field_data_input, planting_data_input, logs_data_input, soil_data_input, yield_data_input])