Skip to content

Commit

Permalink
Let Auth Token be defined as env or sys prop
Browse files Browse the repository at this point in the history
  • Loading branch information
lordofthejars committed Nov 24, 2024
1 parent 33e4958 commit 9ffebb7
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

public class Downloader {

private static final String AUTH_TOKEN_ENV_VAR = "JLAMA_AUTH_TOKEN";
private static final String AUTH_TOKEN_PROP = "jlama.auth.token";
private final String modelDir;
private final String modelOwner;
private final String modelName;
Expand Down Expand Up @@ -82,9 +84,21 @@ public File huggingFaceModel() throws IOException {
this.modelName,
this.downloadWeights,
Optional.ofNullable(this.branch),
Optional.ofNullable(this.authToken),
Optional.ofNullable(getAuthToken()),
Optional.ofNullable(this.progressReporter)
);
}

private String getAuthToken() {
String token = System.getenv(AUTH_TOKEN_ENV_VAR);
if (token == null) {
token = System.getProperty(AUTH_TOKEN_PROP);
if (token == null) {
token = this.authToken;
}
}

return token;
}

}

0 comments on commit 9ffebb7

Please sign in to comment.