bulltrackers-module 1.0.76 → 1.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,11 +21,20 @@ async function getSentimentFromGemini(dependencies, snippet) {
21
21
  return 'Neutral';
22
22
  }
23
23
 
24
- const prompt = `You are a financial sentiment analyzer for social media posts.
25
- Classify the following post as 'Bullish', 'Bearish', or 'Neutral'.
26
- Respond with only one of those three words.
24
+ const prompt = `You are a financial sentiment analyzer specializing in social media posts about trading.
25
+ Your task is to determine the sentiment of the author toward the mentioned asset(s).
26
+
27
+ Possible labels:
28
+ - Bullish: Positive outlook, confidence, or optimism about the asset.
29
+ - Bearish: Negative outlook, loss, or pessimism about the asset.
30
+ - Neutral: Informational or balanced, with no clear positive or negative tone.
31
+
32
+ Important: If the author reports selling at a loss, expresses regret, or uses negative emojis or language about the asset, classify as Bearish.
33
+
34
+ Return only one word: Bullish, Bearish, or Neutral.
35
+
36
+ Post: "${snippet}"`
27
37
 
28
- Post: "${snippet}"`;
29
38
 
30
39
  try {
31
40
  // --- START FIX: Corrected Request Payload ---
@@ -51,15 +60,15 @@ Post: "${snippet}"`;
51
60
 
52
61
  // --- START FIX: Corrected Response Parsing ---
53
62
  // The text is located at `content.parts[0].text`,
54
- // not `content[0].text` as in the original file.
55
63
  const text = response?.candidates?.[0]?.content?.parts?.[0]?.text?.trim() || '';
56
64
  // --- END FIX ---
57
65
 
58
66
  // Robust parsing: Find the keyword, case-insensitive.
59
- const match = text.match(/(Bullish|Bearish|Neutral)/i);
67
+ const match = text.match(/\b(Bullish|Bearish|Neutral)\b/i);
60
68
  if (match && match[0]) {
61
69
  // Capitalize first letter, e.g., "bullish" -> "Bullish"
62
70
  const sentiment = match[0].charAt(0).toUpperCase() + match[0].slice(1).toLowerCase();
71
+ logger.log('TRACE', `[getSentimentFromGemini] Raw Gemini response: ${JSON.stringify(response)}`);
63
72
  logger.log('INFO', `[getSentimentFromGemini] Classified sentiment: ${sentiment}`);
64
73
  return sentiment;
65
74
  }
@@ -193,6 +202,25 @@ exports.handleSocialTask = async (message, context, config, dependencies) => {
193
202
  processedInThisRun.add(post.id);
194
203
  const text = post.message.text;
195
204
 
205
+ // --- START: Enhanced Data Extraction ---
206
+ const likeCount = discussion.emotionsData?.like?.paging?.totalCount || 0;
207
+ const commentCount = discussion.summary?.totalCommentsAndReplies || 0;
208
+ let pollData = null;
209
+
210
+ // Check for poll data and extract it
211
+ if (post.type === 'Poll' && post.metadata?.poll?.options) {
212
+ pollData = {
213
+ id: post.metadata.poll.id,
214
+ options: post.metadata.poll.options.map(opt => ({
215
+ id: opt.id,
216
+ text: opt.text,
217
+ votesCount: opt.votesCount || 0
218
+ }))
219
+ };
220
+ }
221
+ // --- END: Enhanced Data Extraction ---
222
+
223
+
196
224
  // 1. Truncate for AI
197
225
  const MAX_CHARS = 500; // ~125 tokens, very cheap
198
226
  let snippet = text;
@@ -212,9 +240,13 @@ exports.handleSocialTask = async (message, context, config, dependencies) => {
212
240
  const postData = {
213
241
  sentiment: sentiment,
214
242
  textSnippet: snippet,
243
+ fullText: text, // Store the full original text
215
244
  language: lang,
216
245
  tickers: post.tags.map(t => t.market?.symbolName).filter(Boolean),
217
246
  postOwnerId: post.owner?.id,
247
+ likeCount: likeCount, // Store like count
248
+ commentCount: commentCount, // Store comment count
249
+ pollData: pollData, // Store poll data (will be null if not a poll)
218
250
  createdAt: post.created,
219
251
  fetchedAt: FieldValue.serverTimestamp()
220
252
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.76",
3
+ "version": "1.0.78",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [