Update maker.py
Browse files
maker.py
CHANGED
@@ -97,31 +97,23 @@ def extract_title_prompt_example(text, title, system_prompt, example_input):
|
|
97 |
prompt_start = -1
|
98 |
example_start = -1
|
99 |
try:
|
100 |
-
title_start = text.lower().
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
example_input = text[example_start + len("Example input:"):].strip().split("\n")[0]
|
118 |
-
print("Example Input:", example_input)
|
119 |
-
|
120 |
-
else:
|
121 |
-
example_input = ""
|
122 |
-
except Exception as e:
|
123 |
-
print(f"Error in extract_title_prompt_example: {e}")
|
124 |
-
return text, title, system_prompt, example_input
|
125 |
return text, title, system_prompt, example_input
|
126 |
|
127 |
def make_open_gpt(message, history, current_title, system_prompt, current_example_input):
|
@@ -137,8 +129,6 @@ textbox_preview = gr.Textbox(scale=7, container=False)
|
|
137 |
|
138 |
def test_preview_chatbot(message, history, system_prompt):
|
139 |
response = predict_beta(message, history, system_prompt)
|
140 |
-
text_start = response.rfind("<|assistant|>", ) + len("<|assistant|>")
|
141 |
-
response = response[text_start:]
|
142 |
return response
|
143 |
|
144 |
|
|
|
97 |
prompt_start = -1
|
98 |
example_start = -1
|
99 |
try:
|
100 |
+
title_start = text.lower().rfind("title:") + len("title:")
|
101 |
+
prompt_start = text.lower().rfind("system prompt:")
|
102 |
+
title = text[title_start:prompt_start].strip()
|
103 |
+
except ValueError:
|
104 |
+
pass
|
105 |
+
try:
|
106 |
+
prompt_start = text.lower().rfind("system prompt:") + len("system prompt:")
|
107 |
+
example_start = text.lower().rfind("example input:")
|
108 |
+
system_prompt = text[prompt_start:example_start].strip()
|
109 |
+
except ValueError:
|
110 |
+
pass
|
111 |
+
try:
|
112 |
+
example_start = text.lower().rfind("example input:") + len("example input:")
|
113 |
+
example_input = text[example_start:].strip()
|
114 |
+
example_input = example_input[:example_input.index("\n")]
|
115 |
+
except ValueError:
|
116 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
return text, title, system_prompt, example_input
|
118 |
|
119 |
def make_open_gpt(message, history, current_title, system_prompt, current_example_input):
|
|
|
129 |
|
130 |
def test_preview_chatbot(message, history, system_prompt):
|
131 |
response = predict_beta(message, history, system_prompt)
|
|
|
|
|
132 |
return response
|
133 |
|
134 |
|