From 04df6f65e5dadc42c6b2db40be20a0dfe647ff4e Mon Sep 17 00:00:00 2001 From: FloRul Date: Wed, 20 Mar 2024 21:21:53 -0400 Subject: [PATCH] Fix session ID handling and add exception handling for query parameter --- lambdas/inference/src/index.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lambdas/inference/src/index.py b/lambdas/inference/src/index.py index aba78a7..117d003 100644 --- a/lambdas/inference/src/index.py +++ b/lambdas/inference/src/index.py @@ -111,17 +111,17 @@ def invoke_model( @tracer.capture_lambda_handler def lambda_handler(event, context): response = "this is a dummy response" - source = event.get("queryStringParameters", {}).get("source", "message") - embedding_collection_name = event["queryStringParameters"]["collectionName"] + try: + source = event.get("queryStringParameters", {}).get("source", "message") + embedding_collection_name = event["queryStringParameters"]["collectionName"] - sessionId = str(uuid.uuid1()) + sessionId = str(uuid.uuid1()) - if "sessionId" in event["queryStringParameters"]: - sessionId = event["queryStringParameters"]["sessionId"] + if "sessionId" in event["queryStringParameters"]: + sessionId = event["queryStringParameters"]["sessionId"] - history = History(session_id=sessionId) + history = History(session_id=sessionId) - try: query = event["queryStringParameters"]["query"] docs = []