Update maker.py
Browse files
maker.py
CHANGED
@@ -94,26 +94,25 @@ def extract_title_prompt_example(text, title, system_prompt, example_input):
|
|
94 |
prompt_start = -1
|
95 |
example_start = -1
|
96 |
try:
|
97 |
-
title_start = text.lower().find("
|
98 |
-
if title_start >= len("
|
99 |
-
prompt_start = text.lower().find("
|
100 |
title = text[title_start:prompt_start].strip() if prompt_start != -1 else ""
|
101 |
else:
|
102 |
title = ""
|
103 |
|
104 |
if prompt_start >= 0:
|
105 |
-
example_start = text.lower().find("
|
106 |
-
system_prompt = text[prompt_start + len("
|
107 |
else:
|
108 |
system_prompt = ""
|
109 |
|
110 |
if example_start >= 0:
|
111 |
-
example_input = text[example_start + len("
|
112 |
else:
|
113 |
example_input = ""
|
114 |
except Exception as e:
|
115 |
print(f"Error in extract_title_prompt_example: {e}")
|
116 |
-
# Return the original values if there's an error
|
117 |
return text, title, system_prompt, example_input
|
118 |
|
119 |
return text, title, system_prompt, example_input
|
|
|
94 |
prompt_start = -1
|
95 |
example_start = -1
|
96 |
try:
|
97 |
+
title_start = text.lower().find("# Title:") + len("# Title:")
|
98 |
+
if title_start >= len("# Title:"):
|
99 |
+
prompt_start = text.lower().find("# System prompt:", title_start)
|
100 |
title = text[title_start:prompt_start].strip() if prompt_start != -1 else ""
|
101 |
else:
|
102 |
title = ""
|
103 |
|
104 |
if prompt_start >= 0:
|
105 |
+
example_start = text.lower().find("# Example input:", prompt_start)
|
106 |
+
system_prompt = text[prompt_start + len("# System prompt:"):example_start].strip() if example_start != -1 else ""
|
107 |
else:
|
108 |
system_prompt = ""
|
109 |
|
110 |
if example_start >= 0:
|
111 |
+
example_input = text[example_start + len("Example input:"):].strip().split("\n")[0]
|
112 |
else:
|
113 |
example_input = ""
|
114 |
except Exception as e:
|
115 |
print(f"Error in extract_title_prompt_example: {e}")
|
|
|
116 |
return text, title, system_prompt, example_input
|
117 |
|
118 |
return text, title, system_prompt, example_input
|