File size: 1,585 Bytes
772d253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { useEffect, useState } from "react";

interface CorrectionSource {
  text: string;
  url: string;
}

interface Claim {
  claim: string;
  verification_status: string;
}

interface MetaAnalysis {
  information_ecosystem_impact: string;
  recommended_actions: string[];
}

interface OverallAnalysis {
  key_findings: string[];
  patterns_identified: string[];
  reliability_assessment: string;
  truth_score: number;
}

interface DetailedAnalysis {
  claim_analysis: Claim[];
  meta_analysis: MetaAnalysis;
  overall_analysis: OverallAnalysis;
}

interface Result {
  timestamp: string;
  original_text: string;
  detailed_analysis: DetailedAnalysis;
  correction_sources: {
    [key: string]: {
      [key: string]: CorrectionSource[];
    };
  };
  url: string;
  title: string;
  summary: string;
}

interface ApiResponse {
  result: Result;
}

const FactCheckStream = () => {
  const [factChecks, setFactChecks] = useState<ApiResponse[] | []>([]);

  useEffect(() => {
    const ws = new WebSocket("http://localhost:8000/ws/factcheck-stream");

    ws.onmessage = (event) => {
      const result = JSON.parse(event.data);
      console.log(result);
      setFactChecks((prev) => [result, ...prev]);
    };

    ws.onerror = (error) => {
      console.error("WebSocket error:", error);
    };

    return () => {
      ws.close();
    };
  }, []);

  return (
    <div>
      <h2>Live Fact Checks</h2>
      {factChecks.map((check, index) => (
        <div key={index} className="fact-check-card">

        </div>
      ))}
    </div>
  );
};

export default FactCheckStream;