Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
elitan committed Oct 9, 2023
1 parent 2b13438 commit 21b5ae9
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 45 deletions.
4 changes: 2 additions & 2 deletions worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
"kysely": "^0.26.1",
"kysely-codegen": "^0.10.1",
"node-fetch": "^2.4.0",
"openai": "^3.3.0",
"openai": "^4.11.1",
"pg": "^8.11.1",
"slugify": "^1.6.6",
"ts-node": "^10.9.1",
"twitter-api-v2": "^1.15.1",
"typescript": "^5.1.6",
"uuid": "^9.0.0",
"zod": "^3.21.4"
"zod": "^3.22.4"
},
"devDependencies": {
"@types/fb": "^0.0.28",
Expand Down
149 changes: 127 additions & 22 deletions worker/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 18 additions & 7 deletions worker/src/3-openai.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import slugify from 'slugify';

import { db } from './utils/db';
import { generateArticle, textIsRelatedToSweden } from './utils/openai';
import slugify from 'slugify';

(async () => {
const articlesToRefine = await db
Expand All @@ -21,11 +22,15 @@ import slugify from 'slugify';
console.log('check if the source information is related to sweden');

// check if the article is related to sweden or not
const isRelatedToSweden = await textIsRelatedToSweden(
article.transcribedText as string,
);

console.log({ isRelatedToSweden });
let isRelatedToSweden = false;
try {
isRelatedToSweden = await textIsRelatedToSweden(
article.transcribedText as string,
);
} catch (e) {
console.error('error: ', e);
continue;
}

await db
.updateTable('articles')
Expand All @@ -43,7 +48,13 @@ import slugify from 'slugify';

console.log('generate article...');

const generatedArticle = await generateArticle(article.transcribedText);
let generatedArticle = null;
try {
generatedArticle = await generateArticle(article.transcribedText);
} catch (e) {
console.error(e);
continue;
}

console.log('article generation compelted');

Expand Down
Loading

0 comments on commit 21b5ae9

Please sign in to comment.