You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fact_checker_cli/README.md
+83-49Lines changed: 83 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,94 +13,126 @@ A command-line tool that identifies false or misleading claims in articles or st
13
13
14
14
## Installation
15
15
16
-
1. Install required dependencies:
16
+
### 1. Install required dependencies
17
17
18
-
```bash
19
-
pip install requests pydantic
18
+
```bash
19
+
pip install requests pydantic
20
+
```
20
21
21
-
2. Make the script executable:
22
+
### 2. Make the script executable
22
23
24
+
```bash
23
25
chmod +x fact_checker.py
26
+
```
24
27
28
+
## API Key Setup
25
29
30
+
The tool requires a Perplexity API key to function. You can provide it in one of these ways:
26
31
27
-
API Key Setup
32
+
### 1. As a command-line argument
28
33
29
-
The tool requires a Perplexity API key to function. You can provide it in one of these ways:
30
-
1. As a command-line argument:
31
-
--api-key YOUR_API_KEY
32
-
2. As an environment variable:
34
+
```bash
35
+
./fact_checker.py --api-key YOUR_API_KEY
36
+
```
37
+
38
+
### 2. As an environment variable
39
+
40
+
```bash
33
41
export PPLX_API_KEY=YOUR_API_KEY
34
-
3. In a file named pplx_api_key or .pplx_api_key in the same directory as the script:
42
+
```
35
43
36
-
# Create a file to store your API key
37
-
echo"YOUR_API_KEY"> .pplx_api_key
38
-
# Make sure to protect your API key
39
-
chmod 600 .pplx_api_key
44
+
### 3. In a file
40
45
46
+
Create a file named `pplx_api_key` or `.pplx_api_key` in the same directory as the script:
41
47
48
+
```bash
49
+
echo"YOUR_API_KEY"> .pplx_api_key
50
+
chmod 600 .pplx_api_key
51
+
```
42
52
43
-
Note: If you’re using the structured outputs feature, you’ll need a Perplexity API account with Tier 3 or higher access level.
53
+
**Note:** If you're using the structured outputs feature, you'll need a Perplexity API account with Tier 3 or higher access level.
44
54
45
-
Quick Start
55
+
## Quick Start
46
56
47
-
Here’s a command you can copy and run immediately after setup:
57
+
Run the following command immediately after setup:
48
58
59
+
```bash
49
60
./fact_checker.py -t "The Earth is flat and NASA is hiding the truth."
61
+
```
50
62
51
-
This will analyze the claim, research it using Perplexity’s Sonar API, and return a detailed fact check with ratings, explanations, and sources.
52
-
53
-
Usage
63
+
This will analyze the claim, research it using Perplexity's Sonar API, and return a detailed fact check with ratings, explanations, and sources.
54
64
55
-
Basic Usage
65
+
##Usage
56
66
57
-
Check a claim:
67
+
### Check a claim
58
68
69
+
```bash
59
70
./fact_checker.py --text "The Earth is flat and NASA is hiding the truth."
71
+
```
60
72
61
-
Check an Article from a File
73
+
### Check an article from a file
62
74
75
+
```bash
63
76
./fact_checker.py --file article.txt
77
+
```
64
78
65
-
Specify a Different Model
79
+
### Specify a different model
66
80
81
+
```bash
67
82
./fact_checker.py --text "Global temperatures have decreased over the past century." --model "sonar-pro"
83
+
```
68
84
69
-
Output Results as JSON
85
+
### Output results as JSON
70
86
87
+
```bash
71
88
./fact_checker.py --text "Mars has a breathable atmosphere." --json
89
+
```
72
90
73
-
Use a Custom Prompt File
91
+
### Use a custom prompt file
74
92
93
+
```bash
75
94
./fact_checker.py --text "The first human heart transplant was performed in the United States." --prompt-file custom_prompt.md
95
+
```
76
96
77
-
Enable Structured Outputs (for Tier 3+ Users)
97
+
### Enable structured outputs (for Tier 3+ users)
78
98
79
-
Structured output is disabled by default. To enablestructured outputs (for reliable JSON parsing), pass the --structured-output flag:
99
+
Structured output is disabled by default. To enable it, pass the `--structured-output` flag:
80
100
101
+
```bash
81
102
./fact_checker.py --text "Vaccines cause autism." --structured-output
103
+
```
82
104
83
-
Get Help
105
+
### Get help
84
106
107
+
```bash
85
108
./fact_checker.py --help
109
+
```
86
110
87
-
Output Format
111
+
## Output Format
88
112
89
113
The tool provides output including:
90
-
• Overall rating: MOSTLY_TRUE, MIXED, or MOSTLY_FALSE
91
-
• Summary: A brief overview of the fact-checking findings
92
-
• Claims Analysis: A list of specific claims with individual ratings:
93
-
• TRUE: Factually accurate and supported by evidence
94
-
• FALSE: Contradicted by evidence
95
-
• MISLEADING: Contains some truth but presented in a way that could lead to incorrect conclusions
96
-
• UNVERIFIABLE: Cannot be conclusively verified with available information
97
-
• Explanations: Detailed reasoning for each claim
98
-
• Sources: Citations and URLs used for verification
99
114
100
-
Example
115
+
-**Overall Rating**: MOSTLY_TRUE, MIXED, or MOSTLY_FALSE
116
+
-**Summary**: A brief overview of the fact-checking findings
117
+
-**Claims Analysis**: A list of specific claims with individual ratings:
118
+
- TRUE: Factually accurate and supported by evidence
119
+
- FALSE: Contradicted by evidence
120
+
- MISLEADING: Contains some truth but could lead to incorrect conclusions
121
+
- UNVERIFIABLE: Cannot be conclusively verified with available information
122
+
-**Explanations**: Detailed reasoning for each claim
123
+
-**Sources**: Citations and URLs used for verification
124
+
125
+
## Example
101
126
102
-
$ ./fact_checker.py -t "The Great Wall of China is visible from the moon."
127
+
Run the following command:
103
128
129
+
```bash
130
+
./fact_checker.py -t "The Great Wall of China is visible from the moon."
131
+
```
132
+
133
+
Example output:
134
+
135
+
```
104
136
Fact checking in progress...
105
137
106
138
🔴 OVERALL RATING: MOSTLY_FALSE
@@ -110,16 +142,18 @@ The claim that the Great Wall of China is visible from the moon is false. This i
110
142
111
143
🔍 CLAIMS ANALYSIS:
112
144
113
-
Claim 1: ❌ FALSE
114
-
Statement: "The Great Wall of China is visible from the moon."
115
-
Explanation: The Great Wall of China is not visible from the moon with the naked eye. NASA astronauts have confirmed this, including Neil Armstrong who stated he could not see the Wall from lunar orbit. The Wall is too narrow and is similar in color to its surroundings when viewed from such a distance.
145
+
Claim 1: ❌ FALSE
146
+
Statement: "The Great Wall of China is visible from the moon."
147
+
Explanation: The Great Wall of China is not visible from the moon with the naked eye. NASA astronauts have confirmed this, including Neil Armstrong who stated he could not see the Wall from lunar orbit. The Wall is too narrow and is similar in color to its surroundings when viewed from such a distance.
116
148
Sources:
117
149
- NASA.gov
118
150
- Scientific American
119
151
- National Geographic
152
+
```
153
+
154
+
## Limitations
120
155
121
-
Limitations
122
-
• The accuracy of fact-checking depends on the quality of information available through the Perplexity Sonar API
123
-
• Like all language models, the underlying AI may have limitations in certain specialized domains
124
-
• The structured outputs feature requires a Tier 3 or higher Perplexity API account
125
-
• The tool does not replace professional fact-checking services for highly sensitive or complex content
156
+
- The accuracy of fact-checking depends on the quality of information available through the Perplexity Sonar API.
157
+
- Like all language models, the underlying AI may have limitations in certain specialized domains.
158
+
- The structured outputs feature requires a Tier 3 or higher Perplexity API account.
159
+
- The tool does not replace professional fact-checking services for highly sensitive or complex content.
0 commit comments