Module utils

Module utils 

Source

Functions§

content_to_provider_value
Convert Content into a JSON value suitable for generic providers.
health_check
Simple health check helper for provider base URLs. Tries to GET {base_url}/models (common OpenAI-compatible endpoint) or the base URL and returns Ok(()) if reachable and returns an AiLibError otherwise.
upload_file_inline
Upload or inline a local file path; current default behavior is to inline as data URL Returns a data URL string if successful, or None on failure.
upload_file_to_provider
Upload a local file to the provider’s upload endpoint using multipart/form-data. This function is conservative: it only attempts an upload when an upload_url is provided. Returns the provider-hosted file URL on success.
upload_file_with_transport
Upload a file using an injected transport if available. If transport is Some, it will be used to post a multipart form. Otherwise, falls back to upload_file_to_provider which constructs its own client.