Skip to content

Commit

Permalink
feat: llm txt
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-jerry-ye committed Jan 15, 2025
1 parent d48adfe commit b18d596
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
35 changes: 27 additions & 8 deletions .github/workflows/llm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,40 @@ defaults:
working-directory: next

jobs:
llm-upload:
llm-upload-en:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: aliyun/setup-aliyun-cli-action@v1
- uses: actions/setup-python@v5
- name: install
run: pip install -r requirements.txt
- name: build
run: make markdown
- name: compilation
run: python3 llm.py
- name: upload
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
AWS_DEFAULT_REGION: ${{secrets.AWS_DEFAULT_REGION}}
run: |
echo 'soyo' > llm.txt
aliyun configure set --profile default --mode AK --access-key-id ${{secrets.ALIBABA_CLOUD_ACCESS_KEY_ID}} --access-key-secret ${{secrets.ALIBABA_CLOUD_ACCESS_KEY_SECRET}} --region ${{secrets.ALIBABA_REGION}}
echo y | aliyun oss cp llm.txt ${{secrets.ALIYUN_HOMEPAGE_BUCKET}}/llm.txt
aliyun cdn RefreshObjectCaches --ObjectPath https://www.moonbitlang.cn/llm.txt --ObjectType File
aws s3 cp llm.txt ${{secrets.AWS_HOMEPAGE_BUCKET}}/llm.txt
aws s3 cp ./_build/markdown/llm.txt ${{secrets.AWS_HOMEPAGE_BUCKET}}/llm.txt
aws cloudfront create-invalidation --distribution-id ${{secrets.AWS_CLOUDFRONT_HOMEPAGE_DISTRIBUTION_ID}} --paths "/llm.txt"
llm-upload-zh:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: install
run: pip install -r requirements.txt
- name: build
run: LANGUAGE="zh_CN" make markdown
- name: compilation
run: python3 llm.py
- uses: aliyun/setup-aliyun-cli-action@v1
- name: upload
run: |
aliyun configure set --profile default --mode AK --access-key-id ${{secrets.ALIBABA_CLOUD_ACCESS_KEY_ID}} --access-key-secret ${{secrets.ALIBABA_CLOUD_ACCESS_KEY_SECRET}} --region ${{secrets.ALIBABA_REGION}}
echo y | aliyun oss cp ./_build/markdown/llm.txt ${{secrets.ALIYUN_HOMEPAGE_BUCKET}}/llm.txt
aliyun cdn RefreshObjectCaches --ObjectPath https://www.moonbitlang.cn/llm.txt --ObjectType File
17 changes: 17 additions & 0 deletions next/llm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
BUILD_DIR="_build/markdown"

filenames = ["index.md", "tutorial/tour.md", "language/index.md", "language/introduction.md",
"language/fundamentals.md", "language/methods.md", "language/error-handling.md",
"language/packages.md", "language/tests.md", "language/docs.md", "language/ffi-and-wasm-host.md",
"language/derive.md", "language/async-experimental.md"]

with open(f"{BUILD_DIR}/llm.md", "w") as f:
print("# MoonBit Documentation", file=f)
for fname in filenames:
with open(f"{BUILD_DIR}/{fname}", "r") as g:
print(f"<!-- path: {fname} -->", file=f)
for line in g:
if line.startswith('#'):
f.write(f"#{line}")
else:
f.write(line)

0 comments on commit b18d596

Please sign in to comment.