AI::ProviderUtils
Constants
Class methods
Combines multiple header hashes into one, with lowercase keys and no nil values. Later hashes override earlier ones.
Converts a Uint8Array (Bytes) to a base64 string.
Converts a Uint8Array (Bytes) to a hex string.
Converts a Uint8Array (Bytes) to a UTF-8 string.
Converts a UTF-8 string to a Uint8Array (Bytes).
Creates an ID generator. The total length of the ID is the sum of the prefix, separator, and random part length. Not cryptographically secure.
Creates a delay for a specified duration in milliseconds. @param delay_in_ms - The delay duration in milliseconds. If nil, resolves immediately.
Generates a 16-character random string to use for IDs. Not cryptographically secure.
Loads an API key from a parameter or environment variable.
Loads an optional string setting from a parameter or environment variable.
Loads a string setting from a parameter or environment variable.
Maps a media type to its corresponding file extension.
Normalizes headers by converting keys to lowercase and removing nil values.
Parses a JSON string and returns a JSON::Any object. @param text - The JSON string to parse. @throws {JSONParseError} - If the JSON string is invalid.
Removes entries from a hash where the value is nil. @param hash - The input hash whose entries may be nil. @returns A new hash containing only entries with non-nil values.