Hub
Last updated
Last updated
Utility functions to interact with the BOINC AI Hub ()
static
⇒ Promise.<(FileResponse|Response)>
⇒ Promise
: string
: Response
| FileResponse
| undefined
⇒ Promise.<Object>
inner
⇒ void
⇒ FileResponse
⇒ Promise.<ArrayBuffer>
⇒ Promise.<Blob>
⇒ Promise.<string>
⇒ Promise.<Object>
⇒ Promise.<(FileResponse|undefined)>
⇒ Promise.<void>
⇒ boolean
⇒ null
⇒ Promise.<(FileResponse|Response|undefined)>
⇒ Promise.<Uint8Array>
⇒ string
: Object
Helper function to get a file, using either the Fetch API or FileSystem API.
urlOrPath
URL
| string
The URL/path of the file to get.
Retrieves a file from either a remote URL using the Fetch API or from the local file system using the FileSystem API. If the filesystem is available and env.useCache = true
, the file will be downloaded and cached.
Will throw an error if the file is not found and fatal
is true.
path_or_repo_id
string
This can be either:
a string, the model id of a model repo on boincai.com.
a path to a directory potentially containing the file.
filename
string
The name of the file to locate in path_or_repo
.
[fatal]
boolean
true
Whether to throw an error if the file is not found.
[options]
PretrainedOptions
An object containing optional parameters.
Fetches a JSON file from a given path and file name.
Will throw an error if the file is not found and fatal
is true.
modelPath
string
The path to the directory containing the file.
fileName
string
The name of the file to fetch.
[fatal]
boolean
true
Whether to throw an error if the file is not found.
[options]
PretrainedOptions
An object containing optional parameters.
Creates a new FileResponse
object.
filePath
string
| URL
Mapping from file extensions to MIME types.
Updates the ‘content-type’ header property of the response based on the extension of the file specified by the filePath property of the current object.
Clone the current FileResponse object.
Reads the contents of the file specified by the filePath property and returns a Promise that resolves with an ArrayBuffer containing the file’s contents.
Error
If the file cannot be read.
Reads the contents of the file specified by the filePath property and returns a Promise that resolves with a Blob containing the file’s contents.
Error
If the file cannot be read.
Reads the contents of the file specified by the filePath property and returns a Promise that resolves with a string containing the file’s contents.
Error
If the file cannot be read.
Reads the contents of the file specified by the filePath property and returns a Promise that resolves with a parsed JavaScript object containing the file’s contents.
Error
If the file cannot be read.
Instantiate a FileCache
object.
path
string
Checks whether the given request is in the cache.
request
string
Adds the given response to the cache.
request
string
response
Response
| FileResponse
Determines whether the given string is a valid HTTP or HTTPS URL.
string
string
| URL
The string to test for validity as an HTTP or HTTPS URL.
[validHosts]
Array.<string>
A list of valid hostnames. If specified, the URL's hostname must be in this list.
Helper method to handle fatal errors that occur while trying to load a file from the BOINC AI Hub.
Error
If `fatal = false`.
status
number
The HTTP status code of the error.
remoteURL
string
The URL of the file that could not be loaded.
fatal
boolean
Whether to raise an error if the file could not be loaded.
cache
FileCache
| Cache
The cache to search
...names
Array.<string>
The names of the item to search for
Read and track progress when reading a Response object
response
any
The Response object to read
progress_callback
function
The function to call with progress updates
Joins multiple parts of a path into a single path, while handling leading and trailing slashes.
...parts
string
Multiple parts of a path.
Options for loading a pretrained model.
[quantized]
boolean
true
Whether to load the 8-bit quantized version of the model (only applicable when loading model files).
[progress_callback]
function
If specified, this function will be called during model construction, to provide the user with progress updates.
[config]
Object
Configuration for the model to use instead of an automatically loaded configuration. Configuration can be automatically loaded when:
The model is a model provided by the library (loaded with the model id string of a pretrained model).
The model is loaded by supplying a local directory as pretrained_model_name_or_path
and a configuration JSON file named config.json is found in the directory.
[cache_dir]
string
null
Path to a directory in which a downloaded pretrained model configuration should be cached if the standard cache should not be used.
[local_files_only]
boolean
false
Whether or not to only look at local files (e.g., not try downloading the model).
[revision]
string
"'main'"
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a git-based system for storing models and other artifacts on boincai.com, so revision
can be any identifier allowed by git. NOTE: This setting is ignored for local requests.
[model_file_name]
string
null
If specified, load the model with this name (excluding the .onnx suffix). Currently only valid for encoder- or decoder-only models.
Kind: static method of
Returns: Promise.<(FileResponse|Response)>
- A promise that resolves to a FileResponse object (if the file is retrieved using the FileSystem API), or a Response object (if the file is retrieved using the Fetch API).
Kind: static method of
Returns: Promise
- A Promise that resolves with the file content as a buffer.
Throws:
⇒ Promise
: string
: Response
| FileResponse
| undefined
Kind: inner property of
Kind: inner property of
Kind: static method of
Returns: Promise.<Object>
- The JSON data parsed into a JavaScript object.
Throws:
Kind: inner class of
⇒ void
⇒ FileResponse
⇒ Promise.<ArrayBuffer>
⇒ Promise.<Blob>
⇒ Promise.<string>
⇒ Promise.<Object>
Kind: instance property of
Kind: instance method of
Kind: instance method of
Returns: FileResponse
- A new FileResponse object with the same properties as the current object.
Kind: instance method of
Returns: Promise.<ArrayBuffer>
- A Promise that resolves with an ArrayBuffer containing the file’s contents.
Throws:
Kind: instance method of
Returns: Promise.<Blob>
- A Promise that resolves with a Blob containing the file’s contents.
Throws:
Kind: instance method of
Returns: Promise.<string>
- A Promise that resolves with a string containing the file’s contents.
Throws:
Kind: instance method of
Returns: Promise.<Object>
- A Promise that resolves with a parsed JavaScript object containing the file’s contents.
Throws:
Kind: inner class of
⇒ Promise.<(FileResponse|undefined)>
⇒ Promise.<void>
Kind: instance method of
Kind: instance method of
Kind: inner method of
Returns: boolean
- True if the string is a valid HTTP or HTTPS URL, false otherwise.
Kind: inner method of
Returns: null
- Returns null
if fatal = true
.
Throws:
Kind: inner method of
Returns: Promise.<(FileResponse|Response|undefined)>
- The item from the cache, or undefined if not found.
Kind: inner method of
Returns: Promise.<Uint8Array>
- A Promise that resolves with the Uint8Array buffer
Kind: inner method of
Returns: string
- A string representing the joined path.
Kind: inner typedef of Properties