Skip to content

Commit

Permalink
feat: add tag generation for YouTube
Browse files Browse the repository at this point in the history
- use latest GHA action versions without warnings
- add Luciano's PR feedback

Co-authored-by: Luciano Mammino <lucianomammino@gmail.com>
  • Loading branch information
eoinsha and lmammino committed Nov 2, 2023
1 parent 5006da9 commit fdbe860
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 18.x
- run: npm ci
Expand Down
3 changes: 3 additions & 0 deletions functions/pull-request/pr-description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ ${summary.episodeSummary}
## Suggested Chapters
${ytChapters}
## Suggested Tags
${summary.tags.join('\n')}
`
}
6 changes: 4 additions & 2 deletions lib/prompt-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ The transcript segments have start and end time in floating point seconds.
Include these timestamps taken exactly from the segments.
The chapter summaries should not include the speaker names.
The results should be provided as JSON with an episodeSummary property and a chapters property, which
is an array of objects with properties "summary" and "startTimestamp".
is an array of objects with properties "summary" and "startTimestamp". In addition, include an array
with at least 20 relevant tags that can be added to the YouTube video.
For example, {
"episodeSummary": "...",
"chapters": [
{{"startTimestamp": 0, "summary": "Introduction"}},
{{"startTimestamp": 23.4, "summary": "Pros and cons of CloudTrail vs. third-party solutions"}},
{{"startTimestamp": 69.1, "summary": "Using CloudTrail with Athena"}}
]
],
"tags": ["AWS", "CloudTrail", "Athena", "Glue", "Hive", "CloudFormation", ...]
}
${JSON.stringify(transcript)}
Expand Down
1 change: 1 addition & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Chapter {
export interface Summary {
episodeSummary: string
chapters: Chapter[]
tags: string[]
}

export interface TranscriptSegment {
Expand Down
2 changes: 1 addition & 1 deletion price-monitor/lib/price-monitor-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class PriceMonitorStack extends cdk.Stack {
metricName: 'OutputTokenCount',
region: bedrockRegion,
statistic: 'Sum',
label: 'Input Tokens',
label: 'Output Tokens',
dimensionsMap: {
ModelId: modelId
}
Expand Down
9 changes: 8 additions & 1 deletion tests/functions/pull-request/pr-description.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ test('PR description is correctly generated', async () => {
startTimestamp: 2999.123,
summary: 'Conclusion and desperate appeal for more subscribers'
}
]
],
tags: ['InfiniDash', 'SpodlgeWrangler', 'CloudFormation', 'Cost Explorer']
}

const markdown = createPullRequestDescription(summary)
Expand All @@ -60,5 +61,11 @@ We hallucinate about topics we don't understand
06:31 Securing a second mortgage to pay for InfiniDash
17:10 How to lobby the CloudFormation team for full InfiniDash support
49:59 Conclusion and desperate appeal for more subscribers
## Suggested Tags
InfiniDash
SpodlgeWrangler
CloudFormation
Cost Explorer
`)
})
13 changes: 3 additions & 10 deletions tests/functions/summary/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,12 @@ const testSummary = {
chapters: [
{ start_timestamp: 0, summary: 'Introduction' },
{ start_timestamp: 1046.38, summary: 'Conclusion and recommendations' }
]
],
tags: ['AWS', 'Stuff', 'Things']
}

test('summary Lambda function loads transcript and ', async () => {
const transcriptKey = 'transcripts/999.json'
const summary = {
episodeSummary: 'We discuss the options for publishing reusable AWS resources like Lambda functions. They cover approaches like GitHub, Serverless Application Repository, Terraform Modules, and more.',
chapters: [
{ start_timestamp: 0, summary: 'Introduction' },
{ start_timestamp: 1046.38, summary: 'Conclusion and recommendations' }
]
}

mockS3.on(GetObjectCommand).callsFakeOnce((input) => {
assert.equal(input.Key, transcriptKey)
return {
Expand All @@ -55,5 +48,5 @@ test('summary Lambda function loads transcript and ', async () => {
(createSummary as Mock).mockReturnValueOnce(testSummary)

const result = await handleEvent({ transcriptKey }, fakeLambdaContext)
assert.deepEqual(result.summary, summary)
assert.deepEqual(result.summary, testSummary)
})
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"strictNullChecks": true,
"alwaysStrict": true,
"noEmit": true,
"moduleResolution": "node",
"moduleResolution": "nodenext",
"resolveJsonModule": true,
"target": "ESNext",
"allowSyntheticDefaultImports": true,
Expand Down

0 comments on commit fdbe860

Please sign in to comment.