ChatON:P3:meta json to hpp: Retain esc seqs and more kv pairs

Use repr to retain the escape sequences in the read string.
And parallely skip the single quote around strings wrt repr.

Bring in more k-v pairs wrt chaton_meta.json
This commit is contained in:
HanishKVC 2024-05-12 13:06:22 +05:30
parent 078e04d32b
commit 7b5fb0a2fa

View file

@ -7,7 +7,7 @@ import json
def kv(j, tmpl, k1, k2, comma): def kv(j, tmpl, k1, k2, comma):
print("\t\t{{ \"{}\", \"{}\" }}{}".format("{}-{}".format(k1,k2), j[tmpl][k1][k2], comma)) print("\t\t{{ \"{}\", \"{}\" }}{}".format("{}-{}".format(k1,k2), repr(j[tmpl][k1][k2])[1:-1], comma))
fp=open(sys.argv[1]) fp=open(sys.argv[1])
@ -15,7 +15,23 @@ j=json.load(fp)
print("{") print("{")
for tmpl in j: for tmpl in j:
print("\t{{ \"{}\", {{".format(tmpl)) print("\t{{ \"{}\", {{".format(tmpl))
kv(j, tmpl, "global", "begin", ",") kv(j, tmpl, "global", "begin", ",")
kv(j, tmpl, "global", "end", ",") kv(j, tmpl, "global", "end", ",")
print("\t}},")
kv(j, tmpl, "system", "begin", ",")
kv(j, tmpl, "system", "prefix", ",")
kv(j, tmpl, "system", "suffix", ",")
kv(j, tmpl, "system", "end", ",")
kv(j, tmpl, "user", "begin", ",")
kv(j, tmpl, "user", "prefix", ",")
kv(j, tmpl, "user", "suffix", ",")
kv(j, tmpl, "user", "end", ",")
kv(j, tmpl, "assistant", "begin", ",")
kv(j, tmpl, "assistant", "prefix", ",")
kv(j, tmpl, "assistant", "suffix", ",")
kv(j, tmpl, "assistant", "end", ",")
print("\t}},")