generated from OPCODE-Open-Spring-Fest/template
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
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?"}' | jqExpected: 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_countandneg_count. label= existingclassify(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 }.
- Reuse existing word-count approach to compute
I/O
- Input:
text: str. - Output:
Dictwith keyslabel,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).