Skip to content

Commit a1e8bab

Browse files
authored
Merge pull request #230 from AgentOps-AI/compile_llms_txt
compile .mdx files to llms.txt and add workflow to update llms.txt
2 parents 754b3c5 + 09939d6 commit a1e8bab

File tree

4 files changed

+1169
-95
lines changed

4 files changed

+1169
-95
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Compile llms.txt
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'docs/**/*.mdx'
9+
10+
jobs:
11+
compile:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.x'
19+
- name: Compile llms.txt
20+
run: |
21+
cd docs
22+
python compile_llms.py
23+
- name: Commit and push changes
24+
run: |
25+
git config --local user.email "action@github.com"
26+
git config --local user.name "GitHub Action"
27+
git add docs/llms.txt
28+
git commit -m "Update llms.txt" || exit 0
29+
git push

docs/compile_llms_txt.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
3+
def compile_llms_txt():
4+
# Get the docs directory path (where this script is located)
5+
docs_dir = os.path.dirname(os.path.abspath(__file__))
6+
content = ''
7+
# Define names of directories and files to exclude
8+
excluded_names = {'tool'}
9+
10+
# Change to docs directory
11+
os.chdir(docs_dir)
12+
13+
for root, _, files in os.walk('.'):
14+
# Get the last part of the current directory
15+
current_dir = os.path.basename(root)
16+
if current_dir in excluded_names:
17+
continue
18+
19+
for file in files:
20+
if file.endswith('.mdx'):
21+
if file in excluded_names:
22+
continue
23+
24+
file_path = os.path.join(root, file)
25+
relative_path = os.path.relpath(file_path, '.')
26+
27+
with open(file_path, 'r', encoding='utf-8') as f:
28+
file_content = f.read()
29+
content += f"## {relative_path}\n\n{file_content}\n\n"
30+
31+
# Write the complete content, replacing the existing file
32+
output_path = os.path.join(docs_dir, 'llms.txt')
33+
with open(output_path, 'w', encoding='utf-8') as f:
34+
f.write(content)
35+
36+
if __name__ == "__main__":
37+
compile_llms_txt()

docs/development.mdx

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

0 commit comments

Comments
 (0)