-
Notifications
You must be signed in to change notification settings - Fork 0
34 lines (29 loc) · 854 Bytes
/
token-count.yml
File metadata and controls
34 lines (29 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
name: Update token count
on:
push:
paths:
- "instructions.txt"
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
count:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Count tokens
run: |
pip install tiktoken -q
COUNT=$(python3 -c "
import tiktoken
enc = tiktoken.get_encoding('cl100k_base')
print(len(enc.encode(open('instructions.txt').read())))
")
sed -i "s/Tokens-~[0-9]*/Tokens-~$COUNT/" README.md
- name: Commit updated README
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
git diff --quiet || (git add README.md && git commit -m "Update token count" && git push)