This example shows how to use the duohub graph memory integration with AWS Lambda, supporting both Python and TypeScript implementations.
These Lambda functions integrate with duohub's memory retrieval API to fetch relevant information based on queries. They support both standard queries and memory-specific retrievals using a memoryID.
- AWS Account with Lambda access
- Node.js 18+ (for TypeScript) or Python 3.8+ (for Python)
- duohub API key
-
Clone this repository
-
Install dependencies:
For TypeScript:
cd lambda/typescript npm install # or yarn install
For Python:
cd lambda/python pip install -r requirements.txt
-
Set up your environment variables in AWS Lambda:
API_KEY
: Your duohub API key
lambda/
├── python/
│ ├── chat_handler.py
│ ├── create_user.py
│ └── list_user_messages.py
└── typescript/
├── chat_handler.ts
├── create_user.ts
├── get_memory_response.ts
└── list_user_messages.ts
- Build the TypeScript code:
cd lambda/typescript tsc
- Zip the contents of the
dist
folder along withnode_modules
- Upload to AWS Lambda
- Create a ZIP file containing your Python files and dependencies:
cd lambda/python zip -r ../function.zip .
- Upload to AWS Lambda
The Lambda functions accept events with the following structure:
TypeScript/JavaScript:
{
"query": string, // Required: The query to search for
"memoryID": string // Required: Specific memory ID to search within
}
Python:
{
"query": str, # Required: The query to search for
"memoryID": str # Required: Specific memory ID to search within
}
chat_handler
: Handles chat interactionscreate_user
: Creates new usersget_memory_response
: Retrieves memory-specific responseslist_user_messages
: Lists messages for a specific user
chat_handler
: Handles chat interactionscreate_user
: Creates new userslist_user_messages
: Lists messages for a specific user