Skip to content

Commit 1ec8997

Browse files
committed
refactor: apply code review suggestions from bot
- Remove redundant hasattr(report, 'content') check; invoke_structured_or_freetext already returns str - Fix overlapping numeric ranges in overall_band description; clarify Neutral vs Mixed distinction - Add extra blank line in render_sentiment_report header for proper markdown block separation
1 parent 8855c6c commit 1ec8997

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

tradingagents/agents/analysts/social_media_analyst.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ def social_media_analyst_node(state):
7676
render_sentiment_report,
7777
"Social Media Analyst",
7878
)
79-
# invoke_structured_or_freetext falls back to plain llm.invoke when
80-
# structured output fails; in that case it returns an AIMessage, not a str.
81-
if hasattr(report, "content"):
82-
report = report.content
8379

8480
return {
8581
"messages": [result],

tradingagents/agents/schemas.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,10 @@ class SentimentReport(BaseModel):
265265
overall_band: SentimentBand = Field(
266266
description=(
267267
"Categorical sentiment label. Pick the band that best matches the "
268-
"overall_score: Bullish (7-10), Mildly Bullish (5.5-7), Neutral/Mixed "
269-
"(4.5-5.5), Mildly Bearish (3-4.5), Bearish (0-3)."
268+
"overall_score: Bullish (7.1-10), Mildly Bullish (5.6-7.0), Neutral "
269+
"(4.5-5.5, flat outlook with no strong signal), Mixed "
270+
"(4.5-5.5, high-volume but conflicting signals), "
271+
"Mildly Bearish (3.0-4.4), Bearish (0-2.9)."
270272
),
271273
)
272274
confidence: Literal["low", "medium", "high"] = Field(
@@ -296,5 +298,6 @@ def render_sentiment_report(report: SentimentReport) -> str:
296298
f"**Overall Sentiment:** **{report.overall_band.value}** "
297299
f"(Score: {report.overall_score:.1f}/10, Confidence: {report.confidence})",
298300
"",
301+
"",
299302
])
300303
return header + report.narrative

0 commit comments

Comments
 (0)