@juspay/neurolink 9.64.0 → 9.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +18 -17
- package/dist/adapters/providerImageAdapter.js +29 -1
- package/dist/adapters/replicate/auth.d.ts +19 -0
- package/dist/adapters/replicate/auth.js +32 -0
- package/dist/adapters/replicate/predictionLifecycle.d.ts +46 -0
- package/dist/adapters/replicate/predictionLifecycle.js +283 -0
- package/dist/adapters/video/klingVideoHandler.d.ts +37 -0
- package/dist/adapters/video/klingVideoHandler.js +305 -0
- package/dist/adapters/video/replicateVideoHandler.d.ts +29 -0
- package/dist/adapters/video/replicateVideoHandler.js +157 -0
- package/dist/adapters/video/runwayVideoHandler.d.ts +32 -0
- package/dist/adapters/video/runwayVideoHandler.js +316 -0
- package/dist/adapters/video/vertexVideoHandler.d.ts +19 -1
- package/dist/adapters/video/vertexVideoHandler.js +33 -9
- package/dist/autoresearch/runner.js +8 -2
- package/dist/avatar/index.d.ts +13 -0
- package/dist/avatar/index.js +13 -0
- package/dist/avatar/providers/DIDAvatar.d.ts +49 -0
- package/dist/avatar/providers/DIDAvatar.js +501 -0
- package/dist/avatar/providers/HeyGenAvatar.d.ts +30 -0
- package/dist/avatar/providers/HeyGenAvatar.js +337 -0
- package/dist/avatar/providers/ReplicateAvatar.d.ts +36 -0
- package/dist/avatar/providers/ReplicateAvatar.js +267 -0
- package/dist/browser/neurolink.min.js +633 -610
- package/dist/cli/commands/mcp.js +29 -0
- package/dist/cli/commands/proxy.js +24 -5
- package/dist/cli/factories/commandFactory.d.ts +11 -1
- package/dist/cli/factories/commandFactory.js +291 -38
- package/dist/constants/contextWindows.js +101 -0
- package/dist/constants/enums.d.ts +273 -2
- package/dist/constants/enums.js +290 -1
- package/dist/constants/videoErrors.d.ts +4 -0
- package/dist/constants/videoErrors.js +4 -0
- package/dist/core/baseProvider.d.ts +22 -2
- package/dist/core/baseProvider.js +217 -11
- package/dist/core/constants.d.ts +11 -0
- package/dist/core/constants.js +69 -1
- package/dist/core/redisConversationMemoryManager.js +6 -0
- package/dist/evaluation/index.d.ts +2 -0
- package/dist/evaluation/index.js +4 -0
- package/dist/factories/providerFactory.js +7 -1
- package/dist/factories/providerRegistry.js +202 -5
- package/dist/features/ppt/contentPlanner.js +42 -14
- package/dist/index.d.ts +9 -1
- package/dist/index.js +16 -1
- package/dist/lib/adapters/providerImageAdapter.js +29 -1
- package/dist/lib/adapters/replicate/auth.d.ts +19 -0
- package/dist/lib/adapters/replicate/auth.js +33 -0
- package/dist/lib/adapters/replicate/predictionLifecycle.d.ts +46 -0
- package/dist/lib/adapters/replicate/predictionLifecycle.js +284 -0
- package/dist/lib/adapters/video/klingVideoHandler.d.ts +37 -0
- package/dist/lib/adapters/video/klingVideoHandler.js +306 -0
- package/dist/lib/adapters/video/replicateVideoHandler.d.ts +29 -0
- package/dist/lib/adapters/video/replicateVideoHandler.js +158 -0
- package/dist/lib/adapters/video/runwayVideoHandler.d.ts +32 -0
- package/dist/lib/adapters/video/runwayVideoHandler.js +317 -0
- package/dist/lib/adapters/video/vertexVideoHandler.d.ts +19 -1
- package/dist/lib/adapters/video/vertexVideoHandler.js +33 -9
- package/dist/lib/autoresearch/runner.js +8 -2
- package/dist/lib/avatar/index.d.ts +13 -0
- package/dist/lib/avatar/index.js +14 -0
- package/dist/lib/avatar/providers/DIDAvatar.d.ts +49 -0
- package/dist/lib/avatar/providers/DIDAvatar.js +502 -0
- package/dist/lib/avatar/providers/HeyGenAvatar.d.ts +30 -0
- package/dist/lib/avatar/providers/HeyGenAvatar.js +338 -0
- package/dist/lib/avatar/providers/ReplicateAvatar.d.ts +36 -0
- package/dist/lib/avatar/providers/ReplicateAvatar.js +268 -0
- package/dist/lib/constants/contextWindows.js +101 -0
- package/dist/lib/constants/enums.d.ts +273 -2
- package/dist/lib/constants/enums.js +290 -1
- package/dist/lib/constants/videoErrors.d.ts +4 -0
- package/dist/lib/constants/videoErrors.js +4 -0
- package/dist/lib/core/baseProvider.d.ts +22 -2
- package/dist/lib/core/baseProvider.js +217 -11
- package/dist/lib/core/constants.d.ts +11 -0
- package/dist/lib/core/constants.js +69 -1
- package/dist/lib/core/redisConversationMemoryManager.js +6 -0
- package/dist/lib/evaluation/index.d.ts +2 -0
- package/dist/lib/evaluation/index.js +4 -0
- package/dist/lib/factories/providerFactory.js +7 -1
- package/dist/lib/factories/providerRegistry.js +202 -5
- package/dist/lib/features/ppt/contentPlanner.js +42 -14
- package/dist/lib/index.d.ts +9 -1
- package/dist/lib/index.js +16 -1
- package/dist/lib/middleware/builtin/lifecycle.js +39 -9
- package/dist/lib/music/index.d.ts +13 -0
- package/dist/lib/music/index.js +14 -0
- package/dist/lib/music/providers/BeatovenMusic.d.ts +31 -0
- package/dist/lib/music/providers/BeatovenMusic.js +334 -0
- package/dist/lib/music/providers/ElevenLabsMusic.d.ts +30 -0
- package/dist/lib/music/providers/ElevenLabsMusic.js +169 -0
- package/dist/lib/music/providers/LyriaMusic.d.ts +29 -0
- package/dist/lib/music/providers/LyriaMusic.js +173 -0
- package/dist/lib/music/providers/ReplicateMusic.d.ts +31 -0
- package/dist/lib/music/providers/ReplicateMusic.js +262 -0
- package/dist/lib/neurolink.d.ts +30 -0
- package/dist/lib/neurolink.js +323 -77
- package/dist/lib/providers/amazonBedrock.d.ts +10 -0
- package/dist/lib/providers/amazonBedrock.js +94 -39
- package/dist/lib/providers/anthropic.js +55 -7
- package/dist/lib/providers/anthropicBaseProvider.js +1 -1
- package/dist/lib/providers/azureOpenai.js +66 -17
- package/dist/lib/providers/cloudflare.d.ts +35 -0
- package/dist/lib/providers/cloudflare.js +174 -0
- package/dist/lib/providers/cohere.d.ts +52 -0
- package/dist/lib/providers/cohere.js +253 -0
- package/dist/lib/providers/deepseek.js +72 -17
- package/dist/lib/providers/fireworks.d.ts +33 -0
- package/dist/lib/providers/fireworks.js +164 -0
- package/dist/lib/providers/googleAiStudio.js +45 -6
- package/dist/lib/providers/googleNativeGemini3.d.ts +24 -1
- package/dist/lib/providers/googleNativeGemini3.js +173 -21
- package/dist/lib/providers/googleVertex.js +173 -17
- package/dist/lib/providers/groq.d.ts +33 -0
- package/dist/lib/providers/groq.js +181 -0
- package/dist/lib/providers/huggingFace.js +9 -8
- package/dist/lib/providers/ideogram.d.ts +34 -0
- package/dist/lib/providers/ideogram.js +184 -0
- package/dist/lib/providers/index.d.ts +13 -0
- package/dist/lib/providers/index.js +13 -0
- package/dist/lib/providers/jina.d.ts +59 -0
- package/dist/lib/providers/jina.js +218 -0
- package/dist/lib/providers/llamaCpp.js +14 -46
- package/dist/lib/providers/lmStudio.js +14 -47
- package/dist/lib/providers/mistral.js +7 -7
- package/dist/lib/providers/nvidiaNim.js +160 -19
- package/dist/lib/providers/ollama.js +7 -7
- package/dist/lib/providers/openAI.d.ts +22 -1
- package/dist/lib/providers/openAI.js +181 -0
- package/dist/lib/providers/openRouter.js +35 -23
- package/dist/lib/providers/openaiCompatible.js +9 -8
- package/dist/lib/providers/perplexity.d.ts +33 -0
- package/dist/lib/providers/perplexity.js +179 -0
- package/dist/lib/providers/recraft.d.ts +34 -0
- package/dist/lib/providers/recraft.js +197 -0
- package/dist/lib/providers/replicate.d.ts +75 -0
- package/dist/lib/providers/replicate.js +403 -0
- package/dist/lib/providers/stability.d.ts +37 -0
- package/dist/lib/providers/stability.js +191 -0
- package/dist/lib/providers/togetherAi.d.ts +33 -0
- package/dist/lib/providers/togetherAi.js +176 -0
- package/dist/lib/providers/voyage.d.ts +47 -0
- package/dist/lib/providers/voyage.js +177 -0
- package/dist/lib/providers/xai.d.ts +33 -0
- package/dist/lib/providers/xai.js +172 -0
- package/dist/lib/telemetry/index.d.ts +1 -1
- package/dist/lib/telemetry/index.js +1 -1
- package/dist/lib/telemetry/tracers.d.ts +19 -0
- package/dist/lib/telemetry/tracers.js +19 -0
- package/dist/lib/telemetry/withSpan.d.ts +35 -0
- package/dist/lib/telemetry/withSpan.js +103 -0
- package/dist/lib/types/avatar.d.ts +143 -0
- package/dist/lib/types/avatar.js +20 -0
- package/dist/lib/types/cli.d.ts +6 -0
- package/dist/lib/types/generate.d.ts +62 -5
- package/dist/lib/types/index.d.ts +5 -0
- package/dist/lib/types/index.js +7 -0
- package/dist/lib/types/middleware.d.ts +27 -0
- package/dist/lib/types/multimodal.d.ts +35 -2
- package/dist/lib/types/music.d.ts +165 -0
- package/dist/lib/types/music.js +21 -0
- package/dist/lib/types/providers.d.ts +144 -1
- package/dist/lib/types/replicate.d.ts +67 -0
- package/dist/lib/types/replicate.js +10 -0
- package/dist/lib/types/safeFetch.d.ts +15 -0
- package/dist/lib/types/safeFetch.js +7 -0
- package/dist/lib/types/stream.d.ts +2 -1
- package/dist/lib/types/tools.d.ts +13 -0
- package/dist/lib/types/video.d.ts +89 -0
- package/dist/lib/types/video.js +15 -0
- package/dist/lib/utils/avatarProcessor.d.ts +68 -0
- package/dist/lib/utils/avatarProcessor.js +172 -0
- package/dist/lib/utils/cloneOptions.d.ts +36 -0
- package/dist/lib/utils/cloneOptions.js +62 -0
- package/dist/lib/utils/lifecycleCallbacks.d.ts +51 -8
- package/dist/lib/utils/lifecycleCallbacks.js +82 -26
- package/dist/lib/utils/lifecycleTimeout.d.ts +25 -0
- package/dist/lib/utils/lifecycleTimeout.js +39 -0
- package/dist/lib/utils/logSanitize.d.ts +49 -0
- package/dist/lib/utils/logSanitize.js +170 -0
- package/dist/lib/utils/loggingFetch.d.ts +29 -0
- package/dist/lib/utils/loggingFetch.js +60 -0
- package/dist/lib/utils/messageBuilder.js +43 -25
- package/dist/lib/utils/modelChoices.js +236 -3
- package/dist/lib/utils/musicProcessor.d.ts +67 -0
- package/dist/lib/utils/musicProcessor.js +189 -0
- package/dist/lib/utils/optionsConversion.js +3 -2
- package/dist/lib/utils/parameterValidation.js +14 -4
- package/dist/lib/utils/pricing.js +193 -0
- package/dist/lib/utils/providerConfig.d.ts +55 -0
- package/dist/lib/utils/providerConfig.js +224 -0
- package/dist/lib/utils/safeFetch.d.ts +26 -0
- package/dist/lib/utils/safeFetch.js +83 -0
- package/dist/lib/utils/sizeGuard.d.ts +34 -0
- package/dist/lib/utils/sizeGuard.js +45 -0
- package/dist/lib/utils/ssrfGuard.d.ts +52 -0
- package/dist/lib/utils/ssrfGuard.js +411 -0
- package/dist/lib/utils/videoProcessor.d.ts +60 -0
- package/dist/lib/utils/videoProcessor.js +201 -0
- package/dist/lib/voice/providers/FishAudioTTS.d.ts +27 -0
- package/dist/lib/voice/providers/FishAudioTTS.js +183 -0
- package/dist/lib/workflow/core/ensembleExecutor.js +26 -9
- package/dist/middleware/builtin/lifecycle.js +39 -9
- package/dist/music/index.d.ts +13 -0
- package/dist/music/index.js +13 -0
- package/dist/music/providers/BeatovenMusic.d.ts +31 -0
- package/dist/music/providers/BeatovenMusic.js +333 -0
- package/dist/music/providers/ElevenLabsMusic.d.ts +30 -0
- package/dist/music/providers/ElevenLabsMusic.js +168 -0
- package/dist/music/providers/LyriaMusic.d.ts +29 -0
- package/dist/music/providers/LyriaMusic.js +172 -0
- package/dist/music/providers/ReplicateMusic.d.ts +31 -0
- package/dist/music/providers/ReplicateMusic.js +261 -0
- package/dist/neurolink.d.ts +30 -0
- package/dist/neurolink.js +323 -77
- package/dist/providers/amazonBedrock.d.ts +10 -0
- package/dist/providers/amazonBedrock.js +94 -39
- package/dist/providers/anthropic.js +55 -7
- package/dist/providers/anthropicBaseProvider.js +1 -1
- package/dist/providers/azureOpenai.js +66 -17
- package/dist/providers/cloudflare.d.ts +35 -0
- package/dist/providers/cloudflare.js +173 -0
- package/dist/providers/cohere.d.ts +52 -0
- package/dist/providers/cohere.js +252 -0
- package/dist/providers/deepseek.js +72 -17
- package/dist/providers/fireworks.d.ts +33 -0
- package/dist/providers/fireworks.js +163 -0
- package/dist/providers/googleAiStudio.js +45 -6
- package/dist/providers/googleNativeGemini3.d.ts +24 -1
- package/dist/providers/googleNativeGemini3.js +173 -21
- package/dist/providers/googleVertex.js +173 -17
- package/dist/providers/groq.d.ts +33 -0
- package/dist/providers/groq.js +180 -0
- package/dist/providers/huggingFace.js +9 -8
- package/dist/providers/ideogram.d.ts +34 -0
- package/dist/providers/ideogram.js +183 -0
- package/dist/providers/index.d.ts +13 -0
- package/dist/providers/index.js +13 -0
- package/dist/providers/jina.d.ts +59 -0
- package/dist/providers/jina.js +217 -0
- package/dist/providers/llamaCpp.js +14 -46
- package/dist/providers/lmStudio.js +14 -47
- package/dist/providers/mistral.js +7 -7
- package/dist/providers/nvidiaNim.js +160 -19
- package/dist/providers/ollama.js +7 -7
- package/dist/providers/openAI.d.ts +22 -1
- package/dist/providers/openAI.js +181 -0
- package/dist/providers/openRouter.js +35 -23
- package/dist/providers/openaiCompatible.js +9 -8
- package/dist/providers/perplexity.d.ts +33 -0
- package/dist/providers/perplexity.js +178 -0
- package/dist/providers/recraft.d.ts +34 -0
- package/dist/providers/recraft.js +196 -0
- package/dist/providers/replicate.d.ts +75 -0
- package/dist/providers/replicate.js +402 -0
- package/dist/providers/stability.d.ts +37 -0
- package/dist/providers/stability.js +190 -0
- package/dist/providers/togetherAi.d.ts +33 -0
- package/dist/providers/togetherAi.js +175 -0
- package/dist/providers/voyage.d.ts +47 -0
- package/dist/providers/voyage.js +176 -0
- package/dist/providers/xai.d.ts +33 -0
- package/dist/providers/xai.js +171 -0
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry/tracers.d.ts +19 -0
- package/dist/telemetry/tracers.js +19 -0
- package/dist/telemetry/withSpan.d.ts +35 -0
- package/dist/telemetry/withSpan.js +103 -0
- package/dist/types/avatar.d.ts +143 -0
- package/dist/types/avatar.js +19 -0
- package/dist/types/cli.d.ts +6 -0
- package/dist/types/generate.d.ts +62 -5
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +7 -0
- package/dist/types/middleware.d.ts +27 -0
- package/dist/types/multimodal.d.ts +35 -2
- package/dist/types/music.d.ts +165 -0
- package/dist/types/music.js +20 -0
- package/dist/types/providers.d.ts +144 -1
- package/dist/types/replicate.d.ts +67 -0
- package/dist/types/replicate.js +9 -0
- package/dist/types/safeFetch.d.ts +15 -0
- package/dist/types/safeFetch.js +6 -0
- package/dist/types/stream.d.ts +2 -1
- package/dist/types/tools.d.ts +13 -0
- package/dist/types/video.d.ts +89 -0
- package/dist/types/video.js +14 -0
- package/dist/utils/avatarProcessor.d.ts +68 -0
- package/dist/utils/avatarProcessor.js +171 -0
- package/dist/utils/cloneOptions.d.ts +36 -0
- package/dist/utils/cloneOptions.js +61 -0
- package/dist/utils/lifecycleCallbacks.d.ts +51 -8
- package/dist/utils/lifecycleCallbacks.js +82 -26
- package/dist/utils/lifecycleTimeout.d.ts +25 -0
- package/dist/utils/lifecycleTimeout.js +38 -0
- package/dist/utils/logSanitize.d.ts +49 -0
- package/dist/utils/logSanitize.js +169 -0
- package/dist/utils/loggingFetch.d.ts +29 -0
- package/dist/utils/loggingFetch.js +59 -0
- package/dist/utils/messageBuilder.js +43 -25
- package/dist/utils/modelChoices.js +236 -3
- package/dist/utils/musicProcessor.d.ts +67 -0
- package/dist/utils/musicProcessor.js +188 -0
- package/dist/utils/optionsConversion.js +3 -2
- package/dist/utils/parameterValidation.js +14 -4
- package/dist/utils/pricing.js +193 -0
- package/dist/utils/providerConfig.d.ts +55 -0
- package/dist/utils/providerConfig.js +224 -0
- package/dist/utils/safeFetch.d.ts +26 -0
- package/dist/utils/safeFetch.js +82 -0
- package/dist/utils/sizeGuard.d.ts +34 -0
- package/dist/utils/sizeGuard.js +44 -0
- package/dist/utils/ssrfGuard.d.ts +52 -0
- package/dist/utils/ssrfGuard.js +410 -0
- package/dist/utils/videoProcessor.d.ts +60 -0
- package/dist/utils/videoProcessor.js +200 -0
- package/dist/voice/providers/FishAudioTTS.d.ts +27 -0
- package/dist/voice/providers/FishAudioTTS.js +182 -0
- package/dist/workflow/core/ensembleExecutor.js +26 -9
- package/package.json +32 -5
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Centralized model choices for CLI commands
|
|
3
3
|
* Derives choices from model enums to ensure consistency
|
|
4
4
|
*/
|
|
5
|
-
import { AIProviderName, OpenAIModels, AnthropicModels, GoogleAIModels, BedrockModels, VertexModels, MistralModels, OllamaModels, AzureOpenAIModels, LiteLLMModels, HuggingFaceModels, SageMakerModels, OpenRouterModels, DeepSeekModels, NvidiaNimModels, } from "../constants/enums.js";
|
|
5
|
+
import { AIProviderName, OpenAIModels, AnthropicModels, GoogleAIModels, BedrockModels, VertexModels, MistralModels, OllamaModels, AzureOpenAIModels, LiteLLMModels, HuggingFaceModels, SageMakerModels, OpenRouterModels, DeepSeekModels, NvidiaNimModels, XaiModels, GroqModels, CohereModels, TogetherAIModels, FireworksModels, PerplexityModels, CloudflareModels, VoyageModels, JinaModels, StabilityModels, IdeogramModels, RecraftModels, ReplicateModels, } from "../constants/enums.js";
|
|
6
6
|
/**
|
|
7
7
|
* Top models per provider with descriptions for CLI prompts
|
|
8
8
|
* These are curated lists of the most commonly used/recommended models
|
|
@@ -209,7 +209,7 @@ const TOP_MODELS_CONFIG = {
|
|
|
209
209
|
],
|
|
210
210
|
[AIProviderName.OPENROUTER]: [
|
|
211
211
|
{
|
|
212
|
-
model: OpenRouterModels.
|
|
212
|
+
model: OpenRouterModels.CLAUDE_SONNET_4_5,
|
|
213
213
|
description: "Anthropic via OpenRouter",
|
|
214
214
|
},
|
|
215
215
|
{ model: OpenRouterModels.GPT_4O, description: "OpenAI via OpenRouter" },
|
|
@@ -271,6 +271,213 @@ const TOP_MODELS_CONFIG = {
|
|
|
271
271
|
description: "Use whatever model llama-server has loaded",
|
|
272
272
|
},
|
|
273
273
|
],
|
|
274
|
+
[AIProviderName.XAI]: [
|
|
275
|
+
{
|
|
276
|
+
model: XaiModels.GROK_3,
|
|
277
|
+
description: "Recommended - Latest flagship Grok",
|
|
278
|
+
},
|
|
279
|
+
{ model: XaiModels.GROK_3_MINI, description: "Faster + cheaper Grok 3" },
|
|
280
|
+
{
|
|
281
|
+
model: XaiModels.GROK_2_VISION_LATEST,
|
|
282
|
+
description: "Multimodal (text + images)",
|
|
283
|
+
},
|
|
284
|
+
{ model: XaiModels.GROK_2_LATEST, description: "Previous flagship" },
|
|
285
|
+
{ model: XaiModels.GROK_BETA, description: "Pre-release / experimental" },
|
|
286
|
+
],
|
|
287
|
+
[AIProviderName.GROQ]: [
|
|
288
|
+
{
|
|
289
|
+
model: GroqModels.LLAMA_3_3_70B_VERSATILE,
|
|
290
|
+
description: "Recommended - Production default; sub-100ms",
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
model: GroqModels.LLAMA_3_1_8B_INSTANT,
|
|
294
|
+
description: "Lowest latency tier",
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
model: GroqModels.LLAMA_3_2_90B_VISION_PREVIEW,
|
|
298
|
+
description: "Multimodal (vision)",
|
|
299
|
+
},
|
|
300
|
+
{ model: GroqModels.GEMMA_2_9B_IT, description: "Google Gemma 2 9B" },
|
|
301
|
+
{
|
|
302
|
+
model: GroqModels.MIXTRAL_8X7B_32768,
|
|
303
|
+
description: "Mistral 8x7B MoE, 32K context",
|
|
304
|
+
},
|
|
305
|
+
],
|
|
306
|
+
[AIProviderName.COHERE]: [
|
|
307
|
+
{
|
|
308
|
+
model: CohereModels.COMMAND_R_PLUS,
|
|
309
|
+
description: "Recommended - Flagship RAG-tuned chat",
|
|
310
|
+
},
|
|
311
|
+
{ model: CohereModels.COMMAND_R, description: "Smaller RAG-tuned chat" },
|
|
312
|
+
{ model: CohereModels.COMMAND_R7B, description: "Most compact" },
|
|
313
|
+
],
|
|
314
|
+
[AIProviderName.TOGETHER_AI]: [
|
|
315
|
+
{
|
|
316
|
+
model: TogetherAIModels.LLAMA_3_3_70B_INSTRUCT_TURBO,
|
|
317
|
+
description: "Recommended - Llama 3.3 70B Turbo",
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
model: TogetherAIModels.LLAMA_3_1_405B_INSTRUCT_TURBO,
|
|
321
|
+
description: "Flagship 405B",
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
model: TogetherAIModels.QWEN_2_5_72B_INSTRUCT_TURBO,
|
|
325
|
+
description: "Qwen 2.5 72B Turbo",
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
model: TogetherAIModels.DEEPSEEK_R1,
|
|
329
|
+
description: "DeepSeek R1 reasoning",
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
model: TogetherAIModels.MIXTRAL_8X22B_INSTRUCT,
|
|
333
|
+
description: "Mistral 8x22B MoE",
|
|
334
|
+
},
|
|
335
|
+
],
|
|
336
|
+
[AIProviderName.FIREWORKS]: [
|
|
337
|
+
{
|
|
338
|
+
model: FireworksModels.DEEPSEEK_V4_PRO,
|
|
339
|
+
description: "Recommended - DeepSeek V4 Pro",
|
|
340
|
+
},
|
|
341
|
+
{ model: FireworksModels.GLM_5P1, description: "GLM 5.1 (Zhipu)" },
|
|
342
|
+
{ model: FireworksModels.KIMI_K2P6, description: "Kimi K2.6 (Moonshot)" },
|
|
343
|
+
{ model: FireworksModels.GPT_OSS_120B, description: "GPT-OSS 120B" },
|
|
344
|
+
],
|
|
345
|
+
[AIProviderName.PERPLEXITY]: [
|
|
346
|
+
{
|
|
347
|
+
model: PerplexityModels.SONAR,
|
|
348
|
+
description: "Recommended - Sonar with web grounding",
|
|
349
|
+
},
|
|
350
|
+
{ model: PerplexityModels.SONAR_PRO, description: "Better reasoning" },
|
|
351
|
+
{
|
|
352
|
+
model: PerplexityModels.SONAR_REASONING,
|
|
353
|
+
description: "Explicit reasoning traces",
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
model: PerplexityModels.SONAR_REASONING_PRO,
|
|
357
|
+
description: "Flagship reasoning + web",
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
model: PerplexityModels.SONAR_DEEP_RESEARCH,
|
|
361
|
+
description: "Long-form research with citations",
|
|
362
|
+
},
|
|
363
|
+
],
|
|
364
|
+
[AIProviderName.CLOUDFLARE]: [
|
|
365
|
+
{
|
|
366
|
+
model: CloudflareModels.LLAMA_3_3_70B_FAST,
|
|
367
|
+
description: "Recommended - Llama 3.3 70B FP8 fast",
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
model: CloudflareModels.LLAMA_3_1_70B_INSTRUCT,
|
|
371
|
+
description: "Llama 3.1 70B",
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
model: CloudflareModels.LLAMA_3_1_8B_FAST,
|
|
375
|
+
description: "Llama 3.1 8B fast",
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
model: CloudflareModels.LLAMA_3_2_11B_VISION,
|
|
379
|
+
description: "Multimodal (vision)",
|
|
380
|
+
},
|
|
381
|
+
],
|
|
382
|
+
[AIProviderName.REPLICATE]: [
|
|
383
|
+
{
|
|
384
|
+
model: "meta/meta-llama-3-70b-instruct",
|
|
385
|
+
description: "Recommended - Llama 3 70B Instruct (stable)",
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
model: "meta/meta-llama-3.1-405b-instruct",
|
|
389
|
+
description: "Llama 3.1 405B (flagship)",
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
model: "mistralai/mixtral-8x7b-instruct-v0.1",
|
|
393
|
+
description: "Mixtral 8x7B v0.1",
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
model: "black-forest-labs/flux-1.1-pro",
|
|
397
|
+
description: "FLUX 1.1 Pro (image-gen)",
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
model: "stability-ai/stable-diffusion-3.5-large",
|
|
401
|
+
description: "SD 3.5 Large (image-gen)",
|
|
402
|
+
},
|
|
403
|
+
],
|
|
404
|
+
[AIProviderName.VOYAGE]: [
|
|
405
|
+
{
|
|
406
|
+
model: VoyageModels.VOYAGE_3_5,
|
|
407
|
+
description: "Recommended - General-purpose embeddings",
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
model: VoyageModels.VOYAGE_3_LARGE,
|
|
411
|
+
description: "Flagship — highest accuracy",
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
model: VoyageModels.VOYAGE_CODE_3,
|
|
415
|
+
description: "Code-tuned embeddings",
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
model: VoyageModels.VOYAGE_MULTILINGUAL_2,
|
|
419
|
+
description: "Multilingual embeddings",
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
model: VoyageModels.VOYAGE_3_5_LITE,
|
|
423
|
+
description: "Smaller / cheaper",
|
|
424
|
+
},
|
|
425
|
+
],
|
|
426
|
+
[AIProviderName.JINA]: [
|
|
427
|
+
{
|
|
428
|
+
model: JinaModels.JINA_EMBEDDINGS_V3,
|
|
429
|
+
description: "Recommended - Multilingual flagship",
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
model: JinaModels.JINA_EMBEDDINGS_V2_BASE_EN,
|
|
433
|
+
description: "v2 base English",
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
model: JinaModels.JINA_EMBEDDINGS_V2_BASE_CODE,
|
|
437
|
+
description: "v2 base code",
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
model: JinaModels.JINA_RERANKER_V2_BASE_MULTILINGUAL,
|
|
441
|
+
description: "Reranker (multilingual)",
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
model: JinaModels.JINA_COLBERT_V2,
|
|
445
|
+
description: "Late-interaction retrieval",
|
|
446
|
+
},
|
|
447
|
+
],
|
|
448
|
+
[AIProviderName.STABILITY]: [
|
|
449
|
+
{
|
|
450
|
+
model: StabilityModels.STABLE_IMAGE_ULTRA,
|
|
451
|
+
description: "Recommended - Flagship quality",
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
model: StabilityModels.STABLE_IMAGE_CORE,
|
|
455
|
+
description: "Fast tier",
|
|
456
|
+
},
|
|
457
|
+
{ model: StabilityModels.SD_3_5_LARGE, description: "SD 3.5 Large" },
|
|
458
|
+
{
|
|
459
|
+
model: StabilityModels.SD_3_5_LARGE_TURBO,
|
|
460
|
+
description: "SD 3.5 Large Turbo",
|
|
461
|
+
},
|
|
462
|
+
{ model: StabilityModels.SD_3_5_MEDIUM, description: "SD 3.5 Medium" },
|
|
463
|
+
],
|
|
464
|
+
[AIProviderName.IDEOGRAM]: [
|
|
465
|
+
{ model: IdeogramModels.IDEOGRAM_V3, description: "Recommended - V3" },
|
|
466
|
+
{ model: IdeogramModels.IDEOGRAM_V2, description: "V2" },
|
|
467
|
+
{ model: IdeogramModels.IDEOGRAM_V2_TURBO, description: "V2 Turbo (fast)" },
|
|
468
|
+
{ model: IdeogramModels.IDEOGRAM_V1, description: "V1" },
|
|
469
|
+
],
|
|
470
|
+
[AIProviderName.RECRAFT]: [
|
|
471
|
+
{
|
|
472
|
+
model: RecraftModels.RECRAFT_V3,
|
|
473
|
+
description: "Recommended - Raster V3",
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
model: RecraftModels.RECRAFT_V3_SVG,
|
|
477
|
+
description: "Vector / SVG output",
|
|
478
|
+
},
|
|
479
|
+
{ model: RecraftModels.RECRAFT_V2, description: "V2" },
|
|
480
|
+
],
|
|
274
481
|
[AIProviderName.AUTO]: [],
|
|
275
482
|
};
|
|
276
483
|
/**
|
|
@@ -288,7 +495,7 @@ export const DEFAULT_MODELS = {
|
|
|
288
495
|
[AIProviderName.LITELLM]: LiteLLMModels.OPENAI_GPT_4O,
|
|
289
496
|
[AIProviderName.HUGGINGFACE]: HuggingFaceModels.LLAMA_3_3_70B_INSTRUCT,
|
|
290
497
|
[AIProviderName.SAGEMAKER]: SageMakerModels.LLAMA_4_MAVERICK_17B_128E,
|
|
291
|
-
[AIProviderName.OPENROUTER]: OpenRouterModels.
|
|
498
|
+
[AIProviderName.OPENROUTER]: OpenRouterModels.CLAUDE_SONNET_4_5,
|
|
292
499
|
[AIProviderName.OPENAI_COMPATIBLE]: "gpt-4o",
|
|
293
500
|
[AIProviderName.DEEPSEEK]: DeepSeekModels.DEEPSEEK_CHAT,
|
|
294
501
|
[AIProviderName.NVIDIA_NIM]: NvidiaNimModels.LLAMA_3_3_70B_INSTRUCT,
|
|
@@ -296,6 +503,19 @@ export const DEFAULT_MODELS = {
|
|
|
296
503
|
// an empty default is the documented signal to use that path.
|
|
297
504
|
[AIProviderName.LM_STUDIO]: "",
|
|
298
505
|
[AIProviderName.LLAMACPP]: "",
|
|
506
|
+
[AIProviderName.XAI]: XaiModels.GROK_3,
|
|
507
|
+
[AIProviderName.GROQ]: GroqModels.LLAMA_3_3_70B_VERSATILE,
|
|
508
|
+
[AIProviderName.COHERE]: CohereModels.COMMAND_R_PLUS,
|
|
509
|
+
[AIProviderName.TOGETHER_AI]: TogetherAIModels.LLAMA_3_3_70B_INSTRUCT_TURBO,
|
|
510
|
+
[AIProviderName.FIREWORKS]: FireworksModels.DEEPSEEK_V4_PRO,
|
|
511
|
+
[AIProviderName.PERPLEXITY]: PerplexityModels.SONAR,
|
|
512
|
+
[AIProviderName.CLOUDFLARE]: CloudflareModels.LLAMA_3_3_70B_FAST,
|
|
513
|
+
[AIProviderName.REPLICATE]: "meta/meta-llama-3-70b-instruct",
|
|
514
|
+
[AIProviderName.VOYAGE]: VoyageModels.VOYAGE_3_5,
|
|
515
|
+
[AIProviderName.JINA]: JinaModels.JINA_EMBEDDINGS_V3,
|
|
516
|
+
[AIProviderName.STABILITY]: StabilityModels.STABLE_IMAGE_ULTRA,
|
|
517
|
+
[AIProviderName.IDEOGRAM]: IdeogramModels.IDEOGRAM_V3,
|
|
518
|
+
[AIProviderName.RECRAFT]: RecraftModels.RECRAFT_V3,
|
|
299
519
|
};
|
|
300
520
|
/**
|
|
301
521
|
* Model enum mappings for getAllModels
|
|
@@ -318,6 +538,19 @@ const MODEL_ENUMS = {
|
|
|
318
538
|
[AIProviderName.NVIDIA_NIM]: NvidiaNimModels,
|
|
319
539
|
[AIProviderName.LM_STUDIO]: null,
|
|
320
540
|
[AIProviderName.LLAMACPP]: null,
|
|
541
|
+
[AIProviderName.XAI]: XaiModels,
|
|
542
|
+
[AIProviderName.GROQ]: GroqModels,
|
|
543
|
+
[AIProviderName.COHERE]: CohereModels,
|
|
544
|
+
[AIProviderName.TOGETHER_AI]: TogetherAIModels,
|
|
545
|
+
[AIProviderName.FIREWORKS]: FireworksModels,
|
|
546
|
+
[AIProviderName.PERPLEXITY]: PerplexityModels,
|
|
547
|
+
[AIProviderName.CLOUDFLARE]: CloudflareModels,
|
|
548
|
+
[AIProviderName.REPLICATE]: ReplicateModels,
|
|
549
|
+
[AIProviderName.VOYAGE]: VoyageModels,
|
|
550
|
+
[AIProviderName.JINA]: JinaModels,
|
|
551
|
+
[AIProviderName.STABILITY]: StabilityModels,
|
|
552
|
+
[AIProviderName.IDEOGRAM]: IdeogramModels,
|
|
553
|
+
[AIProviderName.RECRAFT]: RecraftModels,
|
|
321
554
|
[AIProviderName.AUTO]: null,
|
|
322
555
|
};
|
|
323
556
|
/**
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Music Generation Processing Utility
|
|
3
|
+
*
|
|
4
|
+
* Central registry + dispatch for music-generation handlers across
|
|
5
|
+
* providers (Beatoven, ElevenLabs Music, Lyria, Replicate-hosted models).
|
|
6
|
+
*
|
|
7
|
+
* Mirrors the static-handler-registry pattern established by
|
|
8
|
+
* `TTSProcessor` / `STTProcessor` / `VideoProcessor`.
|
|
9
|
+
*
|
|
10
|
+
* @module utils/musicProcessor
|
|
11
|
+
*/
|
|
12
|
+
import { ErrorCategory, ErrorSeverity } from "../constants/enums.js";
|
|
13
|
+
import type { MusicHandler, MusicOptions, MusicResult } from "../types/index.js";
|
|
14
|
+
import { NeuroLinkError } from "./errorHandling.js";
|
|
15
|
+
/**
|
|
16
|
+
* Music-specific error codes.
|
|
17
|
+
*/
|
|
18
|
+
export declare const MUSIC_ERROR_CODES: {
|
|
19
|
+
readonly PROVIDER_NOT_SUPPORTED: "MUSIC_PROVIDER_NOT_SUPPORTED";
|
|
20
|
+
readonly PROVIDER_NOT_CONFIGURED: "MUSIC_PROVIDER_NOT_CONFIGURED";
|
|
21
|
+
readonly GENERATION_FAILED: "MUSIC_GENERATION_FAILED";
|
|
22
|
+
readonly POLL_TIMEOUT: "MUSIC_POLL_TIMEOUT";
|
|
23
|
+
readonly PROMPT_REQUIRED: "MUSIC_PROMPT_REQUIRED";
|
|
24
|
+
readonly DURATION_INVALID: "MUSIC_DURATION_INVALID";
|
|
25
|
+
readonly INVALID_INPUT: "MUSIC_INVALID_INPUT";
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Typed error class for music-generation failures.
|
|
29
|
+
*/
|
|
30
|
+
export declare class MusicError extends NeuroLinkError {
|
|
31
|
+
constructor(options: {
|
|
32
|
+
code: string;
|
|
33
|
+
message: string;
|
|
34
|
+
category?: ErrorCategory;
|
|
35
|
+
severity?: ErrorSeverity;
|
|
36
|
+
retriable?: boolean;
|
|
37
|
+
context?: Record<string, unknown>;
|
|
38
|
+
originalError?: Error;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Static processor managing the music handler registry.
|
|
43
|
+
*/
|
|
44
|
+
export declare class MusicProcessor {
|
|
45
|
+
private static readonly handlers;
|
|
46
|
+
/**
|
|
47
|
+
* Register a music handler for a specific provider.
|
|
48
|
+
*/
|
|
49
|
+
static registerHandler(providerName: string, handler: MusicHandler): void;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a provider has a registered music handler.
|
|
52
|
+
*/
|
|
53
|
+
static supports(providerName: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* List the names of all registered providers.
|
|
56
|
+
*/
|
|
57
|
+
static listProviders(): string[];
|
|
58
|
+
private static getHandler;
|
|
59
|
+
private static buildSpanAttributes;
|
|
60
|
+
/**
|
|
61
|
+
* Generate a music track via the registered handler.
|
|
62
|
+
*
|
|
63
|
+
* @throws MusicError on registry miss, handler-not-configured, or
|
|
64
|
+
* generation failure.
|
|
65
|
+
*/
|
|
66
|
+
static generate(provider: string, options: MusicOptions): Promise<MusicResult>;
|
|
67
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Music Generation Processing Utility
|
|
3
|
+
*
|
|
4
|
+
* Central registry + dispatch for music-generation handlers across
|
|
5
|
+
* providers (Beatoven, ElevenLabs Music, Lyria, Replicate-hosted models).
|
|
6
|
+
*
|
|
7
|
+
* Mirrors the static-handler-registry pattern established by
|
|
8
|
+
* `TTSProcessor` / `STTProcessor` / `VideoProcessor`.
|
|
9
|
+
*
|
|
10
|
+
* @module utils/musicProcessor
|
|
11
|
+
*/
|
|
12
|
+
import { ErrorCategory, ErrorSeverity } from "../constants/enums.js";
|
|
13
|
+
import { SpanSerializer, SpanStatus, SpanType, getMetricsAggregator, } from "../observability/index.js";
|
|
14
|
+
import { NeuroLinkError } from "./errorHandling.js";
|
|
15
|
+
import { logger } from "./logger.js";
|
|
16
|
+
/**
|
|
17
|
+
* Music-specific error codes.
|
|
18
|
+
*/
|
|
19
|
+
export const MUSIC_ERROR_CODES = {
|
|
20
|
+
PROVIDER_NOT_SUPPORTED: "MUSIC_PROVIDER_NOT_SUPPORTED",
|
|
21
|
+
PROVIDER_NOT_CONFIGURED: "MUSIC_PROVIDER_NOT_CONFIGURED",
|
|
22
|
+
GENERATION_FAILED: "MUSIC_GENERATION_FAILED",
|
|
23
|
+
POLL_TIMEOUT: "MUSIC_POLL_TIMEOUT",
|
|
24
|
+
PROMPT_REQUIRED: "MUSIC_PROMPT_REQUIRED",
|
|
25
|
+
DURATION_INVALID: "MUSIC_DURATION_INVALID",
|
|
26
|
+
INVALID_INPUT: "MUSIC_INVALID_INPUT",
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Typed error class for music-generation failures.
|
|
30
|
+
*/
|
|
31
|
+
export class MusicError extends NeuroLinkError {
|
|
32
|
+
constructor(options) {
|
|
33
|
+
super({
|
|
34
|
+
code: options.code,
|
|
35
|
+
message: options.message,
|
|
36
|
+
category: options.category ?? ErrorCategory.EXECUTION,
|
|
37
|
+
severity: options.severity ?? ErrorSeverity.HIGH,
|
|
38
|
+
retriable: options.retriable ?? false,
|
|
39
|
+
context: options.context,
|
|
40
|
+
originalError: options.originalError,
|
|
41
|
+
});
|
|
42
|
+
this.name = "MusicError";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Static processor managing the music handler registry.
|
|
47
|
+
*/
|
|
48
|
+
export class MusicProcessor {
|
|
49
|
+
static handlers = new Map();
|
|
50
|
+
/**
|
|
51
|
+
* Register a music handler for a specific provider.
|
|
52
|
+
*/
|
|
53
|
+
static registerHandler(providerName, handler) {
|
|
54
|
+
if (!providerName) {
|
|
55
|
+
throw new Error("Provider name is required");
|
|
56
|
+
}
|
|
57
|
+
if (!handler) {
|
|
58
|
+
throw new Error("Handler is required");
|
|
59
|
+
}
|
|
60
|
+
const key = providerName.toLowerCase();
|
|
61
|
+
if (this.handlers.has(key)) {
|
|
62
|
+
logger.warn(`[MusicProcessor] Overwriting existing handler for provider: ${key}`);
|
|
63
|
+
}
|
|
64
|
+
this.handlers.set(key, handler);
|
|
65
|
+
logger.debug(`[MusicProcessor] Registered music handler: ${key}`);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Check if a provider has a registered music handler.
|
|
69
|
+
*/
|
|
70
|
+
static supports(providerName) {
|
|
71
|
+
if (!providerName) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return this.handlers.has(providerName.toLowerCase());
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* List the names of all registered providers.
|
|
78
|
+
*/
|
|
79
|
+
static listProviders() {
|
|
80
|
+
return Array.from(this.handlers.keys());
|
|
81
|
+
}
|
|
82
|
+
static getHandler(providerName) {
|
|
83
|
+
return this.handlers.get(providerName.toLowerCase());
|
|
84
|
+
}
|
|
85
|
+
static buildSpanAttributes(provider, options) {
|
|
86
|
+
return {
|
|
87
|
+
"music.operation": "generate",
|
|
88
|
+
"music.provider": provider,
|
|
89
|
+
"music.duration": options.duration,
|
|
90
|
+
"music.format": options.format,
|
|
91
|
+
"music.genre": options.genre,
|
|
92
|
+
"music.mood": options.mood,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Generate a music track via the registered handler.
|
|
97
|
+
*
|
|
98
|
+
* @throws MusicError on registry miss, handler-not-configured, or
|
|
99
|
+
* generation failure.
|
|
100
|
+
*/
|
|
101
|
+
static async generate(provider, options) {
|
|
102
|
+
const span = SpanSerializer.createSpan(SpanType.MEDIA_GENERATION, "music.generate", this.buildSpanAttributes(provider, options));
|
|
103
|
+
try {
|
|
104
|
+
const trimmedPrompt = options.prompt?.trim();
|
|
105
|
+
if (!trimmedPrompt) {
|
|
106
|
+
throw new MusicError({
|
|
107
|
+
code: MUSIC_ERROR_CODES.PROMPT_REQUIRED,
|
|
108
|
+
message: "Music generation requires a non-empty prompt",
|
|
109
|
+
category: ErrorCategory.VALIDATION,
|
|
110
|
+
severity: ErrorSeverity.LOW,
|
|
111
|
+
retriable: false,
|
|
112
|
+
context: { provider },
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const handler = this.getHandler(provider);
|
|
116
|
+
if (!handler) {
|
|
117
|
+
throw new MusicError({
|
|
118
|
+
code: MUSIC_ERROR_CODES.PROVIDER_NOT_SUPPORTED,
|
|
119
|
+
message: `Music provider "${provider}" is not registered. Available: ${this.listProviders().join(", ")}`,
|
|
120
|
+
category: ErrorCategory.CONFIGURATION,
|
|
121
|
+
severity: ErrorSeverity.HIGH,
|
|
122
|
+
retriable: false,
|
|
123
|
+
context: { provider, available: this.listProviders() },
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
if (!handler.isConfigured()) {
|
|
127
|
+
throw new MusicError({
|
|
128
|
+
code: MUSIC_ERROR_CODES.PROVIDER_NOT_CONFIGURED,
|
|
129
|
+
message: `Music provider "${provider}" is not configured. Set the required credentials.`,
|
|
130
|
+
category: ErrorCategory.CONFIGURATION,
|
|
131
|
+
severity: ErrorSeverity.HIGH,
|
|
132
|
+
retriable: false,
|
|
133
|
+
context: { provider },
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
// Optional duration validation against per-provider max.
|
|
137
|
+
if (options.duration !== undefined &&
|
|
138
|
+
handler.maxDurationSeconds !== undefined &&
|
|
139
|
+
options.duration > handler.maxDurationSeconds) {
|
|
140
|
+
throw new MusicError({
|
|
141
|
+
code: MUSIC_ERROR_CODES.DURATION_INVALID,
|
|
142
|
+
message: `Requested duration (${options.duration}s) exceeds provider maximum (${handler.maxDurationSeconds}s) for "${provider}"`,
|
|
143
|
+
category: ErrorCategory.VALIDATION,
|
|
144
|
+
severity: ErrorSeverity.MEDIUM,
|
|
145
|
+
retriable: false,
|
|
146
|
+
context: {
|
|
147
|
+
provider,
|
|
148
|
+
requested: options.duration,
|
|
149
|
+
maximum: handler.maxDurationSeconds,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
logger.debug(`[MusicProcessor] Starting music generation with provider: ${provider}`);
|
|
154
|
+
const result = await handler.generate({
|
|
155
|
+
...options,
|
|
156
|
+
prompt: trimmedPrompt,
|
|
157
|
+
});
|
|
158
|
+
const ended = SpanSerializer.endSpan(span, SpanStatus.OK);
|
|
159
|
+
getMetricsAggregator().recordSpan(ended);
|
|
160
|
+
logger.info(`[MusicProcessor] Generated ${result.size} bytes (${provider})`);
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
const ended = SpanSerializer.endSpan(span, SpanStatus.ERROR, err instanceof Error ? err.message : String(err));
|
|
165
|
+
getMetricsAggregator().recordSpan(ended);
|
|
166
|
+
if (err instanceof MusicError) {
|
|
167
|
+
throw err;
|
|
168
|
+
}
|
|
169
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
170
|
+
throw new MusicError({
|
|
171
|
+
code: MUSIC_ERROR_CODES.GENERATION_FAILED,
|
|
172
|
+
message: `Music generation failed for provider "${provider}": ${message}`,
|
|
173
|
+
category: ErrorCategory.EXECUTION,
|
|
174
|
+
severity: ErrorSeverity.HIGH,
|
|
175
|
+
retriable: true,
|
|
176
|
+
context: {
|
|
177
|
+
provider,
|
|
178
|
+
duration: options.duration,
|
|
179
|
+
format: options.format,
|
|
180
|
+
genre: options.genre,
|
|
181
|
+
mood: options.mood,
|
|
182
|
+
tempo: options.tempo,
|
|
183
|
+
},
|
|
184
|
+
originalError: err instanceof Error ? err : undefined,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export function convertGenerateToStreamOptions(generateOptions) {
|
|
12
12
|
const streamOptions = {
|
|
13
|
-
// Core input mapping
|
|
14
|
-
|
|
13
|
+
// Core input mapping — GenerateOptions.input is optional (media-only callers
|
|
14
|
+
// may omit it); fall back to an empty object so StreamOptions stays valid.
|
|
15
|
+
input: generateOptions.input ?? {},
|
|
15
16
|
// Provider and model settings
|
|
16
17
|
provider: generateOptions.provider,
|
|
17
18
|
model: generateOptions.model,
|
|
@@ -229,10 +229,20 @@ export function validateTextGenerationOptions(options) {
|
|
|
229
229
|
return { isValid: false, errors, warnings, suggestions };
|
|
230
230
|
}
|
|
231
231
|
const opts = options;
|
|
232
|
-
//
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
232
|
+
// Modality dispatch (output.mode === 'video' | 'avatar' | 'music') carries
|
|
233
|
+
// its own typed prompt inside `output.{video|avatar|music}`. The textual
|
|
234
|
+
// prompt is irrelevant for these modes, so skip the prompt-required check.
|
|
235
|
+
// Same exemption applies for STT-driven flows where `input.text` is
|
|
236
|
+
// synthesized from transcription downstream.
|
|
237
|
+
const outputMode = opts.output?.mode;
|
|
238
|
+
const isMediaModalityMode = outputMode === "video" || outputMode === "avatar" || outputMode === "music";
|
|
239
|
+
const hasSttAudio = !!opts.stt?.audio;
|
|
240
|
+
// Validate prompt (skipped for modality dispatch + STT-driven flows)
|
|
241
|
+
if (!isMediaModalityMode && !hasSttAudio) {
|
|
242
|
+
const promptError = validateRequiredString(opts.prompt, "prompt", 1);
|
|
243
|
+
if (promptError) {
|
|
244
|
+
errors.push(promptError);
|
|
245
|
+
}
|
|
236
246
|
}
|
|
237
247
|
if (opts.prompt && opts.prompt.length > SYSTEM_LIMITS.MAX_PROMPT_LENGTH) {
|
|
238
248
|
errors.push(new ValidationError(`Prompt too large: ${opts.prompt.length} characters (max: ${SYSTEM_LIMITS.MAX_PROMPT_LENGTH})`, "prompt", "MAX_LENGTH", [
|