bulltrackers-module 1.0.75 → 1.0.77

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,21 +21,30 @@ 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
- // --- START FIX ---
32
- // The request payload was malformed.
33
- // 1. `contents` must have a `parts` array.
34
- // 2. `generationConfig` must be a nested object.
40
+ // --- START FIX: Corrected Request Payload ---
41
+ // The payload must include `role: 'user'` and a `parts` array.
42
+ // Generation settings are nested under `generationConfig`.
35
43
  const request = {
36
44
  contents: [
37
- {
38
- parts: [ { text: prompt } ]
45
+ {
46
+ role: "user",
47
+ parts: [ { text: prompt } ]
39
48
  }
40
49
  ],
41
50
  generationConfig: {
@@ -49,16 +58,18 @@ Post: "${snippet}"`;
49
58
  const result = await geminiModel.generateContent(request);
50
59
  const response = result.response;
51
60
 
52
- // --- START FIX ---
53
- // 3. The response structure is content.parts[0].text, not content[0].text
61
+ // --- START FIX: Corrected Response Parsing ---
62
+ // The text is located at `content.parts[0].text`,
63
+ // not `content[0].text` as in the original file.
54
64
  const text = response?.candidates?.[0]?.content?.parts?.[0]?.text?.trim() || '';
55
65
  // --- END FIX ---
56
66
 
57
67
  // Robust parsing: Find the keyword, case-insensitive.
58
- const match = text.match(/(Bullish|Bearish|Neutral)/i);
68
+ const match = text.match(/\b(Bullish|Bearish|Neutral)\b/i);
59
69
  if (match && match[0]) {
60
70
  // Capitalize first letter, e.g., "bullish" -> "Bullish"
61
71
  const sentiment = match[0].charAt(0).toUpperCase() + match[0].slice(1).toLowerCase();
72
+ logger.log('TRACE', `[getSentimentFromGemini] Raw Gemini response: ${JSON.stringify(response)}`);
62
73
  logger.log('INFO', `[getSentimentFromGemini] Classified sentiment: ${sentiment}`);
63
74
  return sentiment;
64
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.75",
3
+ "version": "1.0.77",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [