Update maker.py
Browse files
maker.py
CHANGED
|
@@ -74,32 +74,30 @@ def predict_beta(message, chatbot=[], system_prompt=system_prompt, max_new_token
|
|
| 74 |
error_msg = f"An error occurred: {str(e)}"
|
| 75 |
raise gr.Error(error_msg)
|
| 76 |
|
| 77 |
-
|
| 78 |
def extract_title_prompt_example(text, title, system_prompt, example_input):
|
| 79 |
try:
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
prompt_start
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
example_start
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
pass
|
| 103 |
return text, title, system_prompt, example_input
|
| 104 |
|
| 105 |
def make_open_gpt(message, history, current_title, system_prompt, current_example_input):
|
|
|
|
| 74 |
error_msg = f"An error occurred: {str(e)}"
|
| 75 |
raise gr.Error(error_msg)
|
| 76 |
|
|
|
|
| 77 |
def extract_title_prompt_example(text, title, system_prompt, example_input):
|
| 78 |
try:
|
| 79 |
+
title_start = text.lower().find("title:") + len("title:")
|
| 80 |
+
if title_start >= len("title:"):
|
| 81 |
+
prompt_start = text.lower().find("system prompt:", title_start)
|
| 82 |
+
title = text[title_start:prompt_start].strip() if prompt_start != -1 else ""
|
| 83 |
+
else:
|
| 84 |
+
title = ""
|
| 85 |
+
|
| 86 |
+
if prompt_start >= 0:
|
| 87 |
+
example_start = text.lower().find("example input:", prompt_start)
|
| 88 |
+
system_prompt = text[prompt_start + len("system prompt:"):example_start].strip() if example_start != -1 else ""
|
| 89 |
+
else:
|
| 90 |
+
system_prompt = ""
|
| 91 |
+
|
| 92 |
+
if example_start >= 0:
|
| 93 |
+
example_input = text[example_start + len("example input:"):].strip().split("\n")[0]
|
| 94 |
+
else:
|
| 95 |
+
example_input = ""
|
| 96 |
+
except Exception as e:
|
| 97 |
+
print(f"Error in extract_title_prompt_example: {e}")
|
| 98 |
+
# Return the original values if there's an error
|
| 99 |
+
return text, title, system_prompt, example_input
|
| 100 |
+
|
|
|
|
| 101 |
return text, title, system_prompt, example_input
|
| 102 |
|
| 103 |
def make_open_gpt(message, history, current_title, system_prompt, current_example_input):
|