@juspay/neurolink 9.65.1 → 9.66.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 +8 -0
- package/dist/adapters/video/videoAnalyzer.d.ts +1 -1
- package/dist/agent/directTools.d.ts +9 -17
- package/dist/agent/directTools.js +1 -5
- package/dist/autoresearch/tools.d.ts +2 -214
- package/dist/autoresearch/tools.js +1 -1
- package/dist/browser/neurolink.min.js +388 -386
- package/dist/cli/commands/proxy.js +154 -5
- package/dist/client/reactHooks.js +16 -8
- package/dist/client/reactHooks.tsx +24 -9
- package/dist/core/baseProvider.d.ts +1 -6
- package/dist/core/baseProvider.js +1 -1
- package/dist/core/modules/GenerationHandler.d.ts +2 -2
- package/dist/core/modules/GenerationHandler.js +3 -1
- package/dist/core/modules/MessageBuilder.d.ts +1 -15
- package/dist/core/modules/MessageBuilder.js +0 -14
- package/dist/core/modules/StreamHandler.js +1 -1
- package/dist/core/modules/ToolsManager.d.ts +1 -17
- package/dist/core/modules/ToolsManager.js +1 -17
- package/dist/core/streamAnalytics.js +1 -1
- package/dist/evaluation/contextBuilder.d.ts +1 -4
- package/dist/evaluation/contextBuilder.js +0 -3
- package/dist/evaluation/index.d.ts +1 -4
- package/dist/evaluation/index.js +0 -3
- package/dist/files/fileTools.d.ts +2 -18
- package/dist/files/fileTools.js +3 -19
- package/dist/lib/adapters/video/videoAnalyzer.d.ts +1 -1
- package/dist/lib/agent/directTools.d.ts +9 -17
- package/dist/lib/agent/directTools.js +1 -5
- package/dist/lib/autoresearch/tools.d.ts +2 -214
- package/dist/lib/autoresearch/tools.js +1 -1
- package/dist/lib/client/reactHooks.js +16 -8
- package/dist/lib/core/baseProvider.d.ts +1 -6
- package/dist/lib/core/baseProvider.js +1 -1
- package/dist/lib/core/modules/GenerationHandler.d.ts +2 -2
- package/dist/lib/core/modules/GenerationHandler.js +3 -1
- package/dist/lib/core/modules/MessageBuilder.d.ts +1 -15
- package/dist/lib/core/modules/MessageBuilder.js +0 -14
- package/dist/lib/core/modules/StreamHandler.js +1 -1
- package/dist/lib/core/modules/ToolsManager.d.ts +1 -17
- package/dist/lib/core/modules/ToolsManager.js +1 -17
- package/dist/lib/core/streamAnalytics.js +1 -1
- package/dist/lib/evaluation/contextBuilder.d.ts +1 -4
- package/dist/lib/evaluation/contextBuilder.js +0 -3
- package/dist/lib/evaluation/index.d.ts +1 -4
- package/dist/lib/evaluation/index.js +0 -3
- package/dist/lib/files/fileTools.d.ts +2 -18
- package/dist/lib/files/fileTools.js +3 -19
- package/dist/lib/memory/memoryRetrievalTools.d.ts +2 -126
- package/dist/lib/memory/memoryRetrievalTools.js +1 -9
- package/dist/lib/middleware/builtin/autoEvaluation.d.ts +0 -3
- package/dist/lib/middleware/builtin/autoEvaluation.js +0 -3
- package/dist/lib/middleware/builtin/guardrails.js +1 -1
- package/dist/lib/middleware/builtin/lifecycle.d.ts +0 -9
- package/dist/lib/middleware/builtin/lifecycle.js +0 -9
- package/dist/lib/middleware/factory.d.ts +1 -1
- package/dist/lib/middleware/factory.js +1 -1
- package/dist/lib/middleware/registry.d.ts +1 -1
- package/dist/lib/neurolink.d.ts +14 -2
- package/dist/lib/neurolink.js +46 -18
- package/dist/lib/processors/media/AudioProcessor.js +8 -3
- package/dist/lib/providers/amazonBedrock.js +1 -2
- package/dist/lib/providers/amazonSagemaker.d.ts +1 -7
- package/dist/lib/providers/amazonSagemaker.js +0 -6
- package/dist/lib/providers/anthropic.d.ts +1 -1
- package/dist/lib/providers/anthropic.js +2 -1
- package/dist/lib/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/lib/providers/anthropicBaseProvider.js +2 -1
- package/dist/lib/providers/azureOpenai.d.ts +1 -1
- package/dist/lib/providers/azureOpenai.js +2 -1
- package/dist/lib/providers/cloudflare.d.ts +1 -1
- package/dist/lib/providers/cloudflare.js +2 -1
- package/dist/lib/providers/cohere.d.ts +1 -1
- package/dist/lib/providers/cohere.js +2 -1
- package/dist/lib/providers/deepseek.d.ts +1 -1
- package/dist/lib/providers/deepseek.js +2 -1
- package/dist/lib/providers/fireworks.d.ts +1 -1
- package/dist/lib/providers/fireworks.js +2 -1
- package/dist/lib/providers/googleAiStudio.d.ts +1 -1
- package/dist/lib/providers/googleAiStudio.js +0 -1
- package/dist/lib/providers/googleNativeGemini3.d.ts +1 -1
- package/dist/lib/providers/googleNativeGemini3.js +1 -1
- package/dist/lib/providers/googleVertex.d.ts +1 -1
- package/dist/lib/providers/googleVertex.js +0 -1
- package/dist/lib/providers/groq.d.ts +1 -1
- package/dist/lib/providers/groq.js +2 -1
- package/dist/lib/providers/huggingFace.d.ts +1 -1
- package/dist/lib/providers/huggingFace.js +3 -1
- package/dist/lib/providers/ideogram.d.ts +1 -1
- package/dist/lib/providers/jina.d.ts +1 -1
- package/dist/lib/providers/litellm.d.ts +1 -1
- package/dist/lib/providers/litellm.js +12 -6
- package/dist/lib/providers/llamaCpp.d.ts +1 -1
- package/dist/lib/providers/llamaCpp.js +2 -1
- package/dist/lib/providers/lmStudio.d.ts +1 -1
- package/dist/lib/providers/lmStudio.js +2 -1
- package/dist/lib/providers/mistral.d.ts +1 -1
- package/dist/lib/providers/mistral.js +2 -1
- package/dist/lib/providers/nvidiaNim.d.ts +1 -1
- package/dist/lib/providers/nvidiaNim.js +2 -1
- package/dist/lib/providers/ollama.d.ts +1 -1
- package/dist/lib/providers/ollama.js +1 -2
- package/dist/lib/providers/openAI.d.ts +1 -1
- package/dist/lib/providers/openAI.js +3 -1
- package/dist/lib/providers/openRouter.d.ts +1 -1
- package/dist/lib/providers/openRouter.js +3 -1
- package/dist/lib/providers/openaiCompatible.d.ts +1 -1
- package/dist/lib/providers/openaiCompatible.js +3 -1
- package/dist/lib/providers/perplexity.d.ts +1 -1
- package/dist/lib/providers/perplexity.js +2 -1
- package/dist/lib/providers/providerTypeUtils.d.ts +2 -7
- package/dist/lib/providers/providerTypeUtils.js +0 -6
- package/dist/lib/providers/recraft.d.ts +1 -1
- package/dist/lib/providers/replicate.d.ts +1 -1
- package/dist/lib/providers/stability.d.ts +1 -1
- package/dist/lib/providers/togetherAi.d.ts +1 -1
- package/dist/lib/providers/togetherAi.js +2 -1
- package/dist/lib/providers/voyage.d.ts +1 -1
- package/dist/lib/providers/xai.d.ts +1 -1
- package/dist/lib/providers/xai.js +2 -1
- package/dist/lib/proxy/claudeFormat.d.ts +0 -15
- package/dist/lib/proxy/claudeFormat.js +1 -11
- package/dist/lib/proxy/modelRouter.d.ts +5 -1
- package/dist/lib/proxy/modelRouter.js +8 -0
- package/dist/lib/proxy/openaiFormat.d.ts +137 -0
- package/dist/lib/proxy/openaiFormat.js +801 -0
- package/dist/lib/proxy/proxyTranslationEngine.d.ts +124 -0
- package/dist/lib/proxy/proxyTranslationEngine.js +679 -0
- package/dist/lib/rag/ragIntegration.d.ts +1 -12
- package/dist/lib/rag/ragIntegration.js +0 -8
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +6 -5
- package/dist/lib/server/routes/claudeProxyRoutes.js +22 -355
- package/dist/lib/server/routes/index.d.ts +1 -0
- package/dist/lib/server/routes/index.js +10 -2
- package/dist/lib/server/routes/openaiProxyRoutes.d.ts +30 -0
- package/dist/lib/server/routes/openaiProxyRoutes.js +337 -0
- package/dist/lib/tasks/tools/taskTools.d.ts +2 -117
- package/dist/lib/tasks/tools/taskTools.js +1 -10
- package/dist/lib/types/aliases.d.ts +1 -1
- package/dist/lib/types/conversation.d.ts +1 -0
- package/dist/lib/types/evaluation.d.ts +1 -5
- package/dist/lib/types/evaluation.js +0 -4
- package/dist/lib/types/generate.d.ts +2 -22
- package/dist/lib/types/guardrails.d.ts +1 -1
- package/dist/lib/types/middleware.d.ts +8 -3
- package/dist/lib/types/providers.d.ts +2 -1
- package/dist/lib/types/proxy.d.ts +179 -0
- package/dist/lib/types/rag.d.ts +1 -1
- package/dist/lib/types/rag.js +0 -6
- package/dist/lib/types/server.d.ts +3 -0
- package/dist/lib/types/stream.d.ts +2 -11
- package/dist/lib/types/tools.d.ts +2 -1
- package/dist/lib/utils/generation.d.ts +8 -0
- package/dist/lib/utils/generation.js +9 -0
- package/dist/lib/utils/generationErrors.d.ts +10 -0
- package/dist/lib/utils/generationErrors.js +11 -0
- package/dist/lib/utils/messageBuilder.d.ts +1 -6
- package/dist/lib/utils/messageBuilder.js +0 -5
- package/dist/lib/utils/noOutputSentinel.d.ts +0 -13
- package/dist/lib/utils/noOutputSentinel.js +1 -14
- package/dist/lib/utils/providerRetry.js +1 -1
- package/dist/lib/utils/tool.d.ts +8 -0
- package/dist/lib/utils/tool.js +9 -0
- package/dist/lib/utils/toolCallRepair.d.ts +1 -16
- package/dist/lib/utils/toolCallRepair.js +1 -16
- package/dist/lib/utils/toolChoice.d.ts +1 -1
- package/dist/lib/utils/videoAnalysisProcessor.d.ts +1 -8
- package/dist/lib/utils/videoAnalysisProcessor.js +0 -7
- package/dist/memory/memoryRetrievalTools.d.ts +2 -126
- package/dist/memory/memoryRetrievalTools.js +1 -9
- package/dist/middleware/builtin/autoEvaluation.d.ts +0 -3
- package/dist/middleware/builtin/autoEvaluation.js +0 -3
- package/dist/middleware/builtin/guardrails.js +1 -1
- package/dist/middleware/builtin/lifecycle.d.ts +0 -9
- package/dist/middleware/builtin/lifecycle.js +0 -9
- package/dist/middleware/factory.d.ts +1 -1
- package/dist/middleware/factory.js +1 -1
- package/dist/middleware/registry.d.ts +1 -1
- package/dist/neurolink.d.ts +14 -2
- package/dist/neurolink.js +46 -18
- package/dist/processors/media/AudioProcessor.js +8 -3
- package/dist/providers/amazonBedrock.js +1 -2
- package/dist/providers/amazonSagemaker.d.ts +1 -7
- package/dist/providers/amazonSagemaker.js +0 -6
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +2 -1
- package/dist/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/providers/anthropicBaseProvider.js +2 -1
- package/dist/providers/azureOpenai.d.ts +1 -1
- package/dist/providers/azureOpenai.js +2 -1
- package/dist/providers/cloudflare.d.ts +1 -1
- package/dist/providers/cloudflare.js +2 -1
- package/dist/providers/cohere.d.ts +1 -1
- package/dist/providers/cohere.js +2 -1
- package/dist/providers/deepseek.d.ts +1 -1
- package/dist/providers/deepseek.js +2 -1
- package/dist/providers/fireworks.d.ts +1 -1
- package/dist/providers/fireworks.js +2 -1
- package/dist/providers/googleAiStudio.d.ts +1 -1
- package/dist/providers/googleNativeGemini3.d.ts +1 -1
- package/dist/providers/googleNativeGemini3.js +1 -1
- package/dist/providers/googleVertex.d.ts +1 -1
- package/dist/providers/groq.d.ts +1 -1
- package/dist/providers/groq.js +2 -1
- package/dist/providers/huggingFace.d.ts +1 -1
- package/dist/providers/huggingFace.js +3 -1
- package/dist/providers/ideogram.d.ts +1 -1
- package/dist/providers/jina.d.ts +1 -1
- package/dist/providers/litellm.d.ts +1 -1
- package/dist/providers/litellm.js +12 -6
- package/dist/providers/llamaCpp.d.ts +1 -1
- package/dist/providers/llamaCpp.js +2 -1
- package/dist/providers/lmStudio.d.ts +1 -1
- package/dist/providers/lmStudio.js +2 -1
- package/dist/providers/mistral.d.ts +1 -1
- package/dist/providers/mistral.js +2 -1
- package/dist/providers/nvidiaNim.d.ts +1 -1
- package/dist/providers/nvidiaNim.js +2 -1
- package/dist/providers/ollama.d.ts +1 -1
- package/dist/providers/ollama.js +1 -2
- package/dist/providers/openAI.d.ts +1 -1
- package/dist/providers/openAI.js +3 -1
- package/dist/providers/openRouter.d.ts +1 -1
- package/dist/providers/openRouter.js +3 -1
- package/dist/providers/openaiCompatible.d.ts +1 -1
- package/dist/providers/openaiCompatible.js +3 -1
- package/dist/providers/perplexity.d.ts +1 -1
- package/dist/providers/perplexity.js +2 -1
- package/dist/providers/providerTypeUtils.d.ts +2 -7
- package/dist/providers/providerTypeUtils.js +0 -6
- package/dist/providers/recraft.d.ts +1 -1
- package/dist/providers/replicate.d.ts +1 -1
- package/dist/providers/stability.d.ts +1 -1
- package/dist/providers/togetherAi.d.ts +1 -1
- package/dist/providers/togetherAi.js +2 -1
- package/dist/providers/voyage.d.ts +1 -1
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/xai.js +2 -1
- package/dist/proxy/claudeFormat.d.ts +0 -15
- package/dist/proxy/claudeFormat.js +1 -11
- package/dist/proxy/modelRouter.d.ts +5 -1
- package/dist/proxy/modelRouter.js +8 -0
- package/dist/proxy/openaiFormat.d.ts +137 -0
- package/dist/proxy/openaiFormat.js +800 -0
- package/dist/proxy/proxyTranslationEngine.d.ts +124 -0
- package/dist/proxy/proxyTranslationEngine.js +678 -0
- package/dist/rag/ragIntegration.d.ts +1 -12
- package/dist/rag/ragIntegration.js +0 -8
- package/dist/server/routes/claudeProxyRoutes.d.ts +6 -5
- package/dist/server/routes/claudeProxyRoutes.js +22 -355
- package/dist/server/routes/index.d.ts +1 -0
- package/dist/server/routes/index.js +10 -2
- package/dist/server/routes/openaiProxyRoutes.d.ts +30 -0
- package/dist/server/routes/openaiProxyRoutes.js +336 -0
- package/dist/tasks/tools/taskTools.d.ts +2 -117
- package/dist/tasks/tools/taskTools.js +1 -10
- package/dist/types/aliases.d.ts +1 -1
- package/dist/types/conversation.d.ts +1 -0
- package/dist/types/evaluation.d.ts +1 -5
- package/dist/types/evaluation.js +0 -4
- package/dist/types/generate.d.ts +2 -22
- package/dist/types/guardrails.d.ts +1 -1
- package/dist/types/middleware.d.ts +8 -3
- package/dist/types/providers.d.ts +2 -1
- package/dist/types/proxy.d.ts +179 -0
- package/dist/types/rag.d.ts +1 -1
- package/dist/types/rag.js +0 -6
- package/dist/types/server.d.ts +3 -0
- package/dist/types/stream.d.ts +2 -11
- package/dist/types/tools.d.ts +2 -1
- package/dist/utils/generation.d.ts +8 -0
- package/dist/utils/generation.js +8 -0
- package/dist/utils/generationErrors.d.ts +10 -0
- package/dist/utils/generationErrors.js +10 -0
- package/dist/utils/messageBuilder.d.ts +1 -6
- package/dist/utils/messageBuilder.js +0 -5
- package/dist/utils/noOutputSentinel.d.ts +0 -13
- package/dist/utils/noOutputSentinel.js +1 -14
- package/dist/utils/providerRetry.js +1 -1
- package/dist/utils/tool.d.ts +8 -0
- package/dist/utils/tool.js +8 -0
- package/dist/utils/toolCallRepair.d.ts +1 -16
- package/dist/utils/toolCallRepair.js +1 -16
- package/dist/utils/toolChoice.d.ts +1 -1
- package/dist/utils/videoAnalysisProcessor.d.ts +1 -8
- package/dist/utils/videoAnalysisProcessor.js +0 -7
- package/package.json +2 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* DeepSeek Provider
|
|
7
7
|
* OpenAI-compatible chat completions; supports deepseek-chat (V3) and
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { DeepSeekModels } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
14
13
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
16
15
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
17
18
|
const makeLoggingFetch = (provider) => {
|
|
18
19
|
const base = createProxyFetch();
|
|
19
20
|
return (async (input, init) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Fireworks AI Provider
|
|
7
7
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { FireworksModels } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
14
13
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
16
15
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
17
18
|
const FIREWORKS_DEFAULT_BASE_URL = "https://api.fireworks.ai/inference/v1";
|
|
18
19
|
const getFireworksApiKey = () => validateApiKey(createFireworksConfig());
|
|
19
20
|
const getDefaultFireworksModel = () => getProviderModel("FIREWORKS_MODEL", FireworksModels.DEEPSEEK_V4_PRO);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel, type Schema } from "ai";
|
|
2
1
|
import { type AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { ZodUnknownSchema, EnhancedGenerateResult, TextGenerationOptions, StreamOptions, StreamResult } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel, Schema } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Google AI Studio provider implementation using BaseProvider
|
|
7
7
|
* Migrated from original GoogleAIStudio class to new factory pattern
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* This module extracts the functions that are duplicated between the two
|
|
9
9
|
* providers so they can share a single implementation.
|
|
10
10
|
*/
|
|
11
|
-
import { type Tool } from "ai";
|
|
12
11
|
import type { ThinkingConfig, ChatMessage, CollectedChunkResult, MinimalChatMessage, NativeFunctionCall, NativeFunctionResponse, NativeToolDeclarationsResult, NativeToolsConfig, TextChannel, VertexNativePart, GeminiMultimodalInput } from "../types/index.js";
|
|
12
|
+
import type { Tool } from "../types/index.js";
|
|
13
13
|
export declare function sanitizeForGoogleFunctionName(name: string): string;
|
|
14
14
|
/**
|
|
15
15
|
* Resolve a sanitized Gemini tool name to one that is both unique within
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
import { randomUUID } from "node:crypto";
|
|
12
12
|
import { existsSync, readFileSync } from "node:fs";
|
|
13
13
|
import { extname } from "node:path";
|
|
14
|
-
import { jsonSchema as aiJsonSchema, tool as createAISDKTool, } from "ai";
|
|
15
14
|
import { DEFAULT_MAX_STEPS, DEFAULT_TOOL_MAX_RETRIES, } from "../core/constants.js";
|
|
16
15
|
import { logger } from "../utils/logger.js";
|
|
17
16
|
import { convertZodToJsonSchema, ensureNestedSchemaTypes, inlineJsonSchema, isZodSchema, normalizeJsonSchemaObject, } from "../utils/schemaConversion.js";
|
|
18
17
|
import { createNativeThinkingConfig } from "../utils/thinkingConfig.js";
|
|
18
|
+
import { jsonSchema as aiJsonSchema, tool as createAISDKTool, } from "../utils/tool.js";
|
|
19
19
|
// ── Functions ──
|
|
20
20
|
/**
|
|
21
21
|
* Google's `function_declarations[].name` validator regex.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ZodType } from "zod";
|
|
2
|
-
import { type Schema, type LanguageModel } from "ai";
|
|
3
2
|
import { AIProviderName } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import type { EnhancedGenerateResult, TextGenerationOptions, StreamOptions, StreamResult } from "../types/index.js";
|
|
5
|
+
import type { Schema, LanguageModel } from "../types/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* Resolve the effective Vertex region for a given model.
|
|
8
8
|
*
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import os from "os";
|
|
6
|
-
import {} from "ai";
|
|
7
6
|
import { AIProviderName, ErrorCategory, ErrorSeverity, } from "../constants/enums.js";
|
|
8
7
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
9
8
|
import { DEFAULT_MAX_STEPS, DEFAULT_TOOL_MAX_RETRIES, GLOBAL_LOCATION_MODELS, IMAGE_GENERATION_MODELS, TOOL_STORAGE_TIMEOUT_MS, } from "../core/constants.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Groq Provider
|
|
7
7
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { GroqModels } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
14
13
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
16
15
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
17
18
|
const GROQ_DEFAULT_BASE_URL = "https://api.groq.com/openai/v1";
|
|
18
19
|
const getGroqApiKey = () => validateApiKey(createGroqConfig());
|
|
19
20
|
const getDefaultGroqModel = () => getProviderModel("GROQ_MODEL", GroqModels.LLAMA_3_3_70B_VERSATILE);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type LanguageModel, type Schema } from "ai";
|
|
2
1
|
import type { ZodType } from "zod";
|
|
3
2
|
import type { AIProviderName } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import type { NeurolinkCredentials, StreamOptions, StreamResult } from "../types/index.js";
|
|
5
|
+
import type { LanguageModel, Schema } from "../types/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* HuggingFace Provider - BaseProvider Implementation
|
|
8
8
|
* Using AI SDK with HuggingFace's OpenAI-compatible endpoint
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { NoOutputGeneratedError, stepCountIs, streamText, } from "ai";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
5
4
|
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
@@ -10,6 +9,9 @@ import { buildNoOutputSentinel, detectPostStreamNoOutput, stampNoOutputSpan, } f
|
|
|
10
9
|
import { createHuggingFaceConfig, getProviderModel, validateApiKey, } from "../utils/providerConfig.js";
|
|
11
10
|
import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
|
|
12
11
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
12
|
+
import { NoOutputGeneratedError } from "../utils/generationErrors.js";
|
|
13
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
14
|
+
import { streamText } from "../utils/generation.js";
|
|
13
15
|
// Configuration helpers - now using consolidated utility
|
|
14
16
|
const getHuggingFaceApiKey = () => {
|
|
15
17
|
return validateApiKey(createHuggingFaceConfig());
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { EnhancedGenerateResult, NeurolinkCredentials, StreamOptions, StreamResult, TextGenerationOptions, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Ideogram Provider — direct image generation with strong typography.
|
|
7
7
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Jina AI Provider — embeddings + reranking.
|
|
7
7
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type LanguageModel, type Schema } from "ai";
|
|
2
1
|
import type { ZodType } from "zod";
|
|
3
2
|
import type { AIProviderName } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import type { StreamOptions, StreamResult } from "../types/index.js";
|
|
5
|
+
import type { LanguageModel, Schema } from "../types/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* LiteLLM Provider - BaseProvider Implementation
|
|
8
8
|
* Provides access to 100+ models via LiteLLM proxy server
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
2
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
3
|
-
import { NoOutputGeneratedError, Output, stepCountIs, streamText, } from "ai";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
6
5
|
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
@@ -12,9 +11,12 @@ import { logger } from "../utils/logger.js";
|
|
|
12
11
|
import { buildNoOutputSentinel, detectPostStreamNoOutput, stampNoOutputSpan, } from "../utils/noOutputSentinel.js";
|
|
13
12
|
import { calculateCost } from "../utils/pricing.js";
|
|
14
13
|
import { getProviderModel } from "../utils/providerConfig.js";
|
|
15
|
-
import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
|
|
14
|
+
import { composeAbortSignals, createTimeoutController, TimeoutError, withTimeout, } from "../utils/timeout.js";
|
|
16
15
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
17
16
|
import { getModelId } from "./providerTypeUtils.js";
|
|
17
|
+
import { NoOutputGeneratedError } from "../utils/generationErrors.js";
|
|
18
|
+
import { Output, stepCountIs } from "../utils/tool.js";
|
|
19
|
+
import { streamText } from "../utils/generation.js";
|
|
18
20
|
const streamTracer = trace.getTracer("neurolink.provider.litellm");
|
|
19
21
|
// Configuration helpers
|
|
20
22
|
const getLiteLLMConfig = () => {
|
|
@@ -425,7 +427,7 @@ export class LiteLLMProvider extends BaseProvider {
|
|
|
425
427
|
* Uses the LiteLLM proxy with OpenAI-compatible embedding API
|
|
426
428
|
*/
|
|
427
429
|
async embed(text, modelName) {
|
|
428
|
-
const { embed: aiEmbed } = await import("
|
|
430
|
+
const { embed: aiEmbed } = await import("../utils/generation.js");
|
|
429
431
|
const { createOpenAI } = await import("@ai-sdk/openai");
|
|
430
432
|
const config = getLiteLLMConfig();
|
|
431
433
|
const embeddingModelName = modelName ||
|
|
@@ -437,7 +439,10 @@ export class LiteLLMProvider extends BaseProvider {
|
|
|
437
439
|
fetch: createProxyFetch(),
|
|
438
440
|
});
|
|
439
441
|
const embeddingModel = customOpenAI.textEmbeddingModel(embeddingModelName);
|
|
440
|
-
|
|
442
|
+
// Wrap in withTimeout so stalled upstream embedding requests abort instead
|
|
443
|
+
// of hanging forever. 30s matches the default for embedding endpoints
|
|
444
|
+
// across the OpenAI-compatible cluster.
|
|
445
|
+
const result = await withTimeout(aiEmbed({ model: embeddingModel, value: text }), 30_000, "litellm", "generate");
|
|
441
446
|
return result.embedding;
|
|
442
447
|
}
|
|
443
448
|
/**
|
|
@@ -445,7 +450,7 @@ export class LiteLLMProvider extends BaseProvider {
|
|
|
445
450
|
* Uses the LiteLLM proxy with OpenAI-compatible embedding API
|
|
446
451
|
*/
|
|
447
452
|
async embedMany(texts, modelName) {
|
|
448
|
-
const { embedMany: aiEmbedMany } = await import("
|
|
453
|
+
const { embedMany: aiEmbedMany } = await import("../utils/generation.js");
|
|
449
454
|
const { createOpenAI } = await import("@ai-sdk/openai");
|
|
450
455
|
const config = getLiteLLMConfig();
|
|
451
456
|
const embeddingModelName = modelName ||
|
|
@@ -457,7 +462,8 @@ export class LiteLLMProvider extends BaseProvider {
|
|
|
457
462
|
fetch: createProxyFetch(),
|
|
458
463
|
});
|
|
459
464
|
const embeddingModel = customOpenAI.textEmbeddingModel(embeddingModelName);
|
|
460
|
-
|
|
465
|
+
// Wrap in withTimeout so a single slow batch doesn't hang indefinitely.
|
|
466
|
+
const result = await withTimeout(aiEmbedMany({ model: embeddingModel, values: texts }), 30_000, "litellm", "generate");
|
|
461
467
|
return result.embeddings;
|
|
462
468
|
}
|
|
463
469
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* llama.cpp Provider
|
|
7
7
|
* Wraps a llama-server process (https://github.com/ggerganov/llama.cpp) that
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
5
4
|
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
@@ -13,6 +12,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
13
12
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
14
13
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
15
14
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
15
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
16
|
+
import { streamText } from "../utils/generation.js";
|
|
16
17
|
const LLAMACPP_DEFAULT_BASE_URL = "http://localhost:8080/v1";
|
|
17
18
|
const LLAMACPP_PLACEHOLDER_KEY = "llamacpp";
|
|
18
19
|
const FALLBACK_MODEL = "loaded-model";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* LM Studio Provider
|
|
7
7
|
* Wraps the LM Studio local server (https://lmstudio.ai/) which exposes an
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
5
4
|
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
@@ -13,6 +12,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
13
12
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
14
13
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
15
14
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
15
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
16
|
+
import { streamText } from "../utils/generation.js";
|
|
16
17
|
const LM_STUDIO_DEFAULT_BASE_URL = "http://localhost:1234/v1";
|
|
17
18
|
const LM_STUDIO_PLACEHOLDER_KEY = "lm-studio";
|
|
18
19
|
const FALLBACK_MODEL = "local-model";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Mistral AI Provider v2 - BaseProvider Implementation
|
|
7
7
|
* Supports official AI-SDK integration with all Mistral models
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createMistral } from "@ai-sdk/mistral";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
5
4
|
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
@@ -12,6 +11,8 @@ import { createMistralConfig, getProviderModel, validateApiKey, } from "../utils
|
|
|
12
11
|
import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
|
|
13
12
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
14
13
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
14
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
15
|
+
import { streamText } from "../utils/generation.js";
|
|
15
16
|
// Configuration helpers - now using consolidated utility
|
|
16
17
|
const getMistralApiKey = () => {
|
|
17
18
|
return validateApiKey(createMistralConfig());
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* NVIDIA NIM Provider
|
|
7
7
|
* Wraps NVIDIA's hosted (or self-hosted) inference endpoints via OpenAI-compat.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { NvidiaNimModels } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
14
13
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
16
15
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
17
18
|
/**
|
|
18
19
|
* Decide whether a NIM 400 response body is a rejection of the named
|
|
19
20
|
* field (as opposed to an unrelated 400 that happens to mention the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { LanguageModel, Schema } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { StreamOptions, StreamResult, ZodUnknownSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel, Schema } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Ollama Provider v2 - BaseProvider Implementation
|
|
7
7
|
*
|
|
@@ -706,8 +706,7 @@ export class OllamaProvider extends BaseProvider {
|
|
|
706
706
|
let iteration = 0;
|
|
707
707
|
// Get all available tools (direct + MCP + external)
|
|
708
708
|
// BaseProvider.stream() pre-merges base tools + external tools into options.tools
|
|
709
|
-
const allTools = options.tools ||
|
|
710
|
-
(await this.getAllTools());
|
|
709
|
+
const allTools = options.tools || (await this.getAllTools());
|
|
711
710
|
// Convert tools to Ollama format
|
|
712
711
|
const ollamaTools = this.convertToolsToOllamaFormat(allTools);
|
|
713
712
|
span.setAttribute(ATTR.NL_TOOL_COUNT, ollamaTools.length);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeuroLink } from "../neurolink.js";
|
|
5
4
|
import type { EnhancedGenerateResult, TextGenerationOptions, ValidationSchema, StreamOptions, StreamResult } from "../types/index.js";
|
|
5
|
+
import type { LanguageModel } from "../types/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* OpenAI Provider v2 - BaseProvider Implementation
|
|
8
8
|
* Migrated to use factory pattern with exact Google AI provider pattern
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
2
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
3
|
-
import { embed, embedMany, NoOutputGeneratedError, stepCountIs, streamText, } from "ai";
|
|
4
3
|
import { AIProviderName } from "../constants/enums.js";
|
|
5
4
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
6
5
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -18,6 +17,9 @@ import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
|
18
17
|
import { MAX_IMAGE_BYTES, readBoundedBuffer } from "../utils/sizeGuard.js";
|
|
19
18
|
import { assertSafeUrl } from "../utils/ssrfGuard.js";
|
|
20
19
|
import { getModelId } from "./providerTypeUtils.js";
|
|
20
|
+
import { NoOutputGeneratedError } from "../utils/generationErrors.js";
|
|
21
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
22
|
+
import { embed, embedMany, streamText } from "../utils/generation.js";
|
|
21
23
|
/**
|
|
22
24
|
* Retrieve a tool's schema, handling both AI SDK v6 (`inputSchema`) and
|
|
23
25
|
* legacy v4 (`parameters`) field names.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type LanguageModel, type Schema } from "ai";
|
|
2
1
|
import type { ZodType } from "zod";
|
|
3
2
|
import { AIProviderName } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import type { StreamOptions, StreamResult } from "../types/index.js";
|
|
5
|
+
import type { LanguageModel, Schema } from "../types/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* OpenRouter Provider - BaseProvider Implementation
|
|
8
8
|
* Provides access to 300+ models from 60+ providers via OpenRouter unified gateway
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
|
|
2
|
-
import { NoOutputGeneratedError, Output, stepCountIs, streamText, } from "ai";
|
|
3
2
|
import { AIProviderName } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -13,6 +12,9 @@ import { buildNoOutputSentinel, detectPostStreamNoOutput, stampNoOutputSpan, } f
|
|
|
13
12
|
import { getProviderModel } from "../utils/providerConfig.js";
|
|
14
13
|
import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
15
|
+
import { NoOutputGeneratedError } from "../utils/generationErrors.js";
|
|
16
|
+
import { Output, stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
16
18
|
// Constants
|
|
17
19
|
const MODELS_DISCOVERY_TIMEOUT_MS = 5000; // 5 seconds for model discovery
|
|
18
20
|
// Configuration helpers
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel, type Schema } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { StreamOptions, StreamResult, ZodUnknownSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel, Schema } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* OpenAI Compatible Provider - BaseProvider Implementation
|
|
7
7
|
* Provides access to one of the OpenAI-compatible endpoint (OpenRouter, vLLM, LiteLLM, etc.)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { NoOutputGeneratedError, stepCountIs, streamText, } from "ai";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
5
4
|
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
@@ -11,6 +10,9 @@ import { buildNoOutputSentinel, detectPostStreamNoOutput, stampNoOutputSpan, } f
|
|
|
11
10
|
import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
|
|
12
11
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
13
12
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
13
|
+
import { NoOutputGeneratedError } from "../utils/generationErrors.js";
|
|
14
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
15
|
+
import { streamText } from "../utils/generation.js";
|
|
14
16
|
// Constants
|
|
15
17
|
const FALLBACK_OPENAI_COMPATIBLE_MODEL = "gpt-3.5-turbo";
|
|
16
18
|
// Configuration helpers
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Perplexity Provider
|
|
7
7
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { PerplexityModels } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
14
13
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
16
15
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
17
18
|
const PERPLEXITY_DEFAULT_BASE_URL = "https://api.perplexity.ai";
|
|
18
19
|
const getPerplexityApiKey = () => validateApiKey(createPerplexityConfig());
|
|
19
20
|
const getDefaultPerplexityModel = () => getProviderModel("PERPLEXITY_MODEL", PerplexityModels.SONAR);
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared type utilities for AI SDK provider integration.
|
|
3
|
-
*
|
|
4
|
-
* Provides type-safe helpers to bridge between the AI SDK's generic types
|
|
5
|
-
* and NeuroLink's internal type system without resorting to `as any` casts.
|
|
6
|
-
*/
|
|
7
|
-
import type { LanguageModel, streamText } from "ai";
|
|
8
1
|
import type { StreamTextResult } from "../types/index.js";
|
|
2
|
+
import type { LanguageModel } from "../types/index.js";
|
|
3
|
+
import type { streamText } from "../utils/generation.js";
|
|
9
4
|
/**
|
|
10
5
|
* Extract the model identifier from a LanguageModel value.
|
|
11
6
|
*
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared type utilities for AI SDK provider integration.
|
|
3
|
-
*
|
|
4
|
-
* Provides type-safe helpers to bridge between the AI SDK's generic types
|
|
5
|
-
* and NeuroLink's internal type system without resorting to `as any` casts.
|
|
6
|
-
*/
|
|
7
1
|
/**
|
|
8
2
|
* Type guard: checks whether a LanguageModel value is an object with `modelId`
|
|
9
3
|
* (i.e. LanguageModelV2 or LanguageModelV3) rather than a bare string ID.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { EnhancedGenerateResult, NeurolinkCredentials, StreamOptions, StreamResult, TextGenerationOptions, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Recraft Provider — image generation with vector / illustration focus.
|
|
7
7
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { EnhancedGenerateResult, NeurolinkCredentials, StreamOptions, StreamResult, TextGenerationOptions, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Replicate LLM Provider — predict-then-stream pattern.
|
|
7
7
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { EnhancedGenerateResult, NeurolinkCredentials, StreamOptions, StreamResult, TextGenerationOptions, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Stability AI Provider — direct image generation.
|
|
7
7
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Together AI Provider
|
|
7
7
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { TogetherAIModels } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
14
13
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
16
15
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
17
18
|
const TOGETHER_DEFAULT_BASE_URL = "https://api.together.xyz/v1";
|
|
18
19
|
const getTogetherApiKey = () => validateApiKey(createTogetherAIConfig());
|
|
19
20
|
const getDefaultTogetherModel = () => getProviderModel("TOGETHER_MODEL", TogetherAIModels.LLAMA_3_3_70B_INSTRUCT_TURBO);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Voyage AI Provider — embedding-only.
|
|
7
7
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* xAI Grok Provider
|
|
7
7
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { XaiModels } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
14
13
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
16
15
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
17
18
|
/**
|
|
18
19
|
* Logging fetch wrapper — masks the proxy URL on non-2xx responses so
|
|
19
20
|
* stack traces and log lines don't leak the upstream's internal token /
|