Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
471a352f
Unverified
Commit
471a352f
authored
May 28, 2025
by
Graham King
Committed by
GitHub
May 28, 2025
Browse files
fix(dynamo-llm): Use HF_TOKEN env var (#1249)
Fixes #286
parent
a7c54213
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
lib/llm/src/hub.rs
lib/llm/src/hub.rs
+15
-2
No files found.
lib/llm/src/hub.rs
View file @
471a352f
...
@@ -14,15 +14,28 @@
...
@@ -14,15 +14,28 @@
// limitations under the License.
// limitations under the License.
use
hf_hub
::
api
::
tokio
::
ApiBuilder
;
use
hf_hub
::
api
::
tokio
::
ApiBuilder
;
use
std
::
env
;
use
std
::
path
::{
Path
,
PathBuf
};
use
std
::
path
::{
Path
,
PathBuf
};
const
IGNORED
:
[
&
str
;
3
]
=
[
".gitattributes"
,
"LICENSE"
,
"README.md"
];
const
IGNORED
:
[
&
str
;
5
]
=
[
".gitattributes"
,
"LICENSE"
,
"LICENSE.txt"
,
"README.md"
,
"USE_POLICY.md"
,
];
const
HF_TOKEN_ENV_VAR
:
&
str
=
"HF_TOKEN"
;
/// Attempt to download a model from Hugging Face
/// Attempt to download a model from Hugging Face
/// Returns the directory it is in
/// Returns the directory it is in
pub
async
fn
from_hf
(
name
:
impl
AsRef
<
Path
>
)
->
anyhow
::
Result
<
PathBuf
>
{
pub
async
fn
from_hf
(
name
:
impl
AsRef
<
Path
>
)
->
anyhow
::
Result
<
PathBuf
>
{
let
name
=
name
.as_ref
();
let
name
=
name
.as_ref
();
let
api
=
ApiBuilder
::
new
()
.with_progress
(
true
)
.build
()
?
;
let
token
=
env
::
var
(
HF_TOKEN_ENV_VAR
)
.ok
();
let
api
=
ApiBuilder
::
new
()
.with_progress
(
true
)
.with_token
(
token
)
.build
()
?
;
let
model_name
=
name
.display
()
.to_string
();
let
model_name
=
name
.display
()
.to_string
();
let
repo
=
api
.model
(
model_name
.clone
());
let
repo
=
api
.model
(
model_name
.clone
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment