1
- Fact Checker CLI
1
+ # Fact Checker CLI
2
2
3
- A command-line tool that identifies false or misleading claims in articles or statements using Perplexity’ s Sonar API for web research.
3
+ A command-line tool that identifies false or misleading claims in articles or statements using Perplexity' s Sonar API for web research.
4
4
5
- Features
6
- • Analyze claims or entire articles for factual accuracy
7
- • Identify false, misleading, or unverifiable claims
8
- • Provide explanations and corrections for inaccurate information
9
- • Output results in human-readable format or structured JSON
10
- • Cite reliable sources for fact-checking assessments
11
- • Leverages Perplexity’s structured outputs for reliable JSON parsing (for Tier 3+ users)
5
+ ## Features
12
6
13
- Installation
14
- 1. Install required dependencies:
7
+ - Analyze claims or entire articles for factual accuracy
8
+ - Identify false, misleading, or unverifiable claims
9
+ - Provide explanations and corrections for inaccurate information
10
+ - Output results in human-readable format or structured JSON
11
+ - Cite reliable sources for fact-checking assessments
12
+ - Leverages Perplexity's structured outputs for reliable JSON parsing (for Tier 3+ users)
15
13
16
- pip install requests pydantic
14
+ ## Installation
17
15
16
+ 1 . Install required dependencies:
17
+
18
+ ``` bash
19
+ pip install requests pydantic
18
20
19
21
2. Make the script executable:
20
22
@@ -25,8 +27,10 @@ chmod +x fact_checker.py
25
27
API Key Setup
26
28
27
29
The tool requires a Perplexity API key to function. You can provide it in one of these ways:
28
- 1. As a command-line argument: --api-key YOUR_API_KEY
29
- 2. As an environment variable: export PPLX_API_KEY=YOUR_API_KEY
30
+ 1. As a command-line argument:
31
+ --api-key YOUR_API_KEY
32
+ 2. As an environment variable:
33
+ export PPLX_API_KEY=YOUR_API_KEY
30
34
3. In a file named pplx_api_key or .pplx_api_key in the same directory as the script:
31
35
32
36
# Create a file to store your API key
@@ -42,7 +46,6 @@ Quick Start
42
46
43
47
Here’s a command you can copy and run immediately after setup:
44
48
45
- # Make sure your API key is set up as described above, then run:
46
49
./fact_checker.py -t " The Earth is flat and NASA is hiding the truth."
47
50
48
51
This will analyze the claim, research it using Perplexity’s Sonar API, and return a detailed fact check with ratings, explanations, and sources.
@@ -73,7 +76,7 @@ Use a Custom Prompt File
73
76
74
77
Enable Structured Outputs (for Tier 3+ Users)
75
78
76
- Structured output is disabled by default. If you want to enable structured outputs (for reliable JSON parsing), pass the --structured-output flag:
79
+ Structured output is disabled by default. To enable structured outputs (for reliable JSON parsing), pass the --structured-output flag:
77
80
78
81
./fact_checker.py --text " Vaccines cause autism." --structured-output
79
82
@@ -120,6 +123,3 @@ Limitations
120
123
• Like all language models, the underlying AI may have limitations in certain specialized domains
121
124
• The structured outputs feature requires a Tier 3 or higher Perplexity API account
122
125
• The tool does not replace professional fact-checking services for highly sensitive or complex content
123
-
124
- ⸻
125
-
0 commit comments