@juspay/neurolink 5.0.0 → 5.2.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 +20 -7
- package/README.md +160 -172
- package/dist/agent/direct-tools.d.ts +6 -6
- package/dist/chat/sse-handler.js +5 -4
- package/dist/chat/websocket-chat-handler.js +9 -9
- package/dist/cli/commands/config.d.ts +3 -3
- package/dist/cli/commands/mcp.js +9 -8
- package/dist/cli/commands/ollama.js +3 -3
- package/dist/cli/factories/command-factory.d.ts +18 -0
- package/dist/cli/factories/command-factory.js +183 -0
- package/dist/cli/index.js +105 -157
- package/dist/cli/utils/interactive-setup.js +2 -2
- package/dist/core/base-provider.d.ts +423 -0
- package/dist/core/base-provider.js +365 -0
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/dynamic-models.d.ts +6 -6
- package/dist/core/evaluation.d.ts +19 -80
- package/dist/core/evaluation.js +185 -484
- package/dist/core/factory.d.ts +3 -3
- package/dist/core/factory.js +31 -91
- package/dist/core/service-registry.d.ts +47 -0
- package/dist/core/service-registry.js +112 -0
- package/dist/core/types.d.ts +49 -49
- package/dist/core/types.js +1 -0
- package/dist/factories/compatibility-factory.d.ts +20 -0
- package/dist/factories/compatibility-factory.js +69 -0
- package/dist/factories/provider-factory.d.ts +72 -0
- package/dist/factories/provider-factory.js +144 -0
- package/dist/factories/provider-generate-factory.d.ts +20 -0
- package/dist/factories/provider-generate-factory.js +87 -0
- package/dist/factories/provider-registry.d.ts +38 -0
- package/dist/factories/provider-registry.js +107 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +5 -5
- package/dist/lib/agent/direct-tools.d.ts +6 -6
- package/dist/lib/chat/sse-handler.js +5 -4
- package/dist/lib/chat/websocket-chat-handler.js +9 -9
- package/dist/lib/core/base-provider.d.ts +423 -0
- package/dist/lib/core/base-provider.js +365 -0
- package/dist/lib/core/constants.d.ts +1 -1
- package/dist/lib/core/constants.js +1 -1
- package/dist/lib/core/dynamic-models.d.ts +6 -6
- package/dist/lib/core/evaluation.d.ts +19 -80
- package/dist/lib/core/evaluation.js +185 -484
- package/dist/lib/core/factory.d.ts +3 -3
- package/dist/lib/core/factory.js +30 -91
- package/dist/lib/core/service-registry.d.ts +47 -0
- package/dist/lib/core/service-registry.js +112 -0
- package/dist/lib/core/types.d.ts +49 -49
- package/dist/lib/core/types.js +1 -0
- package/dist/lib/factories/compatibility-factory.d.ts +20 -0
- package/dist/lib/factories/compatibility-factory.js +69 -0
- package/dist/lib/factories/provider-factory.d.ts +72 -0
- package/dist/lib/factories/provider-factory.js +144 -0
- package/dist/lib/factories/provider-generate-factory.d.ts +20 -0
- package/dist/lib/factories/provider-generate-factory.js +87 -0
- package/dist/lib/factories/provider-registry.d.ts +38 -0
- package/dist/lib/factories/provider-registry.js +107 -0
- package/dist/lib/index.d.ts +8 -5
- package/dist/lib/index.js +5 -5
- package/dist/lib/mcp/client.js +5 -5
- package/dist/lib/mcp/config.js +28 -3
- package/dist/lib/mcp/dynamic-orchestrator.js +8 -8
- package/dist/lib/mcp/external-client.js +2 -2
- package/dist/lib/mcp/factory.d.ts +1 -1
- package/dist/lib/mcp/factory.js +1 -1
- package/dist/lib/mcp/function-calling.js +1 -1
- package/dist/lib/mcp/initialize-tools.d.ts +1 -1
- package/dist/lib/mcp/initialize-tools.js +45 -1
- package/dist/lib/mcp/initialize.js +16 -6
- package/dist/lib/mcp/neurolink-mcp-client.js +10 -10
- package/dist/lib/mcp/orchestrator.js +4 -4
- package/dist/lib/mcp/servers/agent/direct-tools-server.d.ts +8 -0
- package/dist/lib/mcp/servers/agent/direct-tools-server.js +109 -0
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +10 -10
- package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +8 -6
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +16 -16
- package/dist/lib/mcp/unified-registry.d.ts +4 -0
- package/dist/lib/mcp/unified-registry.js +42 -9
- package/dist/lib/neurolink.d.ts +161 -174
- package/dist/lib/neurolink.js +723 -397
- package/dist/lib/providers/amazon-bedrock.d.ts +32 -0
- package/dist/lib/providers/amazon-bedrock.js +143 -0
- package/dist/lib/providers/analytics-helper.js +7 -4
- package/dist/lib/providers/anthropic-baseprovider.d.ts +23 -0
- package/dist/lib/providers/anthropic-baseprovider.js +114 -0
- package/dist/lib/providers/anthropic.d.ts +19 -39
- package/dist/lib/providers/anthropic.js +84 -378
- package/dist/lib/providers/azure-openai.d.ts +20 -0
- package/dist/lib/providers/azure-openai.js +89 -0
- package/dist/lib/providers/function-calling-provider.d.ts +14 -12
- package/dist/lib/providers/function-calling-provider.js +114 -64
- package/dist/lib/providers/google-ai-studio.d.ts +23 -0
- package/dist/lib/providers/google-ai-studio.js +107 -0
- package/dist/lib/providers/google-vertex.d.ts +47 -0
- package/dist/lib/providers/google-vertex.js +205 -0
- package/dist/lib/providers/huggingFace.d.ts +33 -27
- package/dist/lib/providers/huggingFace.js +103 -400
- package/dist/lib/providers/index.d.ts +9 -9
- package/dist/lib/providers/index.js +9 -9
- package/dist/lib/providers/mcp-provider.d.ts +13 -8
- package/dist/lib/providers/mcp-provider.js +63 -18
- package/dist/lib/providers/mistral.d.ts +42 -0
- package/dist/lib/providers/mistral.js +160 -0
- package/dist/lib/providers/ollama.d.ts +52 -35
- package/dist/lib/providers/ollama.js +297 -477
- package/dist/lib/providers/openAI.d.ts +21 -21
- package/dist/lib/providers/openAI.js +81 -245
- package/dist/lib/sdk/tool-extension.d.ts +181 -0
- package/dist/lib/sdk/tool-extension.js +283 -0
- package/dist/lib/sdk/tool-registration.d.ts +95 -0
- package/dist/lib/sdk/tool-registration.js +167 -0
- package/dist/lib/types/generate-types.d.ts +80 -0
- package/dist/lib/types/generate-types.js +1 -0
- package/dist/lib/types/mcp-types.d.ts +116 -0
- package/dist/lib/types/mcp-types.js +5 -0
- package/dist/lib/types/stream-types.d.ts +95 -0
- package/dist/lib/types/stream-types.js +1 -0
- package/dist/lib/types/universal-provider-options.d.ts +87 -0
- package/dist/lib/types/universal-provider-options.js +53 -0
- package/dist/lib/utils/providerUtils-fixed.js +1 -1
- package/dist/lib/utils/streaming-utils.d.ts +14 -2
- package/dist/lib/utils/streaming-utils.js +0 -3
- package/dist/mcp/client.js +5 -5
- package/dist/mcp/config.js +28 -3
- package/dist/mcp/dynamic-orchestrator.js +8 -8
- package/dist/mcp/external-client.js +2 -2
- package/dist/mcp/factory.d.ts +1 -1
- package/dist/mcp/factory.js +1 -1
- package/dist/mcp/function-calling.js +1 -1
- package/dist/mcp/initialize-tools.d.ts +1 -1
- package/dist/mcp/initialize-tools.js +45 -1
- package/dist/mcp/initialize.js +16 -6
- package/dist/mcp/neurolink-mcp-client.js +10 -10
- package/dist/mcp/orchestrator.js +4 -4
- package/dist/mcp/servers/agent/direct-tools-server.d.ts +8 -0
- package/dist/mcp/servers/agent/direct-tools-server.js +109 -0
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +10 -10
- package/dist/mcp/servers/ai-providers/ai-core-server.js +8 -6
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +16 -16
- package/dist/mcp/unified-registry.d.ts +4 -0
- package/dist/mcp/unified-registry.js +42 -9
- package/dist/neurolink.d.ts +161 -174
- package/dist/neurolink.js +723 -397
- package/dist/providers/amazon-bedrock.d.ts +32 -0
- package/dist/providers/amazon-bedrock.js +143 -0
- package/dist/providers/analytics-helper.js +7 -4
- package/dist/providers/anthropic-baseprovider.d.ts +23 -0
- package/dist/providers/anthropic-baseprovider.js +114 -0
- package/dist/providers/anthropic.d.ts +19 -39
- package/dist/providers/anthropic.js +83 -377
- package/dist/providers/azure-openai.d.ts +20 -0
- package/dist/providers/azure-openai.js +89 -0
- package/dist/providers/function-calling-provider.d.ts +14 -12
- package/dist/providers/function-calling-provider.js +114 -64
- package/dist/providers/google-ai-studio.d.ts +23 -0
- package/dist/providers/google-ai-studio.js +108 -0
- package/dist/providers/google-vertex.d.ts +47 -0
- package/dist/providers/google-vertex.js +205 -0
- package/dist/providers/huggingFace.d.ts +33 -27
- package/dist/providers/huggingFace.js +102 -399
- package/dist/providers/index.d.ts +9 -9
- package/dist/providers/index.js +9 -9
- package/dist/providers/mcp-provider.d.ts +13 -8
- package/dist/providers/mcp-provider.js +63 -18
- package/dist/providers/mistral.d.ts +42 -0
- package/dist/providers/mistral.js +160 -0
- package/dist/providers/ollama.d.ts +52 -35
- package/dist/providers/ollama.js +297 -476
- package/dist/providers/openAI.d.ts +21 -21
- package/dist/providers/openAI.js +81 -246
- package/dist/sdk/tool-extension.d.ts +181 -0
- package/dist/sdk/tool-extension.js +283 -0
- package/dist/sdk/tool-registration.d.ts +95 -0
- package/dist/sdk/tool-registration.js +168 -0
- package/dist/types/generate-types.d.ts +80 -0
- package/dist/types/generate-types.js +1 -0
- package/dist/types/mcp-types.d.ts +116 -0
- package/dist/types/mcp-types.js +5 -0
- package/dist/types/stream-types.d.ts +95 -0
- package/dist/types/stream-types.js +1 -0
- package/dist/types/universal-provider-options.d.ts +87 -0
- package/dist/types/universal-provider-options.js +53 -0
- package/dist/utils/providerUtils-fixed.js +1 -1
- package/dist/utils/streaming-utils.d.ts +14 -2
- package/dist/utils/streaming-utils.js +0 -3
- package/package.json +15 -10
- package/dist/lib/providers/agent-enhanced-provider.d.ts +0 -89
- package/dist/lib/providers/agent-enhanced-provider.js +0 -614
- package/dist/lib/providers/amazonBedrock.d.ts +0 -19
- package/dist/lib/providers/amazonBedrock.js +0 -334
- package/dist/lib/providers/azureOpenAI.d.ts +0 -39
- package/dist/lib/providers/azureOpenAI.js +0 -436
- package/dist/lib/providers/googleAIStudio.d.ts +0 -49
- package/dist/lib/providers/googleAIStudio.js +0 -333
- package/dist/lib/providers/googleVertexAI.d.ts +0 -38
- package/dist/lib/providers/googleVertexAI.js +0 -519
- package/dist/lib/providers/mistralAI.d.ts +0 -34
- package/dist/lib/providers/mistralAI.js +0 -294
- package/dist/providers/agent-enhanced-provider.d.ts +0 -89
- package/dist/providers/agent-enhanced-provider.js +0 -614
- package/dist/providers/amazonBedrock.d.ts +0 -19
- package/dist/providers/amazonBedrock.js +0 -334
- package/dist/providers/azureOpenAI.d.ts +0 -39
- package/dist/providers/azureOpenAI.js +0 -437
- package/dist/providers/googleAIStudio.d.ts +0 -49
- package/dist/providers/googleAIStudio.js +0 -333
- package/dist/providers/googleVertexAI.d.ts +0 -38
- package/dist/providers/googleVertexAI.js +0 -519
- package/dist/providers/mistralAI.d.ts +0 -34
- package/dist/providers/mistralAI.js +0 -294
package/CHANGELOG.md
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
# [5.
|
|
1
|
+
# [5.2.0](https://github.com/juspay/neurolink/compare/v5.1.0...v5.2.0) (2025-07-22)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
### Features
|
|
5
5
|
|
|
6
|
+
* **core:** implement comprehensive factory pattern architecture with full MCP integration and provider unification ([b13963a](https://github.com/juspay/neurolink/commit/b13963aaf6f95233be8b1e9bdc69ce1b65604cdf))
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
# [5.1.0](https://github.com/juspay/neurolink/compare/v5.0.0...v5.1.0) (2025-07-13)
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
- **core:** complete unified multimodal AI platform architecture with generate/stream unification ([846e409](https://github.com/juspay/neurolink/commit/846e409a4a77024ddee9961c9b5049bc99f8335e))
|
|
13
|
+
|
|
14
|
+
# [5.0.0](https://github.com/juspay/neurolink/compare/v4.2.0...v5.0.0) (2025-07-11)
|
|
10
15
|
|
|
16
|
+
- refactor(cli)!: remove agent-generate command, unify CLI to single generate command ([9c034b7](https://github.com/juspay/neurolink/commit/9c034b7b5a8df3b861fccae0e617c5aa4c85a903))
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
- **scripts:** update docs:generate to use docs:validate instead of removed docs:sync ([3277bab](https://github.com/juspay/neurolink/commit/3277bab3eb1cec24a60fe28bf3897fce63d83d3a))
|
|
11
21
|
|
|
12
22
|
### BREAKING CHANGES
|
|
13
23
|
|
|
14
|
-
|
|
24
|
+
- agent-generate command has been removed
|
|
15
25
|
|
|
16
|
-
The agent-generate command has been completely removed from the CLI. All
|
|
17
|
-
functionality is now available through the enhanced generate command with
|
|
26
|
+
The agent-generate command has been completely removed from the CLI. All
|
|
27
|
+
functionality is now available through the enhanced generate command with
|
|
18
28
|
tools enabled by default.
|
|
19
29
|
|
|
20
30
|
### Changes Made:
|
|
31
|
+
|
|
21
32
|
- Delete src/cli/commands/agent-generate.ts command implementation
|
|
22
33
|
- Remove agent-generate import and registration from src/cli/index.ts
|
|
23
34
|
- Update docs/CLI-GUIDE.md to remove agent-generate documentation
|
|
@@ -25,12 +36,14 @@ tools enabled by default.
|
|
|
25
36
|
- Remove agent-generate test cases from scripts/corrected-functionality-test.js
|
|
26
37
|
|
|
27
38
|
### Migration Guide:
|
|
39
|
+
|
|
28
40
|
- Replace `neurolink agent-generate "prompt"` with `neurolink generate "prompt"`
|
|
29
41
|
- Tools are enabled by default in generate command
|
|
30
42
|
- Use `--disable-tools` flag if tool-calling is not desired
|
|
31
43
|
- All previous agent-generate functionality available in generate command
|
|
32
44
|
|
|
33
45
|
### Technical Impact:
|
|
46
|
+
|
|
34
47
|
- Simplified CLI interface with single text generation command
|
|
35
48
|
- Reduced codebase complexity and maintenance overhead
|
|
36
49
|
- Enhanced generate command provides all tool-calling capabilities
|
package/README.md
CHANGED
|
@@ -7,69 +7,48 @@
|
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
8
|
[](https://github.com/juspay/neurolink/actions)
|
|
9
9
|
|
|
10
|
-
> Enterprise AI Development Platform with
|
|
10
|
+
> Enterprise AI Development Platform with built-in tools, universal provider support, and factory pattern architecture. Production-ready with TypeScript support.
|
|
11
11
|
|
|
12
|
-
**NeuroLink** is an Enterprise AI Development Platform that unifies 9 major AI providers with intelligent fallback
|
|
12
|
+
**NeuroLink** is an Enterprise AI Development Platform that unifies 9 major AI providers with intelligent fallback and built-in tool support. Available as both a **programmatic SDK** and **professional CLI tool**. Features 6 core tools working across all providers plus SDK custom tool registration. Extracted from production use at Juspay.
|
|
13
13
|
|
|
14
14
|
## 🚀 Enterprise Platform Features
|
|
15
15
|
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
16
|
+
- **🏭 Factory Pattern Architecture** - Unified provider management through BaseProvider inheritance
|
|
17
|
+
- **🔧 Tools-First Design** - All providers include built-in tool support without additional configuration
|
|
18
|
+
- **🌐 Real-time WebSocket Infrastructure** - [Coming Soon - Broken in migration, being fixed]
|
|
19
|
+
- **📊 Advanced Telemetry** - [Coming Soon - Broken in migration, being fixed]
|
|
20
|
+
- **💬 Enhanced Chat Services** - [Coming Soon - Broken in migration, being fixed]
|
|
21
|
+
- **🏗️ Enterprise Architecture** - Production-ready with clean abstractions
|
|
22
|
+
- **🔄 Configuration Management** - Flexible provider configuration
|
|
23
|
+
- **✅ Type Safety** - Industry-standard TypeScript interfaces
|
|
24
|
+
- **⚡ Performance** - Fast response times with streaming support
|
|
25
|
+
- **🛡️ Error Recovery** - Graceful failures with provider fallback
|
|
20
26
|
|
|
21
|
-
##
|
|
27
|
+
## ✅ LATEST UPDATE: Factory Pattern Refactoring Complete (2025-01-20)
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
**NeuroLink now features a unified factory pattern architecture with automatic tool support for all providers.**
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
- ✅ **Unified Architecture**: All providers inherit from BaseProvider with built-in tool support
|
|
32
|
+
- ✅ **Direct Tools**: Six core tools available across all providers (getCurrentTime, readFile, listDirectory, calculateMath, writeFile, searchFiles)
|
|
33
|
+
- ✅ **Simplified Providers**: Removed duplicate code - providers now focus only on model-specific logic
|
|
34
|
+
- ✅ **Better Testing**: 78% of providers fully working with tools (7/9 providers), 22% partial support
|
|
35
|
+
- ✅ **Zero Breaking Changes**: All existing code continues working (backward compatibility)
|
|
36
|
+
- ✅ **SDK Custom Tools**: Register your own tools programmatically with the SDK
|
|
29
37
|
|
|
30
|
-
|
|
31
|
-
npm run config:validate
|
|
32
|
-
# ✅ Config validated with suggestions and warnings
|
|
33
|
-
```
|
|
38
|
+
> **Factory Pattern**: NeuroLink uses BaseProvider inheritance to provide consistent tool support across all AI providers without code duplication.
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
## ✅ Stream Function Migration Complete (2025-01-12)
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
// Modern camelCase interfaces with rich context
|
|
39
|
-
interface ExecutionContext {
|
|
40
|
-
sessionId?: string;
|
|
41
|
-
userId?: string;
|
|
42
|
-
aiProvider?: string;
|
|
43
|
-
permissions?: string[];
|
|
44
|
-
cacheOptions?: CacheOptions;
|
|
45
|
-
fallbackOptions?: FallbackOptions;
|
|
46
|
-
metadata?: Record<string, unknown>;
|
|
47
|
-
}
|
|
42
|
+
**NeuroLink uses `stream()` as the primary streaming function with future-ready multi-modal interface.**
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
config?: unknown,
|
|
54
|
-
context?: ExecutionContext,
|
|
55
|
-
): Promise<void>;
|
|
56
|
-
executeTool?<T>(
|
|
57
|
-
toolName: string,
|
|
58
|
-
args?: unknown,
|
|
59
|
-
context?: ExecutionContext,
|
|
60
|
-
): Promise<T>;
|
|
61
|
-
listTools?(context?: ExecutionContext): Promise<ToolInfo[]>;
|
|
62
|
-
}
|
|
63
|
-
```
|
|
44
|
+
- ✅ **New Primary Streaming**: `stream()` with multi-modal ready interface
|
|
45
|
+
- ✅ **Enhanced Generation**: `generate()` as primary generation function
|
|
46
|
+
- ✅ **Factory Enhanced**: Better provider management across all methods
|
|
47
|
+
- ✅ **Zero Breaking Changes**: All existing code continues working (backward compatibility)
|
|
64
48
|
|
|
65
|
-
|
|
49
|
+
> **Enhanced API**: NeuroLink uses `stream()` and `generate()` as primary functions with multi-modal ready interfaces and improved factory patterns.
|
|
66
50
|
|
|
67
|
-
|
|
68
|
-
- **✅ Config Validation** - Comprehensive validation with suggestions
|
|
69
|
-
- **🏗️ Factory-First MCP** - Lighthouse-compatible architecture (99% compatible)
|
|
70
|
-
- **🔧 Type Safety** - Industry-standard TypeScript interfaces
|
|
71
|
-
- **⚡ Performance** - Tool execution <1ms, pipeline execution ~22ms
|
|
72
|
-
- **🛡️ Error Recovery** - Graceful failures with auto-restore
|
|
51
|
+
---
|
|
73
52
|
|
|
74
53
|
## 🚀 Quick Start
|
|
75
54
|
|
|
@@ -83,7 +62,11 @@ export GOOGLE_AI_API_KEY="AIza-your-google-ai-api-key"
|
|
|
83
62
|
npx @juspay/neurolink generate "Hello, AI"
|
|
84
63
|
npx @juspay/neurolink gen "Hello, AI" # Shortest form
|
|
85
64
|
|
|
86
|
-
#
|
|
65
|
+
# ✨ Primary Method (generate) - Recommended
|
|
66
|
+
npx @juspay/neurolink generate "Explain AI" --provider google-ai
|
|
67
|
+
npx @juspay/neurolink gen "Write code" --provider openai # Shortest form
|
|
68
|
+
|
|
69
|
+
# 🆕 AI Enhancement Features
|
|
87
70
|
npx @juspay/neurolink generate "Explain AI" --enable-analytics --debug
|
|
88
71
|
npx @juspay/neurolink generate "Write code" --enable-evaluation --debug
|
|
89
72
|
npx @juspay/neurolink generate "Help me" --context '{"userId":"123"}' --debug
|
|
@@ -99,16 +82,24 @@ npm install @juspay/neurolink
|
|
|
99
82
|
### Basic Usage
|
|
100
83
|
|
|
101
84
|
```typescript
|
|
102
|
-
import {
|
|
85
|
+
import { NeuroLink } from "@juspay/neurolink";
|
|
103
86
|
|
|
104
|
-
//
|
|
105
|
-
const
|
|
106
|
-
const result = await
|
|
107
|
-
|
|
87
|
+
// NEW: Primary method (recommended)
|
|
88
|
+
const neurolink = new NeuroLink();
|
|
89
|
+
const result = await neurolink.generate({
|
|
90
|
+
input: { text: "Write a haiku about programming" },
|
|
91
|
+
provider: "google-ai",
|
|
108
92
|
timeout: "30s", // Optional: Set custom timeout (default: 30s)
|
|
109
93
|
});
|
|
94
|
+
// Alternative: Auto-selects best available provider
|
|
95
|
+
import { createBestAIProvider } from "@juspay/neurolink";
|
|
96
|
+
const provider = createBestAIProvider();
|
|
97
|
+
const providerResult = await provider.generate({
|
|
98
|
+
input: { text: "Write a haiku about programming" },
|
|
99
|
+
timeout: "30s",
|
|
100
|
+
});
|
|
110
101
|
|
|
111
|
-
console.log(result.
|
|
102
|
+
console.log(result.content);
|
|
112
103
|
console.log(`Used: ${result.provider}`);
|
|
113
104
|
```
|
|
114
105
|
|
|
@@ -118,22 +109,22 @@ Method aliases that match CLI command names:
|
|
|
118
109
|
|
|
119
110
|
```typescript
|
|
120
111
|
// All three methods are equivalent:
|
|
121
|
-
const result1 = await provider.
|
|
122
|
-
const result2 = await provider.generate({
|
|
123
|
-
const result3 = await provider.gen({
|
|
112
|
+
const result1 = await provider.generate({ input: { text: "Hello" } }); // Original
|
|
113
|
+
const result2 = await provider.generate({ input: { text: "Hello" } }); // Matches CLI 'generate'
|
|
114
|
+
const result3 = await provider.gen({ input: { text: "Hello" } }); // Matches CLI 'gen'
|
|
124
115
|
|
|
125
116
|
// Use whichever style you prefer:
|
|
126
117
|
const provider = createBestAIProvider();
|
|
127
118
|
|
|
128
119
|
// Detailed method name
|
|
129
|
-
const story = await provider.
|
|
130
|
-
|
|
120
|
+
const story = await provider.generate({
|
|
121
|
+
input: { text: "Write a short story about AI" },
|
|
131
122
|
maxTokens: 200,
|
|
132
123
|
});
|
|
133
124
|
|
|
134
125
|
// CLI-style method names
|
|
135
|
-
const poem = await provider.generate({
|
|
136
|
-
const joke = await provider.gen({
|
|
126
|
+
const poem = await provider.generate({ input: { text: "Write a poem" } });
|
|
127
|
+
const joke = await provider.gen({ input: { text: "Tell me a joke" } });
|
|
137
128
|
```
|
|
138
129
|
|
|
139
130
|
### 🆕 Enhanced Usage (NEW! ✨)
|
|
@@ -162,11 +153,11 @@ import { NeuroLink } from "@juspay/neurolink";
|
|
|
162
153
|
const neurolink = new NeuroLink();
|
|
163
154
|
|
|
164
155
|
// Basic usage
|
|
165
|
-
const result = await neurolink.
|
|
156
|
+
const result = await neurolink.generate({ input: { text: "Write a story" } });
|
|
166
157
|
|
|
167
158
|
// With enhancements (NEW!)
|
|
168
|
-
const enhancedResult = await neurolink.
|
|
169
|
-
|
|
159
|
+
const enhancedResult = await neurolink.generate({
|
|
160
|
+
input: { text: "Write a business proposal" },
|
|
170
161
|
enableAnalytics: true, // Get usage & cost data
|
|
171
162
|
enableEvaluation: true, // Get AI quality scores
|
|
172
163
|
context: { project: "Q1-sales" }, // Custom context
|
|
@@ -177,36 +168,8 @@ console.log("📊 Usage:", enhancedResult.analytics);
|
|
|
177
168
|
console.log("⭐ Quality:", enhancedResult.evaluation);
|
|
178
169
|
console.log("Response:", enhancedResult.content);
|
|
179
170
|
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
performEnhancedEvaluation,
|
|
183
|
-
createEnhancedContext,
|
|
184
|
-
} from "@juspay/neurolink";
|
|
185
|
-
|
|
186
|
-
const enhancedContext = createEnhancedContext(
|
|
187
|
-
"Write a business proposal for Q1 expansion",
|
|
188
|
-
enhancedResult.text,
|
|
189
|
-
{
|
|
190
|
-
domain: "Business development",
|
|
191
|
-
role: "Business proposal assistant",
|
|
192
|
-
toolsUsed: ["generate-text", "analytics-helper"],
|
|
193
|
-
conversationHistory: [
|
|
194
|
-
{ role: "user", content: "I need help with our Q1 business plan" },
|
|
195
|
-
{
|
|
196
|
-
role: "assistant",
|
|
197
|
-
content: "I can help you create a comprehensive plan",
|
|
198
|
-
},
|
|
199
|
-
],
|
|
200
|
-
},
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
const domainEvaluation = await performEnhancedEvaluation(enhancedContext);
|
|
204
|
-
console.log("🎯 Enhanced Evaluation:", domainEvaluation);
|
|
205
|
-
// {
|
|
206
|
-
// relevanceScore: 9, accuracyScore: 8, completenessScore: 9,
|
|
207
|
-
// domainAlignment: 9, terminologyAccuracy: 8, toolEffectiveness: 9,
|
|
208
|
-
// overall: 8.7, alertSeverity: 'none'
|
|
209
|
-
// }
|
|
171
|
+
// Enhanced evaluation included when enableEvaluation is true
|
|
172
|
+
// Returns basic quality scores for the generated content
|
|
210
173
|
```
|
|
211
174
|
|
|
212
175
|
### 🌐 Enterprise Real-time Features (NEW! 🚀)
|
|
@@ -273,7 +236,7 @@ console.log("Version:", status.version);
|
|
|
273
236
|
|
|
274
237
|
// All AI operations are now automatically monitored
|
|
275
238
|
const provider = await createBestAIProvider();
|
|
276
|
-
const result = await provider.
|
|
239
|
+
const result = await provider.generate({
|
|
277
240
|
prompt: "Generate business report",
|
|
278
241
|
});
|
|
279
242
|
// Telemetry automatically tracks: response time, token usage, cost, errors
|
|
@@ -295,6 +258,8 @@ npx @juspay/neurolink status
|
|
|
295
258
|
|
|
296
259
|
## ✨ Key Features
|
|
297
260
|
|
|
261
|
+
- 🏭 **Factory Pattern Architecture** - Unified provider management with BaseProvider inheritance
|
|
262
|
+
- 🔧 **Tools-First Design** - All providers automatically include direct tool support (getCurrentTime, readFile, listDirectory, calculateMath, writeFile, searchFiles)
|
|
298
263
|
- 🔄 **9 AI Providers** - OpenAI, Bedrock, Vertex AI, Google AI Studio, Anthropic, Azure, Hugging Face, Ollama, Mistral AI
|
|
299
264
|
- ⚡ **Dynamic Model System** - Self-updating model configurations without code changes
|
|
300
265
|
- 💰 **Cost Optimization** - Automatic selection of cheapest models for tasks
|
|
@@ -310,16 +275,17 @@ npx @juspay/neurolink status
|
|
|
310
275
|
- 🌍 **Open Source Models** - Access 100,000+ models via Hugging Face
|
|
311
276
|
- 🇪🇺 **GDPR Compliance** - European data processing with Mistral AI
|
|
312
277
|
|
|
313
|
-
## 🛠️ MCP Integration Status
|
|
278
|
+
## 🛠️ MCP Integration Status ✅ **BUILT-IN TOOLS WORKING**
|
|
314
279
|
|
|
315
|
-
| Component | Status | Description
|
|
316
|
-
| ------------------- | ------------------ |
|
|
317
|
-
| Built-in Tools | ✅ **Working** |
|
|
318
|
-
|
|
|
319
|
-
|
|
|
320
|
-
|
|
|
321
|
-
| **
|
|
322
|
-
|
|
|
280
|
+
| Component | Status | Description |
|
|
281
|
+
| ------------------- | ------------------ | -------------------------------------------------------- |
|
|
282
|
+
| Built-in Tools | ✅ **Working** | 6 core tools fully functional across all providers |
|
|
283
|
+
| SDK Custom Tools | ✅ **Working** | Register custom tools programmatically |
|
|
284
|
+
| External Discovery | 🔍 **Discovery** | 58+ MCP servers discovered from AI tools ecosystem |
|
|
285
|
+
| Tool Execution | ✅ **Working** | Real-time AI tool calling with built-in tools |
|
|
286
|
+
| **External Tools** | 🚧 **Development** | Manual config needs one-line fix, activation in progress |
|
|
287
|
+
| **CLI Integration** | ✅ **READY** | **Production-ready with built-in tools** |
|
|
288
|
+
| External Activation | 🔧 **Development** | Discovery complete, activation protocol in progress |
|
|
323
289
|
|
|
324
290
|
### ✅ Quick MCP Test (v1.7.1)
|
|
325
291
|
|
|
@@ -327,18 +293,54 @@ npx @juspay/neurolink status
|
|
|
327
293
|
# Test built-in tools (works immediately)
|
|
328
294
|
npx @juspay/neurolink generate "What time is it?" --debug
|
|
329
295
|
|
|
330
|
-
#
|
|
331
|
-
npx @juspay/neurolink
|
|
296
|
+
# Disable tools for pure text generation
|
|
297
|
+
npx @juspay/neurolink generate "Write a poem" --disable-tools
|
|
298
|
+
|
|
299
|
+
# Discover available MCP servers
|
|
300
|
+
npx @juspay/neurolink mcp discover --format table
|
|
301
|
+
```
|
|
332
302
|
|
|
333
|
-
|
|
334
|
-
npx @juspay/neurolink generate "What tools do you have access to?" --debug
|
|
303
|
+
### 🔧 SDK Custom Tool Registration (NEW!)
|
|
335
304
|
|
|
336
|
-
|
|
337
|
-
npx @juspay/neurolink gen "What tools do you have access to?" --debug
|
|
305
|
+
Register your own tools programmatically with the SDK:
|
|
338
306
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
307
|
+
```typescript
|
|
308
|
+
import { NeuroLink } from "@juspay/neurolink";
|
|
309
|
+
const neurolink = new NeuroLink();
|
|
310
|
+
|
|
311
|
+
// Register a simple tool
|
|
312
|
+
neurolink.registerTool("weatherLookup", {
|
|
313
|
+
description: "Get current weather for a city",
|
|
314
|
+
parameters: z.object({
|
|
315
|
+
city: z.string().describe("City name"),
|
|
316
|
+
units: z.enum(["celsius", "fahrenheit"]).optional(),
|
|
317
|
+
}),
|
|
318
|
+
execute: async ({ city, units = "celsius" }) => {
|
|
319
|
+
// Your implementation here
|
|
320
|
+
return {
|
|
321
|
+
city,
|
|
322
|
+
temperature: 22,
|
|
323
|
+
units,
|
|
324
|
+
condition: "sunny",
|
|
325
|
+
};
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
// Use it in generation
|
|
330
|
+
const result = await neurolink.generate({
|
|
331
|
+
input: { text: "What's the weather in London?" },
|
|
332
|
+
provider: "google-ai",
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
// Register multiple tools at once
|
|
336
|
+
neurolink.registerTools({
|
|
337
|
+
stockPrice: {
|
|
338
|
+
/* tool definition */
|
|
339
|
+
},
|
|
340
|
+
calculator: {
|
|
341
|
+
/* tool definition */
|
|
342
|
+
},
|
|
343
|
+
});
|
|
342
344
|
```
|
|
343
345
|
|
|
344
346
|
## ⚡ Dynamic Model System (v1.8.0)
|
|
@@ -426,7 +428,20 @@ export const POST: RequestHandler = async ({ request }) => {
|
|
|
426
428
|
const provider = createBestAIProvider();
|
|
427
429
|
|
|
428
430
|
try {
|
|
429
|
-
|
|
431
|
+
// NEW: Primary streaming method (recommended)
|
|
432
|
+
const result = await provider.stream({
|
|
433
|
+
input: { text: message },
|
|
434
|
+
timeout: "2m", // 2 minutes for streaming
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
// Process stream
|
|
438
|
+
for await (const chunk of result.stream) {
|
|
439
|
+
// Handle streaming content
|
|
440
|
+
console.log(chunk.content);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// LEGACY: Backward compatibility (still works)
|
|
444
|
+
const legacyResult = await provider.stream({ input: { text:
|
|
430
445
|
prompt: message,
|
|
431
446
|
timeout: "2m", // 2 minutes for streaming
|
|
432
447
|
});
|
|
@@ -444,12 +459,12 @@ export async function POST(request: NextRequest) {
|
|
|
444
459
|
const { prompt } = await request.json();
|
|
445
460
|
const provider = createBestAIProvider();
|
|
446
461
|
|
|
447
|
-
const result = await provider.
|
|
462
|
+
const result = await provider.generate({
|
|
448
463
|
prompt,
|
|
449
464
|
timeout: process.env.AI_TIMEOUT || "30s", // Configurable timeout
|
|
450
465
|
});
|
|
451
466
|
|
|
452
|
-
return NextResponse.json({ text: result.
|
|
467
|
+
return NextResponse.json({ text: result.content });
|
|
453
468
|
}
|
|
454
469
|
```
|
|
455
470
|
|
|
@@ -494,6 +509,7 @@ cd neurolink-demo && node server.js
|
|
|
494
509
|
|
|
495
510
|
### Advanced Features
|
|
496
511
|
|
|
512
|
+
- **[🏭 Factory Pattern Migration](./docs/FACTORY-PATTERN-MIGRATION.md)** - Guide to the new unified provider architecture
|
|
497
513
|
- **[🔄 MCP Foundation](./docs/MCP-FOUNDATION.md)** - Model Context Protocol architecture
|
|
498
514
|
- **[⚡ Dynamic Models](./docs/DYNAMIC-MODELS.md)** - Self-updating model configurations and cost optimization
|
|
499
515
|
- **[🧠 AI Analysis Tools](./docs/AI-ANALYSIS-TOOLS.md)** - Usage optimization and benchmarking
|
|
@@ -507,17 +523,24 @@ cd neurolink-demo && node server.js
|
|
|
507
523
|
|
|
508
524
|
## 🏗️ Supported Providers & Models
|
|
509
525
|
|
|
510
|
-
| Provider | Models
|
|
511
|
-
| -------------------- |
|
|
512
|
-
| **OpenAI** | GPT-4o, GPT-4o-mini
|
|
513
|
-
| **Google AI Studio** | Gemini
|
|
514
|
-
| **Amazon Bedrock** | Claude 3.5/3.7 Sonnet
|
|
515
|
-
| **Google Vertex AI** | Gemini 2.5 Flash
|
|
516
|
-
| **Anthropic** | Claude 3.5 Sonnet
|
|
517
|
-
| **Azure OpenAI** | GPT-4, GPT-3.5
|
|
518
|
-
| **Hugging Face** 🆕 | 100,000+ models
|
|
519
|
-
| **Ollama** 🆕 | Llama 2,
|
|
520
|
-
| **Mistral AI** 🆕 | Tiny, Small, Medium, Large
|
|
526
|
+
| Provider | Models | Auth Method | Free Tier | Tool Support |
|
|
527
|
+
| -------------------- | -------------------------- | ------------------ | --------- | ------------ |
|
|
528
|
+
| **OpenAI** | GPT-4o, GPT-4o-mini | API Key | ❌ | ✅ Full |
|
|
529
|
+
| **Google AI Studio** | Gemini 2.5 Flash/Pro | API Key | ✅ | ✅ Full |
|
|
530
|
+
| **Amazon Bedrock** | Claude 3.5/3.7 Sonnet | AWS Credentials | ❌ | ✅ Full\* |
|
|
531
|
+
| **Google Vertex AI** | Gemini 2.5 Flash | Service Account | ❌ | ✅ Full |
|
|
532
|
+
| **Anthropic** | Claude 3.5 Sonnet | API Key | ❌ | ✅ Full |
|
|
533
|
+
| **Azure OpenAI** | GPT-4, GPT-3.5 | API Key + Endpoint | ❌ | ✅ Full |
|
|
534
|
+
| **Hugging Face** 🆕 | 100,000+ models | API Key | ✅ | ⚠️ Partial |
|
|
535
|
+
| **Ollama** 🆕 | Llama 3.2, Gemma, Mistral | None (Local) | ✅ | ⚠️ Partial |
|
|
536
|
+
| **Mistral AI** 🆕 | Tiny, Small, Medium, Large | API Key | ✅ | ✅ Full |
|
|
537
|
+
|
|
538
|
+
**Tool Support Legend:**
|
|
539
|
+
|
|
540
|
+
- ✅ Full: All tools working correctly
|
|
541
|
+
- ⚠️ Partial: Tools visible but may not execute properly
|
|
542
|
+
- ❌ Limited: Issues with model or configuration
|
|
543
|
+
- \* Bedrock requires valid AWS credentials, Ollama requires specific models like gemma3n for tool support
|
|
521
544
|
|
|
522
545
|
**✨ Auto-Selection**: NeuroLink automatically chooses the best available provider based on speed, reliability, and configuration.
|
|
523
546
|
|
|
@@ -538,51 +561,16 @@ cd neurolink-demo && node server.js
|
|
|
538
561
|
- **Extensibility**: Connect external tools and services via MCP protocol
|
|
539
562
|
- **🆕 Dynamic Server Management**: Programmatically add MCP servers at runtime
|
|
540
563
|
|
|
541
|
-
### 🔧
|
|
564
|
+
### 🔧 Programmatic MCP Server Management [Coming Soon]
|
|
542
565
|
|
|
543
|
-
**
|
|
544
|
-
|
|
545
|
-
```typescript
|
|
546
|
-
import { NeuroLink } from "@juspay/neurolink";
|
|
547
|
-
const neurolink = new NeuroLink();
|
|
548
|
-
|
|
549
|
-
// Add Bitbucket integration
|
|
550
|
-
await neurolink.addMCPServer("bitbucket", {
|
|
551
|
-
command: "npx",
|
|
552
|
-
args: ["-y", "@nexus2520/bitbucket-mcp-server"],
|
|
553
|
-
env: {
|
|
554
|
-
BITBUCKET_USERNAME: "your-username",
|
|
555
|
-
BITBUCKET_APP_PASSWORD: "your-app-password",
|
|
556
|
-
},
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
// Add custom database connector
|
|
560
|
-
await neurolink.addMCPServer("database", {
|
|
561
|
-
command: "node",
|
|
562
|
-
args: ["./custom-db-mcp-server.js"],
|
|
563
|
-
env: { DB_CONNECTION_STRING: "postgresql://..." },
|
|
564
|
-
});
|
|
565
|
-
|
|
566
|
-
// Add any MCP-compatible server
|
|
567
|
-
await neurolink.addMCPServer("slack-integration", {
|
|
568
|
-
command: "npx",
|
|
569
|
-
args: ["-y", "@slack/mcp-server"],
|
|
570
|
-
env: { SLACK_BOT_TOKEN: "xoxb-..." },
|
|
571
|
-
cwd: "/tmp",
|
|
572
|
-
});
|
|
573
|
-
|
|
574
|
-
// Verify servers are registered
|
|
575
|
-
const status = await neurolink.getMCPStatus();
|
|
576
|
-
console.log("Active servers:", status.totalServers);
|
|
577
|
-
console.log("Available tools:", status.totalTools);
|
|
578
|
-
```
|
|
566
|
+
**Note**: External MCP server activation is in development. Currently available:
|
|
579
567
|
|
|
580
|
-
|
|
568
|
+
- ✅ 6 built-in tools working across all providers
|
|
569
|
+
- ✅ SDK custom tool registration
|
|
570
|
+
- 🔍 MCP server discovery (58+ servers found)
|
|
571
|
+
- 🚧 External server activation (one-line fix pending)
|
|
581
572
|
|
|
582
|
-
|
|
583
|
-
- **Custom Tool Development**: Your own MCP servers
|
|
584
|
-
- **Dynamic Workflows**: Add servers based on project needs
|
|
585
|
-
- **Enterprise Applications**: Runtime tool ecosystem management
|
|
573
|
+
Manual MCP configuration (`.mcp-config.json`) support coming soon.
|
|
586
574
|
|
|
587
575
|
## 🤝 Contributing
|
|
588
576
|
|
|
@@ -220,8 +220,8 @@ export declare const directAgentTools: {
|
|
|
220
220
|
mode: z.ZodDefault<z.ZodEnum<["create", "overwrite", "append"]>>;
|
|
221
221
|
}, "strip", z.ZodTypeAny, {
|
|
222
222
|
path: string;
|
|
223
|
-
mode: "create" | "overwrite" | "append";
|
|
224
223
|
content: string;
|
|
224
|
+
mode: "create" | "overwrite" | "append";
|
|
225
225
|
}, {
|
|
226
226
|
path: string;
|
|
227
227
|
content: string;
|
|
@@ -250,8 +250,8 @@ export declare const directAgentTools: {
|
|
|
250
250
|
}> & {
|
|
251
251
|
execute: (args: {
|
|
252
252
|
path: string;
|
|
253
|
-
mode: "create" | "overwrite" | "append";
|
|
254
253
|
content: string;
|
|
254
|
+
mode: "create" | "overwrite" | "append";
|
|
255
255
|
}, options: import("ai").ToolExecutionOptions) => PromiseLike<{
|
|
256
256
|
success: boolean;
|
|
257
257
|
error: string;
|
|
@@ -563,8 +563,8 @@ export declare function getToolsForCategory(category?: "basic" | "filesystem" |
|
|
|
563
563
|
mode: z.ZodDefault<z.ZodEnum<["create", "overwrite", "append"]>>;
|
|
564
564
|
}, "strip", z.ZodTypeAny, {
|
|
565
565
|
path: string;
|
|
566
|
-
mode: "create" | "overwrite" | "append";
|
|
567
566
|
content: string;
|
|
567
|
+
mode: "create" | "overwrite" | "append";
|
|
568
568
|
}, {
|
|
569
569
|
path: string;
|
|
570
570
|
content: string;
|
|
@@ -593,8 +593,8 @@ export declare function getToolsForCategory(category?: "basic" | "filesystem" |
|
|
|
593
593
|
}> & {
|
|
594
594
|
execute: (args: {
|
|
595
595
|
path: string;
|
|
596
|
-
mode: "create" | "overwrite" | "append";
|
|
597
596
|
content: string;
|
|
597
|
+
mode: "create" | "overwrite" | "append";
|
|
598
598
|
}, options: import("ai").ToolExecutionOptions) => PromiseLike<{
|
|
599
599
|
success: boolean;
|
|
600
600
|
error: string;
|
|
@@ -907,8 +907,8 @@ export declare function getToolsForCategory(category?: "basic" | "filesystem" |
|
|
|
907
907
|
mode: z.ZodDefault<z.ZodEnum<["create", "overwrite", "append"]>>;
|
|
908
908
|
}, "strip", z.ZodTypeAny, {
|
|
909
909
|
path: string;
|
|
910
|
-
mode: "create" | "overwrite" | "append";
|
|
911
910
|
content: string;
|
|
911
|
+
mode: "create" | "overwrite" | "append";
|
|
912
912
|
}, {
|
|
913
913
|
path: string;
|
|
914
914
|
content: string;
|
|
@@ -937,8 +937,8 @@ export declare function getToolsForCategory(category?: "basic" | "filesystem" |
|
|
|
937
937
|
}> & {
|
|
938
938
|
execute: (args: {
|
|
939
939
|
path: string;
|
|
940
|
-
mode: "create" | "overwrite" | "append";
|
|
941
940
|
content: string;
|
|
941
|
+
mode: "create" | "overwrite" | "append";
|
|
942
942
|
}, options: import("ai").ToolExecutionOptions) => PromiseLike<{
|
|
943
943
|
success: boolean;
|
|
944
944
|
error: string;
|
package/dist/chat/sse-handler.js
CHANGED
|
@@ -42,14 +42,15 @@ export class SSEChatHandler {
|
|
|
42
42
|
data: { type: "start", sessionId, messageId: userMessage.id },
|
|
43
43
|
});
|
|
44
44
|
// Generate AI response with streaming
|
|
45
|
-
const aiResponse = await this.provider.
|
|
46
|
-
|
|
45
|
+
const aiResponse = await this.provider.stream({
|
|
46
|
+
input: { text: message },
|
|
47
47
|
temperature: options.temperature,
|
|
48
48
|
maxTokens: options.maxTokens,
|
|
49
49
|
systemPrompt: options.systemPrompt,
|
|
50
50
|
});
|
|
51
|
-
if (aiResponse?.
|
|
52
|
-
|
|
51
|
+
if (aiResponse?.stream) {
|
|
52
|
+
// Convert async iterable to readable stream
|
|
53
|
+
const reader = aiResponse.stream;
|
|
53
54
|
let fullResponse = "";
|
|
54
55
|
try {
|
|
55
56
|
while (true) {
|