Welcome to this repository. This is a "so-so" Chatbot AI hosted to AWS Service.
This project need an environment variable during the build phase. Never upload the .env file to the Git repository or you will lose the point.
NEXT_PUBLIC_COGNITO_AUTHORITY="YOUR_COGNITO_IDP_URL"
NEXT_PUBLIC_COGNITO_CLIENT_ID="YOUR_COGNITO_APP_CLIENT_ID"
NEXT_PUBLIC_REDIRECT_URI="YOUR_AMPLIFY_URL/login/callback"
NEXT_PUBLIC_APIGW_URL="YOUR_API_GATEWAY_URL"You need to configure API Endpoint. The specification you can check on Document detail.
Single Conversation Format
{
"conversation": {
"role": "user" | "assistant",
"content": "Hello, there?"
}
}{uid} is User ID (Generated when user is registered to cognito) and {id} is Conversation ID (Generate using UUID)
You can use all Lambda requirements in /serverless/src but don't forget to configure your database in the next section.
For storing all conversation, we need database. Now, we're using DynamoDB. This is a schema of database configuration:
-
Primary Key: user_id (string | uuid)
-
Sort Key: conversation_id (string | uuid)
-
Keys: created_at (ISO String), updated_at (ISO String), messages (array)
messages Format
{
"messages": [{
"role": "user",
"content": "Siapa presiden ketujuh indonesia?"
}, {
"role": "assistant",
"content": "Presiden ke-7 Indonesia adalah **Joko Widodo**, atau yang sering disebut Jokowi."
}, ...]
}All configurations for AI Worker should be managed using Ansible playbook for automated configuration. You can use the playbook located at /serverless/playbook.yml for automate the configuration. Before running, you need to adjust the necessary variables for s3_filesystem_id.
You can execute the playbook using AWS System Manager (SSM).