summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRyder Wishart <ryderwishart@gmail.com>2023-10-08 03:55:58 -0700
committerGitHub <noreply@github.com>2023-10-08 13:55:58 +0300
commit8e6716a102e390e930594d51302730184dac83cc (patch)
tree2b5f6c4098e869473e12c0b1f14b399129c56f93 /examples
parent9c38d181d40b9d27f8f42152c18e7c70bfffcf37 (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>
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/server/api_like_OAI.py8
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):