@juspay/neurolink 5.1.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.
Files changed (166) hide show
  1. package/CHANGELOG.md +15 -9
  2. package/README.md +123 -126
  3. package/dist/agent/direct-tools.d.ts +6 -6
  4. package/dist/cli/commands/config.d.ts +3 -3
  5. package/dist/cli/commands/mcp.js +8 -7
  6. package/dist/cli/factories/command-factory.d.ts +4 -0
  7. package/dist/cli/factories/command-factory.js +57 -3
  8. package/dist/cli/index.js +87 -140
  9. package/dist/core/base-provider.d.ts +423 -0
  10. package/dist/core/base-provider.js +365 -0
  11. package/dist/core/constants.d.ts +1 -1
  12. package/dist/core/constants.js +1 -1
  13. package/dist/core/dynamic-models.d.ts +6 -6
  14. package/dist/core/evaluation.d.ts +19 -80
  15. package/dist/core/evaluation.js +185 -484
  16. package/dist/core/factory.d.ts +3 -3
  17. package/dist/core/factory.js +31 -91
  18. package/dist/core/service-registry.d.ts +47 -0
  19. package/dist/core/service-registry.js +112 -0
  20. package/dist/core/types.d.ts +8 -1
  21. package/dist/factories/compatibility-factory.js +1 -1
  22. package/dist/factories/provider-factory.d.ts +72 -0
  23. package/dist/factories/provider-factory.js +144 -0
  24. package/dist/factories/provider-registry.d.ts +38 -0
  25. package/dist/factories/provider-registry.js +107 -0
  26. package/dist/index.d.ts +4 -3
  27. package/dist/index.js +2 -4
  28. package/dist/lib/agent/direct-tools.d.ts +6 -6
  29. package/dist/lib/core/base-provider.d.ts +423 -0
  30. package/dist/lib/core/base-provider.js +365 -0
  31. package/dist/lib/core/constants.d.ts +1 -1
  32. package/dist/lib/core/constants.js +1 -1
  33. package/dist/lib/core/dynamic-models.d.ts +6 -6
  34. package/dist/lib/core/evaluation.d.ts +19 -80
  35. package/dist/lib/core/evaluation.js +185 -484
  36. package/dist/lib/core/factory.d.ts +3 -3
  37. package/dist/lib/core/factory.js +30 -91
  38. package/dist/lib/core/service-registry.d.ts +47 -0
  39. package/dist/lib/core/service-registry.js +112 -0
  40. package/dist/lib/core/types.d.ts +8 -1
  41. package/dist/lib/factories/compatibility-factory.js +1 -1
  42. package/dist/lib/factories/provider-factory.d.ts +72 -0
  43. package/dist/lib/factories/provider-factory.js +144 -0
  44. package/dist/lib/factories/provider-registry.d.ts +38 -0
  45. package/dist/lib/factories/provider-registry.js +107 -0
  46. package/dist/lib/index.d.ts +4 -3
  47. package/dist/lib/index.js +2 -4
  48. package/dist/lib/mcp/config.js +28 -3
  49. package/dist/lib/mcp/function-calling.js +1 -1
  50. package/dist/lib/mcp/initialize-tools.d.ts +1 -1
  51. package/dist/lib/mcp/initialize-tools.js +45 -1
  52. package/dist/lib/mcp/initialize.js +16 -6
  53. package/dist/lib/mcp/servers/agent/direct-tools-server.d.ts +8 -0
  54. package/dist/lib/mcp/servers/agent/direct-tools-server.js +109 -0
  55. package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +3 -1
  56. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
  57. package/dist/lib/mcp/unified-registry.d.ts +4 -0
  58. package/dist/lib/mcp/unified-registry.js +42 -9
  59. package/dist/lib/neurolink.d.ts +156 -117
  60. package/dist/lib/neurolink.js +619 -404
  61. package/dist/lib/providers/amazon-bedrock.d.ts +32 -0
  62. package/dist/lib/providers/amazon-bedrock.js +143 -0
  63. package/dist/lib/providers/analytics-helper.js +7 -4
  64. package/dist/lib/providers/anthropic-baseprovider.d.ts +23 -0
  65. package/dist/lib/providers/anthropic-baseprovider.js +114 -0
  66. package/dist/lib/providers/anthropic.d.ts +19 -43
  67. package/dist/lib/providers/anthropic.js +82 -306
  68. package/dist/lib/providers/azure-openai.d.ts +20 -0
  69. package/dist/lib/providers/azure-openai.js +89 -0
  70. package/dist/lib/providers/google-ai-studio.d.ts +23 -0
  71. package/dist/lib/providers/google-ai-studio.js +107 -0
  72. package/dist/lib/providers/google-vertex.d.ts +47 -0
  73. package/dist/lib/providers/google-vertex.js +205 -0
  74. package/dist/lib/providers/huggingFace.d.ts +32 -25
  75. package/dist/lib/providers/huggingFace.js +97 -431
  76. package/dist/lib/providers/index.d.ts +9 -9
  77. package/dist/lib/providers/index.js +9 -9
  78. package/dist/lib/providers/mcp-provider.js +4 -0
  79. package/dist/lib/providers/mistral.d.ts +42 -0
  80. package/dist/lib/providers/mistral.js +160 -0
  81. package/dist/lib/providers/ollama.d.ts +52 -36
  82. package/dist/lib/providers/ollama.js +297 -520
  83. package/dist/lib/providers/openAI.d.ts +19 -18
  84. package/dist/lib/providers/openAI.js +76 -275
  85. package/dist/lib/sdk/tool-extension.d.ts +181 -0
  86. package/dist/lib/sdk/tool-extension.js +283 -0
  87. package/dist/lib/sdk/tool-registration.d.ts +95 -0
  88. package/dist/lib/sdk/tool-registration.js +167 -0
  89. package/dist/lib/types/generate-types.d.ts +1 -0
  90. package/dist/lib/types/mcp-types.d.ts +116 -0
  91. package/dist/lib/types/mcp-types.js +5 -0
  92. package/dist/lib/types/stream-types.d.ts +30 -18
  93. package/dist/lib/types/universal-provider-options.d.ts +87 -0
  94. package/dist/lib/types/universal-provider-options.js +53 -0
  95. package/dist/mcp/config.js +28 -3
  96. package/dist/mcp/function-calling.js +1 -1
  97. package/dist/mcp/initialize-tools.d.ts +1 -1
  98. package/dist/mcp/initialize-tools.js +45 -1
  99. package/dist/mcp/initialize.js +16 -6
  100. package/dist/mcp/servers/agent/direct-tools-server.d.ts +8 -0
  101. package/dist/mcp/servers/agent/direct-tools-server.js +109 -0
  102. package/dist/mcp/servers/ai-providers/ai-core-server.js +3 -1
  103. package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
  104. package/dist/mcp/unified-registry.d.ts +4 -0
  105. package/dist/mcp/unified-registry.js +42 -9
  106. package/dist/neurolink.d.ts +156 -117
  107. package/dist/neurolink.js +619 -404
  108. package/dist/providers/amazon-bedrock.d.ts +32 -0
  109. package/dist/providers/amazon-bedrock.js +143 -0
  110. package/dist/providers/analytics-helper.js +7 -4
  111. package/dist/providers/anthropic-baseprovider.d.ts +23 -0
  112. package/dist/providers/anthropic-baseprovider.js +114 -0
  113. package/dist/providers/anthropic.d.ts +19 -43
  114. package/dist/providers/anthropic.js +81 -305
  115. package/dist/providers/azure-openai.d.ts +20 -0
  116. package/dist/providers/azure-openai.js +89 -0
  117. package/dist/providers/google-ai-studio.d.ts +23 -0
  118. package/dist/providers/google-ai-studio.js +108 -0
  119. package/dist/providers/google-vertex.d.ts +47 -0
  120. package/dist/providers/google-vertex.js +205 -0
  121. package/dist/providers/huggingFace.d.ts +32 -25
  122. package/dist/providers/huggingFace.js +96 -430
  123. package/dist/providers/index.d.ts +9 -9
  124. package/dist/providers/index.js +9 -9
  125. package/dist/providers/mcp-provider.js +4 -0
  126. package/dist/providers/mistral.d.ts +42 -0
  127. package/dist/providers/mistral.js +160 -0
  128. package/dist/providers/ollama.d.ts +52 -36
  129. package/dist/providers/ollama.js +297 -519
  130. package/dist/providers/openAI.d.ts +19 -18
  131. package/dist/providers/openAI.js +76 -276
  132. package/dist/sdk/tool-extension.d.ts +181 -0
  133. package/dist/sdk/tool-extension.js +283 -0
  134. package/dist/sdk/tool-registration.d.ts +95 -0
  135. package/dist/sdk/tool-registration.js +168 -0
  136. package/dist/types/generate-types.d.ts +1 -0
  137. package/dist/types/mcp-types.d.ts +116 -0
  138. package/dist/types/mcp-types.js +5 -0
  139. package/dist/types/stream-types.d.ts +30 -18
  140. package/dist/types/universal-provider-options.d.ts +87 -0
  141. package/dist/types/universal-provider-options.js +53 -0
  142. package/package.json +15 -10
  143. package/dist/lib/providers/agent-enhanced-provider.d.ts +0 -93
  144. package/dist/lib/providers/agent-enhanced-provider.js +0 -605
  145. package/dist/lib/providers/amazonBedrock.d.ts +0 -28
  146. package/dist/lib/providers/amazonBedrock.js +0 -364
  147. package/dist/lib/providers/azureOpenAI.d.ts +0 -42
  148. package/dist/lib/providers/azureOpenAI.js +0 -347
  149. package/dist/lib/providers/googleAIStudio.d.ts +0 -42
  150. package/dist/lib/providers/googleAIStudio.js +0 -364
  151. package/dist/lib/providers/googleVertexAI.d.ts +0 -34
  152. package/dist/lib/providers/googleVertexAI.js +0 -547
  153. package/dist/lib/providers/mistralAI.d.ts +0 -37
  154. package/dist/lib/providers/mistralAI.js +0 -325
  155. package/dist/providers/agent-enhanced-provider.d.ts +0 -93
  156. package/dist/providers/agent-enhanced-provider.js +0 -606
  157. package/dist/providers/amazonBedrock.d.ts +0 -28
  158. package/dist/providers/amazonBedrock.js +0 -364
  159. package/dist/providers/azureOpenAI.d.ts +0 -42
  160. package/dist/providers/azureOpenAI.js +0 -348
  161. package/dist/providers/googleAIStudio.d.ts +0 -42
  162. package/dist/providers/googleAIStudio.js +0 -364
  163. package/dist/providers/googleVertexAI.d.ts +0 -34
  164. package/dist/providers/googleVertexAI.js +0 -547
  165. package/dist/providers/mistralAI.d.ts +0 -37
  166. package/dist/providers/mistralAI.js +0 -325
@@ -0,0 +1,47 @@
1
+ import type { ZodType, ZodTypeDef } from "zod";
2
+ import { type Schema, type LanguageModelV1 } from "ai";
3
+ import type { AIProviderName } from "../core/types.js";
4
+ import type { StreamOptions, StreamResult } from "../types/stream-types.js";
5
+ import { BaseProvider } from "../core/base-provider.js";
6
+ /**
7
+ * Google Vertex AI Provider v2 - BaseProvider Implementation
8
+ *
9
+ * PHASE 3.5: Simple BaseProvider wrap around existing @ai-sdk/google-vertex implementation
10
+ *
11
+ * Features:
12
+ * - Extends BaseProvider for shared functionality
13
+ * - Preserves existing Google Cloud authentication
14
+ * - Maintains Anthropic model support via dynamic imports
15
+ * - Uses pre-initialized Vertex instance for efficiency
16
+ * - Enhanced error handling with setup guidance
17
+ */
18
+ export declare class GoogleVertexProvider extends BaseProvider {
19
+ private vertex;
20
+ private model;
21
+ private projectId;
22
+ private location;
23
+ private cachedAnthropicModel;
24
+ constructor(modelName?: string);
25
+ protected getProviderName(): AIProviderName;
26
+ protected getDefaultModel(): string;
27
+ /**
28
+ * Returns the Vercel AI SDK model instance for Google Vertex
29
+ * Handles both Google and Anthropic models
30
+ */
31
+ protected getAISDKModel(): Promise<LanguageModelV1>;
32
+ protected executeStream(options: StreamOptions, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<StreamResult>;
33
+ protected handleProviderError(error: any): Error;
34
+ private validateStreamOptions;
35
+ /**
36
+ * Check if Anthropic models are available
37
+ * @returns Promise<boolean> indicating if Anthropic support is available
38
+ */
39
+ hasAnthropicSupport(): Promise<boolean>;
40
+ /**
41
+ * Create an Anthropic model instance if available
42
+ * @param modelName Anthropic model name (e.g., 'claude-3-sonnet@20240229')
43
+ * @returns LanguageModelV1 instance or null if not available
44
+ */
45
+ createAnthropicModel(modelName: string): Promise<LanguageModelV1 | null>;
46
+ }
47
+ export default GoogleVertexProvider;
@@ -0,0 +1,205 @@
1
+ import { createVertex, } from "@ai-sdk/google-vertex";
2
+ import { streamText, Output } from "ai";
3
+ import { BaseProvider } from "../core/base-provider.js";
4
+ import { logger } from "../utils/logger.js";
5
+ import { createTimeoutController, TimeoutError, getDefaultTimeout, } from "../utils/timeout.js";
6
+ import { DEFAULT_MAX_TOKENS } from "../core/constants.js";
7
+ // Cache for anthropic module to avoid repeated imports
8
+ let _createVertexAnthropic = null;
9
+ let _anthropicImportAttempted = false;
10
+ // Function to dynamically import anthropic support
11
+ async function getCreateVertexAnthropic() {
12
+ if (_anthropicImportAttempted) {
13
+ return _createVertexAnthropic;
14
+ }
15
+ _anthropicImportAttempted = true;
16
+ try {
17
+ // Try to import the anthropic module - available in @ai-sdk/google-vertex ^2.2.0+
18
+ const anthropicModule = await import("@ai-sdk/google-vertex/anthropic");
19
+ _createVertexAnthropic = anthropicModule.createVertexAnthropic;
20
+ logger.debug("[GoogleVertexAI] Anthropic module successfully loaded");
21
+ return _createVertexAnthropic;
22
+ }
23
+ catch (error) {
24
+ // Anthropic module not available
25
+ logger.warn("[GoogleVertexAI] Anthropic module not available. Install @ai-sdk/google-vertex ^2.2.0 for Anthropic model support.");
26
+ return null;
27
+ }
28
+ }
29
+ // Configuration helpers
30
+ const getVertexProjectId = () => {
31
+ const projectId = process.env.GOOGLE_CLOUD_PROJECT_ID ||
32
+ process.env.VERTEX_PROJECT_ID ||
33
+ process.env.GOOGLE_VERTEX_PROJECT;
34
+ if (!projectId) {
35
+ throw new Error(`āŒ Google Vertex AI Provider Configuration Error\n\nMissing required environment variables: GOOGLE_CLOUD_PROJECT_ID or VERTEX_PROJECT_ID\n\nšŸ”§ Step 1: Get Google Cloud Credentials\n1. Visit: https://console.cloud.google.com/\n2. Create or select a project\n3. Enable Vertex AI API\n4. Set up authentication\n\nšŸ”§ Step 2: Set Environment Variables\nAdd to your .env file:\nGOOGLE_CLOUD_PROJECT_ID=your_project_id_here\nGOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json\n\nšŸ”§ Step 3: Restart Application\nRestart your application to load the new environment variables.`);
36
+ }
37
+ return projectId;
38
+ };
39
+ const getVertexLocation = () => {
40
+ return (process.env.GOOGLE_CLOUD_LOCATION ||
41
+ process.env.VERTEX_LOCATION ||
42
+ process.env.GOOGLE_VERTEX_LOCATION ||
43
+ "us-central1");
44
+ };
45
+ const getDefaultVertexModel = () => {
46
+ return process.env.VERTEX_MODEL || "gemini-1.5-pro";
47
+ };
48
+ const hasGoogleCredentials = () => {
49
+ return !!(process.env.GOOGLE_APPLICATION_CREDENTIALS ||
50
+ process.env.GOOGLE_SERVICE_ACCOUNT_KEY ||
51
+ (process.env.GOOGLE_AUTH_CLIENT_EMAIL &&
52
+ process.env.GOOGLE_AUTH_PRIVATE_KEY));
53
+ };
54
+ /**
55
+ * Google Vertex AI Provider v2 - BaseProvider Implementation
56
+ *
57
+ * PHASE 3.5: Simple BaseProvider wrap around existing @ai-sdk/google-vertex implementation
58
+ *
59
+ * Features:
60
+ * - Extends BaseProvider for shared functionality
61
+ * - Preserves existing Google Cloud authentication
62
+ * - Maintains Anthropic model support via dynamic imports
63
+ * - Uses pre-initialized Vertex instance for efficiency
64
+ * - Enhanced error handling with setup guidance
65
+ */
66
+ export class GoogleVertexProvider extends BaseProvider {
67
+ vertex;
68
+ model;
69
+ projectId;
70
+ location;
71
+ cachedAnthropicModel = null;
72
+ constructor(modelName) {
73
+ super(modelName, "vertex");
74
+ // Validate Google Cloud credentials
75
+ if (!hasGoogleCredentials()) {
76
+ throw new Error(`āŒ Google Vertex AI Provider Configuration Error\n\nMissing Google Cloud authentication. One of the following is required:\n\nšŸ”§ Option 1: Service Account Key File\nGOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json\n\nšŸ”§ Option 2: Service Account Key (Base64)\nGOOGLE_SERVICE_ACCOUNT_KEY=base64_encoded_key\n\nšŸ”§ Option 3: Individual Credentials\nGOOGLE_AUTH_CLIENT_EMAIL=your-service-account@project.iam.gserviceaccount.com\nGOOGLE_AUTH_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----...\n\nšŸ”§ Step 4: Restart Application\nRestart your application to load the new environment variables.`);
77
+ }
78
+ // Initialize Google Cloud configuration
79
+ this.projectId = getVertexProjectId();
80
+ this.location = getVertexLocation();
81
+ const vertexConfig = {
82
+ project: this.projectId,
83
+ location: this.location,
84
+ };
85
+ // Create Vertex provider instance
86
+ this.vertex = createVertex(vertexConfig);
87
+ // Pre-initialize model for efficiency
88
+ this.model = this.vertex(this.modelName || getDefaultVertexModel());
89
+ logger.debug("Google Vertex AI BaseProvider v2 initialized", {
90
+ modelName: this.modelName,
91
+ projectId: this.projectId,
92
+ location: this.location,
93
+ provider: this.providerName,
94
+ });
95
+ }
96
+ getProviderName() {
97
+ return "vertex";
98
+ }
99
+ getDefaultModel() {
100
+ return getDefaultVertexModel();
101
+ }
102
+ /**
103
+ * Returns the Vercel AI SDK model instance for Google Vertex
104
+ * Handles both Google and Anthropic models
105
+ */
106
+ async getAISDKModel() {
107
+ // Check if this is an Anthropic model
108
+ if (this.modelName && this.modelName.includes("claude")) {
109
+ // Return cached Anthropic model if available
110
+ if (this.cachedAnthropicModel) {
111
+ return this.cachedAnthropicModel;
112
+ }
113
+ // Create and cache new Anthropic model
114
+ const anthropicModel = await this.createAnthropicModel(this.modelName);
115
+ if (anthropicModel) {
116
+ this.cachedAnthropicModel = anthropicModel;
117
+ return anthropicModel;
118
+ }
119
+ // Fall back to regular model if Anthropic not available
120
+ logger.warn(`Anthropic model ${this.modelName} requested but not available, falling back to Google model`);
121
+ }
122
+ return this.model;
123
+ }
124
+ // executeGenerate removed - BaseProvider handles all generation with tools
125
+ async executeStream(options, analysisSchema) {
126
+ try {
127
+ this.validateStreamOptions(options);
128
+ const result = await streamText({
129
+ model: this.model,
130
+ prompt: options.input.text,
131
+ system: options.systemPrompt,
132
+ maxTokens: options.maxTokens || DEFAULT_MAX_TOKENS,
133
+ temperature: options.temperature,
134
+ });
135
+ return {
136
+ stream: (async function* () {
137
+ for await (const chunk of result.textStream) {
138
+ yield { content: chunk };
139
+ }
140
+ })(),
141
+ provider: this.providerName,
142
+ model: this.modelName,
143
+ };
144
+ }
145
+ catch (error) {
146
+ throw this.handleProviderError(error);
147
+ }
148
+ }
149
+ handleProviderError(error) {
150
+ if (error.name === "TimeoutError") {
151
+ return new TimeoutError(`Google Vertex AI request timed out. Consider increasing timeout or using a lighter model.`, this.defaultTimeout);
152
+ }
153
+ if (error.message?.includes("PERMISSION_DENIED")) {
154
+ return new Error(`āŒ Google Vertex AI Permission Denied\n\nYour Google Cloud credentials don't have permission to access Vertex AI.\n\nšŸ”§ Required Steps:\n1. Ensure your service account has Vertex AI User role\n2. Check if Vertex AI API is enabled in your project\n3. Verify your project ID is correct\n4. Confirm your location/region has Vertex AI available`);
155
+ }
156
+ if (error.message?.includes("NOT_FOUND")) {
157
+ return new Error(`āŒ Google Vertex AI Model Not Found\n\n${error.message}\n\nšŸ”§ Check:\n1. Model name is correct (e.g., 'gemini-1.5-pro')\n2. Model is available in your region (${this.location})\n3. Your project has access to the model\n4. Model supports your request parameters`);
158
+ }
159
+ if (error.message?.includes("QUOTA_EXCEEDED")) {
160
+ return new Error(`āŒ Google Vertex AI Quota Exceeded\n\n${error.message}\n\nšŸ”§ Solutions:\n1. Check your Vertex AI quotas in Google Cloud Console\n2. Request quota increase if needed\n3. Try a different model or reduce request frequency\n4. Consider using a different region`);
161
+ }
162
+ if (error.message?.includes("INVALID_ARGUMENT")) {
163
+ return new Error(`āŒ Google Vertex AI Invalid Request\n\n${error.message}\n\nšŸ”§ Check:\n1. Request parameters are within model limits\n2. Input text is properly formatted\n3. Temperature and other settings are valid\n4. Model supports your request type`);
164
+ }
165
+ return new Error(`āŒ Google Vertex AI Provider Error\n\n${error.message || "Unknown error occurred"}\n\nšŸ”§ Troubleshooting:\n1. Check Google Cloud credentials and permissions\n2. Verify project ID and location settings\n3. Ensure Vertex AI API is enabled\n4. Check network connectivity`);
166
+ }
167
+ validateStreamOptions(options) {
168
+ if (!options.input?.text?.trim()) {
169
+ throw new Error("Prompt is required for streaming");
170
+ }
171
+ if (options.maxTokens &&
172
+ (options.maxTokens < 1 || options.maxTokens > 8192)) {
173
+ throw new Error("maxTokens must be between 1 and 8192 for Google Vertex AI");
174
+ }
175
+ if (options.temperature &&
176
+ (options.temperature < 0 || options.temperature > 2)) {
177
+ throw new Error("temperature must be between 0 and 2");
178
+ }
179
+ }
180
+ /**
181
+ * Check if Anthropic models are available
182
+ * @returns Promise<boolean> indicating if Anthropic support is available
183
+ */
184
+ async hasAnthropicSupport() {
185
+ const createVertexAnthropic = await getCreateVertexAnthropic();
186
+ return createVertexAnthropic !== null;
187
+ }
188
+ /**
189
+ * Create an Anthropic model instance if available
190
+ * @param modelName Anthropic model name (e.g., 'claude-3-sonnet@20240229')
191
+ * @returns LanguageModelV1 instance or null if not available
192
+ */
193
+ async createAnthropicModel(modelName) {
194
+ const createVertexAnthropic = await getCreateVertexAnthropic();
195
+ if (!createVertexAnthropic) {
196
+ return null;
197
+ }
198
+ const vertexAnthropic = createVertexAnthropic({
199
+ project: this.projectId,
200
+ location: this.location,
201
+ });
202
+ return vertexAnthropic(modelName);
203
+ }
204
+ }
205
+ export default GoogleVertexProvider;
@@ -1,32 +1,39 @@
1
1
  import type { ZodType, ZodTypeDef } from "zod";
2
- import { type Schema } from "ai";
3
- import type { GenerateResult } from "../types/generate-types.js";
2
+ import { type Schema, type LanguageModelV1 } from "ai";
3
+ import type { AIProviderName } from "../core/types.js";
4
4
  import type { StreamOptions, StreamResult } from "../types/stream-types.js";
5
- import type { AIProvider, TextGenerationOptions, EnhancedGenerateResult } from "../core/types.js";
6
- export declare class HuggingFace implements AIProvider {
7
- private modelName;
8
- private client;
5
+ import { BaseProvider } from "../core/base-provider.js";
6
+ /**
7
+ * HuggingFace Provider - BaseProvider Implementation
8
+ * Using AI SDK with HuggingFace's OpenAI-compatible endpoint
9
+ */
10
+ export declare class HuggingFaceProvider extends BaseProvider {
11
+ private model;
12
+ constructor(modelName?: string);
9
13
  /**
10
- * Initializes a new instance of HuggingFace
11
- * @param modelName - Optional model name to override the default from config
14
+ * HuggingFace models currently don't properly support tool/function calling
15
+ *
16
+ * **Tested Models & Issues:**
17
+ * - microsoft/DialoGPT-medium: Describes tools instead of executing them
18
+ * - Most HF models via router endpoint: Function schema passed but not executed
19
+ * - Issue: Models treat tool definitions as conversation context rather than executable functions
20
+ *
21
+ * **Known Limitations:**
22
+ * - Tools are visible to model but treated as descriptive text
23
+ * - No proper function call response format handling
24
+ * - HuggingFace router endpoint doesn't enforce OpenAI-compatible tool execution
25
+ *
26
+ * @returns false to disable tools by default until proper implementation
12
27
  */
13
- constructor(modelName?: string | null);
28
+ supportsTools(): boolean;
29
+ protected executeStream(options: StreamOptions, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<StreamResult>;
30
+ protected getProviderName(): AIProviderName;
31
+ protected getDefaultModel(): string;
14
32
  /**
15
- * Gets the appropriate model instance
16
- * @private
33
+ * Returns the Vercel AI SDK model instance for HuggingFace
17
34
  */
18
- private getModel;
19
- /**
20
- * PRIMARY METHOD: Stream content using AI (recommended for new code)
21
- * Future-ready for multi-modal capabilities with current text focus
22
- */
23
- stream(optionsOrPrompt: StreamOptions | string, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<StreamResult>;
24
- /**
25
- * Processes text using non-streaming approach with optional schema validation
26
- * @param prompt - The input text prompt to analyze
27
- * @param analysisSchema - Optional Zod schema or Schema object for output validation
28
- * @returns Promise resolving to GenerateResult or null if operation fails
29
- */
30
- generate(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<GenerateResult>;
31
- gen(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: any): Promise<EnhancedGenerateResult | null>;
35
+ protected getAISDKModel(): LanguageModelV1;
36
+ protected handleProviderError(error: any): Error;
37
+ private validateStreamOptions;
32
38
  }
39
+ export default HuggingFaceProvider;