Skip to content

Commit 2b3eeb7

Browse files
authored
Merge pull request #18 from ppl-ai/kesku/cookbook-sync
refactor(cookbook): sync cookbook and docs site
2 parents 6029b27 + cff4f46 commit 2b3eeb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1335
-216
lines changed

.github/PULL_REQUEST_TEMPLATE/pull_request_template.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/sync-to-docs.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Sync Cookbook to Docs Site
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
sync-cookbook:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout cookbook repository
13+
uses: actions/checkout@v4
14+
with:
15+
path: cookbook-repo
16+
17+
- name: Checkout docs repository
18+
uses: actions/checkout@v4
19+
with:
20+
repository: ${{ secrets.DOCS_REPO_NAME || 'ppl-ai/api-docs' }}
21+
token: ${{ secrets.DOCS_REPO_TOKEN }}
22+
path: docs-repo
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '18'
28+
cache: 'npm'
29+
cache-dependency-path: docs-repo/package.json
30+
31+
- name: Install docs dependencies
32+
run: |
33+
cd docs-repo
34+
npm install
35+
36+
- name: Clear existing cookbook content
37+
run: |
38+
rm -rf docs-repo/cookbook/* || true
39+
40+
- name: Copy cookbook content to docs repository
41+
run: |
42+
# Create cookbook directory if it doesn't exist
43+
mkdir -p docs-repo/cookbook
44+
45+
# Copy docs content from cookbook to docs repo (already in MDX format)
46+
cp -r cookbook-repo/docs/* docs-repo/cookbook/
47+
48+
# Copy static assets if they exist
49+
if [ -d "cookbook-repo/static" ]; then
50+
mkdir -p docs-repo/cookbook/static
51+
cp -r cookbook-repo/static/* docs-repo/cookbook/static/
52+
fi
53+
54+
- name: Generate cookbook navigation
55+
run: |
56+
cd docs-repo
57+
# Run the navigation generation script
58+
node scripts/generate-cookbook-nav.js
59+
60+
- name: Configure git
61+
run: |
62+
cd docs-repo
63+
git config --local user.email "[email protected]"
64+
git config --local user.name "Cookbook Sync Bot"
65+
66+
- name: Commit and push changes
67+
run: |
68+
cd docs-repo
69+
git add .
70+
if git diff --staged --quiet; then
71+
echo "No changes to commit"
72+
echo "CHANGES_MADE=false" >> $GITHUB_ENV
73+
else
74+
git commit -m "📚 Sync cookbook from ${{ github.repository }}@${{ github.sha }}
75+
76+
Updated cookbook content and navigation from community contributions.
77+
78+
Source: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}"
79+
git push
80+
echo "CHANGES_MADE=true" >> $GITHUB_ENV
81+
fi
82+
83+
- name: Create deployment comment
84+
if: env.CHANGES_MADE == 'true'
85+
continue-on-error: true
86+
uses: actions/github-script@v7
87+
with:
88+
script: |
89+
try {
90+
const { owner, repo } = context.repo;
91+
const sha = context.sha;
92+
93+
await github.rest.repos.createCommitComment({
94+
owner,
95+
repo,
96+
commit_sha: sha,
97+
body: `✅ **Cookbook sync completed successfully!**
98+
99+
The cookbook content has been synced to the docs site and navigation has been updated automatically.
100+
101+
📈 Changes will be live on docs.perplexity.ai within a few minutes.
102+
103+
🔗 [View docs site](https://docs.perplexity.ai/cookbook)`
104+
});
105+
console.log('✅ Success comment posted successfully');
106+
} catch (error) {
107+
console.log('⚠️ Could not post comment (insufficient permissions):', error.message);
108+
console.log('✅ Sync completed successfully anyway!');
109+
}
110+
111+
- name: Report sync failure
112+
if: failure()
113+
continue-on-error: true
114+
uses: actions/github-script@v7
115+
with:
116+
script: |
117+
try {
118+
const { owner, repo } = context.repo;
119+
const sha = context.sha;
120+
121+
await github.rest.repos.createCommitComment({
122+
owner,
123+
repo,
124+
commit_sha: sha,
125+
body: `❌ **Cookbook sync failed**
126+
127+
There was an error syncing the cookbook content to the docs site.
128+
Please check the [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
129+
130+
The docs site may not reflect the latest cookbook changes until this is resolved.`
131+
});
132+
} catch (error) {
133+
console.log('⚠️ Could not post failure comment (insufficient permissions):', error.message);
134+
console.log('❌ Sync failed - check workflow logs for details');
135+
}
136+
137+
- name: Log sync status
138+
if: always()
139+
run: |
140+
if [ "${{ env.CHANGES_MADE }}" = "true" ]; then
141+
echo "🎉 COOKBOOK SYNC SUCCESS!"
142+
echo "📚 Content synced to docs repository"
143+
echo "🔧 Navigation updated automatically"
144+
echo "🚀 Changes will be live on docs.perplexity.ai within minutes"
145+
else
146+
echo "ℹ️ No changes to sync"
147+
echo "📄 Cookbook content is already up to date"
148+
fi

.gitignore

Lines changed: 15 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,23 @@
1-
# API Keys
2-
pplx_api_key
3-
.pplx_api_key
4-
PPLX_API_KEY
5-
.PPLX_API_KEY
6-
*.key
7-
.env
8-
.env.*
1+
# Dependencies
2+
/node_modules
93

10-
# Python
11-
__pycache__/
12-
*.py[cod]
13-
*$py.class
14-
*.so
15-
.Python
16-
build/
17-
develop-eggs/
18-
dist/
19-
downloads/
20-
eggs/
21-
.eggs/
22-
lib/
23-
lib64/
24-
parts/
25-
sdist/
26-
var/
27-
wheels/
28-
*.egg-info/
29-
.installed.cfg
30-
*.egg
4+
# Production
5+
/build
316

32-
# Virtual environments
33-
venv/
34-
env/
35-
ENV/
36-
.venv/
37-
.env/
38-
.ENV/
39-
env.bak/
40-
venv.bak/
41-
.python-version
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
4210

43-
# IDE specific files
44-
.idea/
45-
.vscode/
46-
*.swp
47-
*.swo
48-
*~
49-
.project
50-
.pydevproject
51-
.settings/
52-
.DS_Store
11+
# Content directory (pulled during build)
12+
/content
5313

54-
# Testing
55-
.coverage
56-
htmlcov/
57-
.pytest_cache/
58-
.tox/
59-
nosetests.xml
60-
coverage.xml
61-
*.cover
62-
.hypothesis/
14+
# Misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
6320

64-
# Logs
65-
logs/
66-
*.log
6721
npm-debug.log*
6822
yarn-debug.log*
6923
yarn-error.log*
70-
71-
# Project-specific
72-
article.txt
73-
claims.txt
74-
facts.txt
75-
test_articles/
76-
results/
77-
custom_prompt.md
78-
output.json
79-
report.json
80-
81-
# OS specific files
82-
.DS_Store
83-
.DS_Store?
84-
._*
85-
.Spotlight-V100
86-
.Trashes
87-
ehthumbs.db
88-
Thumbs.db

README.md

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,14 @@
1-
# Sonar API Projects
1+
<a href="https://sonar.perplexity.ai" target="_blank">
2+
<picture>
3+
<source media="(prefers-color-scheme: dark)" srcset="/static/img/perplexity-sonar.png" style="max-width: 100%; width: 400px; margin-bottom: 20px">
4+
<img src="/static/img/perplexity-sonar.png" alt="Perplexity Sonar" style="max-width: 100%; width: 400px; margin-bottom: 20px">
5+
</picture>
6+
</a>
27

3-
NOTE: This repo is still under construction by the Sonar team! Feel free to check back at a later time.
8+
<h3><a href="https://sonar.perplexity.ai" target="_blank">sonar.perplexity.ai</a></h3>
49

5-
![SONAR](assets/perplexity-sonar.png)
610

7-
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.
11+
Example code and guides for accomplishing common tasks with the [Perplexity Sonar API](https://sonar.perplexity.ai/), the fastest, most cost-effective AI answer engine with search.
812

9-
## Contributing
10-
11-
Contributions to this repository are welcome! Whether you want to:
12-
13-
- Fix bugs in existing projects
14-
- Add new features to current tools
15-
- Contribute entirely new Sonar API projects
16-
- Improve documentation or examples
17-
18-
Please check the [CONTRIBUTING.md](./CONTRIBUTING.md) file for guidelines.
19-
20-
21-
## Projects
22-
23-
**[Fact Checker CLI](sonar-use-cases/fact_checker_cli/)** - A command-line tool that analyzes claims or articles for factual accuracy using Sonar API's search capabilities.
24-
25-
**[Daily Knowledge Bot](sonar-use-cases/daily_knowledge_bot/)** - Python application that delivers interesting facts about rotating topics using the Perplexity AI API.
26-
27-
**[Disease Information App](sonar-use-cases/daily_knowledge_bot/)** - Interactive browser-based application providing structured information about diseases using the Sonar API.
28-
29-
## Getting Started
30-
31-
To use any of the projects in this repository, you'll need:
32-
33-
1. A Perplexity API key (sign up [here](https://docs.perplexity.ai/guides/getting-started))
34-
3. Python 3.7+ installed on your system
35-
36-
Each project includes its own README with specific installation and usage instructions.
37-
38-
39-
## License
40-
41-
Unless otherwise specified, all projects in this repository are licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
4213

14+
For more information, check our [docs](https://docs.perplexity.ai).

0 commit comments

Comments
 (0)