MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / resolveAIImageData

Function resolveAIImageData

ai/ai.ts:875–895  ·  view source on GitHub ↗
(
  image: AIImage,
  httpClient: HttpClient,
  token?: AbortToken,
)

Source from the content-addressed store, hash-verified

873
874const resolveAIImageData = async (
875 image: AIImage,
876 httpClient: HttpClient,
877 token?: AbortToken,
878): Promise<AIImage | null> => {
879 if (image.data) return image;
880 if (!image.url) return null;
881 const response = await httpClient.request(
882 {
883 url: image.url,
884 method: "GET",
885 responseType: "arraybuffer",
886 },
887 token,
888 );
889 const contentType =
890 getHeaderContentType(response.headers) ||
891 image.mimeType ||
892 "image/jpeg";
893 return { data: Buffer.from(response.data), mimeType: contentType };
894};
895
896const getVideoExtensionForMime = (mimeType: string): string => {
897 if (mimeType === "video/webm") return ".webm";
898 if (mimeType === "video/quicktime") return ".mov";

Callers 2

resolveImageInputsFunction · 0.85
sendImagesMethod · 0.85

Calls 2

getHeaderContentTypeFunction · 0.85
requestMethod · 0.45

Tested by

no test coverage detected