Upload engine/predict_yearly.py with huggingface_hub
Browse files- engine/predict_yearly.py +20 -2
engine/predict_yearly.py
CHANGED
|
@@ -4562,10 +4562,20 @@ Respond with ONLY this JSON:
|
|
| 4562 |
"p_bull": <float>,
|
| 4563 |
"p_neutral": <float>,
|
| 4564 |
"conviction": <float: 0.0-1.0, confidence in these weights>,
|
| 4565 |
-
"reasoning": "<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4566 |
"risk_flags": ["<combined key risks from both cases>"],
|
| 4567 |
"override_ml": <boolean>
|
| 4568 |
-
}}
|
|
|
|
|
|
|
| 4569 |
|
| 4570 |
|
| 4571 |
def _emit_role(role, phase, entry, *, ret_key="expected_return"):
|
|
@@ -4584,6 +4594,7 @@ def _emit_role(role, phase, entry, *, ret_key="expected_return"):
|
|
| 4584 |
"recommendation": entry.get("recommendation"),
|
| 4585 |
"confidence": entry.get("confidence"),
|
| 4586 |
"reasoning": entry.get("reasoning", ""),
|
|
|
|
| 4587 |
}), flush=True)
|
| 4588 |
except Exception:
|
| 4589 |
pass
|
|
@@ -5016,6 +5027,7 @@ def analyze_llm_debate_yearly(
|
|
| 5016 |
"recommendation": final_rec,
|
| 5017 |
"confidence": final_confidence,
|
| 5018 |
"reasoning": pm_reasoning,
|
|
|
|
| 5019 |
})
|
| 5020 |
|
| 5021 |
# Display-compatible round dicts
|
|
@@ -5026,6 +5038,7 @@ def analyze_llm_debate_yearly(
|
|
| 5026 |
"direction": neutral_result["direction"], "confidence": neutral_result["confidence"],
|
| 5027 |
"recommendation": neutral_result.get("recommendation", "HOLD"),
|
| 5028 |
"reasoning": neutral_result.get("reasoning", ""),
|
|
|
|
| 5029 |
}
|
| 5030 |
if bear_r1:
|
| 5031 |
_round1["kimi"] = {
|
|
@@ -5033,6 +5046,7 @@ def analyze_llm_debate_yearly(
|
|
| 5033 |
"direction": bear_r1.get("direction", "BEARISH"), "confidence": bear_r1["confidence"],
|
| 5034 |
"recommendation": bear_r1.get("recommendation", "HOLD"),
|
| 5035 |
"reasoning": bear_r1.get("reasoning", ""),
|
|
|
|
| 5036 |
}
|
| 5037 |
if bull_r1:
|
| 5038 |
_round1["gpt"] = {
|
|
@@ -5040,6 +5054,7 @@ def analyze_llm_debate_yearly(
|
|
| 5040 |
"direction": bull_r1.get("direction", "BULLISH"), "confidence": bull_r1["confidence"],
|
| 5041 |
"recommendation": bull_r1.get("recommendation", "HOLD"),
|
| 5042 |
"reasoning": bull_r1.get("reasoning", ""),
|
|
|
|
| 5043 |
}
|
| 5044 |
|
| 5045 |
_round2 = {}
|
|
@@ -5049,6 +5064,7 @@ def analyze_llm_debate_yearly(
|
|
| 5049 |
"direction": bear_final.get("direction", "BEARISH"), "confidence": bear_final["confidence"],
|
| 5050 |
"recommendation": bear_final.get("recommendation", "HOLD"),
|
| 5051 |
"reasoning": bear_final.get("reasoning", ""),
|
|
|
|
| 5052 |
"changed": bear_final.get("changed_view", False),
|
| 5053 |
}
|
| 5054 |
if bull_final:
|
|
@@ -5057,12 +5073,14 @@ def analyze_llm_debate_yearly(
|
|
| 5057 |
"direction": bull_final.get("direction", "BULLISH"), "confidence": bull_final["confidence"],
|
| 5058 |
"recommendation": bull_final.get("recommendation", "HOLD"),
|
| 5059 |
"reasoning": bull_final.get("reasoning", ""),
|
|
|
|
| 5060 |
"changed": bull_final.get("changed_view", False),
|
| 5061 |
}
|
| 5062 |
_round2["claude"] = {
|
| 5063 |
"model": "Claude (PM, synthesis)", "return": final_return,
|
| 5064 |
"direction": final_direction, "confidence": final_confidence,
|
| 5065 |
"recommendation": final_rec, "reasoning": pm_reasoning,
|
|
|
|
| 5066 |
"changed": pm_synthesis is not None,
|
| 5067 |
}
|
| 5068 |
|
|
|
|
| 4562 |
"p_bull": <float>,
|
| 4563 |
"p_neutral": <float>,
|
| 4564 |
"conviction": <float: 0.0-1.0, confidence in these weights>,
|
| 4565 |
+
"reasoning": "<ONE-sentence bottom line: which side is better supported and why>",
|
| 4566 |
+
"key_points": [
|
| 4567 |
+
{{"topic": "Business outlook", "point": "<which analyst won here and what moved your weight>"}},
|
| 4568 |
+
{{"topic": "Competitive landscape", "point": "<...>"}},
|
| 4569 |
+
{{"topic": "Business risks", "point": "<...>"}},
|
| 4570 |
+
{{"topic": "Management", "point": "<...>"}},
|
| 4571 |
+
{{"topic": "Valuation", "point": "<...>"}},
|
| 4572 |
+
{{"topic": "Smart money & news", "point": "<...>"}}
|
| 4573 |
+
],
|
| 4574 |
"risk_flags": ["<combined key risks from both cases>"],
|
| 4575 |
"override_ml": <boolean>
|
| 4576 |
+
}}
|
| 4577 |
+
Include in "key_points" ONLY the dimensions that actually moved your weights (drop the rest);
|
| 4578 |
+
each point 1-2 sentences naming which analyst was more convincing and why."""
|
| 4579 |
|
| 4580 |
|
| 4581 |
def _emit_role(role, phase, entry, *, ret_key="expected_return"):
|
|
|
|
| 4594 |
"recommendation": entry.get("recommendation"),
|
| 4595 |
"confidence": entry.get("confidence"),
|
| 4596 |
"reasoning": entry.get("reasoning", ""),
|
| 4597 |
+
"key_points": entry.get("key_points", []),
|
| 4598 |
}), flush=True)
|
| 4599 |
except Exception:
|
| 4600 |
pass
|
|
|
|
| 5027 |
"recommendation": final_rec,
|
| 5028 |
"confidence": final_confidence,
|
| 5029 |
"reasoning": pm_reasoning,
|
| 5030 |
+
"key_points": (pm_synthesis or {}).get("key_points", []),
|
| 5031 |
})
|
| 5032 |
|
| 5033 |
# Display-compatible round dicts
|
|
|
|
| 5038 |
"direction": neutral_result["direction"], "confidence": neutral_result["confidence"],
|
| 5039 |
"recommendation": neutral_result.get("recommendation", "HOLD"),
|
| 5040 |
"reasoning": neutral_result.get("reasoning", ""),
|
| 5041 |
+
"key_points": neutral_result.get("key_points", []),
|
| 5042 |
}
|
| 5043 |
if bear_r1:
|
| 5044 |
_round1["kimi"] = {
|
|
|
|
| 5046 |
"direction": bear_r1.get("direction", "BEARISH"), "confidence": bear_r1["confidence"],
|
| 5047 |
"recommendation": bear_r1.get("recommendation", "HOLD"),
|
| 5048 |
"reasoning": bear_r1.get("reasoning", ""),
|
| 5049 |
+
"key_points": bear_r1.get("key_points", []),
|
| 5050 |
}
|
| 5051 |
if bull_r1:
|
| 5052 |
_round1["gpt"] = {
|
|
|
|
| 5054 |
"direction": bull_r1.get("direction", "BULLISH"), "confidence": bull_r1["confidence"],
|
| 5055 |
"recommendation": bull_r1.get("recommendation", "HOLD"),
|
| 5056 |
"reasoning": bull_r1.get("reasoning", ""),
|
| 5057 |
+
"key_points": bull_r1.get("key_points", []),
|
| 5058 |
}
|
| 5059 |
|
| 5060 |
_round2 = {}
|
|
|
|
| 5064 |
"direction": bear_final.get("direction", "BEARISH"), "confidence": bear_final["confidence"],
|
| 5065 |
"recommendation": bear_final.get("recommendation", "HOLD"),
|
| 5066 |
"reasoning": bear_final.get("reasoning", ""),
|
| 5067 |
+
"key_points": bear_final.get("key_points", []),
|
| 5068 |
"changed": bear_final.get("changed_view", False),
|
| 5069 |
}
|
| 5070 |
if bull_final:
|
|
|
|
| 5073 |
"direction": bull_final.get("direction", "BULLISH"), "confidence": bull_final["confidence"],
|
| 5074 |
"recommendation": bull_final.get("recommendation", "HOLD"),
|
| 5075 |
"reasoning": bull_final.get("reasoning", ""),
|
| 5076 |
+
"key_points": bull_final.get("key_points", []),
|
| 5077 |
"changed": bull_final.get("changed_view", False),
|
| 5078 |
}
|
| 5079 |
_round2["claude"] = {
|
| 5080 |
"model": "Claude (PM, synthesis)", "return": final_return,
|
| 5081 |
"direction": final_direction, "confidence": final_confidence,
|
| 5082 |
"recommendation": final_rec, "reasoning": pm_reasoning,
|
| 5083 |
+
"key_points": (pm_synthesis or {}).get("key_points", []),
|
| 5084 |
"changed": pm_synthesis is not None,
|
| 5085 |
}
|
| 5086 |
|