feat(webui): refine output timeline and model controls (#4108)
* feat(webui): refine output timeline and composer queue * feat(webui): add provider model picker * fix(webui): polish model settings and heartbeat checks * chore: keep heartbeat changes out of webui pr * refactor(webui): isolate settings routes * fix(providers): align minimax anthropic test * fix(providers): keep minimax anthropic base sdk-compatible * fix(providers): normalize anthropic base urls
This commit is contained in:
@@ -8,6 +8,7 @@ const IMAGE_EXTENSIONS = new Set([
|
||||
".webp",
|
||||
".bmp",
|
||||
".ico",
|
||||
".svg",
|
||||
".tif",
|
||||
".tiff",
|
||||
]);
|
||||
@@ -34,26 +35,30 @@ function extensionOf(value?: string): string {
|
||||
return path.slice(dot);
|
||||
}
|
||||
|
||||
export function inferMediaKind(media: { url?: string; name?: string }): UIMediaKind {
|
||||
function explicitMediaKind(media: { url?: string; name?: string }): UIMediaKind | null {
|
||||
const url = media.url ?? "";
|
||||
if (url.startsWith("data:image/")) return "image";
|
||||
if (url.startsWith("data:video/")) return "video";
|
||||
|
||||
const ext = extensionOf(media.name) || extensionOf(url);
|
||||
if (!ext) return null;
|
||||
if (IMAGE_EXTENSIONS.has(ext)) return "image";
|
||||
if (VIDEO_EXTENSIONS.has(ext)) return "video";
|
||||
return "file";
|
||||
}
|
||||
|
||||
export function inferMediaKind(media: { url?: string; name?: string }): UIMediaKind {
|
||||
return explicitMediaKind(media) ?? "file";
|
||||
}
|
||||
|
||||
export function toMediaAttachment(media: {
|
||||
url?: string;
|
||||
name?: string;
|
||||
kind?: UIMediaKind;
|
||||
}): UIMediaAttachment {
|
||||
return {
|
||||
kind: media.kind ?? inferMediaKind(media),
|
||||
kind: explicitMediaKind(media) ?? media.kind ?? "file",
|
||||
url: media.url,
|
||||
name: media.name,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user