Initial commit: AI misinformation detector
Browse files- app.py +27 -2
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -214,8 +214,33 @@ def verify_claim(text: str, mode: str="fast") -> Dict[str, Any]:
|
|
| 214 |
except: pass
|
| 215 |
|
| 216 |
# Step 3: Deep reasoning (placeholder)
|
| 217 |
-
|
| 218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
deep_result = {
|
| 220 |
"outcome":"Unverifiable",
|
| 221 |
"explanation":"Demo mode: Deep reasoning not configured (API key missing).",
|
|
|
|
| 214 |
except: pass
|
| 215 |
|
| 216 |
# Step 3: Deep reasoning (placeholder)
|
| 217 |
+
# Step 3: Deep reasoning
|
| 218 |
+
deep_result = None
|
| 219 |
+
if mode.lower() in ["deep","hybrid"]:
|
| 220 |
+
if GEMINI_CLIENT:
|
| 221 |
+
try:
|
| 222 |
+
prompt = f"""
|
| 223 |
+
Verify the following claim: "{claim}".
|
| 224 |
+
Provide a JSON object with keys:
|
| 225 |
+
outcome (True/False/Unverifiable),
|
| 226 |
+
explanation,
|
| 227 |
+
comparison (list of claim-evidence pairs),
|
| 228 |
+
takeaways (list of advice).
|
| 229 |
+
"""
|
| 230 |
+
response = GEMINI_CLIENT.models.generate_content(
|
| 231 |
+
model="gemini-2.5-flash",
|
| 232 |
+
contents=prompt
|
| 233 |
+
)
|
| 234 |
+
# Parse Gemini response as JSON
|
| 235 |
+
import json
|
| 236 |
+
deep_result = json.loads(response.text)
|
| 237 |
+
except Exception as e:
|
| 238 |
+
deep_result = {
|
| 239 |
+
"outcome":"Unverifiable",
|
| 240 |
+
"explanation": f"Gemini API error: {str(e)}",
|
| 241 |
+
"takeaways":["Search credible sources","Cross-check claims"]
|
| 242 |
+
}
|
| 243 |
+
else:
|
| 244 |
deep_result = {
|
| 245 |
"outcome":"Unverifiable",
|
| 246 |
"explanation":"Demo mode: Deep reasoning not configured (API key missing).",
|
requirements.txt
CHANGED
|
@@ -5,4 +5,5 @@ beautifulsoup4
|
|
| 5 |
python-dotenv
|
| 6 |
transformers
|
| 7 |
sentence-transformers
|
| 8 |
-
torch
|
|
|
|
|
|
| 5 |
python-dotenv
|
| 6 |
transformers
|
| 7 |
sentence-transformers
|
| 8 |
+
torch
|
| 9 |
+
google-genai
|