-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_jsonl.py
More file actions
39 lines (32 loc) · 1.09 KB
/
Copy pathcreate_jsonl.py
File metadata and controls
39 lines (32 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from LineObject import LineObject
import argparse
import sys
def get_jsonl_from_list(jsonl,PEND,CEND):
ans = ""
for each in jsonl:
print(f"PRINJTING EACH: {each}")
each.prompt = each.prompt.replace(PEND, '')
each.completion = each.completion.replace(CEND, '')
ans += '{' + f'"prompt": "{each.prompt}{PEND}", "completion": "{each.completion}{CEND}"' + '}\n'
return '{\n' + ans + '}'
def prompt_create_list():
jsonl = []
while True:
print('PROMPT: ', file=sys.stderr,end="")
p = input()
if not p:
break
print('COMPLETION: ', file=sys.stderr, end="")
c = input()
o = LineObject(p,c)
jsonl.append(o)
return jsonl
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--prompt-end',default= f'\n\n###\n\n')
parser.add_argument('-c','--completion-end', default = '###')
args = parser.parse_args()
PEND = args.prompt_end
CEND = args.completion_end
jsonl = prompt_create_list()
print(get_jsonl_from_list(jsonl, PEND,CEND))