From: Ryder Wishart Date: Sun, 8 Oct 2023 10:55:58 +0000 (-0700) Subject: api_like_OAI.py : compat with Microsoft Guidance (#2746) X-Git-Tag: upstream/0.0.4488~3135 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=8e6716a102e390e930594d51302730184dac83cc;p=pkg%2Fggml%2Fsources%2Fllama.cpp api_like_OAI.py : compat with Microsoft Guidance (#2746) Check for None in addition to empty string check in all request params Co-authored-by: Georgi Gerganov --- diff --git a/examples/server/api_like_OAI.py b/examples/server/api_like_OAI.py index 1b0bf575..14d2dcf6 100755 --- a/examples/server/api_like_OAI.py +++ b/examples/server/api_like_OAI.py @@ -23,7 +23,13 @@ parser.add_argument("--port", type=int, help="Set the port to listen.(default: 8 args = parser.parse_args() def is_present(json, key): - return key in json + try: + buf = json[key] + except KeyError: + return False + if json[key] == None: + return False + return True #convert chat to prompt def convert_chat(messages):