]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
py : add grammar to oai like api (#4294)
authorRickard Edén <redacted>
Sun, 3 Dec 2023 09:03:25 +0000 (10:03 +0100)
committerGitHub <redacted>
Sun, 3 Dec 2023 09:03:25 +0000 (11:03 +0200)
examples/server/api_like_OAI.py

index 830c056d4acfc6d2e864a184727a1f8dbd831b8e..607fe49d3ff151e661f52f83363b8f137d605995 100755 (executable)
@@ -70,6 +70,7 @@ def make_postData(body, chat=False, stream=False):
     if(is_present(body, "mirostat_tau")): postData["mirostat_tau"] = body["mirostat_tau"]
     if(is_present(body, "mirostat_eta")): postData["mirostat_eta"] = body["mirostat_eta"]
     if(is_present(body, "seed")): postData["seed"] = body["seed"]
+    if(is_present(body, "grammar")): postData["grammar"] = body["grammar"]
     if(is_present(body, "logit_bias")): postData["logit_bias"] = [[int(token), body["logit_bias"][token]] for token in body["logit_bias"].keys()]
     if (args.stop != ""):
         postData["stop"] = [args.stop]