diff --git a/list_collections/src/index.py b/list_collections/src/index.py index c372987..ca36c74 100644 --- a/list_collections/src/index.py +++ b/list_collections/src/index.py @@ -8,6 +8,9 @@ PGVECTOR_USER = os.environ.get("PGVECTOR_USER", "postgres") COLLECTION_TABLE_NAME = "langchain_pg_collection" PASSWORD = "dbreader" + +INTENT_NAME = "SelectCollection" +SLOT_TO_ELICIT = "collection" # Initialize the connection outside of the handler conn = psycopg2.connect( dbname=PGVECTOR_DATABASE, @@ -49,10 +52,10 @@ def lambda_handler(event, context): for i, option in enumerate(rows) } - return { + response = { "sessionState": { "intent": { - "name": "SelectCollections", + "name": INTENT_NAME, "state": "ReadyForFulfillment", "confirmationState": "None", "slots": slots, @@ -67,6 +70,40 @@ def lambda_handler(event, context): ], "requestAttributes": {}, } + return test_response() except Exception as e: print(f"Error querying the database: {e}") raise e + + +def test_response(): + return { + "sessionState": { + "dialogAction": { + "slotElicitationStyle": "Default", + "slotToElicit": SLOT_TO_ELICIT, + "type": "ElicitSlot", + }, + "intent": { + "confirmationState": "None", + "name": INTENT_NAME, + "state": "InProgress", + "slots": { + SLOT_TO_ELICIT: { + "shape": "Scalar", + "value": { + "originalValue": "originalValue", + "interpretedValue": "interpretedValue", + "resolvedValues": ["resolvedValues"], + }, + }, + }, + }, + }, + "messages": [ + { + "contentType": "PlainText", + "content": "the content of the message from the lambda list collections", + }, + ], + }