ChatON:P4:meta json to hpp: Insert kv bool

Rename kv helpers to match their semantic.
* whether working with string or bool value
* whether two keys or a single key

Add support for kv with bool value

inturn add the kv boolean pairs used in the chaton_meta.json file

Add the closing bracket
This commit is contained in:
HanishKVC 2024-05-12 13:21:17 +05:30
parent 7b5fb0a2fa
commit b5b274a44b

View file

@ -6,32 +6,44 @@ import sys
import json
def kv(j, tmpl, k1, k2, comma):
def kkv_str(j, tmpl, k1, k2, comma):
print("\t\t{{ \"{}\", \"{}\" }}{}".format("{}-{}".format(k1,k2), repr(j[tmpl][k1][k2])[1:-1], comma))
def kv_bool(j, tmpl, k1, comma):
print("\t\t{{ \"{}\", {} }}{}".format(k1, repr(j[tmpl][k1]).lower(), comma))
fp=open(sys.argv[1])
j=json.load(fp)
print("{")
for tmpl in j:
print("\t{{ \"{}\", {{".format(tmpl))
kv(j, tmpl, "global", "begin", ",")
kv(j, tmpl, "global", "end", ",")
kkv_str(j, tmpl, "global", "begin", ",")
kkv_str(j, tmpl, "global", "end", ",")
kv(j, tmpl, "system", "begin", ",")
kv(j, tmpl, "system", "prefix", ",")
kv(j, tmpl, "system", "suffix", ",")
kv(j, tmpl, "system", "end", ",")
kkv_str(j, tmpl, "system", "begin", ",")
kkv_str(j, tmpl, "system", "prefix", ",")
kkv_str(j, tmpl, "system", "suffix", ",")
kkv_str(j, tmpl, "system", "end", ",")
kv(j, tmpl, "user", "begin", ",")
kv(j, tmpl, "user", "prefix", ",")
kv(j, tmpl, "user", "suffix", ",")
kv(j, tmpl, "user", "end", ",")
kkv_str(j, tmpl, "user", "begin", ",")
kkv_str(j, tmpl, "user", "prefix", ",")
kkv_str(j, tmpl, "user", "suffix", ",")
kkv_str(j, tmpl, "user", "end", ",")
kv(j, tmpl, "assistant", "begin", ",")
kv(j, tmpl, "assistant", "prefix", ",")
kv(j, tmpl, "assistant", "suffix", ",")
kv(j, tmpl, "assistant", "end", ",")
kkv_str(j, tmpl, "assistant", "begin", ",")
kkv_str(j, tmpl, "assistant", "prefix", ",")
kkv_str(j, tmpl, "assistant", "suffix", ",")
kkv_str(j, tmpl, "assistant", "end", ",")
kv_bool(j, tmpl, "systemuser-system-has-suffix", ",")
kv_bool(j, tmpl, "systemuser-system-has-end", ",")
kv_bool(j, tmpl, "systemuser-1st-user-has-begin", ",")
kv_bool(j, tmpl, "systemuser-1st-user-has-prefix", ",")
print("\t}},")
print("}")