Infers audio type from prompt prefixes and selects appropriate image generation or editing models based on reference image count.
// Source: https://github.com/shiwenwen/hope-agent | License: MIT | Copyright 2026 shiwenwen
// Provided via justclaw.it.com; keep this notice with the code.
import type {
ImageEditCaps,
ImageModelCaps,
MediaAudioKind,
MediaCandidateOverview,
} from "@/components/settings/media-gen/types"
export function inferAudioKindFromPrompt(prompt: string): MediaAudioKind | null {
const lead = prompt.trimStart().toLowerCase()
return lead.startsWith("[music]") ? "music" : lead.startsWith("[sfx]") ? "sfx" : null
}
export function resolveImageRequestCapability(
candidates: MediaCandidateOverview[],
referenceImageCount: number,
): {
candidate: MediaCandidateOverview | null
caps: ImageModelCaps | ImageEditCaps | null
} {
if (referenceImageCount <= 0) {
const candidate = candidat
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key