Skip to content

Commit 3c15e5e

Browse files
feat(tweets): categorization (#120)
* feat(tweets): categorization * feat(tweets): categorization * feat(tweets): categorization * feat(tweets): categorization --------- Co-authored-by: Mario Raafat <136023677+MarioRaafat@users.noreply.github.com>
1 parent 3a4c578 commit 3c15e5e

File tree

5 files changed

+176
-118
lines changed

5 files changed

+176
-118
lines changed

dump.rdb

452 Bytes
Binary file not shown.

package-lock.json

Lines changed: 120 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"@azure/storage-blob": "^12.29.1",
4242
"@elastic/elasticsearch": "^8.19.1",
4343
"@ffmpeg-installer/ffmpeg": "^1.1.0",
44-
"@google/genai": "^1.28.0",
4544
"@nestjs-modules/ioredis": "^2.0.2",
4645
"@nestjs-modules/mailer": "^2.0.2",
4746
"@nestjs/azure-storage": "^4.0.0",
@@ -71,6 +70,7 @@
7170
"cookie-parser": "^1.4.7",
7271
"fluent-ffmpeg": "^2.1.3",
7372
"google-auth-library": "^10.4.1",
73+
"groq-sdk": "^0.37.0",
7474
"ioredis": "^5.7.0",
7575
"mongoose": "^8.19.1",
7676
"multer": "^2.0.2",

src/tweets/constants.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
export const TOPICS = ['Sports', 'Entertainment', 'News'];
22

33
export const categorize_prompt = (content: string) => {
4-
return `Analyze the following text and categorize it into these topics: ${TOPICS.join(', ')}.
5-
Return ONLY a JSON object with topic names as keys and percentage values (0-100) as numbers. The percentages should add up to 100.
6-
Only include topics that are relevant (percentage > 0).
4+
return `
5+
You are an expert text classifier.
76
8-
Example format:
9-
{ "Sports": 60, "Entertainment": 30, "News": 10 }
7+
Analyze the following text and assign a percentage (0-100) to EACH of these topics:
8+
${TOPICS.join(', ')}.
109
11-
Text to analyze:
12-
"${content}"
10+
IMPORTANT RULES:
11+
- Always return ALL topics.
12+
- Percentages MUST sum to 100.
13+
- If a topic is not relevant, assign 0 to it (do NOT omit it).
14+
- Return ONLY a JSON object. No explanations. No extra text.
1315
14-
Return only the JSON object, no additional text or explanation.
15-
`;
16+
Example:
17+
{ "Sports": 80, "Entertainment": 20, "News": 0 }
18+
19+
Text:
20+
"${content}"
21+
22+
Return ONLY the JSON object.
23+
`;
1624
};

0 commit comments

Comments
 (0)