Tonic commited on
Commit
40faa53
1 Parent(s): 0b8e27d

Update maker.py

Browse files
Files changed (1) hide show
  1. maker.py +20 -14
maker.py CHANGED
@@ -117,31 +117,37 @@ def extract_title_prompt_example(text):
117
  return text, title, system_prompt, example_input
118
 
119
 
120
- def make_open_gpt(message, history, current_title, current_system_prompt, current_example_input, system_prompt=system_prompt):
121
  try:
122
  response = predict_beta(message, history, system_prompt)
 
 
 
123
  except Exception as e:
124
  response = f"Error in predict_beta: {str(e)}"
125
-
126
- print("Response before extraction:", response) # Print the response before extraction
127
-
128
- try:
129
- response, title, system_prompt, example_input = extract_title_prompt_example(response)
130
- except Exception as e:
131
  title = "Error"
132
- system_prompt = "Error in extraction"
133
  example_input = "Error"
134
- print(f"Error in extract_title_prompt_example: {str(e)}")
 
 
 
 
 
 
 
135
 
136
  # Ensure all expected outputs are returned
137
  return (
138
  "", # Placeholder for textbox
139
  history + [(message, response)], # Updated chatbot history
140
- title, # Extracted or default title
141
- system_prompt, # Extracted or default system prompt
142
- example_input, # Extracted or default example input
143
- [(None, welcome_preview_message.format(title, example_input))], # Updated chatbot preview
144
- example_input, # Example input for textbox_preview
145
  gr.Column(visible=True), # Column visibility control
146
  gr.Group(visible=True) # Group visibility control
147
  )
 
117
  return text, title, system_prompt, example_input
118
 
119
 
120
+ def make_open_gpt(message, history, current_title, current_system_prompt, current_example_input, system_prompt=""):
121
  try:
122
  response = predict_beta(message, history, system_prompt)
123
+ if not response:
124
+ raise ValueError("Empty response from predict_beta")
125
+ print("Response from predict_beta:", response) # Debugging print
126
  except Exception as e:
127
  response = f"Error in predict_beta: {str(e)}"
128
+ print("Error in predict_beta:", response) # Debugging print
129
+ # Set error values
 
 
 
 
130
  title = "Error"
131
+ system_prompt = "Error in predict_beta"
132
  example_input = "Error"
133
+ else:
134
+ try:
135
+ _, title, system_prompt, example_input = extract_title_prompt_example(response)
136
+ except Exception as e:
137
+ title = "Error"
138
+ system_prompt = "Error in extraction"
139
+ example_input = "Error"
140
+ print(f"Error in extract_title_prompt_example: {str(e)}")
141
 
142
  # Ensure all expected outputs are returned
143
  return (
144
  "", # Placeholder for textbox
145
  history + [(message, response)], # Updated chatbot history
146
+ title or current_title, # Extracted or default title
147
+ system_prompt or current_system_prompt, # Extracted or default system prompt
148
+ example_input or current_example_input, # Extracted or default example input
149
+ [(None, welcome_preview_message.format(title or current_title, example_input or current_example_input))], # Updated chatbot preview
150
+ example_input or current_example_input, # Example input for textbox_preview
151
  gr.Column(visible=True), # Column visibility control
152
  gr.Group(visible=True) # Group visibility control
153
  )