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
This Cookbook provides code and guides designed to help developers build with Sonar, offering code snippets that can easily be integrated into your own projects.
3
+
A collection of practical applications and tools built with [Perplexity's Sonar API](https://sonar.perplexity.ai/), the fastest, most cost-effective AI answer engine with robust search capabilities.
4
4
5
-
**Prerequisites**
5
+
## ⚠️ API Key Required
6
6
7
-
You'll need an API key (sign up by following the steps [here](https://docs.perplexity.ai/guides/getting-started))
7
+
**Before you begin:** You'll need a Perplexity API key to use any project in this repository.
8
+
9
+
Sign up for an API key by following the steps in the [Perplexity documentation](https://docs.perplexity.ai/guides/getting-started).
10
+
11
+
## About This Repository
12
+
13
+
This repository contains various projects that demonstrate how to leverage Perplexity's Sonar API for different use cases. Each project is designed to showcase the API's capabilities while providing practical, ready-to-use tools for developers.
14
+
15
+
## Projects
16
+
17
+
### Fact Checker CLI
18
+
19
+
The flagship project in this collection is a command-line tool that analyzes claims or articles for factual accuracy. Using Sonar API's powerful search capabilities, it identifies false or misleading statements, provides corrections, and cites reliable sources.
20
+
21
+
[Read more about the Fact Checker CLI →](./fact-checker/README.md)
22
+
23
+
### Coming Soon
24
+
25
+
We're actively working on adding more projects to this collection:
26
+
27
+
-**Research Assistant**: Automated literature review and summarization tool
28
+
-**News Analyzer**: Track developing stories and analyze reporting biases
29
+
-**Content Verifier**: Browser extension for real-time fact checking
30
+
-**Data Explorer**: Query and visualize complex datasets through natural language
31
+
32
+
## Why Sonar API?
33
+
34
+
Perplexity's Sonar API offers several advantages that make it ideal for building powerful AI applications:
35
+
36
+
-**Fast & Cost-Effective**: Get reliable answers at a fraction of the cost of other AI APIs
37
+
-**Search Grounding**: Internet-connected models that can access and cite the latest information
38
+
-**Easy Integration**: Simple, straightforward API that developers can integrate in minutes
39
+
-**Scalable Pricing**: Pay-as-you-go model that scales with your usage
40
+
41
+
## Getting Started
42
+
43
+
To use any of the projects in this repository, you'll need:
44
+
45
+
1. A Perplexity API key (sign up [here](https://docs.perplexity.ai/guides/getting-started))
46
+
3. Python 3.7+ installed on your system
47
+
48
+
Each project includes its own README with specific installation and usage instructions.
49
+
50
+
## API Access
51
+
52
+
You can sign up for Perplexity's Sonar API at [sonar.perplexity.ai](https://sonar.perplexity.ai/).
53
+
54
+
The API offers:
55
+
- Free tier to get started
56
+
- Straightforward documentation
57
+
- Transparent usage-based pricing
58
+
59
+
## Contributing
60
+
61
+
Contributions to this repository are welcome! Whether you want to:
62
+
63
+
- Fix bugs in existing projects
64
+
- Add new features to current tools
65
+
- Contribute entirely new Sonar API projects
66
+
- Improve documentation or examples
67
+
68
+
Please check the [CONTRIBUTING.md](./CONTRIBUTING.md) file for guidelines.
69
+
70
+
## License
71
+
72
+
Unless otherwise specified, all projects in this repository are licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
73
+
74
+
---
75
+
76
+
*Build with the best AI answer engine. Power your products with the fastest, cheapest API offering out there with search grounding. Get started in minutes.*
Structured output is disabled by default. To enable it, pass the `--structured-output` flag:
92
100
93
101
```bash
94
-
./fact_checker.py --text "Vaccines cause autism." --no-structured-output
102
+
./fact_checker.py --text "Vaccines cause autism." --structured-output
95
103
```
96
104
97
-
### Get help:
105
+
### Get help
98
106
99
107
```bash
100
108
./fact_checker.py --help
101
109
```
102
110
103
111
## Output Format
104
112
105
-
The tool provides a structured output with:
113
+
The tool provides output including:
106
114
107
-
- Overall rating of the content (MOSTLY_TRUE, MIXED, or MOSTLY_FALSE)
108
-
- Summary of findings
109
-
-List of specific claims with individual ratings:
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:
110
118
- TRUE: Factually accurate and supported by evidence
111
119
- FALSE: Contradicted by evidence
112
-
- MISLEADING: Contains some truth but presented in a way that could lead to incorrect conclusions
120
+
- MISLEADING: Contains some truth but could lead to incorrect conclusions
113
121
- UNVERIFIABLE: Cannot be conclusively verified with available information
114
-
- Explanations for each claim
115
-
- Sources used for verification
122
+
-**Explanations**: Detailed reasoning for each claim
123
+
-**Sources**: Citations and URLs used for verification
116
124
117
125
## Example
118
126
127
+
Run the following command:
128
+
129
+
```bash
130
+
./fact_checker.py -t "The Great Wall of China is visible from the moon."
119
131
```
120
-
$ ./fact_checker.py -t "The Great Wall of China is visible from the moon."
121
132
133
+
Example output:
134
+
135
+
```
122
136
Fact checking in progress...
123
137
124
138
🔴 OVERALL RATING: MOSTLY_FALSE
@@ -128,9 +142,9 @@ The claim that the Great Wall of China is visible from the moon is false. This i
128
142
129
143
🔍 CLAIMS ANALYSIS:
130
144
131
-
Claim 1: ❌ FALSE
132
-
Statement: "The Great Wall of China is visible from the moon."
133
-
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.
134
148
Sources:
135
149
- NASA.gov
136
150
- Scientific American
@@ -139,7 +153,7 @@ Claim 1: ❌ FALSE
139
153
140
154
## Limitations
141
155
142
-
- The accuracy of fact-checking depends on the quality of information available through the Perplexity Sonar API
143
-
- Like all language models, the underlying AI may have limitations in certain specialized domains
144
-
- The structured outputs feature requires a Tier 3 or higher Perplexity API account
145
-
- 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