Skip to content

Commit

Permalink
function build
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlevy0 committed Dec 5, 2023
1 parent 1b30a56 commit 7774e13
Show file tree
Hide file tree
Showing 11 changed files with 3,001 additions and 17 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ yarn-error.log*
next-env.d.ts


amplify/backend/function/S3Trigger52a3ac74/src/**/*.js
amplify/backend/function/S3Trigger52a3ac74/src/**/*.json
# amplify/backend/function/**/src/**/*.js
# amplify/backend/function/**/src/**/*.json
amplify/backend/function/S3Triggera6bc74ca/src/**/*.js


#amplify-do-not-edit-begin
amplify/\#current-cloud-backend
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"files.exclude": {
"amplify/backend/function/S3Triggera6bc74ca/**/*.js": true,
"amplify/.config": true,
"amplify/**/*-parameters.json": true,
"amplify/**/amplify.state": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function isKeyMoment(segmentInfo): boolean {

async function analyzeWithChatGPT(text) {
try {
const completion = await await openai.chat.completions.create({
const completion = await openai.chat.completions.create({
messages: [{ role: 'user', content: `${chatGPTPrompt}\n\n${text}` }],
model: conf.openAIConf.model,
max_tokens: conf.openAIConf.maxTokens,
Expand Down
1 change: 1 addition & 0 deletions amplify/backend/function/S3Triggera6bc74ca/src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.js
44 changes: 38 additions & 6 deletions amplify/backend/function/S3Triggera6bc74ca/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
exports.handler = async function (event) {
console.log('Received S3 event:', JSON.stringify(event, null, 2));
const bucket = event.Records[0].s3.bucket.name;
const key = event.Records[0].s3.object.key;
console.log(`Bucket: ${bucket}`, `Key: ${key}`);
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handler = void 0;
const video_1 = require("./video");
const s3_1 = require("./s3");
const getData_1 = require("./getData");
const StatusUploader_1 = require("./StatusUploader");
const types_1 = require("./types");
const utils_1 = require("./utils");
const rekognition_1 = require("./rekognition");
const transcribe_1 = require("./transcribe");
const comprehend_1 = require("./comprehend");
const s3_2 = require("./s3");
const handler = async (event) => {
const statusUploader = StatusUploader_1.default.getInstance();
try {
await statusUploader.setStatus(types_1.EStatus.Init);
const { tmpPath, outputPath, newKey, key, bucket } = await (0, getData_1.getData)(event);
await Promise.all([(0, s3_1.download)(bucket, key, tmpPath), (0, s3_2.waitForS3Replication)(bucket, key)]);
const [{ transcript }, analyzedShots] = await Promise.all([
(0, transcribe_1.getTranscript)(bucket, key),
(0, rekognition_1.analyzeVideo)(key, bucket),
]);
console.log({ transcript });
await (0, comprehend_1.getKeyMoments)(transcript);
await (0, video_1.processVideo)(tmpPath, outputPath, analyzedShots);
await (0, s3_1.upload)(outputPath, bucket, newKey);
await (0, utils_1.cleanTempFiles)(tmpPath, outputPath);
await statusUploader.setStatus(types_1.EStatus.Succeded);
return { statusCode: 200 };
}
catch (error) {
await statusUploader.setStatus(types_1.EStatus.Error);
console.error('Handler error:', error);
return { statusCode: 500, error };
}
};
exports.handler = handler;
Loading

0 comments on commit 7774e13

Please sign in to comment.