]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
api_like_OAI.py : compat with Microsoft Guidance (#2746)
authorRyder Wishart <redacted>
Sun, 8 Oct 2023 10:55:58 +0000 (03:55 -0700)
committerGitHub <redacted>
Sun, 8 Oct 2023 10:55:58 +0000 (13:55 +0300)
Check for None in addition to empty string check in all request params

Co-authored-by: Georgi Gerganov <redacted>
examples/server/api_like_OAI.py

index 1b0bf575706ea4533ac9b6daee0ce7d97ebbdd3d..14d2dcf6580e41a9816377f94f4c19202137a33a 100755 (executable)
@@ -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):