diff options
author | Ryder Wishart <ryderwishart@gmail.com> | 2023-10-08 03:55:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-08 13:55:58 +0300 |
commit | 8e6716a102e390e930594d51302730184dac83cc (patch) | |
tree | 2b5f6c4098e869473e12c0b1f14b399129c56f93 | |
parent | 9c38d181d40b9d27f8f42152c18e7c70bfffcf37 (diff) |
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 <ggerganov@gmail.com>
-rwxr-xr-x | examples/server/api_like_OAI.py | 8 |
1 files changed, 7 insertions, 1 deletions
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): |