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
113113import os
114114from pathlib import Path
115115
116+ os.environ[" GITHUB_ACCESS_TOKEN" ] = " <your_access_token>"
117+
116118def get_github_file_tree (repo_url ):
117119 """ Get repository file structure from GitHub API."""
118120 # Extract owner/repo from URL
119121 parts = repo_url.rstrip(' /' ).split(' /' )
120122 owner, repo = parts[- 2 ], parts[- 1 ]
121123
122124 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+ })
124128
125129 if response.status_code == 200 :
126130 tree_data = response.json()
@@ -135,7 +139,9 @@ def get_github_file_content(repo_url, file_path):
135139 owner, repo = parts[- 2 ], parts[- 1 ]
136140
137141 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+ })
139145
140146 if response.status_code == 200 :
141147 import base64
You can’t perform that action at this time.
0 commit comments