Skip to content

Commit

Permalink
Add intent and slot information to response
Browse files Browse the repository at this point in the history
  • Loading branch information
FloRul committed Feb 4, 2024
1 parent e9b35c2 commit 5a3315f
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions list_collections/src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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",
},
],
}

0 comments on commit 5a3315f

Please sign in to comment.