Skip to content

Commit

Permalink
Merge branch 'deploy/prototype' into 4313-deployment-override
Browse files Browse the repository at this point in the history
  • Loading branch information
bmquinn authored Jan 10, 2024
2 parents 8970634 + 0dd7f7f commit 742a28e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
31 changes: 18 additions & 13 deletions chat/src/handlers/chat.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import traceback
from chat.src.event_config import EventConfig
from src.helpers.response import prepare_response
from handlers.event_config import EventConfig
from helpers.response import prepare_response


def handler(event={}, _context={}):
config = EventConfig(event)
socket = config.setup_websocket()
if config.is_logged_in and socket is not None:
def handler(event, _context):
try:
config = EventConfig(event)
config.setup_websocket()

if not config.is_logged_in:
config.socket.send({"type": "error", "message": "Unauthorized"})
return {"statusCode": 401, "body": "Unauthorized"}

if config.debug_mode:
socket.send(config.debug_message())
config.socket.send(config.debug_message())

config.setup_llm_request()
final_response = prepare_response(config)
socket.send(final_response)
config.socket.send(final_response)
return {"statusCode": 200}
elif socket is not None:
socket.send({"type": "error", "message": "Unauthorized"})
return {"statusCode": 401, "body": "Unauthorized"}
else:
return {"statusCode": 500, "body": "Internal Server Error"}
except Exception as err:
error_message = traceback.format_exc()
config.socket.send(error_message)
print(event)
raise err
2 changes: 1 addition & 1 deletion chat/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Resources:
- x86_64
Layers:
- !Ref ChatDependencies
MemorySize: 128
MemorySize: 1024
Handler: handlers/chat.handler
Timeout: 300
Environment:
Expand Down

0 comments on commit 742a28e

Please sign in to comment.