File tree 1 file changed +20
-9
lines changed
1 file changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -40,15 +40,26 @@ fn models_json_file(registry: &str) -> PathBuf {
40
40
}
41
41
42
42
async fn load_remote_registry ( registry : & str ) -> Result < Vec < ModelInfo > > {
43
- let model_info = reqwest:: get ( format ! (
44
- "https://raw.githubusercontent.com/{}/registry-tabby/main/models.json" ,
45
- registry
46
- ) )
47
- . await
48
- . context ( "Failed to download" ) ?
49
- . json ( )
50
- . await
51
- . context ( "Failed to get JSON" ) ?;
43
+ // Create an HTTP client with a custom timeout.
44
+ // This is necessary because the default timeout settings can sometimes cause requests to hang indefinitely.
45
+ // To prevent such issues, we specify a custom timeout duration.
46
+ let client = reqwest:: Client :: builder ( )
47
+ . timeout ( std:: time:: Duration :: from_secs ( 5 ) )
48
+ . build ( )
49
+ . context ( "Failed to build HTTP client" ) ?;
50
+
51
+ let model_info = client
52
+ . get ( format ! (
53
+ "https://raw.githubusercontent.com/{}/registry-tabby/main/models.json" ,
54
+ registry
55
+ ) )
56
+ . send ( )
57
+ . await
58
+ . context ( "Failed to download" ) ?
59
+ . json ( )
60
+ . await
61
+ . context ( "Failed to get JSON" ) ?;
62
+
52
63
let dir = models_dir ( ) . join ( registry) ;
53
64
// We don't want to fail if the TabbyML directory already exists,
54
65
// which is exactly, what `create_dir_all` will do, see
You can’t perform that action at this time.
0 commit comments