diff --git a/.env.example b/.env.example index fa90fb8..2ae8914 100644 --- a/.env.example +++ b/.env.example @@ -5,8 +5,8 @@ SLACK_SIGNING_SECRET="xxxx" DYNAMODB_TABLE_NAME="gurumi-ai-bot-context" -TEXT_MODEL_ID="anthropic.claude-3-sonnet-20240229-v1:0" -IMAGE_MODEL_ID="stability.stable-diffusion-xl-v1" +MODEL_ID_TEXT="anthropic.claude-3-sonnet-20240229-v1:0" +MODEL_ID_IMAGE="stability.stable-diffusion-xl-v1" ALLOWED_CHANNEL_IDS="C000000,C000001" diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 76378cb..c1ed4ae 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -10,9 +10,9 @@ env: BOT_CURSOR: ${{ vars.BOT_CURSOR }} DYNAMODB_TABLE_NAME: ${{ vars.DYNAMODB_TABLE_NAME }} ENABLE_IMAGE: ${{ vars.ENABLE_IMAGE }} - IMAGE_MODEL_ID: ${{ vars.IMAGE_MODEL_ID }} + MODEL_ID_IMAGE: ${{ vars.MODEL_ID_IMAGE }} SYSTEM_MESSAGE: ${{ vars.SYSTEM_MESSAGE }} - TEXT_MODEL_ID: ${{ vars.TEXT_MODEL_ID }} + MODEL_ID_TEXT: ${{ vars.MODEL_ID_TEXT }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} @@ -52,11 +52,11 @@ jobs: echo "BOT_CURSOR=${BOT_CURSOR}" >> .env echo "DYNAMODB_TABLE_NAME=${DYNAMODB_TABLE_NAME}" >> .env echo "ENABLE_IMAGE=${ENABLE_IMAGE}" >> .env - echo "IMAGE_MODEL_ID=${IMAGE_MODEL_ID}" >> .env + echo "MODEL_ID_IMAGE=${MODEL_ID_IMAGE}" >> .env echo "SLACK_BOT_TOKEN=${SLACK_BOT_TOKEN}" >> .env echo "SLACK_SIGNING_SECRET=${SLACK_SIGNING_SECRET}" >> .env echo "SYSTEM_MESSAGE=${SYSTEM_MESSAGE}" >> .env - echo "TEXT_MODEL_ID=${TEXT_MODEL_ID}" >> .env + echo "MODEL_ID_TEXT=${MODEL_ID_TEXT}" >> .env - name: Deploy to AWS Lambda 🚀 run: npx serverless deploy --region us-east-1 diff --git a/handler.py b/handler.py index b6a1ad7..b7a5ee6 100644 --- a/handler.py +++ b/handler.py @@ -22,8 +22,8 @@ DYNAMODB_TABLE_NAME = os.environ.get("DYNAMODB_TABLE_NAME", "gurumi-ai-bot-context") # Amazon Bedrock Model ID -TEXT_MODEL_ID = os.environ.get("TEXT_MODEL_ID", "anthropic.claude-3") -IMAGE_MODEL_ID = os.environ.get("IMAGE_MODEL_ID", "stability.stable-diffusion-xl") +MODEL_ID_TEXT = os.environ.get("MODEL_ID_TEXT", "anthropic.claude-3") +MODEL_ID_IMAGE = os.environ.get("MODEL_ID_IMAGE", "stability.stable-diffusion-xl") ANTHROPIC_VERSION = os.environ.get("ANTHROPIC_VERSION", "bedrock-2023-05-31") ANTHROPIC_TOKENS = int(os.environ.get("ANTHROPIC_TOKENS", 1024)) @@ -128,7 +128,7 @@ def invoke_claude_3(content): body["system"] = SYSTEM_MESSAGE response = bedrock.invoke_model( - modelId=TEXT_MODEL_ID, + modelId=MODEL_ID_TEXT, body=json.dumps(body), ) @@ -179,7 +179,7 @@ def invoke_stable_diffusion(prompt, seed=0, style_preset="photographic"): body["style_preset"] = style_preset response = bedrock.invoke_model( - modelId=IMAGE_MODEL_ID, + modelId=MODEL_ID_IMAGE, body=json.dumps(body), )