Skip to content

Commit 0867ae8

Browse files
committed
Integrated prettier
1 parent 887d961 commit 0867ae8

26 files changed

+764
-766
lines changed

.coderabbit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ reviews:
1616

1717
# Optional: By default, draft pull requests are not reviewed.
1818
# Set to true if you want Coderabbit to review drafts as well.
19-
drafts: false
19+
drafts: false

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"printWidth": 120,
3+
"trailingComma": "none",
4+
"singleQuote": true,
5+
"semi": true,
6+
"useTabs": false,
7+
"tabWidth": 2,
8+
"arrowParens": "always",
9+
"jsxSingleQuote": true
10+
}

.vscode/launch.json

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
{
2-
// Use IntelliSense to learn about possible attributes.
3-
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5-
"version": "0.2.0",
6-
"configurations": [
7-
{
8-
"type": "node",
9-
"request": "launch",
10-
"name": "Debug redisDedupeListener",
11-
"skipFiles": [
12-
"<node_internals>/**"
13-
],
14-
"program": "${workspaceFolder}/src/redisDedupeListener.ts",
15-
"runtimeExecutable": "npx",
16-
"runtimeArgs": ["tsx"],
17-
"console": "integratedTerminal",
18-
"internalConsoleOptions": "openOnSessionStart",
19-
"env": {
20-
"NODE_OPTIONS": "--enable-source-maps"
21-
}
22-
}
23-
]
24-
}
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Debug redisDedupeListener",
11+
"skipFiles": ["<node_internals>/**"],
12+
"program": "${workspaceFolder}/src/redisDedupeListener.ts",
13+
"runtimeExecutable": "npx",
14+
"runtimeArgs": ["tsx"],
15+
"console": "integratedTerminal",
16+
"internalConsoleOptions": "openOnSessionStart",
17+
"env": {
18+
"NODE_OPTIONS": "--enable-source-maps"
19+
}
20+
}
21+
]
22+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# classifier
2+
23
AI engine for classifying market sentiment, topics, and trustworthiness from raw data.

data/sample_posts.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@
3232
"url": "https://x.com/1003",
3333
"date": "2025-09-03T18:20:00.000Z"
3434
}
35-
]
35+
]

package-lock.json

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

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"start": "node dist/run-classifier.js",
1515
"seed": "tsx src/seed.ts",
1616
"seed:clear": "tsx src/seed.ts clear",
17-
"seed:verify": "tsx src/seed.ts verify"
17+
"seed:verify": "tsx src/seed.ts verify",
18+
"format": "npx prettier --write ."
1819
},
1920
"dependencies": {
2021
"@prisma/client": "^6.15.0",
@@ -26,6 +27,7 @@
2627
},
2728
"devDependencies": {
2829
"@types/node": "^24.3.1",
30+
"prettier": "^3.6.2",
2931
"tsx": "^4.20.5",
3032
"typescript": "^5.9.2"
3133
}

run-classifier.ts

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,62 +9,62 @@ import { generateTitlesForPosts } from './src/generateTitle.js';
99
const command = process.argv[2];
1010

1111
async function main() {
12-
console.log("🤖 SentioPulse Classifier Tool");
13-
console.log("==============================\n");
12+
console.log('🤖 SentioPulse Classifier Tool');
13+
console.log('==============================\n');
1414

15-
switch (command) {
16-
case 'complete':
17-
case 'all':
18-
console.log("Running complete analysis (categorization + sentiment + title generation)...");
19-
await runCompleteAnalysisDemo();
20-
break;
15+
switch (command) {
16+
case 'complete':
17+
case 'all':
18+
console.log('Running complete analysis (categorization + sentiment + title generation)...');
19+
await runCompleteAnalysisDemo();
20+
break;
2121

22-
case 'categorize':
23-
case 'category':
24-
console.log("Running categorization only...");
25-
await runCategorization();
26-
break;
22+
case 'categorize':
23+
case 'category':
24+
console.log('Running categorization only...');
25+
await runCategorization();
26+
break;
2727

28-
case 'sentiment': {
29-
console.log("Running sentiment analysis only...");
30-
const samplePosts = [
31-
"Bitcoin is going to skyrocket after the halving event next month! The fundamentals are incredibly strong and institutional adoption is accelerating. This could be the start of the next major bull run.",
32-
"Ethereum might drop below $1000 soon due to the current risky market conditions. The macro environment is deteriorating and there's too much leverage in the system right now.",
33-
"The market seems calm today with no major moves in either direction. Bitcoin is trading sideways and most altcoins are following suit. It's a good time to accumulate quality projects."
34-
];
35-
const sentimentResults = await analyzeMultiplePosts(samplePosts);
36-
console.log("Sentiment Results:", JSON.stringify(sentimentResults, null, 2));
37-
break;
38-
}
28+
case 'sentiment': {
29+
console.log('Running sentiment analysis only...');
30+
const samplePosts = [
31+
'Bitcoin is going to skyrocket after the halving event next month! The fundamentals are incredibly strong and institutional adoption is accelerating. This could be the start of the next major bull run.',
32+
"Ethereum might drop below $1000 soon due to the current risky market conditions. The macro environment is deteriorating and there's too much leverage in the system right now.",
33+
"The market seems calm today with no major moves in either direction. Bitcoin is trading sideways and most altcoins are following suit. It's a good time to accumulate quality projects."
34+
];
35+
const sentimentResults = await analyzeMultiplePosts(samplePosts);
36+
console.log('Sentiment Results:', JSON.stringify(sentimentResults, null, 2));
37+
break;
38+
}
3939

40-
case 'title':
41-
case 'titles': {
42-
console.log("Running title generation only...");
43-
const titlePosts = [
44-
"Benchmarking tiny on-device ML models for edge inference — latency down 40% with the new quantization pipeline.",
45-
"Q2 fintech update: payments startup doubled TPV and improved take rate; unit economics are trending positive.",
46-
"Reading a new whitepaper on Web3 compliance and institutional custody — regulatory clarity is the next catalyst for adoption."
47-
];
48-
const titleResults = await generateTitlesForPosts(titlePosts);
49-
console.log("Title Results:", JSON.stringify(titleResults, null, 2));
50-
break;
51-
}
40+
case 'title':
41+
case 'titles': {
42+
console.log('Running title generation only...');
43+
const titlePosts = [
44+
'Benchmarking tiny on-device ML models for edge inference — latency down 40% with the new quantization pipeline.',
45+
'Q2 fintech update: payments startup doubled TPV and improved take rate; unit economics are trending positive.',
46+
'Reading a new whitepaper on Web3 compliance and institutional custody — regulatory clarity is the next catalyst for adoption.'
47+
];
48+
const titleResults = await generateTitlesForPosts(titlePosts);
49+
console.log('Title Results:', JSON.stringify(titleResults, null, 2));
50+
break;
51+
}
5252

53-
case 'help':
54-
case '--help':
55-
case '-h':
56-
showHelp();
57-
break;
53+
case 'help':
54+
case '--help':
55+
case '-h':
56+
showHelp();
57+
break;
5858

59-
default:
60-
console.log("No command specified. Running complete analysis by default...");
61-
await runCompleteAnalysisDemo();
62-
break;
63-
}
59+
default:
60+
console.log('No command specified. Running complete analysis by default...');
61+
await runCompleteAnalysisDemo();
62+
break;
63+
}
6464
}
6565

6666
function showHelp() {
67-
console.log(`
67+
console.log(`
6868
Usage: npm run classify [command]
6969
7070
Commands:
@@ -86,6 +86,6 @@ If no command is provided, complete analysis will run by default.
8686

8787
// Handle errors gracefully
8888
main().catch((error) => {
89-
console.error("❌ Error running classifier:", error);
90-
process.exit(1);
89+
console.error('❌ Error running classifier:', error);
90+
process.exit(1);
9191
});

src/analyzeSentiment.ts

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ import { callOpenAIWithValidation } from './openaiValidationUtil.js';
44
import { z } from 'zod';
55
import { generateTitleForPost } from './generateTitle.js';
66

7-
// Sentiment analysis result type
7+
// Sentiment analysis result type
88
export type SentimentResult = {
9-
post: string;
10-
sentiment: "BULLISH" | "BEARISH" | "NEUTRAL";
9+
post: string;
10+
sentiment: 'BULLISH' | 'BEARISH' | 'NEUTRAL';
1111
};
1212

1313
// Zod schema for sentiment validation
1414
const SentimentSchema = z.object({
15-
sentiment: z.enum(["BULLISH", "BEARISH", "NEUTRAL"])
15+
sentiment: z.enum(['BULLISH', 'BEARISH', 'NEUTRAL'])
1616
});
1717

1818
// Analyze multiple posts at once
1919
export async function analyzeMultiplePosts(posts: string[]): Promise<SentimentResult[]> {
20-
const results: SentimentResult[] = [];
21-
const systemPrompt = `You are a sentiment analysis system for crypto-related posts.
20+
const results: SentimentResult[] = [];
21+
const systemPrompt = `You are a sentiment analysis system for crypto-related posts.
2222
Classify the sentiment of posts into one of: BULLISH, BEARISH, NEUTRAL.
2323
2424
Important: Always return the sentiment in uppercase letters exactly like this: BULLISH, BEARISH, NEUTRAL,
@@ -29,52 +29,52 @@ Return only valid JSON in this format:
2929
"sentiment": "BULLISH"
3030
}`;
3131

32-
for (const post of posts) {
33-
try {
34-
const validated = await callOpenAIWithValidation({
35-
client: openai,
36-
systemPrompt,
37-
userPrompt: post,
38-
schema: SentimentSchema,
39-
retryCount: 3
40-
});
32+
for (const post of posts) {
33+
try {
34+
const validated = await callOpenAIWithValidation({
35+
client: openai,
36+
systemPrompt,
37+
userPrompt: post,
38+
schema: SentimentSchema,
39+
retryCount: 3
40+
});
4141

42-
if (validated) {
43-
results.push({ post, sentiment: validated.sentiment });
44-
}
45-
} catch (e) {
46-
console.error("Error analyzing post:", post, e);
47-
continue;
48-
}
42+
if (validated) {
43+
results.push({ post, sentiment: validated.sentiment });
44+
}
45+
} catch (e) {
46+
console.error('Error analyzing post:', post, e);
47+
continue;
4948
}
50-
return results;
49+
}
50+
return results;
5151
}
5252

5353
async function runExample() {
54-
// Example runner
55-
const posts = [
56-
"Bitcoin is going to skyrocket after the halving event next month! The fundamentals are incredibly strong and institutional adoption is accelerating. This could be the start of the next major bull run that takes us to new all-time highs.",
57-
"Ethereum might drop below $1000 soon due to the current risky market conditions. The macro environment is deteriorating and there's too much leverage in the system. I'm expecting a significant correction in the coming weeks.",
58-
"The market seems calm today with no major moves in either direction. Bitcoin is trading sideways and most altcoins are following suit. It's a good time to accumulate quality projects at these levels."
59-
];
54+
// Example runner
55+
const posts = [
56+
'Bitcoin is going to skyrocket after the halving event next month! The fundamentals are incredibly strong and institutional adoption is accelerating. This could be the start of the next major bull run that takes us to new all-time highs.',
57+
"Ethereum might drop below $1000 soon due to the current risky market conditions. The macro environment is deteriorating and there's too much leverage in the system. I'm expecting a significant correction in the coming weeks.",
58+
"The market seems calm today with no major moves in either direction. Bitcoin is trading sideways and most altcoins are following suit. It's a good time to accumulate quality projects at these levels."
59+
];
6060

61-
const results = await analyzeMultiplePosts(posts);
62-
const resultsByPost = new Map(results.map(r => [r.post, r.sentiment]));
63-
for (const post of posts) {
64-
const sentiment = resultsByPost.get(post);
65-
const title = await generateTitleForPost(post);
66-
console.log(`Post: ${post}`);
67-
if (title) {
68-
console.log(`Title: ${title}`);
69-
}
70-
if (sentiment) {
71-
console.log(`Sentiment: ${sentiment}`);
72-
}
73-
console.log('─'.repeat(40));
61+
const results = await analyzeMultiplePosts(posts);
62+
const resultsByPost = new Map(results.map((r) => [r.post, r.sentiment]));
63+
for (const post of posts) {
64+
const sentiment = resultsByPost.get(post);
65+
const title = await generateTitleForPost(post);
66+
console.log(`Post: ${post}`);
67+
if (title) {
68+
console.log(`Title: ${title}`);
7469
}
70+
if (sentiment) {
71+
console.log(`Sentiment: ${sentiment}`);
72+
}
73+
console.log('─'.repeat(40));
74+
}
7575
}
7676

7777
// Run example if this file is executed directly (not imported)
7878
if (require.main === module) {
79-
runExample();
80-
}
79+
runExample();
80+
}

0 commit comments

Comments
 (0)