Skip to content

Issue 3: Mission — Weigh the Cursed Mood #3

@saumya1317

Description

@saumya1317

Mission: Weigh the Cursed Mood

Minimal Reproducible Example (MRE)

uvicorn Jujutsu-Quants.app.adk.main:app --reload
curl -s -X POST http://localhost:8000/api/v2/report -H "Content-Type: application/json" -d '{"question":"Sentiment on BTC ETF flows?"}' | jq

Expected: sentiment includes a score and label from classify_with_confidence.

Task

Provide a small, focused implementation task: implement a new method classify_with_confidence(text: str) -> Dict in SentimentAgent that wraps the existing classify and returns a confidence score and reason.

What to Implement (tiny scope)

  • Add method signature:
    • def classify_with_confidence(self, text: str) -> Dict[str, Any]:
  • Logic:
    • Reuse existing word-count approach to compute pos_count and neg_count.
    • label = existing classify(text).
    • confidence = min(1.0, (pos_count + neg_count) / 5.0) (capped).
    • reason = f"pos={pos_count}, neg={neg_count}".
    • Return { 'label': label, 'confidence': confidence, 'reason': reason }.

I/O

  • Input: text: str.
  • Output: Dict with keys label, confidence, reason.

Example

agent = create_sentiment_agent()
agent.classify_with_confidence("Stock surges on strong earnings")
# {'label': 'positive', 'confidence': 0.8, 'reason': 'pos=4, neg=0'} (example)

Acceptance Criteria

  • Method exists and returns dict with keys label, confidence, reason.
  • Confidence is capped at 1.0 and increases with more matched words.
  • Existing analyze() can optionally include this method later; no other changes required.

Hints

  • Count matches using sum(1 for w in self.positive_words if w in text.lower()) (same as classify).

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions