Skip to content

Commit 1d8f92d

Browse files
committed
refactor(cookbook): sync cookbook and docs site
1 parent 6029b27 commit 1d8f92d

File tree

61 files changed

+1741
-216
lines changed

Some content is hidden

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

61 files changed

+1741
-216
lines changed

.github/PULL_REQUEST_TEMPLATE/pull_request_template.md

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

.github/workflows/sync-content.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Sync Content to Site
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
sync-content:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout content repository
13+
uses: actions/checkout@v4
14+
with:
15+
path: content-repo
16+
17+
- name: Checkout site repository
18+
uses: actions/checkout@v4
19+
with:
20+
repository: kesku/api-cookbook-site
21+
token: ${{ secrets.SITE_REPO_TOKEN }}
22+
path: site-repo
23+
24+
- name: Clear existing content
25+
run: |
26+
rm -rf site-repo/content/docs/* || true
27+
rm -rf site-repo/static/img/* || true
28+
29+
- name: Copy content to site repository
30+
run: |
31+
# Create directories if they don't exist
32+
mkdir -p site-repo/content/docs
33+
mkdir -p site-repo/static/img
34+
35+
# Copy docs content
36+
cp -r content-repo/docs/* site-repo/content/docs/
37+
38+
# Copy static assets
39+
cp -r content-repo/static/* site-repo/static/
40+
41+
- name: Configure git
42+
run: |
43+
cd site-repo
44+
git config --local user.email "[email protected]"
45+
git config --local user.name "GitHub Action"
46+
47+
- name: Commit and push changes
48+
run: |
49+
cd site-repo
50+
git add .
51+
if git diff --staged --quiet; then
52+
echo "No changes to commit"
53+
else
54+
git commit -m "Sync content from api-cookbook@${{ github.sha }}"
55+
git push
56+
fi

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

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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+
uses: actions/github-script@v7
86+
with:
87+
script: |
88+
const { owner, repo } = context.repo;
89+
const sha = context.sha;
90+
91+
await github.rest.repos.createCommitComment({
92+
owner,
93+
repo,
94+
commit_sha: sha,
95+
body: `✅ **Cookbook sync completed successfully!**
96+
97+
The cookbook content has been synced to the docs site and navigation has been updated automatically.
98+
99+
📈 Changes will be live on docs.perplexity.ai within a few minutes.
100+
101+
🔗 [View docs site](https://docs.perplexity.ai/cookbook)`
102+
});
103+
104+
- name: Report sync failure
105+
if: failure()
106+
uses: actions/github-script@v7
107+
with:
108+
script: |
109+
const { owner, repo } = context.repo;
110+
const sha = context.sha;
111+
112+
await github.rest.repos.createCommitComment({
113+
owner,
114+
repo,
115+
commit_sha: sha,
116+
body: `❌ **Cookbook sync failed**
117+
118+
There was an error syncing the cookbook content to the docs site.
119+
Please check the [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
120+
121+
The docs site may not reflect the latest cookbook changes until this is resolved.`
122+
});

.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)