From 8e6716a102e390e930594d51302730184dac83cc Mon Sep 17 00:00:00 2001 From: Ryder Wishart Date: Sun, 8 Oct 2023 03:55:58 -0700 Subject: [PATCH] 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 --- examples/server/api_like_OAI.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/server/api_like_OAI.py b/examples/server/api_like_OAI.py index 1b0bf5757..14d2dcf65 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):