Spaces:
Runtime error
Runtime error
Update app.py
Browse files47 unmodified lines4849505152535431 unmodified lines86878889909192302 unmodified lines39539639739839940040110 unmodified lines41241341441541641741847 unmodified linesKeys to return:"sentiment_score": A float between -1.0 (highly negative) and 1.0 (highly positive)."primary_tone": The single dominant emotion."dynamic_topic": A 3-to-5 word summary of the article's specific angle or frame."tone_scores": A dictionary scoring THESE EXACT 6 EMOTIONS from 0.0 to 1.0: {{"anger": 0.0, "fear": 0.0, "joy": 0.0, "sadness": 0.0, "surprise": 0.0, "trust": 0.0}}."framing_words": A list of dictionaries containing the 5 to 8 most emotionally charged or biased words, and the specific emotion they evoke. Format: [{{"word": "draconian", "emotion": "fear"}}, {{"word": "titans", "emotion": "awe"}}]."subjectivity_score": A float between 0.0 (completely objective/factual) and 1.0 (highly opinionated/subjective).31 unmodified linesreturn {"sentiment_score": llm_data.get("sentiment_score", 0.0),"primary_tone": llm_data.get("primary_tone", "neutral"),"dynamic_topic": llm_data.get("dynamic_topic", "Unclear Topic"),"tone_scores": standard_tones,"framing_words": llm_data.get("framing_words", []),"subjectivity_score": llm_data.get("subjectivity_score", 0.0),302 unmodified linesm3, m4 = st.columns(2)m1.metric("Subjectivity", f"{r_a['subjectivity_score']:.2f}", help="0 is objective, 1 is highly opinionated.")m2.metric("Primary Emotion", str(r_a['primary_tone']).title())m3.metric("Dynamic Topic", str(r_a['dynamic_topic']).title())m4.metric("Reading Ease", f"{r_a['reading_ease']:.1f}", help="0-30 is college graduate level, 60-70 is 8th grade.")st.plotly_chart(_create_sentiment_gauge(r_a["sentiment_score"], "Sentiment Bias"), use_container_width=True, key="gauge_a")10 unmodified linesm3, m4 = st.columns(2)m1.metric("Subjectivity", f"{r_b['subjectivity_score']:.2f}", help="0 is objective, 1 is highly opinionated.")m2.metric("Primary Emotion", str(r_b['primary_tone']).title())m3.metric("Dynamic Topic", str(r_b['dynamic_topic']).title())m4.metric("Reading Ease", f"{r_b['reading_ease']:.1f}", help="0-30 is college graduate level, 60-70 is 8th grade.")st.plotly_chart(_create_sentiment_gauge(r_b["sentiment_score"], "Sentiment Bias"), use_container_width=True, key="gauge_b")47 unmodified lines4849505152535431 unmodified lines86878889909192302 unmodified lines39539639739839940040110 unmodified lines41241341441541641741847 unmodified linesKeys to return:"sentiment_score": A float between -1.0 (highly negative) and 1.0 (highly positive)."primary_tone": The single dominant emotion."primary_theme": Choose ONE like: ["economic consequences", "moral and ethical fairness", "legal and bureaucratic", "public safety and health"]."tone_scores": A dictionary scoring THESE EXACT 6 EMOTIONS from 0.0 to 1.0: {{"anger": 0.0, "fear": 0.0, "joy": 0.0, "sadness": 0.0, "surprise": 0.0, "trust": 0.0}}."framing_words": A list of dictionaries containing the 5 to 8 most emotionally charged or biased words, and the specific emotion they evoke. Format: [{{"word": "draconian", "emotion": "fear"}}, {{"word": "titans", "emotion": "awe"}}]."subjectivity_score": A float between 0.0 (completely objective/factual) and 1.0 (highly opinionated/subjective).31 unmodified linesreturn {"sentiment_score": llm_data.get("sentiment_score", 0.0),"primary_tone": llm_data.get("primary_tone", "neutral"),"primary_theme": llm_data.get("primary_theme", "unclear"),"tone_scores": standard_tones,"framing_words": llm_data.get("framing_words", []),"subjectivity_score": llm_data.get("subjectivity_score", 0.0),302 unmodified linesm3, m4 = st.columns(2)m1.metric("Subjectivity", f"{r_a['subjectivity_score']:.2f}", help="0 is objective, 1 is highly opinionated.")m2.metric("Primary Emotion", str(r_a['primary_tone']).title())m3.metric("Framing Lens", str(r_a['primary_theme']).title())m4.metric("Reading Ease", f"{r_a['reading_ease']:.1f}", help="0-30 is college graduate level, 60-70 is 8th grade.")st.plotly_chart(_create_sentiment_gauge(r_a["sentiment_score"], "Sentiment Bias"), use_container_width=True, key="gauge_a")10 unmodified linesm3, m4 = st.columns(2)m1.metric("Subjectivity", f"{r_b['subjectivity_score']:.2f}", help="0 is objective, 1 is highly opinionated.")m2.metric("Primary Emotion", str(r_b['primary_tone']).title())m3.metric("Framing Lens", str(r_b['primary_theme']).title())m4.metric("Reading Ease", f"{r_b['reading_ease']:.1f}", help="0-30 is college graduate level, 60-70 is 8th grade.")st.plotly_chart(_create_sentiment_gauge(r_b["sentiment_score"], "Sentiment Bias"), use_container_width=True, key="gauge_b")
app.py+4-4