File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
docs/docs/tutorials/llms_txt_generation Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -113,14 +113,18 @@ import requests
113
113
import os
114
114
from pathlib import Path
115
115
116
+ os.environ[" GITHUB_ACCESS_TOKEN" ] = " <your_access_token>"
117
+
116
118
def get_github_file_tree (repo_url ):
117
119
""" Get repository file structure from GitHub API."""
118
120
# Extract owner/repo from URL
119
121
parts = repo_url.rstrip(' /' ).split(' /' )
120
122
owner, repo = parts[- 2 ], parts[- 1 ]
121
123
122
124
api_url = f " https://api.github.com/repos/ { owner} / { repo} /git/trees/main?recursive=1 "
123
- response = requests.get(api_url)
125
+ response = requests.get(api_url, headers = {
126
+ " Authorization" : f " Bearer { os.environ.get(' GITHUB_ACCESS_TOKEN' )} "
127
+ })
124
128
125
129
if response.status_code == 200 :
126
130
tree_data = response.json()
@@ -135,7 +139,9 @@ def get_github_file_content(repo_url, file_path):
135
139
owner, repo = parts[- 2 ], parts[- 1 ]
136
140
137
141
api_url = f " https://api.github.com/repos/ { owner} / { repo} /contents/ { file_path} "
138
- response = requests.get(api_url)
142
+ response = requests.get(api_url, headers = {
143
+ " Authorization" : f " Bearer { os.environ.get(' GITHUB_ACCESS_TOKEN' )} "
144
+ })
139
145
140
146
if response.status_code == 200 :
141
147
import base64
You can’t perform that action at this time.
0 commit comments