Tonic commited on
Commit
3a82f85
1 Parent(s): b96ceec

Update maker.py

Browse files
Files changed (1) hide show
  1. maker.py +6 -7
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("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 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