Added model and role translation. Rewrite of code's comments.
This commit is contained in:
@@ -1,3 +1,17 @@
|
||||
/**
|
||||
* @fileoverview This file provides a utility function for fetching a remote
|
||||
* image and encoding it in base64.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fetches an image from a URL and returns
|
||||
* its MIME type and base64-encoded data.
|
||||
*
|
||||
* @param url - The URL of the image to fetch.
|
||||
* @returns A promise that resolves to an object containing the MIME type and
|
||||
* base64-encoded image data.
|
||||
* @throws Throws an error if the image fetch fails.
|
||||
*/
|
||||
export async function fetchAndEncode(url: string) {
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) throw new Error(`Failed to fetch image: ${url}`);
|
||||
|
||||
Reference in New Issue
Block a user