File size: 3,875 Bytes
c83cd7e
7a5d5dd
 
 
 
 
 
 
 
 
c83cd7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

---

title: Falcon
emoji: πŸ”₯
colorFrom: indigo
colorTo: yellow
sdk: docker
pinned: false
---


# Falcon: Fake News Analysis and Language Comprehension for Online Neutrality

**Falcon** is an advanced Gen AI-powered system designed to analyze, verify, and classify online claims to promote digital content neutrality. Leveraging state-of-the-art language models, it classifies user-submitted text, detects tone and intent, verifies facts using multiple data sources, and generates an informed verdict about claim credibility.

---

## Features

* **Claim Classification**: Classifies input text into categories like Factual Claim, Opinion, Irrelevant Talk, or Vague/Incomplete.
* **Tone and Intent Detection**: Analyzes the emotional tone and intent behind the claim (e.g., neutral, persuasive, humorous).
* **Fact Verification**: Verifies factual claims by searching reliable sources like Google (via Serper API) and Wikipedia.
* **Verdict Generation**: Produces a clear verdict on the claim’s truthfulness based on gathered evidence and reasoning.
* **Fallback Language Model**: Uses OpenAI’s GPT-4 as the primary LLM and automatically switches to **Deepseek** as a fallback model to ensure high availability and robustness.
* **Simple Web Interface**: Easy-to-use frontend using HTML, CSS, and JavaScript for seamless user interaction.
* **FastAPI Backend**: Fast, lightweight API server handling all processing with asynchronous endpoints.

---

## Tech Stack

* **Backend**: FastAPI (Python)
* **Frontend**: HTML, CSS, JavaScript
* **Language Models**: OpenAI GPT-4 (primary), Deepseek (fallback)
* **APIs**: Serper API (Google Search), Wikipedia API
* **Prompt Engineering**: Carefully crafted templates for accurate and reliable results
* **Deployment**: Docker containerization (optional)

---

## Project Structure

```

falcon/

β”œβ”€β”€ backend/

β”‚   β”œβ”€β”€ api/

β”‚   β”‚   β”œβ”€β”€ claims.py           # Claim classification logic

β”‚   β”‚   β”œβ”€β”€ fact_check.py       # Fact verification logic

β”‚   β”‚   β”œβ”€β”€ tone_intent.py      # Tone and intent detection logic

β”‚   β”œβ”€β”€ langchain_tools.py      # LangChain prompt templates and LLM wrappers

β”‚   β”œβ”€β”€ config.py               # API keys and config variables

β”‚   └── main.py                 # FastAPI app entry point

β”œβ”€β”€ frontend/

β”‚   β”œβ”€β”€ index.html              # Main UI page

β”‚   β”œβ”€β”€ assets/                 # CSS, JS, images

β”œβ”€β”€ Dockerfile                  # Docker container definition (optional)

└── README.md                   # This file

```

---

## Setup Instructions

### Prerequisites

* Python 3.9+
* FastAPI
* Uvicorn (ASGI server)
* OpenAI API key
* Serper API key
* Deepseek API key (for fallback)

### Installation

1. Clone the repository:

```bash

git clone https://github.com/yourusername/falcon.git

cd falcon

```

2. Create and activate a virtual environment:

```bash

python -m venv venv

source venv/bin/activate   # On Windows: venv\Scripts\activate

```

3. Install dependencies:

```bash

pip install -r requirements.txt

```

4. Configure API keys in `backend/config.py`:

```python

OPENAI_API_KEY = "your_openai_api_key"

SERPER_API_KEY = "your_serper_api_key"

DEEPSEEK_API_KEY = "your_deepseek_api_key"

```

5. Run the FastAPI server:

```bash

uvicorn backend.main:app --port 8000

```

6. Open your browser and visit `http://localhost:8000` to use the Falcon app.

---

## Usage

* Enter a claim or statement in the input form.
* The system classifies the claim, detects tone and intent, performs fact verification if applicable, and returns a detailed verdict with supporting evidence.
* The fallback model Deepseek is automatically used if GPT-4 is unavailable, ensuring consistent performance.