-
Notifications
You must be signed in to change notification settings - Fork 465
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
generate llms.txt for our docs #3273
Open
wjayesh
wants to merge
18
commits into
develop
Choose a base branch
from
docs/llms.txt
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+403
−0
Open
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c68275b
Add new toc (#3255)
htahir1 5abcd1a
docs and code separate
wjayesh 945a94c
first version
wjayesh 89ecf8d
use the batch api
wjayesh b835d5b
write file from batch output
wjayesh 316e658
70k version of docs
wjayesh 2e9d234
slightly improved with filenames
wjayesh 6e5dbf6
add file names to output
wjayesh 5ca3247
add workflows
wjayesh cfe4b57
add scripts
wjayesh 5a03670
fix repomix output
wjayesh 5476e72
add gemini script
wjayesh 1aaf1c7
rm testing files
wjayesh 50de6a7
update huggingface repo name
wjayesh 80a1acb
add the full docs too
wjayesh f1c333d
Merge branch 'develop' into docs/llms.txt
wjayesh a9fe9ea
rm docs file
wjayesh 54d8c98
rm breakpoint
wjayesh 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 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,90 @@ | ||
name: Check Docs Summarization | ||
|
||
on: | ||
push: | ||
branches: [release/**] | ||
|
||
jobs: | ||
check-batch: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
permissions: | ||
contents: read | ||
id-token: write | ||
actions: read | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install openai huggingface_hub | ||
|
||
- name: List artifacts | ||
uses: actions/github-script@v6 | ||
id: artifacts | ||
with: | ||
script: | | ||
const artifacts = await github.rest.actions.listArtifactsForRepo({ | ||
owner: context.repo.owner, | ||
repo: context.repo.name, | ||
}); | ||
const batchArtifact = artifacts.data.artifacts | ||
.find(artifact => artifact.name.startsWith('batch-id-')); | ||
if (!batchArtifact) { | ||
throw new Error('No batch ID artifact found'); | ||
} | ||
console.log(`Found artifact: ${batchArtifact.name}`); | ||
return batchArtifact.name; | ||
|
||
- name: Download batch ID | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ steps.artifacts.outputs.result }} | ||
|
||
- name: Download repomix outputs | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: repomix-outputs | ||
path: repomix-outputs | ||
|
||
- name: Process batch results and upload to HuggingFace | ||
env: | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
run: | | ||
# Process OpenAI batch results | ||
python scripts/check_batch_output.py | ||
|
||
# Upload all files to HuggingFace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The first half of the step here is in the |
||
python -c ' | ||
from huggingface_hub import HfApi | ||
import os | ||
|
||
api = HfApi() | ||
|
||
# Upload OpenAI summary | ||
api.upload_file( | ||
token=os.environ["HF_TOKEN"], | ||
repo_id="zenml/llms.txt", | ||
repo_type="dataset", | ||
path_in_repo="how-to-guides.txt", | ||
path_or_fileobj="zenml_docs.txt", | ||
) | ||
|
||
# Upload repomix outputs | ||
for filename in ["component-guide.txt", "basics.txt", "llms-full.txt"]: | ||
api.upload_file( | ||
token=os.environ["HF_TOKEN"], | ||
repo_id="zenml/llms.txt", | ||
repo_type="dataset", | ||
path_in_repo=filename, | ||
path_or_fileobj=f"repomix-outputs/{filename}", | ||
) | ||
' |
This file contains 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,76 @@ | ||
name: Submit Docs Summarization | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["release-prepare"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
submit-batch: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
permissions: | ||
contents: read | ||
id-token: write | ||
actions: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install openai pathlib repomix | ||
|
||
- name: Generate repomix outputs | ||
run: | | ||
# Create directory for outputs | ||
mkdir -p repomix-outputs | ||
|
||
# Full docs | ||
repomix --include "docs/book/**/*.md" | ||
mv repomix-output.txt repomix-outputs/llms-full.txt | ||
|
||
# Component guide | ||
repomix --include "docs/book/component-guide/**/*.md" | ||
mv repomix-output.txt repomix-outputs/component-guide.txt | ||
|
||
# User guide | ||
repomix --include "docs/book/user-guide/**/*.md" | ||
mv repomix-output.txt user-guide.txt | ||
|
||
# Getting started | ||
repomix --include "docs/book/getting-started/**/*.md" | ||
mv repomix-output.txt getting-started.txt | ||
|
||
# Merge user guide and getting started into basics | ||
cat user-guide.txt getting-started.txt > repomix-outputs/basics.txt | ||
rm user-guide.txt getting-started.txt | ||
|
||
- name: Upload repomix outputs | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: repomix-outputs | ||
path: repomix-outputs | ||
retention-days: 5 | ||
|
||
- name: Submit batch job | ||
env: | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
id: submit | ||
run: | | ||
python scripts/summarize_docs.py | ||
echo "batch_id=$(cat batch_id.txt)" >> $GITHUB_OUTPUT | ||
|
||
- name: Upload batch ID | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: batch-id-${{ steps.submit.outputs.batch_id }} | ||
path: batch_id.txt | ||
retention-days: 5 |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not so sure if I am missing something here, but it seems like the only trigger for this workflow is any push event on the release branches. I have two concerns about this:
The if condition here
github.event.workflow_run.conclusion == 'success'
might not trigger as the push events do not have workflow runs, thus no conclusions.The current trigger logic might trigger when we backport docs changes or similar things to the existing release branches. Is this the desired behaviour?