Skip to content

Commit

Permalink
v1.2.0 - fixes and adds gpt-4o-mini
Browse files Browse the repository at this point in the history
  • Loading branch information
thevops committed Jul 23, 2024
1 parent 5802bbb commit cf1ecc8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ jobs:
- name: 🛠️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: 📝 Get application version
id: version
run: |
echo "APP_VERSION=$(cat ./VERSION)" >> "$GITHUB_ENV"
- name: 📝 Docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: thevops/youtube-summarizer
tags: |
type=sha
type=semver,pattern={{raw}}
type=raw,value=${{ steps.version.outputs.APP_VERSION }}
type=ref,event=branch
type=ref,event=pr
Expand Down
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: local
hooks:
- id: check-version-file
name: Check VERSION file
entry: |
sh -c 'git diff --quiet master ./VERSION || echo "ERROR: The VERSION file must be different from the one in the master branch."'
language: system
files: VERSION
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.2.0
17 changes: 13 additions & 4 deletions src/langchain-openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export async function summaryYouTubeTranscript(transcript: string) {
Słowa kluczowe: <keywords>`;

const model = new ChatOpenAI({
model: "gpt-4o",
model: "gpt-4o-mini",
temperature: 0.2,
topP: 0.9,
apiKey: Config.openai_api_key,
});

Expand Down Expand Up @@ -56,8 +57,12 @@ if (import.meta.main) {
async function test_one() {
// Podrabianie sprzętu komputerowego, w tym #cisco, #yubikey - Mateusz Chrobok
const transcript_1 = await youtube.getTranscript(
"https://www.youtube.com/watch?v=oDlMrMgGGA4",
"oDlMrMgGGA4",
);
if (transcript_1 === null) {
console.log("Transcript is null");
return;
}
console.log(transcript_1);
console.log("--------------------------------------------------");
const [summary_1, usage_1] = await summaryYouTubeTranscript(transcript_1);
Expand All @@ -68,15 +73,19 @@ if (import.meta.main) {
async function test_two() {
// O co chodzi z Passkeys? Pytacie, odpowiadam(y). Q&A @secfense
const transcript_1 = await youtube.getTranscript(
"https://www.youtube.com/watch?v=rf6LriO_dy8",
"rf6LriO_dy8",
);
if (transcript_1 === null) {
console.log("Transcript is null");
return;
}
console.log(transcript_1);
console.log("--------------------------------------------------");
const [summary_1, usage_1] = await summaryYouTubeTranscript(transcript_1);
console.log(summary_1);
console.log(usage_1);
}

// await test_one();
await test_one();
// await test_two();
}
13 changes: 7 additions & 6 deletions src/youtube.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Innertube } from "youtubei.js/web";
import { logger } from "./config.ts";

export async function extractVideoId(videoUrl: string): Promise<string | null> {
const urlParts = videoUrl.split("v=");
Expand Down Expand Up @@ -34,6 +35,7 @@ export async function getTranscript(videoId: string): Promise<string | null> {
.join(" ") ?? ""
);
} catch (error) {
logger.error(`Failed to get the transcript: ${error}`);
return null;
}
}
Expand Down Expand Up @@ -65,30 +67,29 @@ if (import.meta.main) {
async function test_getTranscript() {
// Jak pół sekundy uratowało świat przed zagładą? - Mateusz Chrobok
const transcript_1 = await getTranscript(
"https://www.youtube.com/watch?v=44HSTVBvAO4",
"44HSTVBvAO4",
);
console.log(transcript_1);
console.log("--------------------------------------------------");

// Nix for Everyone: Unleash Devbox for Simplified Development - DevOps Toolkit
const transcript_2 = await getTranscript(
"https://www.youtube.com/watch?v=WiFLtcBvGMU",
"WiFLtcBvGMU",
);
console.log(transcript_2);
console.log("--------------------------------------------------");

// J.K. Rowling czeka na bycie aresztowaną? | Przegląd Idei #111 (08.04.2024) - Szymon mówi
const transcript_3 = await getTranscript(
"https://www.youtube.com/watch?v=Rcw-eWn8hWQ",
"Rcw-eWn8hWQ",
);
console.log(transcript_3);
}

async function test_getVideoDetails() {
// const videoUrl = "https://www.youtube.com/watch?v=rK8gII2FWqA";
const videoUrl2 = "https://www.youtube.com/watch?v=44HSTVBvAO4";
const videoId = "44HSTVBvAO4";
const [title, channel, duration, upload_date] =
await getVideoDetails(videoUrl2);
await getVideoDetails(videoId);
console.log(`${title} ${channel} ${duration} ${upload_date}`);
}

Expand Down

0 comments on commit cf1ecc8

Please sign in to comment.