Update maker.py
Browse files
maker.py
CHANGED
|
@@ -108,37 +108,34 @@ def extract_title_prompt_example(text):
|
|
| 108 |
default_system_prompt = "This is a custom GPT agent."
|
| 109 |
default_example_input = "Type your query here."
|
| 110 |
|
| 111 |
-
#
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
else:
|
| 137 |
-
example_input = default_example_input
|
| 138 |
|
| 139 |
return text, title, system_prompt, example_input
|
| 140 |
|
| 141 |
-
|
| 142 |
def make_open_gpt(message, history, current_title, current_system_prompt, current_example_input, system_prompt=system_prompt):
|
| 143 |
try:
|
| 144 |
response = predict_beta(message, history, system_prompt)
|
|
|
|
| 108 |
default_system_prompt = "This is a custom GPT agent."
|
| 109 |
default_example_input = "Type your query here."
|
| 110 |
|
| 111 |
+
# Split the text into lines and reverse it to start from the end
|
| 112 |
+
lines = text.split('\n')
|
| 113 |
+
lines.reverse()
|
| 114 |
+
|
| 115 |
+
title = default_title
|
| 116 |
+
system_prompt = default_system_prompt
|
| 117 |
+
example_input = default_example_input
|
| 118 |
+
|
| 119 |
+
# Flags to check if we have found the sections
|
| 120 |
+
found_title, found_prompt, found_example = False, False, False
|
| 121 |
+
|
| 122 |
+
for line in lines:
|
| 123 |
+
if not found_example and line.startswith("# Example input:"):
|
| 124 |
+
example_input = line.replace("# Example input:", "").strip()
|
| 125 |
+
found_example = True
|
| 126 |
+
elif not found_prompt and line.startswith("# System prompt:"):
|
| 127 |
+
system_prompt = line.replace("# System prompt:", "").strip()
|
| 128 |
+
found_prompt = True
|
| 129 |
+
elif not found_title and line.startswith("# Title:"):
|
| 130 |
+
title = line.replace("# Title:", "").strip()
|
| 131 |
+
found_title = True
|
| 132 |
+
|
| 133 |
+
# Break the loop if all sections are found
|
| 134 |
+
if found_title and found_prompt and found_example:
|
| 135 |
+
break
|
|
|
|
|
|
|
| 136 |
|
| 137 |
return text, title, system_prompt, example_input
|
| 138 |
|
|
|
|
| 139 |
def make_open_gpt(message, history, current_title, current_system_prompt, current_example_input, system_prompt=system_prompt):
|
| 140 |
try:
|
| 141 |
response = predict_beta(message, history, system_prompt)
|