@juspay/neurolink 7.50.0 → 7.51.1
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 +9 -0
- package/README.md +12 -9
- package/dist/adapters/providerImageAdapter.js +82 -10
- package/dist/agent/directTools.d.ts +10 -10
- package/dist/agent/directTools.js +5 -3
- package/dist/cli/commands/config.js +1 -0
- package/dist/cli/commands/mcp.js +1 -0
- package/dist/cli/commands/models.js +1 -0
- package/dist/cli/commands/ollama.js +1 -0
- package/dist/cli/commands/setup-anthropic.js +1 -0
- package/dist/cli/commands/setup-azure.js +1 -0
- package/dist/cli/commands/setup-bedrock.js +1 -0
- package/dist/cli/commands/setup-gcp.js +1 -0
- package/dist/cli/commands/setup-google-ai.js +1 -0
- package/dist/cli/commands/setup-huggingface.js +1 -0
- package/dist/cli/commands/setup-mistral.js +1 -0
- package/dist/cli/commands/setup-openai.js +1 -0
- package/dist/cli/commands/setup.js +1 -0
- package/dist/cli/errorHandler.js +1 -0
- package/dist/cli/factories/commandFactory.d.ts +1 -0
- package/dist/cli/factories/commandFactory.js +23 -6
- package/dist/cli/factories/ollamaCommandFactory.js +1 -0
- package/dist/cli/factories/sagemakerCommandFactory.js +1 -0
- package/dist/cli/factories/setupCommandFactory.js +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli/loop/conversationSelector.js +1 -0
- package/dist/cli/loop/optionsSchema.js +1 -0
- package/dist/cli/loop/session.js +1 -0
- package/dist/cli/parser.js +1 -0
- package/dist/cli/utils/completeSetup.js +1 -0
- package/dist/cli/utils/envManager.js +1 -0
- package/dist/cli/utils/interactiveSetup.js +1 -0
- package/dist/cli/utils/ollamaUtils.js +1 -0
- package/dist/constants/index.js +1 -1
- package/dist/core/baseProvider.d.ts +5 -0
- package/dist/core/baseProvider.js +70 -20
- package/dist/index.d.ts +3 -3
- package/dist/lib/adapters/providerImageAdapter.js +83 -10
- package/dist/lib/agent/directTools.d.ts +10 -10
- package/dist/lib/agent/directTools.js +6 -3
- package/dist/lib/config/configManager.js +1 -0
- package/dist/lib/config/conversationMemory.js +1 -0
- package/dist/lib/config/taskClassificationConfig.js +1 -0
- package/dist/lib/constants/index.js +2 -1
- package/dist/lib/constants/performance.js +1 -0
- package/dist/lib/constants/retry.js +1 -0
- package/dist/lib/constants/timeouts.js +1 -0
- package/dist/lib/constants/tokens.js +1 -0
- package/dist/lib/core/analytics.js +1 -0
- package/dist/lib/core/baseProvider.d.ts +5 -0
- package/dist/lib/core/baseProvider.js +71 -20
- package/dist/lib/core/constants.js +1 -0
- package/dist/lib/core/conversationMemoryFactory.js +1 -0
- package/dist/lib/core/conversationMemoryInitializer.js +1 -0
- package/dist/lib/core/conversationMemoryManager.js +1 -0
- package/dist/lib/core/dynamicModels.js +1 -0
- package/dist/lib/core/evaluation.js +1 -0
- package/dist/lib/core/evaluationProviders.js +1 -0
- package/dist/lib/core/factory.js +1 -0
- package/dist/lib/core/modelConfiguration.js +1 -0
- package/dist/lib/core/redisConversationMemoryManager.js +1 -0
- package/dist/lib/core/serviceRegistry.js +1 -0
- package/dist/lib/core/streamAnalytics.js +1 -0
- package/dist/lib/evaluation/contextBuilder.js +1 -0
- package/dist/lib/evaluation/index.js +1 -0
- package/dist/lib/evaluation/prompts.js +1 -0
- package/dist/lib/evaluation/ragasEvaluator.js +1 -0
- package/dist/lib/evaluation/retryManager.js +1 -0
- package/dist/lib/evaluation/scoring.js +1 -0
- package/dist/lib/factories/providerFactory.js +1 -0
- package/dist/lib/factories/providerRegistry.js +1 -0
- package/dist/lib/hitl/hitlErrors.js +1 -0
- package/dist/lib/hitl/hitlManager.js +1 -0
- package/dist/lib/hitl/index.js +1 -0
- package/dist/lib/hitl/types.js +1 -0
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +1 -0
- package/dist/lib/mcp/externalServerManager.js +1 -0
- package/dist/lib/mcp/factory.js +1 -0
- package/dist/lib/mcp/flexibleToolValidator.js +1 -0
- package/dist/lib/mcp/index.js +1 -0
- package/dist/lib/mcp/mcpCircuitBreaker.js +1 -0
- package/dist/lib/mcp/mcpClientFactory.js +2 -1
- package/dist/lib/mcp/registry.js +1 -0
- package/dist/lib/mcp/servers/agent/directToolsServer.js +2 -0
- package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.js +1 -0
- package/dist/lib/mcp/servers/aiProviders/aiCoreServer.js +1 -0
- package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +1 -0
- package/dist/lib/mcp/servers/utilities/utilityServer.js +1 -0
- package/dist/lib/mcp/toolDiscoveryService.js +1 -0
- package/dist/lib/mcp/toolRegistry.js +1 -0
- package/dist/lib/memory/mem0Initializer.js +1 -0
- package/dist/lib/middleware/builtin/analytics.js +1 -0
- package/dist/lib/middleware/builtin/autoEvaluation.js +1 -0
- package/dist/lib/middleware/builtin/guardrails.js +1 -0
- package/dist/lib/middleware/factory.js +1 -0
- package/dist/lib/middleware/index.js +1 -0
- package/dist/lib/middleware/registry.js +1 -0
- package/dist/lib/middleware/utils/guardrailsUtils.js +1 -0
- package/dist/lib/models/modelRegistry.js +1 -0
- package/dist/lib/models/modelResolver.js +2 -0
- package/dist/lib/neurolink.d.ts +6 -0
- package/dist/lib/neurolink.js +135 -5
- package/dist/lib/providers/amazonBedrock.d.ts +1 -0
- package/dist/lib/providers/amazonBedrock.js +166 -14
- package/dist/lib/providers/amazonSagemaker.js +1 -0
- package/dist/lib/providers/anthropic.js +7 -21
- package/dist/lib/providers/anthropicBaseProvider.js +1 -0
- package/dist/lib/providers/azureOpenai.js +5 -21
- package/dist/lib/providers/googleAiStudio.js +5 -21
- package/dist/lib/providers/googleVertex.js +8 -1
- package/dist/lib/providers/huggingFace.js +34 -3
- package/dist/lib/providers/index.js +1 -0
- package/dist/lib/providers/litellm.js +34 -3
- package/dist/lib/providers/mistral.js +32 -2
- package/dist/lib/providers/ollama.d.ts +37 -1
- package/dist/lib/providers/ollama.js +544 -58
- package/dist/lib/providers/openAI.js +5 -21
- package/dist/lib/providers/openaiCompatible.js +41 -4
- package/dist/lib/providers/sagemaker/adaptive-semaphore.js +1 -0
- package/dist/lib/providers/sagemaker/client.js +1 -0
- package/dist/lib/providers/sagemaker/config.js +1 -0
- package/dist/lib/providers/sagemaker/detection.js +1 -0
- package/dist/lib/providers/sagemaker/diagnostics.js +1 -0
- package/dist/lib/providers/sagemaker/error-constants.js +1 -0
- package/dist/lib/providers/sagemaker/errors.js +1 -0
- package/dist/lib/providers/sagemaker/index.js +1 -0
- package/dist/lib/providers/sagemaker/language-model.js +1 -0
- package/dist/lib/providers/sagemaker/parsers.js +1 -0
- package/dist/lib/providers/sagemaker/streaming.js +1 -0
- package/dist/lib/providers/sagemaker/structured-parser.js +1 -0
- package/dist/lib/proxy/awsProxyIntegration.js +1 -0
- package/dist/lib/proxy/proxyFetch.js +1 -0
- package/dist/lib/proxy/utils/noProxyUtils.js +1 -0
- package/dist/lib/sdk/toolRegistration.js +2 -0
- package/dist/lib/services/server/ai/observability/instrumentation.js +1 -0
- package/dist/lib/session/globalSessionState.js +1 -0
- package/dist/lib/telemetry/index.js +1 -0
- package/dist/lib/telemetry/telemetryService.js +1 -0
- package/dist/lib/types/analytics.js +1 -0
- package/dist/lib/types/cli.js +1 -0
- package/dist/lib/types/common.js +1 -0
- package/dist/lib/types/configTypes.js +1 -0
- package/dist/lib/types/content.d.ts +14 -1
- package/dist/lib/types/content.js +1 -0
- package/dist/lib/types/contextTypes.js +1 -0
- package/dist/lib/types/conversation.js +1 -0
- package/dist/lib/types/domainTypes.js +1 -0
- package/dist/lib/types/errors.js +1 -0
- package/dist/lib/types/evaluation.js +1 -0
- package/dist/lib/types/evaluationProviders.js +1 -0
- package/dist/lib/types/evaluationTypes.js +1 -0
- package/dist/lib/types/externalMcp.js +1 -0
- package/dist/lib/types/fileTypes.d.ts +44 -0
- package/dist/lib/types/fileTypes.js +1 -0
- package/dist/lib/types/generateTypes.d.ts +1 -0
- package/dist/lib/types/generateTypes.js +1 -0
- package/dist/lib/types/guardrails.js +1 -0
- package/dist/lib/types/index.js +1 -0
- package/dist/lib/types/mcpTypes.js +1 -0
- package/dist/lib/types/middlewareTypes.js +1 -0
- package/dist/lib/types/modelTypes.js +1 -0
- package/dist/lib/types/observability.js +1 -0
- package/dist/lib/types/providers.d.ts +44 -0
- package/dist/lib/types/providers.js +1 -0
- package/dist/lib/types/sdkTypes.js +1 -0
- package/dist/lib/types/serviceTypes.js +1 -0
- package/dist/lib/types/streamTypes.d.ts +1 -0
- package/dist/lib/types/streamTypes.js +1 -0
- package/dist/lib/types/taskClassificationTypes.js +1 -0
- package/dist/lib/types/tools.js +2 -0
- package/dist/lib/types/typeAliases.js +1 -0
- package/dist/lib/types/universalProviderOptions.js +1 -0
- package/dist/lib/utils/analyticsUtils.js +1 -0
- package/dist/lib/utils/conversationMemory.js +1 -0
- package/dist/lib/utils/conversationMemoryUtils.js +1 -0
- package/dist/lib/utils/csvProcessor.js +1 -0
- package/dist/lib/utils/errorHandling.js +1 -0
- package/dist/lib/utils/evaluationUtils.js +1 -0
- package/dist/lib/utils/factoryProcessing.js +1 -0
- package/dist/lib/utils/fileDetector.js +7 -3
- package/dist/lib/utils/imageProcessor.js +1 -0
- package/dist/lib/utils/logger.js +1 -0
- package/dist/lib/utils/loopUtils.js +1 -0
- package/dist/lib/utils/mcpDefaults.js +1 -0
- package/dist/lib/utils/messageBuilder.js +96 -9
- package/dist/lib/utils/modelRouter.js +1 -0
- package/dist/lib/utils/multimodalOptionsBuilder.d.ts +67 -0
- package/dist/lib/utils/multimodalOptionsBuilder.js +65 -0
- package/dist/lib/utils/optionsConversion.js +1 -0
- package/dist/lib/utils/optionsUtils.js +1 -0
- package/dist/lib/utils/parameterValidation.js +1 -0
- package/dist/lib/utils/pdfProcessor.d.ts +10 -0
- package/dist/lib/utils/pdfProcessor.js +199 -0
- package/dist/lib/utils/performance.js +1 -0
- package/dist/lib/utils/promptRedaction.js +1 -0
- package/dist/lib/utils/providerConfig.js +1 -0
- package/dist/lib/utils/providerHealth.js +1 -0
- package/dist/lib/utils/providerSetupMessages.js +1 -0
- package/dist/lib/utils/providerUtils.js +1 -0
- package/dist/lib/utils/redis.js +1 -0
- package/dist/lib/utils/retryHandler.js +1 -0
- package/dist/lib/utils/schemaConversion.js +1 -0
- package/dist/lib/utils/taskClassificationUtils.js +1 -0
- package/dist/lib/utils/taskClassifier.js +1 -0
- package/dist/lib/utils/timeout.js +1 -0
- package/dist/lib/utils/tokenLimits.js +1 -0
- package/dist/lib/utils/toolUtils.js +1 -0
- package/dist/lib/utils/transformationUtils.js +1 -0
- package/dist/lib/utils/typeUtils.js +1 -0
- package/dist/mcp/mcpClientFactory.js +1 -1
- package/dist/mcp/servers/agent/directToolsServer.js +1 -0
- package/dist/models/modelResolver.js +1 -0
- package/dist/neurolink.d.ts +6 -0
- package/dist/neurolink.js +134 -5
- package/dist/providers/amazonBedrock.d.ts +1 -0
- package/dist/providers/amazonBedrock.js +165 -14
- package/dist/providers/anthropic.js +6 -21
- package/dist/providers/azureOpenai.js +4 -21
- package/dist/providers/googleAiStudio.js +4 -21
- package/dist/providers/googleVertex.js +7 -1
- package/dist/providers/huggingFace.js +33 -3
- package/dist/providers/litellm.js +33 -3
- package/dist/providers/mistral.js +31 -2
- package/dist/providers/ollama.d.ts +37 -1
- package/dist/providers/ollama.js +543 -58
- package/dist/providers/openAI.js +4 -21
- package/dist/providers/openaiCompatible.js +40 -4
- package/dist/sdk/toolRegistration.js +1 -0
- package/dist/types/content.d.ts +14 -1
- package/dist/types/fileTypes.d.ts +44 -0
- package/dist/types/generateTypes.d.ts +1 -0
- package/dist/types/providers.d.ts +44 -0
- package/dist/types/streamTypes.d.ts +1 -0
- package/dist/types/tools.js +1 -0
- package/dist/utils/fileDetector.js +6 -3
- package/dist/utils/messageBuilder.js +95 -9
- package/dist/utils/multimodalOptionsBuilder.d.ts +67 -0
- package/dist/utils/multimodalOptionsBuilder.js +64 -0
- package/dist/utils/pdfProcessor.d.ts +10 -0
- package/dist/utils/pdfProcessor.js +198 -0
- package/package.json +11 -20
|
@@ -599,7 +599,8 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
599
599
|
const hasMultimodalInput = !!(options.input?.images?.length ||
|
|
600
600
|
options.input?.content?.length ||
|
|
601
601
|
options.input?.files?.length ||
|
|
602
|
-
options.input?.csvFiles?.length
|
|
602
|
+
options.input?.csvFiles?.length ||
|
|
603
|
+
options.input?.pdfFiles?.length);
|
|
603
604
|
let messages;
|
|
604
605
|
if (hasMultimodalInput) {
|
|
605
606
|
logger.debug(`${functionTag}: Detected multimodal input, using multimodal message builder`, {
|
|
@@ -607,6 +608,8 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
607
608
|
imageCount: options.input?.images?.length || 0,
|
|
608
609
|
hasContent: !!options.input?.content?.length,
|
|
609
610
|
contentCount: options.input?.content?.length || 0,
|
|
611
|
+
hasPDFs: !!options.input?.pdfFiles?.length,
|
|
612
|
+
pdfCount: options.input?.pdfFiles?.length || 0,
|
|
610
613
|
});
|
|
611
614
|
// Create multimodal options for buildMultimodalMessagesArray
|
|
612
615
|
const multimodalOptions = {
|
|
@@ -616,6 +619,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
616
619
|
content: options.input?.content,
|
|
617
620
|
files: options.input?.files,
|
|
618
621
|
csvFiles: options.input?.csvFiles,
|
|
622
|
+
pdfFiles: options.input?.pdfFiles,
|
|
619
623
|
},
|
|
620
624
|
csvOptions: options.csvOptions,
|
|
621
625
|
systemPrompt: options.systemPrompt,
|
|
@@ -1179,6 +1183,8 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
1179
1183
|
/^claude-sonnet-4@\d{8}$/,
|
|
1180
1184
|
/^claude-sonnet-4-5@\d{8}$/,
|
|
1181
1185
|
/^claude-opus-4@\d{8}$/,
|
|
1186
|
+
/^claude-opus-4-1@\d{8}$/,
|
|
1187
|
+
/^claude-3-7-sonnet@\d{8}$/,
|
|
1182
1188
|
/^claude-3-5-sonnet-\d{8}$/,
|
|
1183
1189
|
/^claude-3-5-haiku-\d{8}$/,
|
|
1184
1190
|
/^claude-3-sonnet-\d{8}$/,
|
|
@@ -1430,3 +1436,4 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
1430
1436
|
export default GoogleVertexProvider;
|
|
1431
1437
|
// Re-export for compatibility
|
|
1432
1438
|
export { GoogleVertexProvider as GoogleVertexAI };
|
|
1439
|
+
//# sourceMappingURL=googleVertex.js.map
|
|
@@ -3,8 +3,10 @@ import { streamText, } from "ai";
|
|
|
3
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
4
|
import { logger } from "../utils/logger.js";
|
|
5
5
|
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
6
|
+
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
6
7
|
import { validateApiKey, createHuggingFaceConfig, getProviderModel, } from "../utils/providerConfig.js";
|
|
7
|
-
import { buildMessagesArray } from "../utils/messageBuilder.js";
|
|
8
|
+
import { buildMessagesArray, buildMultimodalMessagesArray, convertToCoreMessages, } from "../utils/messageBuilder.js";
|
|
9
|
+
import { buildMultimodalOptions } from "../utils/multimodalOptionsBuilder.js";
|
|
8
10
|
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
9
11
|
// Configuration helpers - now using consolidated utility
|
|
10
12
|
const getHuggingFaceApiKey = () => {
|
|
@@ -113,13 +115,41 @@ export class HuggingFaceProvider extends BaseProvider {
|
|
|
113
115
|
try {
|
|
114
116
|
// Enhanced tool handling for HuggingFace models
|
|
115
117
|
const streamOptions = this.prepareStreamOptions(options, analysisSchema);
|
|
116
|
-
//
|
|
117
|
-
const
|
|
118
|
+
// Check for multimodal input (images, PDFs, CSVs, files)
|
|
119
|
+
const hasMultimodalInput = !!(options.input?.images?.length ||
|
|
120
|
+
options.input?.content?.length ||
|
|
121
|
+
options.input?.files?.length ||
|
|
122
|
+
options.input?.csvFiles?.length ||
|
|
123
|
+
options.input?.pdfFiles?.length);
|
|
124
|
+
let messages;
|
|
125
|
+
if (hasMultimodalInput) {
|
|
126
|
+
logger.debug(`HuggingFace: Detected multimodal input, using multimodal message builder`, {
|
|
127
|
+
hasImages: !!options.input?.images?.length,
|
|
128
|
+
imageCount: options.input?.images?.length || 0,
|
|
129
|
+
hasContent: !!options.input?.content?.length,
|
|
130
|
+
contentCount: options.input?.content?.length || 0,
|
|
131
|
+
hasFiles: !!options.input?.files?.length,
|
|
132
|
+
fileCount: options.input?.files?.length || 0,
|
|
133
|
+
hasCSVFiles: !!options.input?.csvFiles?.length,
|
|
134
|
+
csvFileCount: options.input?.csvFiles?.length || 0,
|
|
135
|
+
hasPDFFiles: !!options.input?.pdfFiles?.length,
|
|
136
|
+
pdfFileCount: options.input?.pdfFiles?.length || 0,
|
|
137
|
+
});
|
|
138
|
+
const multimodalOptions = buildMultimodalOptions(options, this.providerName, this.modelName);
|
|
139
|
+
const mm = await buildMultimodalMessagesArray(multimodalOptions, this.providerName, this.modelName);
|
|
140
|
+
// Convert multimodal messages to Vercel AI SDK format (CoreMessage[])
|
|
141
|
+
messages = convertToCoreMessages(mm);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
logger.debug(`HuggingFace: Text-only input, using standard message builder`);
|
|
145
|
+
messages = await buildMessagesArray(options);
|
|
146
|
+
}
|
|
118
147
|
const result = await streamText({
|
|
119
148
|
model: this.model,
|
|
120
149
|
messages: messages,
|
|
121
150
|
temperature: options.temperature,
|
|
122
151
|
maxTokens: options.maxTokens, // No default limit - unlimited unless specified
|
|
152
|
+
maxSteps: options.maxSteps || DEFAULT_MAX_STEPS,
|
|
123
153
|
tools: streamOptions.tools, // Tools format conversion handled by prepareStreamOptions
|
|
124
154
|
toolChoice: streamOptions.toolChoice, // Tool choice handled by prepareStreamOptions
|
|
125
155
|
abortSignal: timeoutController?.controller.signal,
|
|
@@ -286,3 +316,4 @@ Available tools will be provided in the function calling format. Use them when t
|
|
|
286
316
|
}
|
|
287
317
|
// Export for factory registration
|
|
288
318
|
export default HuggingFaceProvider;
|
|
319
|
+
//# sourceMappingURL=huggingFace.js.map
|
|
@@ -14,3 +14,4 @@ export { HuggingFaceProvider as HuggingFace } from "./huggingFace.js";
|
|
|
14
14
|
export { OllamaProvider as Ollama } from "./ollama.js";
|
|
15
15
|
export { MistralProvider as MistralAI } from "./mistral.js";
|
|
16
16
|
export { LiteLLMProvider as LiteLLM } from "./litellm.js";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -5,7 +5,9 @@ import { logger } from "../utils/logger.js";
|
|
|
5
5
|
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
6
6
|
import { getProviderModel } from "../utils/providerConfig.js";
|
|
7
7
|
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
8
|
-
import {
|
|
8
|
+
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
9
|
+
import { buildMessagesArray, buildMultimodalMessagesArray, convertToCoreMessages, } from "../utils/messageBuilder.js";
|
|
10
|
+
import { buildMultimodalOptions } from "../utils/multimodalOptionsBuilder.js";
|
|
9
11
|
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
10
12
|
// Configuration helpers
|
|
11
13
|
const getLiteLLMConfig = () => {
|
|
@@ -120,14 +122,42 @@ export class LiteLLMProvider extends BaseProvider {
|
|
|
120
122
|
const timeout = this.getTimeout(options);
|
|
121
123
|
const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
|
|
122
124
|
try {
|
|
123
|
-
//
|
|
124
|
-
const
|
|
125
|
+
// Check for multimodal input (images, PDFs, CSVs, files)
|
|
126
|
+
const hasMultimodalInput = !!(options.input?.images?.length ||
|
|
127
|
+
options.input?.content?.length ||
|
|
128
|
+
options.input?.files?.length ||
|
|
129
|
+
options.input?.csvFiles?.length ||
|
|
130
|
+
options.input?.pdfFiles?.length);
|
|
131
|
+
let messages;
|
|
132
|
+
if (hasMultimodalInput) {
|
|
133
|
+
logger.debug(`LiteLLM: Detected multimodal input, using multimodal message builder`, {
|
|
134
|
+
hasImages: !!options.input?.images?.length,
|
|
135
|
+
imageCount: options.input?.images?.length || 0,
|
|
136
|
+
hasContent: !!options.input?.content?.length,
|
|
137
|
+
contentCount: options.input?.content?.length || 0,
|
|
138
|
+
hasFiles: !!options.input?.files?.length,
|
|
139
|
+
fileCount: options.input?.files?.length || 0,
|
|
140
|
+
hasCSVFiles: !!options.input?.csvFiles?.length,
|
|
141
|
+
csvFileCount: options.input?.csvFiles?.length || 0,
|
|
142
|
+
hasPDFFiles: !!options.input?.pdfFiles?.length,
|
|
143
|
+
pdfFileCount: options.input?.pdfFiles?.length || 0,
|
|
144
|
+
});
|
|
145
|
+
const multimodalOptions = buildMultimodalOptions(options, this.providerName, this.modelName);
|
|
146
|
+
const mm = await buildMultimodalMessagesArray(multimodalOptions, this.providerName, this.modelName);
|
|
147
|
+
// Convert multimodal messages to Vercel AI SDK format (CoreMessage[])
|
|
148
|
+
messages = convertToCoreMessages(mm);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
logger.debug(`LiteLLM: Text-only input, using standard message builder`);
|
|
152
|
+
messages = await buildMessagesArray(options);
|
|
153
|
+
}
|
|
125
154
|
const model = await this.getAISDKModelWithMiddleware(options); // This is where network connection happens!
|
|
126
155
|
const result = streamText({
|
|
127
156
|
model: model,
|
|
128
157
|
messages: messages,
|
|
129
158
|
temperature: options.temperature,
|
|
130
159
|
maxTokens: options.maxTokens, // No default limit - unlimited unless specified
|
|
160
|
+
maxSteps: options.maxSteps || DEFAULT_MAX_STEPS,
|
|
131
161
|
tools: options.tools,
|
|
132
162
|
toolChoice: "auto",
|
|
133
163
|
abortSignal: timeoutController?.controller.signal,
|
|
@@ -271,3 +301,4 @@ export class LiteLLMProvider extends BaseProvider {
|
|
|
271
301
|
}
|
|
272
302
|
}
|
|
273
303
|
}
|
|
304
|
+
//# sourceMappingURL=litellm.js.map
|
|
@@ -6,7 +6,8 @@ import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
|
6
6
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
7
7
|
import { validateApiKey, createMistralConfig, getProviderModel, } from "../utils/providerConfig.js";
|
|
8
8
|
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
9
|
-
import { buildMessagesArray } from "../utils/messageBuilder.js";
|
|
9
|
+
import { buildMessagesArray, buildMultimodalMessagesArray, convertToCoreMessages, } from "../utils/messageBuilder.js";
|
|
10
|
+
import { buildMultimodalOptions } from "../utils/multimodalOptionsBuilder.js";
|
|
10
11
|
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
11
12
|
// Configuration helpers - now using consolidated utility
|
|
12
13
|
const getMistralApiKey = () => {
|
|
@@ -49,7 +50,35 @@ export class MistralProvider extends BaseProvider {
|
|
|
49
50
|
// Get tools consistently with generate method
|
|
50
51
|
const shouldUseTools = !options.disableTools && this.supportsTools();
|
|
51
52
|
const tools = shouldUseTools ? await this.getAllTools() : {};
|
|
52
|
-
|
|
53
|
+
// Check for multimodal input (images, PDFs, CSVs, files)
|
|
54
|
+
const hasMultimodalInput = !!(options.input?.images?.length ||
|
|
55
|
+
options.input?.content?.length ||
|
|
56
|
+
options.input?.files?.length ||
|
|
57
|
+
options.input?.csvFiles?.length ||
|
|
58
|
+
options.input?.pdfFiles?.length);
|
|
59
|
+
let messages;
|
|
60
|
+
if (hasMultimodalInput) {
|
|
61
|
+
logger.debug(`Mistral: Detected multimodal input, using multimodal message builder`, {
|
|
62
|
+
hasImages: !!options.input?.images?.length,
|
|
63
|
+
imageCount: options.input?.images?.length || 0,
|
|
64
|
+
hasContent: !!options.input?.content?.length,
|
|
65
|
+
contentCount: options.input?.content?.length || 0,
|
|
66
|
+
hasFiles: !!options.input?.files?.length,
|
|
67
|
+
fileCount: options.input?.files?.length || 0,
|
|
68
|
+
hasCSVFiles: !!options.input?.csvFiles?.length,
|
|
69
|
+
csvFileCount: options.input?.csvFiles?.length || 0,
|
|
70
|
+
hasPDFFiles: !!options.input?.pdfFiles?.length,
|
|
71
|
+
pdfFileCount: options.input?.pdfFiles?.length || 0,
|
|
72
|
+
});
|
|
73
|
+
const multimodalOptions = buildMultimodalOptions(options, this.providerName, this.modelName);
|
|
74
|
+
const mm = await buildMultimodalMessagesArray(multimodalOptions, this.providerName, this.modelName);
|
|
75
|
+
// Convert multimodal messages to Vercel AI SDK format (CoreMessage[])
|
|
76
|
+
messages = convertToCoreMessages(mm);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
logger.debug(`Mistral: Text-only input, using standard message builder`);
|
|
80
|
+
messages = await buildMessagesArray(options);
|
|
81
|
+
}
|
|
53
82
|
const model = await this.getAISDKModelWithMiddleware(options); // This is where network connection happens!
|
|
54
83
|
const result = await streamText({
|
|
55
84
|
model,
|
|
@@ -149,3 +178,4 @@ export class MistralProvider extends BaseProvider {
|
|
|
149
178
|
}
|
|
150
179
|
}
|
|
151
180
|
export default MistralProvider;
|
|
181
|
+
//# sourceMappingURL=mistral.js.map
|
|
@@ -47,10 +47,20 @@ export declare class OllamaProvider extends BaseProvider {
|
|
|
47
47
|
* @returns true for supported models, false for unsupported models
|
|
48
48
|
*/
|
|
49
49
|
supportsTools(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Extract images from multimodal messages for Ollama API
|
|
52
|
+
* Returns array of base64-encoded images
|
|
53
|
+
*/
|
|
54
|
+
private extractImagesFromMessages;
|
|
55
|
+
/**
|
|
56
|
+
* Convert multimodal messages to Ollama chat format
|
|
57
|
+
* Extracts text content and handles images separately
|
|
58
|
+
*/
|
|
59
|
+
private convertToOllamaMessages;
|
|
50
60
|
protected executeStream(options: StreamOptions, analysisSchema?: ZodUnknownSchema | Schema<unknown>): Promise<StreamResult>;
|
|
51
61
|
/**
|
|
52
62
|
* Execute streaming with Ollama's function calling support
|
|
53
|
-
* Uses
|
|
63
|
+
* Uses conversation loop to handle multi-step tool execution
|
|
54
64
|
*/
|
|
55
65
|
private executeStreamWithTools;
|
|
56
66
|
/**
|
|
@@ -62,6 +72,15 @@ export declare class OllamaProvider extends BaseProvider {
|
|
|
62
72
|
* Convert AI SDK tools format to Ollama's function calling format
|
|
63
73
|
*/
|
|
64
74
|
private convertToolsToOllamaFormat;
|
|
75
|
+
/**
|
|
76
|
+
* Parse tool calls from Ollama API response
|
|
77
|
+
*/
|
|
78
|
+
private parseToolCalls;
|
|
79
|
+
/**
|
|
80
|
+
* Process Ollama streaming response and stream content to controller
|
|
81
|
+
* Returns aggregated content, tool calls, and finish reason
|
|
82
|
+
*/
|
|
83
|
+
private processOllamaResponse;
|
|
65
84
|
/**
|
|
66
85
|
* Process individual stream data chunk from Ollama
|
|
67
86
|
*/
|
|
@@ -74,6 +93,23 @@ export declare class OllamaProvider extends BaseProvider {
|
|
|
74
93
|
* Format tool calls for display when tools aren't executed directly
|
|
75
94
|
*/
|
|
76
95
|
private formatToolCallForDisplay;
|
|
96
|
+
/**
|
|
97
|
+
* Convert AI SDK tools to ToolDefinition format
|
|
98
|
+
*/
|
|
99
|
+
private convertAISDKToolsToToolDefinitions;
|
|
100
|
+
/**
|
|
101
|
+
* Execute a single tool and return the result
|
|
102
|
+
*/
|
|
103
|
+
private executeSingleTool;
|
|
104
|
+
/**
|
|
105
|
+
* Execute tools and format results for Ollama API
|
|
106
|
+
* Similar to Bedrock's executeStreamTools but for Ollama format
|
|
107
|
+
*/
|
|
108
|
+
private executeOllamaTools;
|
|
109
|
+
/**
|
|
110
|
+
* Convert ReadableStream to AsyncIterable for compatibility with StreamResult interface
|
|
111
|
+
*/
|
|
112
|
+
private convertToAsyncIterable;
|
|
77
113
|
/**
|
|
78
114
|
* Create stream generator for Ollama generate API (non-tool mode)
|
|
79
115
|
*/
|