@juspay/neurolink 9.1.1 → 9.3.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 +27 -0
- package/README.md +106 -37
- package/dist/agent/directTools.d.ts +11 -11
- package/dist/cli/commands/config.d.ts +6 -6
- package/dist/cli/commands/rag.d.ts +19 -0
- package/dist/cli/commands/rag.js +756 -0
- package/dist/cli/factories/commandFactory.js +146 -83
- package/dist/cli/parser.js +4 -1
- package/dist/core/baseProvider.d.ts +43 -30
- package/dist/core/baseProvider.js +98 -138
- package/dist/core/conversationMemoryFactory.d.ts +2 -2
- package/dist/core/conversationMemoryFactory.js +2 -2
- package/dist/core/conversationMemoryInitializer.d.ts +1 -2
- package/dist/core/conversationMemoryInitializer.js +2 -2
- package/dist/core/infrastructure/baseError.d.ts +21 -0
- package/dist/core/infrastructure/baseError.js +22 -0
- package/dist/core/infrastructure/baseFactory.d.ts +21 -0
- package/dist/core/infrastructure/baseFactory.js +54 -0
- package/dist/core/infrastructure/baseRegistry.d.ts +21 -0
- package/dist/core/infrastructure/baseRegistry.js +49 -0
- package/dist/core/infrastructure/index.d.ts +5 -0
- package/dist/core/infrastructure/index.js +5 -0
- package/dist/core/infrastructure/retry.d.ts +7 -0
- package/dist/core/infrastructure/retry.js +20 -0
- package/dist/core/infrastructure/typedEventEmitter.d.ts +8 -0
- package/dist/core/infrastructure/typedEventEmitter.js +23 -0
- package/dist/core/redisConversationMemoryManager.d.ts +1 -6
- package/dist/core/redisConversationMemoryManager.js +7 -19
- package/dist/factories/providerFactory.d.ts +5 -3
- package/dist/factories/providerFactory.js +31 -24
- package/dist/image-gen/ImageGenService.d.ts +143 -0
- package/dist/image-gen/ImageGenService.js +345 -0
- package/dist/image-gen/imageGenTools.d.ts +126 -0
- package/dist/image-gen/imageGenTools.js +304 -0
- package/dist/image-gen/index.d.ts +46 -0
- package/dist/image-gen/index.js +48 -0
- package/dist/image-gen/types.d.ts +237 -0
- package/dist/image-gen/types.js +24 -0
- package/dist/index.d.ts +46 -12
- package/dist/index.js +88 -36
- package/dist/lib/agent/directTools.d.ts +8 -8
- package/dist/lib/core/baseProvider.d.ts +43 -30
- package/dist/lib/core/baseProvider.js +98 -138
- package/dist/lib/core/conversationMemoryFactory.d.ts +2 -2
- package/dist/lib/core/conversationMemoryFactory.js +2 -2
- package/dist/lib/core/conversationMemoryInitializer.d.ts +1 -2
- package/dist/lib/core/conversationMemoryInitializer.js +2 -2
- package/dist/lib/core/infrastructure/baseError.d.ts +21 -0
- package/dist/lib/core/infrastructure/baseError.js +23 -0
- package/dist/lib/core/infrastructure/baseFactory.d.ts +21 -0
- package/dist/lib/core/infrastructure/baseFactory.js +55 -0
- package/dist/lib/core/infrastructure/baseRegistry.d.ts +21 -0
- package/dist/lib/core/infrastructure/baseRegistry.js +50 -0
- package/dist/lib/core/infrastructure/index.d.ts +5 -0
- package/dist/lib/core/infrastructure/index.js +6 -0
- package/dist/lib/core/infrastructure/retry.d.ts +7 -0
- package/dist/lib/core/infrastructure/retry.js +21 -0
- package/dist/lib/core/infrastructure/typedEventEmitter.d.ts +8 -0
- package/dist/lib/core/infrastructure/typedEventEmitter.js +24 -0
- package/dist/lib/core/redisConversationMemoryManager.d.ts +1 -6
- package/dist/lib/core/redisConversationMemoryManager.js +7 -19
- package/dist/lib/factories/providerFactory.d.ts +5 -3
- package/dist/lib/factories/providerFactory.js +31 -24
- package/dist/lib/image-gen/ImageGenService.d.ts +143 -0
- package/dist/lib/image-gen/ImageGenService.js +346 -0
- package/dist/lib/image-gen/imageGenTools.d.ts +126 -0
- package/dist/lib/image-gen/imageGenTools.js +305 -0
- package/dist/lib/image-gen/index.d.ts +46 -0
- package/dist/lib/image-gen/index.js +49 -0
- package/dist/lib/image-gen/types.d.ts +237 -0
- package/dist/lib/image-gen/types.js +25 -0
- package/dist/lib/index.d.ts +46 -12
- package/dist/lib/index.js +88 -36
- package/dist/lib/mcp/index.d.ts +6 -5
- package/dist/lib/mcp/index.js +7 -5
- package/dist/lib/neurolink.d.ts +11 -13
- package/dist/lib/neurolink.js +95 -29
- package/dist/lib/processors/base/BaseFileProcessor.d.ts +273 -0
- package/dist/lib/processors/base/BaseFileProcessor.js +614 -0
- package/dist/lib/processors/base/index.d.ts +14 -0
- package/dist/lib/processors/base/index.js +20 -0
- package/dist/lib/processors/base/types.d.ts +593 -0
- package/dist/lib/processors/base/types.js +77 -0
- package/dist/lib/processors/cli/fileProcessorCli.d.ts +163 -0
- package/dist/lib/processors/cli/fileProcessorCli.js +389 -0
- package/dist/lib/processors/cli/index.d.ts +37 -0
- package/dist/lib/processors/cli/index.js +50 -0
- package/dist/lib/processors/code/ConfigProcessor.d.ts +171 -0
- package/dist/lib/processors/code/ConfigProcessor.js +401 -0
- package/dist/lib/processors/code/SourceCodeProcessor.d.ts +174 -0
- package/dist/lib/processors/code/SourceCodeProcessor.js +305 -0
- package/dist/lib/processors/code/index.d.ts +44 -0
- package/dist/lib/processors/code/index.js +61 -0
- package/dist/lib/processors/config/fileTypes.d.ts +283 -0
- package/dist/lib/processors/config/fileTypes.js +521 -0
- package/dist/lib/processors/config/index.d.ts +32 -0
- package/dist/lib/processors/config/index.js +93 -0
- package/dist/lib/processors/config/languageMap.d.ts +66 -0
- package/dist/lib/processors/config/languageMap.js +411 -0
- package/dist/lib/processors/config/mimeTypes.d.ts +376 -0
- package/dist/lib/processors/config/mimeTypes.js +339 -0
- package/dist/lib/processors/config/sizeLimits.d.ts +194 -0
- package/dist/lib/processors/config/sizeLimits.js +247 -0
- package/dist/lib/processors/data/JsonProcessor.d.ts +122 -0
- package/dist/lib/processors/data/JsonProcessor.js +204 -0
- package/dist/lib/processors/data/XmlProcessor.d.ts +160 -0
- package/dist/lib/processors/data/XmlProcessor.js +284 -0
- package/dist/lib/processors/data/YamlProcessor.d.ts +163 -0
- package/dist/lib/processors/data/YamlProcessor.js +295 -0
- package/dist/lib/processors/data/index.d.ts +49 -0
- package/dist/lib/processors/data/index.js +77 -0
- package/dist/lib/processors/document/ExcelProcessor.d.ts +238 -0
- package/dist/lib/processors/document/ExcelProcessor.js +520 -0
- package/dist/lib/processors/document/OpenDocumentProcessor.d.ts +69 -0
- package/dist/lib/processors/document/OpenDocumentProcessor.js +211 -0
- package/dist/lib/processors/document/RtfProcessor.d.ts +152 -0
- package/dist/lib/processors/document/RtfProcessor.js +362 -0
- package/dist/lib/processors/document/WordProcessor.d.ts +168 -0
- package/dist/lib/processors/document/WordProcessor.js +354 -0
- package/dist/lib/processors/document/index.d.ts +54 -0
- package/dist/lib/processors/document/index.js +91 -0
- package/dist/lib/processors/errors/FileErrorCode.d.ts +98 -0
- package/dist/lib/processors/errors/FileErrorCode.js +256 -0
- package/dist/lib/processors/errors/errorHelpers.d.ts +151 -0
- package/dist/lib/processors/errors/errorHelpers.js +379 -0
- package/dist/lib/processors/errors/errorSerializer.d.ts +139 -0
- package/dist/lib/processors/errors/errorSerializer.js +508 -0
- package/dist/lib/processors/errors/index.d.ts +46 -0
- package/dist/lib/processors/errors/index.js +50 -0
- package/dist/lib/processors/index.d.ts +76 -0
- package/dist/lib/processors/index.js +113 -0
- package/dist/lib/processors/integration/FileProcessorIntegration.d.ts +244 -0
- package/dist/lib/processors/integration/FileProcessorIntegration.js +273 -0
- package/dist/lib/processors/integration/index.d.ts +42 -0
- package/dist/lib/processors/integration/index.js +45 -0
- package/dist/lib/processors/markup/HtmlProcessor.d.ts +169 -0
- package/dist/lib/processors/markup/HtmlProcessor.js +250 -0
- package/dist/lib/processors/markup/MarkdownProcessor.d.ts +165 -0
- package/dist/lib/processors/markup/MarkdownProcessor.js +245 -0
- package/dist/lib/processors/markup/SvgProcessor.d.ts +156 -0
- package/dist/lib/processors/markup/SvgProcessor.js +241 -0
- package/dist/lib/processors/markup/TextProcessor.d.ts +135 -0
- package/dist/lib/processors/markup/TextProcessor.js +189 -0
- package/dist/lib/processors/markup/index.d.ts +66 -0
- package/dist/lib/processors/markup/index.js +103 -0
- package/dist/lib/processors/registry/ProcessorRegistry.d.ts +334 -0
- package/dist/lib/processors/registry/ProcessorRegistry.js +609 -0
- package/dist/lib/processors/registry/index.d.ts +12 -0
- package/dist/lib/processors/registry/index.js +17 -0
- package/dist/lib/processors/registry/types.d.ts +53 -0
- package/dist/lib/processors/registry/types.js +11 -0
- package/dist/lib/providers/amazonBedrock.d.ts +15 -2
- package/dist/lib/providers/amazonBedrock.js +65 -8
- package/dist/lib/providers/anthropic.d.ts +3 -3
- package/dist/lib/providers/anthropic.js +10 -7
- package/dist/lib/providers/googleAiStudio.d.ts +5 -5
- package/dist/lib/providers/googleAiStudio.js +10 -7
- package/dist/lib/providers/googleVertex.d.ts +16 -4
- package/dist/lib/providers/googleVertex.js +72 -16
- package/dist/lib/providers/litellm.d.ts +3 -3
- package/dist/lib/providers/litellm.js +10 -10
- package/dist/lib/providers/mistral.d.ts +3 -3
- package/dist/lib/providers/mistral.js +7 -6
- package/dist/lib/providers/ollama.d.ts +3 -4
- package/dist/lib/providers/ollama.js +7 -8
- package/dist/lib/providers/openAI.d.ts +14 -2
- package/dist/lib/providers/openAI.js +60 -6
- package/dist/lib/providers/openRouter.d.ts +2 -2
- package/dist/lib/providers/openRouter.js +10 -6
- package/dist/lib/providers/sagemaker/language-model.d.ts +2 -2
- package/dist/lib/rag/ChunkerFactory.d.ts +91 -0
- package/dist/lib/rag/ChunkerFactory.js +321 -0
- package/dist/lib/rag/ChunkerRegistry.d.ts +91 -0
- package/dist/lib/rag/ChunkerRegistry.js +422 -0
- package/dist/lib/rag/chunkers/BaseChunker.d.ts +53 -0
- package/dist/lib/rag/chunkers/BaseChunker.js +144 -0
- package/dist/lib/rag/chunkers/CharacterChunker.d.ts +18 -0
- package/dist/lib/rag/chunkers/CharacterChunker.js +29 -0
- package/dist/lib/rag/chunkers/HTMLChunker.d.ts +19 -0
- package/dist/lib/rag/chunkers/HTMLChunker.js +39 -0
- package/dist/lib/rag/chunkers/JSONChunker.d.ts +19 -0
- package/dist/lib/rag/chunkers/JSONChunker.js +69 -0
- package/dist/lib/rag/chunkers/LaTeXChunker.d.ts +15 -0
- package/dist/lib/rag/chunkers/LaTeXChunker.js +64 -0
- package/dist/lib/rag/chunkers/MarkdownChunker.d.ts +15 -0
- package/dist/lib/rag/chunkers/MarkdownChunker.js +103 -0
- package/dist/lib/rag/chunkers/RecursiveChunker.d.ts +27 -0
- package/dist/lib/rag/chunkers/RecursiveChunker.js +140 -0
- package/dist/lib/rag/chunkers/SemanticMarkdownChunker.d.ts +22 -0
- package/dist/lib/rag/chunkers/SemanticMarkdownChunker.js +139 -0
- package/dist/lib/rag/chunkers/SentenceChunker.d.ts +19 -0
- package/dist/lib/rag/chunkers/SentenceChunker.js +67 -0
- package/dist/lib/rag/chunkers/TokenChunker.d.ts +19 -0
- package/dist/lib/rag/chunkers/TokenChunker.js +62 -0
- package/dist/lib/rag/chunkers/index.d.ts +15 -0
- package/dist/lib/rag/chunkers/index.js +16 -0
- package/dist/lib/rag/chunking/characterChunker.d.ts +16 -0
- package/dist/lib/rag/chunking/characterChunker.js +143 -0
- package/dist/lib/rag/chunking/chunkerRegistry.d.ts +67 -0
- package/dist/lib/rag/chunking/chunkerRegistry.js +195 -0
- package/dist/lib/rag/chunking/htmlChunker.d.ts +34 -0
- package/dist/lib/rag/chunking/htmlChunker.js +248 -0
- package/dist/lib/rag/chunking/index.d.ts +15 -0
- package/dist/lib/rag/chunking/index.js +18 -0
- package/dist/lib/rag/chunking/jsonChunker.d.ts +20 -0
- package/dist/lib/rag/chunking/jsonChunker.js +282 -0
- package/dist/lib/rag/chunking/latexChunker.d.ts +26 -0
- package/dist/lib/rag/chunking/latexChunker.js +252 -0
- package/dist/lib/rag/chunking/markdownChunker.d.ts +19 -0
- package/dist/lib/rag/chunking/markdownChunker.js +202 -0
- package/dist/lib/rag/chunking/recursiveChunker.d.ts +19 -0
- package/dist/lib/rag/chunking/recursiveChunker.js +149 -0
- package/dist/lib/rag/chunking/semanticChunker.d.ts +41 -0
- package/dist/lib/rag/chunking/semanticChunker.js +307 -0
- package/dist/lib/rag/chunking/sentenceChunker.d.ts +25 -0
- package/dist/lib/rag/chunking/sentenceChunker.js +231 -0
- package/dist/lib/rag/chunking/tokenChunker.d.ts +36 -0
- package/dist/lib/rag/chunking/tokenChunker.js +184 -0
- package/dist/lib/rag/document/MDocument.d.ts +198 -0
- package/dist/lib/rag/document/MDocument.js +393 -0
- package/dist/lib/rag/document/index.d.ts +5 -0
- package/dist/lib/rag/document/index.js +6 -0
- package/dist/lib/rag/document/loaders.d.ts +201 -0
- package/dist/lib/rag/document/loaders.js +501 -0
- package/dist/lib/rag/errors/RAGError.d.ts +244 -0
- package/dist/lib/rag/errors/RAGError.js +275 -0
- package/dist/lib/rag/errors/index.d.ts +6 -0
- package/dist/lib/rag/errors/index.js +7 -0
- package/dist/lib/rag/graphRag/graphRAG.d.ts +115 -0
- package/dist/lib/rag/graphRag/graphRAG.js +385 -0
- package/dist/lib/rag/graphRag/index.d.ts +4 -0
- package/dist/lib/rag/graphRag/index.js +5 -0
- package/dist/lib/rag/index.d.ts +103 -0
- package/dist/lib/rag/index.js +142 -0
- package/dist/lib/rag/metadata/MetadataExtractorFactory.d.ts +157 -0
- package/dist/lib/rag/metadata/MetadataExtractorFactory.js +419 -0
- package/dist/lib/rag/metadata/MetadataExtractorRegistry.d.ts +99 -0
- package/dist/lib/rag/metadata/MetadataExtractorRegistry.js +363 -0
- package/dist/lib/rag/metadata/index.d.ts +6 -0
- package/dist/lib/rag/metadata/index.js +10 -0
- package/dist/lib/rag/metadata/metadataExtractor.d.ts +69 -0
- package/dist/lib/rag/metadata/metadataExtractor.js +278 -0
- package/dist/lib/rag/pipeline/RAGPipeline.d.ts +235 -0
- package/dist/lib/rag/pipeline/RAGPipeline.js +402 -0
- package/dist/lib/rag/pipeline/contextAssembly.d.ts +126 -0
- package/dist/lib/rag/pipeline/contextAssembly.js +338 -0
- package/dist/lib/rag/pipeline/index.d.ts +5 -0
- package/dist/lib/rag/pipeline/index.js +6 -0
- package/dist/lib/rag/ragIntegration.d.ts +38 -0
- package/dist/lib/rag/ragIntegration.js +212 -0
- package/dist/lib/rag/reranker/RerankerFactory.d.ts +184 -0
- package/dist/lib/rag/reranker/RerankerFactory.js +431 -0
- package/dist/lib/rag/reranker/RerankerRegistry.d.ts +119 -0
- package/dist/lib/rag/reranker/RerankerRegistry.js +403 -0
- package/dist/lib/rag/reranker/index.d.ts +6 -0
- package/dist/lib/rag/reranker/index.js +10 -0
- package/dist/lib/rag/reranker/reranker.d.ts +71 -0
- package/dist/lib/rag/reranker/reranker.js +278 -0
- package/dist/lib/rag/resilience/CircuitBreaker.d.ts +215 -0
- package/dist/lib/rag/resilience/CircuitBreaker.js +432 -0
- package/dist/lib/rag/resilience/RetryHandler.d.ts +115 -0
- package/dist/lib/rag/resilience/RetryHandler.js +301 -0
- package/dist/lib/rag/resilience/index.d.ts +7 -0
- package/dist/lib/rag/resilience/index.js +8 -0
- package/dist/lib/rag/retrieval/hybridSearch.d.ts +94 -0
- package/dist/lib/rag/retrieval/hybridSearch.js +314 -0
- package/dist/lib/rag/retrieval/index.d.ts +5 -0
- package/dist/lib/rag/retrieval/index.js +6 -0
- package/dist/lib/rag/retrieval/vectorQueryTool.d.ts +93 -0
- package/dist/lib/rag/retrieval/vectorQueryTool.js +290 -0
- package/dist/lib/rag/types.d.ts +768 -0
- package/dist/lib/rag/types.js +9 -0
- package/dist/lib/server/index.d.ts +15 -11
- package/dist/lib/server/index.js +55 -51
- package/dist/lib/server/utils/validation.d.ts +2 -2
- package/dist/lib/types/common.d.ts +0 -1
- package/dist/lib/types/fileTypes.d.ts +1 -1
- package/dist/lib/types/generateTypes.d.ts +42 -8
- package/dist/lib/types/generateTypes.js +1 -1
- package/dist/lib/types/index.d.ts +25 -24
- package/dist/lib/types/index.js +21 -20
- package/dist/lib/types/modelTypes.d.ts +16 -16
- package/dist/lib/types/pptTypes.d.ts +14 -2
- package/dist/lib/types/pptTypes.js +16 -0
- package/dist/lib/types/streamTypes.d.ts +28 -8
- package/dist/lib/types/streamTypes.js +1 -1
- package/dist/lib/utils/async/delay.d.ts +40 -0
- package/dist/lib/utils/async/delay.js +43 -0
- package/dist/lib/utils/async/index.d.ts +23 -0
- package/dist/lib/utils/async/index.js +24 -0
- package/dist/lib/utils/async/retry.d.ts +141 -0
- package/dist/lib/utils/async/retry.js +172 -0
- package/dist/lib/utils/async/withTimeout.d.ts +73 -0
- package/dist/lib/utils/async/withTimeout.js +97 -0
- package/dist/lib/utils/fileDetector.d.ts +7 -1
- package/dist/lib/utils/fileDetector.js +91 -18
- package/dist/lib/utils/json/extract.d.ts +103 -0
- package/dist/lib/utils/json/extract.js +249 -0
- package/dist/lib/utils/json/index.d.ts +36 -0
- package/dist/lib/utils/json/index.js +37 -0
- package/dist/lib/utils/json/safeParse.d.ts +137 -0
- package/dist/lib/utils/json/safeParse.js +191 -0
- package/dist/lib/utils/messageBuilder.d.ts +2 -2
- package/dist/lib/utils/messageBuilder.js +15 -7
- package/dist/lib/utils/modelRouter.d.ts +4 -4
- package/dist/lib/utils/modelRouter.js +4 -4
- package/dist/lib/utils/sanitizers/filename.d.ts +137 -0
- package/dist/lib/utils/sanitizers/filename.js +366 -0
- package/dist/lib/utils/sanitizers/html.d.ts +170 -0
- package/dist/lib/utils/sanitizers/html.js +326 -0
- package/dist/lib/utils/sanitizers/index.d.ts +26 -0
- package/dist/lib/utils/sanitizers/index.js +30 -0
- package/dist/lib/utils/sanitizers/svg.d.ts +81 -0
- package/dist/lib/utils/sanitizers/svg.js +483 -0
- package/dist/mcp/index.d.ts +6 -5
- package/dist/mcp/index.js +7 -5
- package/dist/neurolink.d.ts +11 -13
- package/dist/neurolink.js +95 -29
- package/dist/processors/base/BaseFileProcessor.d.ts +273 -0
- package/dist/processors/base/BaseFileProcessor.js +613 -0
- package/dist/processors/base/index.d.ts +14 -0
- package/dist/processors/base/index.js +19 -0
- package/dist/processors/base/types.d.ts +593 -0
- package/dist/processors/base/types.js +76 -0
- package/dist/processors/cli/fileProcessorCli.d.ts +163 -0
- package/dist/processors/cli/fileProcessorCli.js +388 -0
- package/dist/processors/cli/index.d.ts +37 -0
- package/dist/processors/cli/index.js +49 -0
- package/dist/processors/code/ConfigProcessor.d.ts +171 -0
- package/dist/processors/code/ConfigProcessor.js +400 -0
- package/dist/processors/code/SourceCodeProcessor.d.ts +174 -0
- package/dist/processors/code/SourceCodeProcessor.js +304 -0
- package/dist/processors/code/index.d.ts +44 -0
- package/dist/processors/code/index.js +60 -0
- package/dist/processors/config/fileTypes.d.ts +283 -0
- package/dist/processors/config/fileTypes.js +520 -0
- package/dist/processors/config/index.d.ts +32 -0
- package/dist/processors/config/index.js +92 -0
- package/dist/processors/config/languageMap.d.ts +66 -0
- package/dist/processors/config/languageMap.js +410 -0
- package/dist/processors/config/mimeTypes.d.ts +376 -0
- package/dist/processors/config/mimeTypes.js +338 -0
- package/dist/processors/config/sizeLimits.d.ts +194 -0
- package/dist/processors/config/sizeLimits.js +246 -0
- package/dist/processors/data/JsonProcessor.d.ts +122 -0
- package/dist/processors/data/JsonProcessor.js +203 -0
- package/dist/processors/data/XmlProcessor.d.ts +160 -0
- package/dist/processors/data/XmlProcessor.js +283 -0
- package/dist/processors/data/YamlProcessor.d.ts +163 -0
- package/dist/processors/data/YamlProcessor.js +294 -0
- package/dist/processors/data/index.d.ts +49 -0
- package/dist/processors/data/index.js +76 -0
- package/dist/processors/document/ExcelProcessor.d.ts +238 -0
- package/dist/processors/document/ExcelProcessor.js +519 -0
- package/dist/processors/document/OpenDocumentProcessor.d.ts +69 -0
- package/dist/processors/document/OpenDocumentProcessor.js +210 -0
- package/dist/processors/document/RtfProcessor.d.ts +152 -0
- package/dist/processors/document/RtfProcessor.js +361 -0
- package/dist/processors/document/WordProcessor.d.ts +168 -0
- package/dist/processors/document/WordProcessor.js +353 -0
- package/dist/processors/document/index.d.ts +54 -0
- package/dist/processors/document/index.js +90 -0
- package/dist/processors/errors/FileErrorCode.d.ts +98 -0
- package/dist/processors/errors/FileErrorCode.js +255 -0
- package/dist/processors/errors/errorHelpers.d.ts +151 -0
- package/dist/processors/errors/errorHelpers.js +378 -0
- package/dist/processors/errors/errorSerializer.d.ts +139 -0
- package/dist/processors/errors/errorSerializer.js +507 -0
- package/dist/processors/errors/index.d.ts +46 -0
- package/dist/processors/errors/index.js +49 -0
- package/dist/processors/index.d.ts +76 -0
- package/dist/processors/index.js +112 -0
- package/dist/processors/integration/FileProcessorIntegration.d.ts +244 -0
- package/dist/processors/integration/FileProcessorIntegration.js +272 -0
- package/dist/processors/integration/index.d.ts +42 -0
- package/dist/processors/integration/index.js +44 -0
- package/dist/processors/markup/HtmlProcessor.d.ts +169 -0
- package/dist/processors/markup/HtmlProcessor.js +249 -0
- package/dist/processors/markup/MarkdownProcessor.d.ts +165 -0
- package/dist/processors/markup/MarkdownProcessor.js +244 -0
- package/dist/processors/markup/SvgProcessor.d.ts +156 -0
- package/dist/processors/markup/SvgProcessor.js +240 -0
- package/dist/processors/markup/TextProcessor.d.ts +135 -0
- package/dist/processors/markup/TextProcessor.js +188 -0
- package/dist/processors/markup/index.d.ts +66 -0
- package/dist/processors/markup/index.js +102 -0
- package/dist/processors/registry/ProcessorRegistry.d.ts +334 -0
- package/dist/processors/registry/ProcessorRegistry.js +608 -0
- package/dist/processors/registry/index.d.ts +12 -0
- package/dist/processors/registry/index.js +16 -0
- package/dist/processors/registry/types.d.ts +53 -0
- package/dist/processors/registry/types.js +10 -0
- package/dist/providers/amazonBedrock.d.ts +15 -2
- package/dist/providers/amazonBedrock.js +65 -8
- package/dist/providers/anthropic.d.ts +3 -3
- package/dist/providers/anthropic.js +10 -7
- package/dist/providers/googleAiStudio.d.ts +5 -5
- package/dist/providers/googleAiStudio.js +10 -7
- package/dist/providers/googleVertex.d.ts +16 -4
- package/dist/providers/googleVertex.js +72 -16
- package/dist/providers/litellm.d.ts +3 -3
- package/dist/providers/litellm.js +10 -10
- package/dist/providers/mistral.d.ts +3 -3
- package/dist/providers/mistral.js +7 -6
- package/dist/providers/ollama.d.ts +3 -4
- package/dist/providers/ollama.js +7 -8
- package/dist/providers/openAI.d.ts +14 -2
- package/dist/providers/openAI.js +60 -6
- package/dist/providers/openRouter.d.ts +2 -2
- package/dist/providers/openRouter.js +10 -6
- package/dist/rag/ChunkerFactory.d.ts +91 -0
- package/dist/rag/ChunkerFactory.js +320 -0
- package/dist/rag/ChunkerRegistry.d.ts +91 -0
- package/dist/rag/ChunkerRegistry.js +421 -0
- package/dist/rag/chunkers/BaseChunker.d.ts +53 -0
- package/dist/rag/chunkers/BaseChunker.js +143 -0
- package/dist/rag/chunkers/CharacterChunker.d.ts +18 -0
- package/dist/rag/chunkers/CharacterChunker.js +28 -0
- package/dist/rag/chunkers/HTMLChunker.d.ts +19 -0
- package/dist/rag/chunkers/HTMLChunker.js +38 -0
- package/dist/rag/chunkers/JSONChunker.d.ts +19 -0
- package/dist/rag/chunkers/JSONChunker.js +68 -0
- package/dist/rag/chunkers/LaTeXChunker.d.ts +15 -0
- package/dist/rag/chunkers/LaTeXChunker.js +63 -0
- package/dist/rag/chunkers/MarkdownChunker.d.ts +15 -0
- package/dist/rag/chunkers/MarkdownChunker.js +102 -0
- package/dist/rag/chunkers/RecursiveChunker.d.ts +27 -0
- package/dist/rag/chunkers/RecursiveChunker.js +139 -0
- package/dist/rag/chunkers/SemanticMarkdownChunker.d.ts +22 -0
- package/dist/rag/chunkers/SemanticMarkdownChunker.js +138 -0
- package/dist/rag/chunkers/SentenceChunker.d.ts +19 -0
- package/dist/rag/chunkers/SentenceChunker.js +66 -0
- package/dist/rag/chunkers/TokenChunker.d.ts +19 -0
- package/dist/rag/chunkers/TokenChunker.js +61 -0
- package/dist/rag/chunkers/index.d.ts +15 -0
- package/dist/rag/chunkers/index.js +15 -0
- package/dist/rag/chunking/characterChunker.d.ts +16 -0
- package/dist/rag/chunking/characterChunker.js +142 -0
- package/dist/rag/chunking/chunkerRegistry.d.ts +67 -0
- package/dist/rag/chunking/chunkerRegistry.js +194 -0
- package/dist/rag/chunking/htmlChunker.d.ts +34 -0
- package/dist/rag/chunking/htmlChunker.js +247 -0
- package/dist/rag/chunking/index.d.ts +15 -0
- package/dist/rag/chunking/index.js +17 -0
- package/dist/rag/chunking/jsonChunker.d.ts +20 -0
- package/dist/rag/chunking/jsonChunker.js +281 -0
- package/dist/rag/chunking/latexChunker.d.ts +26 -0
- package/dist/rag/chunking/latexChunker.js +251 -0
- package/dist/rag/chunking/markdownChunker.d.ts +19 -0
- package/dist/rag/chunking/markdownChunker.js +201 -0
- package/dist/rag/chunking/recursiveChunker.d.ts +19 -0
- package/dist/rag/chunking/recursiveChunker.js +148 -0
- package/dist/rag/chunking/semanticChunker.d.ts +41 -0
- package/dist/rag/chunking/semanticChunker.js +306 -0
- package/dist/rag/chunking/sentenceChunker.d.ts +25 -0
- package/dist/rag/chunking/sentenceChunker.js +230 -0
- package/dist/rag/chunking/tokenChunker.d.ts +36 -0
- package/dist/rag/chunking/tokenChunker.js +183 -0
- package/dist/rag/document/MDocument.d.ts +198 -0
- package/dist/rag/document/MDocument.js +392 -0
- package/dist/rag/document/index.d.ts +5 -0
- package/dist/rag/document/index.js +5 -0
- package/dist/rag/document/loaders.d.ts +201 -0
- package/dist/rag/document/loaders.js +500 -0
- package/dist/rag/errors/RAGError.d.ts +244 -0
- package/dist/rag/errors/RAGError.js +274 -0
- package/dist/rag/errors/index.d.ts +6 -0
- package/dist/rag/errors/index.js +6 -0
- package/dist/rag/graphRag/graphRAG.d.ts +115 -0
- package/dist/rag/graphRag/graphRAG.js +384 -0
- package/dist/rag/graphRag/index.d.ts +4 -0
- package/dist/rag/graphRag/index.js +4 -0
- package/dist/rag/index.d.ts +103 -0
- package/dist/rag/index.js +141 -0
- package/dist/rag/metadata/MetadataExtractorFactory.d.ts +157 -0
- package/dist/rag/metadata/MetadataExtractorFactory.js +418 -0
- package/dist/rag/metadata/MetadataExtractorRegistry.d.ts +99 -0
- package/dist/rag/metadata/MetadataExtractorRegistry.js +362 -0
- package/dist/rag/metadata/index.d.ts +6 -0
- package/dist/rag/metadata/index.js +9 -0
- package/dist/rag/metadata/metadataExtractor.d.ts +69 -0
- package/dist/rag/metadata/metadataExtractor.js +277 -0
- package/dist/rag/pipeline/RAGPipeline.d.ts +235 -0
- package/dist/rag/pipeline/RAGPipeline.js +401 -0
- package/dist/rag/pipeline/contextAssembly.d.ts +126 -0
- package/dist/rag/pipeline/contextAssembly.js +337 -0
- package/dist/rag/pipeline/index.d.ts +5 -0
- package/dist/rag/pipeline/index.js +5 -0
- package/dist/rag/ragIntegration.d.ts +38 -0
- package/dist/rag/ragIntegration.js +211 -0
- package/dist/rag/reranker/RerankerFactory.d.ts +184 -0
- package/dist/rag/reranker/RerankerFactory.js +430 -0
- package/dist/rag/reranker/RerankerRegistry.d.ts +119 -0
- package/dist/rag/reranker/RerankerRegistry.js +402 -0
- package/dist/rag/reranker/index.d.ts +6 -0
- package/dist/rag/reranker/index.js +9 -0
- package/dist/rag/reranker/reranker.d.ts +71 -0
- package/dist/rag/reranker/reranker.js +277 -0
- package/dist/rag/resilience/CircuitBreaker.d.ts +215 -0
- package/dist/rag/resilience/CircuitBreaker.js +431 -0
- package/dist/rag/resilience/RetryHandler.d.ts +115 -0
- package/dist/rag/resilience/RetryHandler.js +300 -0
- package/dist/rag/resilience/index.d.ts +7 -0
- package/dist/rag/resilience/index.js +7 -0
- package/dist/rag/retrieval/hybridSearch.d.ts +94 -0
- package/dist/rag/retrieval/hybridSearch.js +313 -0
- package/dist/rag/retrieval/index.d.ts +5 -0
- package/dist/rag/retrieval/index.js +5 -0
- package/dist/rag/retrieval/vectorQueryTool.d.ts +93 -0
- package/dist/rag/retrieval/vectorQueryTool.js +289 -0
- package/dist/rag/types.d.ts +768 -0
- package/dist/rag/types.js +8 -0
- package/dist/server/index.d.ts +15 -11
- package/dist/server/index.js +55 -51
- package/dist/server/utils/validation.d.ts +8 -8
- package/dist/types/common.d.ts +0 -1
- package/dist/types/fileTypes.d.ts +1 -1
- package/dist/types/generateTypes.d.ts +42 -8
- package/dist/types/generateTypes.js +1 -1
- package/dist/types/index.d.ts +25 -24
- package/dist/types/index.js +21 -20
- package/dist/types/modelTypes.d.ts +10 -10
- package/dist/types/pptTypes.d.ts +14 -2
- package/dist/types/pptTypes.js +16 -0
- package/dist/types/streamTypes.d.ts +28 -8
- package/dist/types/streamTypes.js +1 -1
- package/dist/utils/async/delay.d.ts +40 -0
- package/dist/utils/async/delay.js +42 -0
- package/dist/utils/async/index.d.ts +23 -0
- package/dist/utils/async/index.js +23 -0
- package/dist/utils/async/retry.d.ts +141 -0
- package/dist/utils/async/retry.js +171 -0
- package/dist/utils/async/withTimeout.d.ts +73 -0
- package/dist/utils/async/withTimeout.js +96 -0
- package/dist/utils/fileDetector.d.ts +7 -1
- package/dist/utils/fileDetector.js +91 -18
- package/dist/utils/json/extract.d.ts +103 -0
- package/dist/utils/json/extract.js +248 -0
- package/dist/utils/json/index.d.ts +36 -0
- package/dist/utils/json/index.js +36 -0
- package/dist/utils/json/safeParse.d.ts +137 -0
- package/dist/utils/json/safeParse.js +190 -0
- package/dist/utils/messageBuilder.d.ts +2 -2
- package/dist/utils/messageBuilder.js +15 -7
- package/dist/utils/modelRouter.d.ts +4 -4
- package/dist/utils/modelRouter.js +4 -4
- package/dist/utils/sanitizers/filename.d.ts +137 -0
- package/dist/utils/sanitizers/filename.js +365 -0
- package/dist/utils/sanitizers/html.d.ts +170 -0
- package/dist/utils/sanitizers/html.js +325 -0
- package/dist/utils/sanitizers/index.d.ts +26 -0
- package/dist/utils/sanitizers/index.js +29 -0
- package/dist/utils/sanitizers/svg.d.ts +81 -0
- package/dist/utils/sanitizers/svg.js +482 -0
- package/package.json +2 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Processor Registry Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Contains only types unique to the registry module.
|
|
5
|
+
* All shared types (ProcessorMatch, RegistryOptions, etc.) are defined
|
|
6
|
+
* in the single source of truth: processors/base/types.ts
|
|
7
|
+
*
|
|
8
|
+
* @module processors/registry/types
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime";
|
|
2
|
+
import type { AIProviderName } from "../constants/enums.js";
|
|
2
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
|
+
import type { NeuroLink } from "../neurolink.js";
|
|
3
5
|
import type { EnhancedGenerateResult, TextGenerationOptions } from "../types/index.js";
|
|
4
|
-
import { AIProviderName } from "../constants/enums.js";
|
|
5
6
|
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
6
|
-
import type { NeuroLink } from "../neurolink.js";
|
|
7
7
|
export declare class AmazonBedrockProvider extends BaseProvider {
|
|
8
8
|
private bedrockClient;
|
|
9
9
|
private conversationHistory;
|
|
@@ -17,6 +17,11 @@ export declare class AmazonBedrockProvider extends BaseProvider {
|
|
|
17
17
|
getAISDKModel(): never;
|
|
18
18
|
getProviderName(): AIProviderName;
|
|
19
19
|
getDefaultModel(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Get the default embedding model for Amazon Bedrock
|
|
22
|
+
* @returns The default Bedrock embedding model name
|
|
23
|
+
*/
|
|
24
|
+
protected getDefaultEmbeddingModel(): string;
|
|
20
25
|
generate(optionsOrPrompt: TextGenerationOptions | string): Promise<EnhancedGenerateResult | null>;
|
|
21
26
|
private conversationLoop;
|
|
22
27
|
private callBedrock;
|
|
@@ -40,4 +45,12 @@ export declare class AmazonBedrockProvider extends BaseProvider {
|
|
|
40
45
|
*/
|
|
41
46
|
checkBedrockHealth(): Promise<void>;
|
|
42
47
|
handleProviderError(error: unknown): Error;
|
|
48
|
+
/**
|
|
49
|
+
* Generate embeddings for text using Amazon Bedrock embedding models
|
|
50
|
+
* Uses the native AWS SDK InvokeModel command for Titan embeddings
|
|
51
|
+
* @param text - The text to embed
|
|
52
|
+
* @param modelName - The embedding model to use (default: amazon.titan-embed-text-v2:0)
|
|
53
|
+
* @returns Promise resolving to the embedding vector
|
|
54
|
+
*/
|
|
55
|
+
embed(text: string, modelName?: string): Promise<number[]>;
|
|
43
56
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { BedrockRuntimeClient, ConverseCommand, ConverseStreamCommand, ImageFormat, } from "@aws-sdk/client-bedrock-runtime";
|
|
2
1
|
import { BedrockClient, ListFoundationModelsCommand, } from "@aws-sdk/client-bedrock";
|
|
2
|
+
import { BedrockRuntimeClient, ConverseCommand, ConverseStreamCommand, ImageFormat, } from "@aws-sdk/client-bedrock-runtime";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { createAnalytics } from "../core/analytics.js";
|
|
3
5
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
|
-
import {
|
|
6
|
+
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
5
7
|
import { logger } from "../utils/logger.js";
|
|
6
|
-
import { convertZodToJsonSchema } from "../utils/schemaConversion.js";
|
|
7
8
|
import { buildMultimodalMessagesArray } from "../utils/messageBuilder.js";
|
|
8
9
|
import { buildMultimodalOptions } from "../utils/multimodalOptionsBuilder.js";
|
|
9
|
-
import {
|
|
10
|
-
import { createAnalytics } from "../core/analytics.js";
|
|
11
|
-
import path from "path";
|
|
10
|
+
import { convertZodToJsonSchema } from "../utils/schemaConversion.js";
|
|
12
11
|
// Bedrock-specific types now imported from ../types/providerSpecific.js
|
|
13
12
|
export class AmazonBedrockProvider extends BaseProvider {
|
|
14
13
|
bedrockClient;
|
|
@@ -88,6 +87,15 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
88
87
|
getDefaultModel() {
|
|
89
88
|
return (process.env.BEDROCK_MODEL || "anthropic.claude-3-sonnet-20240229-v1:0");
|
|
90
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Get the default embedding model for Amazon Bedrock
|
|
92
|
+
* @returns The default Bedrock embedding model name
|
|
93
|
+
*/
|
|
94
|
+
getDefaultEmbeddingModel() {
|
|
95
|
+
return (process.env.BEDROCK_EMBEDDING_MODEL ||
|
|
96
|
+
process.env.AWS_EMBEDDING_MODEL ||
|
|
97
|
+
"amazon.titan-embed-text-v2:0");
|
|
98
|
+
}
|
|
91
99
|
// Override the main generate method to implement conversation management
|
|
92
100
|
async generate(optionsOrPrompt) {
|
|
93
101
|
logger.debug("[AmazonBedrockProvider] generate() called with conversation management");
|
|
@@ -158,7 +166,6 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
158
166
|
logger.debug(`[AmazonBedrockProvider] Handle response result:`, result);
|
|
159
167
|
if (result.shouldContinue) {
|
|
160
168
|
logger.debug(`[AmazonBedrockProvider] Continuing conversation loop...`);
|
|
161
|
-
continue;
|
|
162
169
|
}
|
|
163
170
|
else {
|
|
164
171
|
logger.debug(`[AmazonBedrockProvider] Conversation completed with final text`);
|
|
@@ -876,7 +883,9 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
876
883
|
logger.info(`🔍 [AmazonBedrockProvider] Message ${index}: role=${msg.role}, content=${JSON.stringify(msg.content)}`);
|
|
877
884
|
});
|
|
878
885
|
// Get all available tools
|
|
879
|
-
|
|
886
|
+
// BaseProvider.stream() pre-merges base tools + external tools into options.tools
|
|
887
|
+
const aiTools = options.tools ||
|
|
888
|
+
(await this.getAllTools());
|
|
880
889
|
const allTools = this.convertAISDKToolsToToolDefinitions(aiTools);
|
|
881
890
|
const toolConfig = this.formatToolsForBedrock(allTools);
|
|
882
891
|
const convertedMessages = this.convertToAWSMessages(this.conversationHistory);
|
|
@@ -1177,5 +1186,53 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
1177
1186
|
}
|
|
1178
1187
|
return new Error(`AWS Bedrock error: ${message}`);
|
|
1179
1188
|
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Generate embeddings for text using Amazon Bedrock embedding models
|
|
1191
|
+
* Uses the native AWS SDK InvokeModel command for Titan embeddings
|
|
1192
|
+
* @param text - The text to embed
|
|
1193
|
+
* @param modelName - The embedding model to use (default: amazon.titan-embed-text-v2:0)
|
|
1194
|
+
* @returns Promise resolving to the embedding vector
|
|
1195
|
+
*/
|
|
1196
|
+
async embed(text, modelName) {
|
|
1197
|
+
const embeddingModelName = modelName || "amazon.titan-embed-text-v2:0";
|
|
1198
|
+
logger.debug("Generating embedding", {
|
|
1199
|
+
provider: this.providerName,
|
|
1200
|
+
model: embeddingModelName,
|
|
1201
|
+
textLength: text.length,
|
|
1202
|
+
});
|
|
1203
|
+
try {
|
|
1204
|
+
const { InvokeModelCommand } = await import("@aws-sdk/client-bedrock-runtime");
|
|
1205
|
+
// Titan Embed models expect a specific input format
|
|
1206
|
+
const requestBody = JSON.stringify({
|
|
1207
|
+
inputText: text,
|
|
1208
|
+
});
|
|
1209
|
+
const command = new InvokeModelCommand({
|
|
1210
|
+
modelId: embeddingModelName,
|
|
1211
|
+
contentType: "application/json",
|
|
1212
|
+
accept: "application/json",
|
|
1213
|
+
body: requestBody,
|
|
1214
|
+
});
|
|
1215
|
+
const response = await this.bedrockClient.send(command);
|
|
1216
|
+
// Parse the response
|
|
1217
|
+
const responseBody = JSON.parse(new TextDecoder().decode(response.body));
|
|
1218
|
+
if (!responseBody.embedding || !Array.isArray(responseBody.embedding)) {
|
|
1219
|
+
throw new Error("Invalid embedding response from Bedrock");
|
|
1220
|
+
}
|
|
1221
|
+
logger.debug("Embedding generated successfully", {
|
|
1222
|
+
provider: this.providerName,
|
|
1223
|
+
model: embeddingModelName,
|
|
1224
|
+
embeddingDimension: responseBody.embedding.length,
|
|
1225
|
+
});
|
|
1226
|
+
return responseBody.embedding;
|
|
1227
|
+
}
|
|
1228
|
+
catch (error) {
|
|
1229
|
+
logger.error("Embedding generation failed", {
|
|
1230
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1231
|
+
model: embeddingModelName,
|
|
1232
|
+
textLength: text.length,
|
|
1233
|
+
});
|
|
1234
|
+
throw this.handleProviderError(error);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1180
1237
|
}
|
|
1181
1238
|
//# sourceMappingURL=amazonBedrock.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type LanguageModelV1 } from "ai";
|
|
2
|
-
import type
|
|
3
|
-
import { AIProviderName } from "../constants/enums.js";
|
|
4
|
-
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
2
|
+
import { type AIProviderName } from "../constants/enums.js";
|
|
5
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
|
+
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
5
|
+
import type { ValidationSchema } from "../types/typeAliases.js";
|
|
6
6
|
/**
|
|
7
7
|
* Anthropic Provider v2 - BaseProvider Implementation
|
|
8
8
|
* Fixed syntax and enhanced with proper error handling
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
2
2
|
import { streamText } from "ai";
|
|
3
|
-
import {
|
|
3
|
+
import { AnthropicModels } from "../constants/enums.js";
|
|
4
4
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
|
-
import { logger } from "../utils/logger.js";
|
|
6
|
-
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
7
|
-
import { AuthenticationError, NetworkError, ProviderError, RateLimitError, } from "../types/errors.js";
|
|
8
5
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
9
|
-
import { validateApiKey, createAnthropicConfig, getProviderModel, } from "../utils/providerConfig.js";
|
|
10
6
|
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
7
|
+
import { AuthenticationError, NetworkError, ProviderError, RateLimitError, } from "../types/errors.js";
|
|
8
|
+
import { logger } from "../utils/logger.js";
|
|
9
|
+
import { createAnthropicConfig, getProviderModel, validateApiKey, } from "../utils/providerConfig.js";
|
|
10
|
+
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
11
11
|
// Configuration helpers - now using consolidated utility
|
|
12
12
|
const getAnthropicApiKey = () => {
|
|
13
13
|
return validateApiKey(createAnthropicConfig());
|
|
@@ -88,9 +88,12 @@ export class AnthropicProvider extends BaseProvider {
|
|
|
88
88
|
const timeout = this.getTimeout(options);
|
|
89
89
|
const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
|
|
90
90
|
try {
|
|
91
|
-
//
|
|
91
|
+
// Get tools - options.tools is pre-merged by BaseProvider.stream() with
|
|
92
|
+
// base tools (MCP/built-in) + user-provided tools (RAG, etc.)
|
|
92
93
|
const shouldUseTools = !options.disableTools && this.supportsTools();
|
|
93
|
-
const tools = shouldUseTools
|
|
94
|
+
const tools = shouldUseTools
|
|
95
|
+
? options.tools || (await this.getAllTools())
|
|
96
|
+
: {};
|
|
94
97
|
// Build message array from options with multimodal support
|
|
95
98
|
// Using protected helper from BaseProvider to eliminate code duplication
|
|
96
99
|
const messages = await this.buildMessagesForStream(options);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type
|
|
3
|
-
import { AIProviderName } from "../constants/enums.js";
|
|
4
|
-
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
5
|
-
import type { TextGenerationOptions, EnhancedGenerateResult } from "../types/generateTypes.js";
|
|
1
|
+
import { type LanguageModelV1, type Schema } from "ai";
|
|
2
|
+
import { type AIProviderName } from "../constants/enums.js";
|
|
6
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
|
+
import type { EnhancedGenerateResult, TextGenerationOptions } from "../types/generateTypes.js";
|
|
5
|
+
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
6
|
+
import type { ZodUnknownSchema } from "../types/typeAliases.js";
|
|
7
7
|
/**
|
|
8
8
|
* Google AI Studio provider implementation using BaseProvider
|
|
9
9
|
* Migrated from original GoogleAIStudio class to new factory pattern
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
2
2
|
import { streamText } from "ai";
|
|
3
|
-
import {
|
|
4
|
-
import { NeuroLinkError, ERROR_CODES } from "../utils/errorHandling.js";
|
|
3
|
+
import { ErrorCategory, ErrorSeverity, GoogleAIModels, } from "../constants/enums.js";
|
|
5
4
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
6
|
-
import { logger } from "../utils/logger.js";
|
|
7
|
-
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
8
|
-
import { AuthenticationError, NetworkError, ProviderError, RateLimitError, } from "../types/errors.js";
|
|
9
5
|
import { DEFAULT_MAX_STEPS, DEFAULT_TOOL_MAX_RETRIES, } from "../core/constants.js";
|
|
10
6
|
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
7
|
+
import { AuthenticationError, NetworkError, ProviderError, RateLimitError, } from "../types/errors.js";
|
|
8
|
+
import { ERROR_CODES, NeuroLinkError } from "../utils/errorHandling.js";
|
|
9
|
+
import { logger } from "../utils/logger.js";
|
|
11
10
|
import { isGemini3Model } from "../utils/modelDetection.js";
|
|
12
11
|
import { convertZodToJsonSchema, inlineJsonSchema, isZodSchema, } from "../utils/schemaConversion.js";
|
|
13
12
|
import { createNativeThinkingConfig } from "../utils/thinkingConfig.js";
|
|
13
|
+
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
14
14
|
// Google AI Live API types now imported from ../types/providerSpecific.js
|
|
15
15
|
// Import proper types for multimodal message handling
|
|
16
16
|
// Create Google GenAI client
|
|
@@ -424,9 +424,12 @@ export class GoogleAIStudioProvider extends BaseProvider {
|
|
|
424
424
|
const timeout = this.getTimeout(options);
|
|
425
425
|
const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
|
|
426
426
|
try {
|
|
427
|
-
// Get tools consistently with generate method
|
|
427
|
+
// Get tools consistently with generate method (include user-provided RAG tools)
|
|
428
428
|
const shouldUseTools = !options.disableTools && this.supportsTools();
|
|
429
|
-
const
|
|
429
|
+
const baseTools = shouldUseTools ? await this.getAllTools() : {};
|
|
430
|
+
const tools = shouldUseTools
|
|
431
|
+
? { ...baseTools, ...(options.tools || {}) }
|
|
432
|
+
: {};
|
|
430
433
|
// Build message array from options with multimodal support
|
|
431
434
|
// Using protected helper from BaseProvider to eliminate code duplication
|
|
432
435
|
const messages = await this.buildMessagesForStream(options);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { type LanguageModel, type LanguageModelV1, type Schema } from "ai";
|
|
1
2
|
import type { ZodType, ZodTypeDef } from "zod";
|
|
2
|
-
import { type
|
|
3
|
-
import { AIProviderName } from "../constants/enums.js";
|
|
4
|
-
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
5
|
-
import type { TextGenerationOptions, EnhancedGenerateResult } from "../types/generateTypes.js";
|
|
3
|
+
import { type AIProviderName } from "../constants/enums.js";
|
|
6
4
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
|
+
import type { EnhancedGenerateResult, TextGenerationOptions } from "../types/generateTypes.js";
|
|
6
|
+
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
7
7
|
/**
|
|
8
8
|
* Google Vertex AI Provider v2 - BaseProvider Implementation
|
|
9
9
|
*
|
|
@@ -64,6 +64,11 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
64
64
|
constructor(modelName?: string, _providerName?: string, sdk?: unknown, region?: string);
|
|
65
65
|
protected getProviderName(): AIProviderName;
|
|
66
66
|
protected getDefaultModel(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Get the default embedding model for Google Vertex
|
|
69
|
+
* @returns The default Vertex AI embedding model name
|
|
70
|
+
*/
|
|
71
|
+
protected getDefaultEmbeddingModel(): string;
|
|
67
72
|
/**
|
|
68
73
|
* Returns the Vercel AI SDK model instance for Google Vertex
|
|
69
74
|
* Creates fresh model instances for each request
|
|
@@ -237,6 +242,13 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
237
242
|
* @returns A promise that resolves to the generation result, including the image data.
|
|
238
243
|
*/
|
|
239
244
|
protected executeImageGeneration(options: TextGenerationOptions): Promise<EnhancedGenerateResult>;
|
|
245
|
+
/**
|
|
246
|
+
* Generate embeddings for text using Google Vertex AI text-embedding models
|
|
247
|
+
* @param text - The text to embed
|
|
248
|
+
* @param modelName - The embedding model to use (default: text-embedding-004)
|
|
249
|
+
* @returns Promise resolving to the embedding vector
|
|
250
|
+
*/
|
|
251
|
+
embed(text: string, modelName?: string): Promise<number[]>;
|
|
240
252
|
/**
|
|
241
253
|
* Get model suggestions when a model is not found
|
|
242
254
|
*/
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { createVertex, } from "@ai-sdk/google-vertex";
|
|
2
2
|
import { createVertexAnthropic, } from "@ai-sdk/google-vertex/anthropic";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { Output, streamText, } from "ai";
|
|
4
|
+
import dns from "dns";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import os from "os";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { ErrorCategory, ErrorSeverity, } from "../constants/enums.js";
|
|
6
9
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
7
|
-
import {
|
|
8
|
-
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
9
|
-
import { AuthenticationError, ProviderError } from "../types/errors.js";
|
|
10
|
-
import { DEFAULT_MAX_STEPS, GLOBAL_LOCATION_MODELS, DEFAULT_TOOL_MAX_RETRIES, } from "../core/constants.js";
|
|
10
|
+
import { DEFAULT_MAX_STEPS, DEFAULT_TOOL_MAX_RETRIES, GLOBAL_LOCATION_MODELS, } from "../core/constants.js";
|
|
11
11
|
import { ModelConfigurationManager } from "../core/modelConfiguration.js";
|
|
12
|
-
import {
|
|
12
|
+
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
13
|
+
import { AuthenticationError, ProviderError } from "../types/errors.js";
|
|
14
|
+
import { ERROR_CODES, NeuroLinkError } from "../utils/errorHandling.js";
|
|
15
|
+
import { FileDetector } from "../utils/fileDetector.js";
|
|
16
|
+
import { logger } from "../utils/logger.js";
|
|
13
17
|
import { isGemini3Model } from "../utils/modelDetection.js";
|
|
18
|
+
import { createGoogleAuthConfig, createVertexProjectConfig, validateApiKey, } from "../utils/providerConfig.js";
|
|
14
19
|
import { convertZodToJsonSchema, inlineJsonSchema, } from "../utils/schemaConversion.js";
|
|
15
20
|
import { createNativeThinkingConfig } from "../utils/thinkingConfig.js";
|
|
16
|
-
import
|
|
17
|
-
import path from "path";
|
|
18
|
-
import os from "os";
|
|
19
|
-
import dns from "dns";
|
|
20
|
-
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
21
|
-
import { FileDetector } from "../utils/fileDetector.js";
|
|
21
|
+
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
22
22
|
// Import proper types for multimodal message handling
|
|
23
23
|
// Enhanced Anthropic support with direct imports
|
|
24
24
|
// Using the dual provider architecture from Vercel AI SDK
|
|
@@ -339,6 +339,15 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
339
339
|
getDefaultModel() {
|
|
340
340
|
return getDefaultVertexModel();
|
|
341
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Get the default embedding model for Google Vertex
|
|
344
|
+
* @returns The default Vertex AI embedding model name
|
|
345
|
+
*/
|
|
346
|
+
getDefaultEmbeddingModel() {
|
|
347
|
+
return (process.env.VERTEX_EMBEDDING_MODEL ||
|
|
348
|
+
process.env.GOOGLE_EMBEDDING_MODEL ||
|
|
349
|
+
"text-embedding-004");
|
|
350
|
+
}
|
|
342
351
|
/**
|
|
343
352
|
* Returns the Vercel AI SDK model instance for Google Vertex
|
|
344
353
|
* Creates fresh model instances for each request
|
|
@@ -702,11 +711,16 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
702
711
|
// Using protected helper from BaseProvider to eliminate code duplication
|
|
703
712
|
const messages = await this.buildMessagesForStream(options);
|
|
704
713
|
const model = await this.getAISDKModelWithMiddleware(options); // This is where network connection happens!
|
|
705
|
-
// Get all available tools (direct + MCP + external) for streaming
|
|
714
|
+
// Get all available tools (direct + MCP + external + user-provided RAG tools) for streaming
|
|
706
715
|
const shouldUseTools = !options.disableTools && this.supportsTools();
|
|
707
|
-
const
|
|
716
|
+
const baseStreamTools = shouldUseTools ? await this.getAllTools() : {};
|
|
717
|
+
const tools = shouldUseTools
|
|
718
|
+
? { ...baseStreamTools, ...(options.tools || {}) }
|
|
719
|
+
: {};
|
|
708
720
|
logger.debug(`${functionTag}: Tools for streaming`, {
|
|
709
721
|
shouldUseTools,
|
|
722
|
+
baseToolCount: Object.keys(baseStreamTools).length,
|
|
723
|
+
externalToolCount: Object.keys(options.tools || {}).length,
|
|
710
724
|
toolCount: Object.keys(tools).length,
|
|
711
725
|
toolNames: Object.keys(tools),
|
|
712
726
|
});
|
|
@@ -2747,6 +2761,48 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
2747
2761
|
throw this.handleProviderError(error);
|
|
2748
2762
|
}
|
|
2749
2763
|
}
|
|
2764
|
+
/**
|
|
2765
|
+
* Generate embeddings for text using Google Vertex AI text-embedding models
|
|
2766
|
+
* @param text - The text to embed
|
|
2767
|
+
* @param modelName - The embedding model to use (default: text-embedding-004)
|
|
2768
|
+
* @returns Promise resolving to the embedding vector
|
|
2769
|
+
*/
|
|
2770
|
+
async embed(text, modelName) {
|
|
2771
|
+
const embeddingModelName = modelName || "text-embedding-004";
|
|
2772
|
+
logger.debug("Generating embedding", {
|
|
2773
|
+
provider: this.providerName,
|
|
2774
|
+
model: embeddingModelName,
|
|
2775
|
+
textLength: text.length,
|
|
2776
|
+
});
|
|
2777
|
+
try {
|
|
2778
|
+
// Create embedding model using the AI SDK
|
|
2779
|
+
const { embed } = await import("ai");
|
|
2780
|
+
// Create the Vertex provider with current settings
|
|
2781
|
+
const vertexSettings = await createVertexSettings(this.location);
|
|
2782
|
+
const vertex = createVertex(vertexSettings);
|
|
2783
|
+
// Get the text embedding model
|
|
2784
|
+
const embeddingModel = vertex.textEmbeddingModel(embeddingModelName);
|
|
2785
|
+
// Generate the embedding
|
|
2786
|
+
const result = await embed({
|
|
2787
|
+
model: embeddingModel,
|
|
2788
|
+
value: text,
|
|
2789
|
+
});
|
|
2790
|
+
logger.debug("Embedding generated successfully", {
|
|
2791
|
+
provider: this.providerName,
|
|
2792
|
+
model: embeddingModelName,
|
|
2793
|
+
embeddingDimension: result.embedding.length,
|
|
2794
|
+
});
|
|
2795
|
+
return result.embedding;
|
|
2796
|
+
}
|
|
2797
|
+
catch (error) {
|
|
2798
|
+
logger.error("Embedding generation failed", {
|
|
2799
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2800
|
+
model: embeddingModelName,
|
|
2801
|
+
textLength: text.length,
|
|
2802
|
+
});
|
|
2803
|
+
throw this.handleProviderError(error);
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2750
2806
|
/**
|
|
2751
2807
|
* Get model suggestions when a model is not found
|
|
2752
2808
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { type LanguageModelV1, type Schema } from "ai";
|
|
1
2
|
import type { ZodType, ZodTypeDef } from "zod";
|
|
2
|
-
import
|
|
3
|
-
import { AIProviderName } from "../constants/enums.js";
|
|
4
|
-
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
3
|
+
import type { AIProviderName } from "../constants/enums.js";
|
|
5
4
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
|
+
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
6
6
|
/**
|
|
7
7
|
* LiteLLM Provider - BaseProvider Implementation
|
|
8
8
|
* Provides access to 100+ models via LiteLLM proxy server
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { streamText,
|
|
3
|
-
import { AIProviderName } from "../constants/enums.js";
|
|
2
|
+
import { Output, streamText, } from "ai";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
|
-
import { logger } from "../utils/logger.js";
|
|
6
|
-
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
7
|
-
import { getProviderModel } from "../utils/providerConfig.js";
|
|
8
|
-
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
9
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
5
|
+
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
10
6
|
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
7
|
+
import { logger } from "../utils/logger.js";
|
|
8
|
+
import { getProviderModel } from "../utils/providerConfig.js";
|
|
9
|
+
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
11
10
|
// Configuration helpers
|
|
12
11
|
const getLiteLLMConfig = () => {
|
|
13
12
|
return {
|
|
@@ -126,9 +125,11 @@ export class LiteLLMProvider extends BaseProvider {
|
|
|
126
125
|
// Using protected helper from BaseProvider to eliminate code duplication
|
|
127
126
|
const messages = await this.buildMessagesForStream(options);
|
|
128
127
|
const model = await this.getAISDKModelWithMiddleware(options); // This is where network connection happens!
|
|
129
|
-
// Get
|
|
128
|
+
// Get tools - options.tools is pre-merged by BaseProvider.stream()
|
|
130
129
|
const shouldUseTools = !options.disableTools && this.supportsTools();
|
|
131
|
-
const tools = shouldUseTools
|
|
130
|
+
const tools = shouldUseTools
|
|
131
|
+
? options.tools || (await this.getAllTools())
|
|
132
|
+
: {};
|
|
132
133
|
logger.debug(`LiteLLM: Tools for streaming`, {
|
|
133
134
|
shouldUseTools,
|
|
134
135
|
toolCount: Object.keys(tools).length,
|
|
@@ -219,8 +220,7 @@ export class LiteLLMProvider extends BaseProvider {
|
|
|
219
220
|
errorType: errorChunk.type,
|
|
220
221
|
errorDetails: errorChunk.error,
|
|
221
222
|
});
|
|
222
|
-
throw new Error(`LiteLLM streaming error: ${errorChunk.error?.message ||
|
|
223
|
-
"Unknown error"}`);
|
|
223
|
+
throw new Error(`LiteLLM streaming error: ${errorChunk.error?.message || "Unknown error"}`);
|
|
224
224
|
}
|
|
225
225
|
if ("textDelta" in chunk) {
|
|
226
226
|
// Text delta from fullStream
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type LanguageModelV1 } from "ai";
|
|
2
|
-
import type {
|
|
3
|
-
import { AIProviderName } from "../constants/enums.js";
|
|
4
|
-
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
2
|
+
import type { AIProviderName } from "../constants/enums.js";
|
|
5
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
|
+
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
5
|
+
import type { ValidationSchema } from "../types/typeAliases.js";
|
|
6
6
|
/**
|
|
7
7
|
* Mistral AI Provider v2 - BaseProvider Implementation
|
|
8
8
|
* Supports official AI-SDK integration with all Mistral models
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { createMistral } from "@ai-sdk/mistral";
|
|
2
2
|
import { streamText } from "ai";
|
|
3
|
-
import { AIProviderName } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
|
-
import { logger } from "../utils/logger.js";
|
|
6
|
-
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
7
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
8
|
-
import { validateApiKey, createMistralConfig, getProviderModel, } from "../utils/providerConfig.js";
|
|
9
5
|
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
10
6
|
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
7
|
+
import { logger } from "../utils/logger.js";
|
|
8
|
+
import { createMistralConfig, getProviderModel, validateApiKey, } from "../utils/providerConfig.js";
|
|
9
|
+
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
11
10
|
// Configuration helpers - now using consolidated utility
|
|
12
11
|
const getMistralApiKey = () => {
|
|
13
12
|
return validateApiKey(createMistralConfig());
|
|
@@ -47,9 +46,11 @@ export class MistralProvider extends BaseProvider {
|
|
|
47
46
|
const timeout = this.getTimeout(options);
|
|
48
47
|
const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
|
|
49
48
|
try {
|
|
50
|
-
// Get tools
|
|
49
|
+
// Get tools - options.tools is pre-merged by BaseProvider.stream()
|
|
51
50
|
const shouldUseTools = !options.disableTools && this.supportsTools();
|
|
52
|
-
const tools = shouldUseTools
|
|
51
|
+
const tools = shouldUseTools
|
|
52
|
+
? options.tools || (await this.getAllTools())
|
|
53
|
+
: {};
|
|
53
54
|
// Build message array from options with multimodal support
|
|
54
55
|
// Using protected helper from BaseProvider to eliminate code duplication
|
|
55
56
|
const messages = await this.buildMessagesForStream(options);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { LanguageModelV1, Schema } from "ai";
|
|
2
|
+
import type { AIProviderName } from "../constants/enums.js";
|
|
3
|
+
import { BaseProvider } from "../core/baseProvider.js";
|
|
3
4
|
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
4
5
|
import type { ZodUnknownSchema } from "../types/typeAliases.js";
|
|
5
|
-
import type { Schema } from "ai";
|
|
6
|
-
import { BaseProvider } from "../core/baseProvider.js";
|
|
7
6
|
/**
|
|
8
7
|
* Ollama Provider v2 - BaseProvider Implementation
|
|
9
8
|
*
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createAnalytics } from "../core/analytics.js";
|
|
2
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
3
|
-
import {
|
|
3
|
+
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
4
4
|
import { modelConfig } from "../core/modelConfiguration.js";
|
|
5
5
|
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
6
|
-
import {
|
|
6
|
+
import { logger } from "../utils/logger.js";
|
|
7
7
|
import { buildMultimodalMessagesArray } from "../utils/messageBuilder.js";
|
|
8
8
|
import { buildMultimodalOptions } from "../utils/multimodalOptionsBuilder.js";
|
|
9
|
-
import {
|
|
10
|
-
import { createAnalytics } from "../core/analytics.js";
|
|
9
|
+
import { TimeoutError } from "../utils/timeout.js";
|
|
11
10
|
// Model version constants (configurable via environment)
|
|
12
11
|
const DEFAULT_OLLAMA_MODEL = "llama3.1:8b";
|
|
13
12
|
const FALLBACK_OLLAMA_MODEL = "llama3.2:latest"; // Used when primary model fails
|
|
@@ -608,7 +607,9 @@ export class OllamaProvider extends BaseProvider {
|
|
|
608
607
|
const maxIterations = options.maxSteps || DEFAULT_MAX_STEPS;
|
|
609
608
|
let iteration = 0;
|
|
610
609
|
// Get all available tools (direct + MCP + external)
|
|
611
|
-
|
|
610
|
+
// BaseProvider.stream() pre-merges base tools + external tools into options.tools
|
|
611
|
+
const allTools = options.tools ||
|
|
612
|
+
(await this.getAllTools());
|
|
612
613
|
// Convert tools to Ollama format
|
|
613
614
|
const ollamaTools = this.convertToolsToOllamaFormat(allTools);
|
|
614
615
|
// Validate that PDFs are not provided
|
|
@@ -698,7 +699,6 @@ export class OllamaProvider extends BaseProvider {
|
|
|
698
699
|
};
|
|
699
700
|
conversationHistory.push(toolMessage);
|
|
700
701
|
iteration++;
|
|
701
|
-
continue; // Next iteration
|
|
702
702
|
}
|
|
703
703
|
else if (finishReason === "length") {
|
|
704
704
|
// Max tokens reached, continue conversation
|
|
@@ -708,7 +708,6 @@ export class OllamaProvider extends BaseProvider {
|
|
|
708
708
|
content: "Please continue.",
|
|
709
709
|
});
|
|
710
710
|
iteration++;
|
|
711
|
-
continue;
|
|
712
711
|
}
|
|
713
712
|
else {
|
|
714
713
|
// Unknown finish reason, end conversation
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type LanguageModelV1 } from "ai";
|
|
2
|
-
import type { ValidationSchema } from "../types/typeAliases.js";
|
|
3
2
|
import { AIProviderName } from "../constants/enums.js";
|
|
4
|
-
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
5
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
6
4
|
import type { NeuroLink } from "../neurolink.js";
|
|
5
|
+
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
6
|
+
import type { ValidationSchema } from "../types/typeAliases.js";
|
|
7
7
|
/**
|
|
8
8
|
* OpenAI Provider v2 - BaseProvider Implementation
|
|
9
9
|
* Migrated to use factory pattern with exact Google AI provider pattern
|
|
@@ -17,6 +17,11 @@ export declare class OpenAIProvider extends BaseProvider {
|
|
|
17
17
|
supportsTools(): boolean;
|
|
18
18
|
getProviderName(): AIProviderName;
|
|
19
19
|
getDefaultModel(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Get the default embedding model for OpenAI
|
|
22
|
+
* @returns The default OpenAI embedding model name
|
|
23
|
+
*/
|
|
24
|
+
protected getDefaultEmbeddingModel(): string;
|
|
20
25
|
/**
|
|
21
26
|
* Returns the Vercel AI SDK model instance for OpenAI
|
|
22
27
|
*/
|
|
@@ -47,5 +52,12 @@ export declare class OpenAIProvider extends BaseProvider {
|
|
|
47
52
|
* and the migration guide in the project repository.
|
|
48
53
|
*/
|
|
49
54
|
protected executeStream(options: StreamOptions, _analysisSchema?: ValidationSchema): Promise<StreamResult>;
|
|
55
|
+
/**
|
|
56
|
+
* Generate embeddings for text using OpenAI text-embedding models
|
|
57
|
+
* @param text - The text to embed
|
|
58
|
+
* @param modelName - The embedding model to use (default: text-embedding-3-small)
|
|
59
|
+
* @returns Promise resolving to the embedding vector
|
|
60
|
+
*/
|
|
61
|
+
embed(text: string, modelName?: string): Promise<number[]>;
|
|
50
62
|
}
|
|
51
63
|
export default OpenAIProvider;
|