File tree 1 file changed +21
-9
lines changed
1 file changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -40,15 +40,27 @@ 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 a client with custom timeout.
44
+ // There have been instances where requests did not adhere to the default timeout,
45
+ // resulting in requests hanging indefinitely.
46
+ // Therefore, it's necessary to specify a custom timeout.
47
+ let client = reqwest:: Client :: builder ( )
48
+ . timeout ( std:: time:: Duration :: from_secs ( 5 ) )
49
+ . build ( )
50
+ . context ( "Failed to build HTTP client" ) ?;
51
+
52
+ let model_info = client
53
+ . get ( format ! (
54
+ "https://raw.githubusercontent.com/{}/registry-tabby/main/models.json" ,
55
+ registry
56
+ ) )
57
+ . send ( )
58
+ . await
59
+ . context ( "Failed to download" ) ?
60
+ . json ( )
61
+ . await
62
+ . context ( "Failed to get JSON" ) ?;
63
+
52
64
let dir = models_dir ( ) . join ( registry) ;
53
65
// We don't want to fail if the TabbyML directory already exists,
54
66
// which is exactly, what `create_dir_all` will do, see
You can’t perform that action at this time.
0 commit comments