Add setter method to set GitHub token
Browse files- pipeline.py +6 -3
pipeline.py
CHANGED
@@ -100,13 +100,16 @@ class RepoEmbeddingPipeline(Pipeline):
|
|
100 |
self.API_HEADERS = {"Accept": "application/vnd.github+json"}
|
101 |
if not github_token:
|
102 |
print(
|
103 |
-
"[!] Consider setting
|
104 |
"For more info, see:"
|
105 |
"https://docs.github.com/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token"
|
106 |
)
|
107 |
else:
|
108 |
-
self.
|
109 |
-
|
|
|
|
|
|
|
110 |
|
111 |
def _sanitize_parameters(self, **kwargs):
|
112 |
_forward_kwargs = {}
|
|
|
100 |
self.API_HEADERS = {"Accept": "application/vnd.github+json"}
|
101 |
if not github_token:
|
102 |
print(
|
103 |
+
"[!] Consider setting GitHub token to avoid hitting rate limits\n"
|
104 |
"For more info, see:"
|
105 |
"https://docs.github.com/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token"
|
106 |
)
|
107 |
else:
|
108 |
+
self.set_github_token(github_token)
|
109 |
+
|
110 |
+
def set_github_token(self, github_token):
|
111 |
+
self.API_HEADERS["Authorization"] = f"Bearer {github_token}"
|
112 |
+
print("[+] GitHub token set")
|
113 |
|
114 |
def _sanitize_parameters(self, **kwargs):
|
115 |
_forward_kwargs = {}
|