-
Notifications
You must be signed in to change notification settings - Fork 141
feat: Enable llms for api & sdk docs #1736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
27c2a04
feat: Enable llms for api & sdk docs
HonzaTuron 24e9192
feat: generated index
HonzaTuron f07a254
feat: merging script
HonzaTuron 58d04a6
feat: enable descriptions
HonzaTuron fbfb762
Merge remote-tracking branch 'origin/master' into feat/llms-all
HonzaTuron 357eb56
feat: categories & join files
HonzaTuron ae6292c
feat: markdown alternate
HonzaTuron 016dd46
feat: Actor whitepaper
HonzaTuron 03b210d
feat: Remove HTML
HonzaTuron 84eab6e
Merge branch 'master' into feat/llms-all
HonzaTuron 7c5c6f5
feat: Fix routes fetching
HonzaTuron 8cbb15b
Merge remote-tracking branch 'origin/feat/llms-all' into feat/llms-all
HonzaTuron c914587
feat: Remove todo
HonzaTuron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import fs from 'node:fs/promises'; | ||
| import path from 'node:path'; | ||
|
|
||
| const BUILD_DIR = path.resolve('build'); | ||
|
|
||
| const FILES_ROUTES = { | ||
| 'llms.txt': [ | ||
| 'https://docs.apify.com/api/client/js/llms.txt', | ||
| 'https://docs.apify.com/api/client/python/llms.txt', | ||
| 'https://docs.apify.com/sdk/js/llms.txt', | ||
| 'https://docs.apify.com/sdk/python/llms.txt', | ||
| 'https://docs.apify.com/cli/llms.txt', | ||
| ], | ||
| 'llms-full.txt': [ | ||
| 'https://docs.apify.com/api/client/js/llms-full.txt', | ||
| 'https://docs.apify.com/api/client/python/llms-full.txt', | ||
| 'https://docs.apify.com/sdk/js/llms-full.txt', | ||
| 'https://docs.apify.com/sdk/python/llms-full.txt', | ||
| 'https://docs.apify.com/cli/llms-full.txt', | ||
| 'https://raw.githubusercontent.com/apify/actor-whitepaper/refs/heads/master/README.md', | ||
| 'https://raw.githubusercontent.com/apify/actor-whitepaper/refs/heads/master/pages/ACTOR_FILE.md', | ||
| 'https://raw.githubusercontent.com/apify/actor-whitepaper/refs/heads/master/pages/DATASET_SCHEMA.md', | ||
| 'https://raw.githubusercontent.com/apify/actor-whitepaper/refs/heads/master/pages/IDEAS.md', | ||
| 'https://raw.githubusercontent.com/apify/actor-whitepaper/refs/heads/master/pages/INPUT_SCHEMA.md', | ||
| 'https://raw.githubusercontent.com/apify/actor-whitepaper/refs/heads/master/pages/KEY_VALUE_STORE_SCHEMA.md', | ||
| 'https://raw.githubusercontent.com/apify/actor-whitepaper/refs/heads/master/pages/OUTPUT_SCHEMA.md', | ||
| 'https://raw.githubusercontent.com/apify/actor-whitepaper/refs/heads/master/pages/REQUEST_QUEUE_SCHEMA.md', | ||
| ], | ||
| }; | ||
|
|
||
| async function fetchFile(route) { | ||
| try { | ||
| const res = await fetch(route); | ||
| if (!res.ok) throw new Error(`Failed to fetch ${route}: ${res.status}`); | ||
| return await res.text(); | ||
| } catch (err) { | ||
| console.error(`Error fetching ${route}:`, err.message); | ||
| return ''; | ||
| } | ||
| } | ||
|
|
||
| async function joinFiles() { | ||
| await fs.mkdir(BUILD_DIR, { recursive: true }); | ||
| for (const [llmsFile, files] of Object.entries(FILES_ROUTES)) { | ||
| const contents = await Promise.all( | ||
| files.map((route) => fetchFile(route)), | ||
| ); | ||
| const joined = contents.filter(Boolean).join('\n\n'); | ||
| await fs.appendFile(path.join(BUILD_DIR, llmsFile), joined, 'utf8'); | ||
| console.log(`Wrote ${llmsFile} to build/`); | ||
| } | ||
| } | ||
|
|
||
| async function sanitizeFile(filePath) { | ||
| const content = await fs.readFile(filePath, 'utf8'); | ||
| const sanitizedContent = content.replace(/<[^>]*>/g, ''); // Remove HTML tags | ||
| await fs.writeFile(filePath, sanitizedContent, 'utf8'); | ||
| console.log(`Sanitized ${filePath}`); | ||
| } | ||
|
|
||
| joinFiles().catch((err) => { | ||
| console.error('Failed to join LLMs files:', err); | ||
| process.exit(1); | ||
| }); | ||
|
|
||
| Object.keys(FILES_ROUTES).forEach((llmsFile) => sanitizeFile(path.join(BUILD_DIR, llmsFile))); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.