GithubHelp home page GithubHelp logo

aws-samples / aws-serverless-ai-stories Goto Github PK

View Code? Open in Web Editor NEW
147.0 7.0 47.0 6.34 MB

Example open source event-driven application that generates a new bed time story for your children every night using Lambda, EventBridge, DynamoDB, App Runner, ChatGPT and DALL-E.

Home Page: https://aws-blogs-prod.amazon.com/compute/implementing-an-event-driven-serverless-story-generation-application-with-chatgpt-and-dall-e/

License: MIT No Attribution

JavaScript 7.00% TypeScript 89.22% Dockerfile 3.62% CSS 0.16%
chatgpt dalle dynamodb event-driven-architecture eventbridge serverless

aws-serverless-ai-stories's Issues

Dosen't work

Can I get any opinions on why it dosen't trigger at the schedule?

I had,

  1. Set open-api-key (ChatGPT) on Secret Manager.
  2. Deployed all stacks on aws via cdk and checked each stack's health.
  3. Populated characters and scenes into dynamoDB.
  4. Gotten an end-point link of apprunner which can connect like sample page.

image

is there anything I missed?

issues with cdk deploy and running into spawnSync docker ENOENT

Great blog and fun idea -- when following the commands to set up the environment, after running npm run deploy I get the following error:

[email protected] deploy
cd backend && cdk deploy --all

Error: spawnSync docker ENOENT
at Object.spawnSync (node:internal/child_process:1117:20)
at Object.spawnSync (node:child_process:871:24)
at Object.dockerExec (/Users/aws/aws-serverless-ai-stories/backend/node_modules/aws-cdk-lib/core/lib/private/asset-staging.js:1:3313)
at Function.fromBuild (/Users/aws/aws-serverless-ai-stories/backend/node_modules/aws-cdk-lib/core/lib/bundling.js:1:3962)
at new Bundling (/Users/aws/aws-serverless-ai-stories/backend/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.js:1:1944)
at Function.bundle (/Users/aws/aws-serverless-ai-stories/backend/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.js:1:3046)
at new NodejsFunction (/Users/aws/aws-serverless-ai-stories/backend/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:1229)
at new BackendStack (/Users/aws/aws-serverless-ai-stories/backend/lib/backend.ts:60:45)
at Object. (/Users/aws/aws-serverless-ai-stories/backend/bin/backend.ts:20:1)
at Module._compile (node:internal/modules/cjs/loader:1275:14) {
errno: -2,
code: 'ENOENT',
syscall: 'spawnSync docker',
path: 'docker',
spawnargs: [
'build',
'-t',
'cdk-84e5538a8e2f550e0f75cd28a4bc048301af951bab38cd4ded047a33760a5a26',
'--platform',
'linux/amd64',
'--build-arg',
'IMAGE=public.ecr.aws/sam/build-nodejs18.x',
'--build-arg',
'ESBUILD_VERSION=0',
'/Users/aws/aws-serverless-ai-stories/backend/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib'
]
}

Subprocess exited with error 1

I also notice that when I run anything with CDK, such as cdk metadata or cdk ls I get the same error.

Error at position 0

I wonder if anyone has had this issue, but whenever I try to trigger the function I get the error below. Really looking forward to making it work!

{ "errorType": "SyntaxError", "errorMessage": "Unexpected token s in JSON at position 0", "stack": [ "SyntaxError: Unexpected token s in JSON at position 0", " at JSON.parse (<anonymous>)", " at Runtime.handler (/var/task/index.js:14326:23)", " at process.processTicksAndRejections (node:internal/process/task_queues:95:5)" ] }

cannot run npm run deploy


executor failed running [/bin/sh -c npm run build]: exit code: 1
[100%] fail: docker build --tag cdkasset-eac8aa482c5b0aaf9cf45dca81711c0e905f42cb36626f8893814cdde62907a0 --platform linux/amd64 . exited with error code 1: #1 [internal] load build definition from Dockerfile
#1 sha256:94ad57c069987cc5f2545ee37b0f671e5b0cc64f5b79f45035c90208c26c311d
#1 transferring dockerfile: 37B done
#1 DONE 0.0s

{A[Y].splice(0,A[v]npm ERR! code ELIFECYCLE
#14 0.836 npm ERR! errno 1
#14 0.839 npm ERR! @ build: next build
#14 0.839 npm ERR! Exit status 1
#14 0.839 npm ERR!
#14 0.840 npm ERR! Failed at the @ build script.
#14 0.840 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
#14 0.844
#14 0.844 npm ERR! A complete log of this run can be found in:
#14 0.844 npm ERR! /root/.npm/_logs/2023-05-19T21_05_51_228Z-debug.log
#14 ERROR: executor failed running [/bin/sh -c npm run build]: exit code: 1

[builder 5/5] RUN npm run build:


executor failed running [/bin/sh -c npm run build]: exit code: 1
stg-aiStoriesBackend: building assets...

[0%] start: Building b4dc6bab39417a56a230ec51c4b77694c3b7e2b741828a002aac1ca2bc339ebb:current_account-current_region
[0%] start: Building 4aea577eb744c3399c23dd93a5ab40e0b5a9bb67b0a65cd383ca9c1b728b6e1b:current_account-current_region
[0%] start: Building 369141d9c3fce053bfb036a3081d5b6ac09d809d33f4e7705d3bb95f4708fe08:current_account-current_region
[0%] start: Building 61c63449bfa374126c263ef985e327bb569ab247e7e1537d0542c77b2e18ab0d:current_account-current_region
[25%] success: Built b4dc6bab39417a56a230ec51c4b77694c3b7e2b741828a002aac1ca2bc339ebb:current_account-current_region
[50%] success: Built 4aea577eb744c3399c23dd93a5ab40e0b5a9bb67b0a65cd383ca9c1b728b6e1b:current_account-current_region
[75%] success: Built 369141d9c3fce053bfb036a3081d5b6ac09d809d33f4e7705d3bb95f4708fe08:current_account-current_region
[100%] success: Built 61c63449bfa374126c263ef985e327bb569ab247e7e1537d0542c77b2e18ab0d:current_account-current_region

stg-aiStoriesBackend: assets built

โŒ Building assets failed: Error: Building Assets Failed: Error: Failed to build one or more assets. See the error messages above for more information.
at buildAllStackAssets (/Users/chiweitseng/WorkSpace/gluten-ai/aws-serverless-ai-stories/backend/node_modules/aws-cdk/lib/index.js:347:116743)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async CdkToolkit.deploy (/Users/chiweitseng/WorkSpace/gluten-ai/aws-serverless-ai-stories/backend/node_modules/aws-cdk/lib/index.js:347:142824)
at async exec4 (/Users/chiweitseng/WorkSpace/gluten-ai/aws-serverless-ai-stories/backend/node_modules/aws-cdk/lib/index.js:402:51795)

Building Assets Failed: Error: Failed to build one or more assets. See the error messages above for more information.

Error: Request failed with status code 429 from Lamba Function stg-aiStoriesBackend-scheduledlambdafunction

Hey, nice blog!
When I execute, the lambda function stg-aiStoriesBackend-scheduledlambdafunction generates an error 429 from the CloudWatch logs. Does someone have any ideas to work around?

2023-04-02T13:23:32.644Z	df3a5f89-d9f8-41d6-827f-f892dce7b4d5	ERROR	Invoke Error 	{
    "message": "Request failed with status code 429",
    "name": "Error",
    "stack": "Error: Request failed with status code 429\n    at createError (/var/task/index.js:356:19)\n    at settle (/var/task/index.js:372:16)\n    at IncomingMessage.handleStreamEnd (/var/task/index.js:2222:15)\n    at IncomingMessage.emit (node:events:525:35)\n    at endReadableNT (node:internal/streams/readable:1359:12)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)",
    "config": {
        "transitional": {
            "silentJSONParsing": true,
            "forcedJSONParsing": true,
            "clarifyTimeoutError": false
        },
        "transformRequest": [
            null
        ],
        "transformResponse": [
            null
        ],
        "timeout": 0,
        "xsrfCookieName": "XSRF-TOKEN",
        "xsrfHeaderName": "X-XSRF-TOKEN",
        "maxContentLength": -1,
        "maxBodyLength": -1,
        "headers": {
            "Accept": "application/json, text/plain, */*",
            "Content-Type": "application/json",
            "User-Agent": "OpenAI/NodeJS/3.1.0",
            "Authorization": "Bearer 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",
            "Content-Length": 289
        },
        "method": "post",
        "data": "{\"model\":\"text-davinci-003\",\"prompt\":\"\\n  Write a title and a rhyming story on 2 main characters called Jerry and Tom.\\n  The story needs to be set within the scene Deep dark woods surrounded by small friendly monsters and be at least 200 words long\\n\",\"max_tokens\":1000,\"temperature\":0.7}",
        "url": "https://api.openai.com/v1/completions"
    },
    "status": 429
}

Extra steps before 'npm run deploy' worked

Cool project - thanks!

I did get it to deploy, but had to take some extra steps to get it to succeed. If I didn't do these steps npm run deploy would bomb out.

  • cd backend/src/create-story && npm i
  • cd backend/src/generate-audio-for-story && npm i
  • cd backend/src/generate-images-for-story && npm i
  • cd frontend && touch .env

I pass this along in case it makes sense to you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.