@juspay/neurolink 9.68.14 → 9.68.15
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 +2 -0
- package/dist/browser/neurolink.min.js +343 -343
- package/dist/lib/providers/groq.d.ts +10 -19
- package/dist/lib/providers/groq.js +29 -126
- package/dist/providers/groq.d.ts +10 -19
- package/dist/providers/groq.js +29 -126
- package/package.json +1 -1
|
@@ -1,33 +1,24 @@
|
|
|
1
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import type { LanguageModel } from "../types/index.js";
|
|
2
|
+
import type { NeurolinkCredentials } from "../types/index.js";
|
|
3
|
+
import { OpenAIChatCompletionsProvider } from "./openaiChatCompletionsBase.js";
|
|
5
4
|
/**
|
|
6
|
-
* Groq Provider
|
|
5
|
+
* Groq Provider — direct HTTP, no AI SDK.
|
|
7
6
|
*
|
|
8
7
|
* Sub-100ms inference of Llama / Mistral / Gemma at api.groq.com/openai/v1
|
|
9
8
|
* (OpenAI-compatible). Best for low-latency tier; trade-off vs other open
|
|
10
9
|
* model hosts is throughput latency, not quality.
|
|
11
10
|
*
|
|
11
|
+
* All request/stream/tool-loop orchestration lives in
|
|
12
|
+
* `OpenAIChatCompletionsProvider`; this class only declares configuration
|
|
13
|
+
* and provider-specific error mapping.
|
|
14
|
+
*
|
|
12
15
|
* @see https://console.groq.com/docs/quickstart
|
|
13
16
|
*/
|
|
14
|
-
export declare class GroqProvider extends
|
|
15
|
-
private model;
|
|
16
|
-
private apiKey;
|
|
17
|
-
private baseURL;
|
|
17
|
+
export declare class GroqProvider extends OpenAIChatCompletionsProvider {
|
|
18
18
|
constructor(modelName?: string, sdk?: unknown, _region?: string, credentials?: NeurolinkCredentials["groq"]);
|
|
19
|
-
protected executeStream(options: StreamOptions, _analysisSchema?: ValidationSchema): Promise<StreamResult>;
|
|
20
|
-
private executeStreamInner;
|
|
21
19
|
protected getProviderName(): AIProviderName;
|
|
22
20
|
protected getDefaultModel(): string;
|
|
23
|
-
protected
|
|
21
|
+
protected getFallbackModelName(): string;
|
|
22
|
+
protected getFallbackModels(): string[];
|
|
24
23
|
protected formatProviderError(error: unknown): Error;
|
|
25
|
-
validateConfiguration(): Promise<boolean>;
|
|
26
|
-
getConfiguration(): {
|
|
27
|
-
provider: AIProviderName;
|
|
28
|
-
model: string;
|
|
29
|
-
defaultModel: string;
|
|
30
|
-
baseURL: string;
|
|
31
|
-
};
|
|
32
24
|
}
|
|
33
|
-
export default GroqProvider;
|
|
@@ -1,144 +1,59 @@
|
|
|
1
|
-
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
1
|
import { GroqModels } from "../constants/enums.js";
|
|
3
|
-
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
|
-
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
5
|
-
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
6
|
-
import { isNeuroLink } from "../neurolink.js";
|
|
7
|
-
import { createLoggingFetch } from "../utils/loggingFetch.js";
|
|
8
|
-
import { tracers, ATTR, withClientStreamSpan } from "../telemetry/index.js";
|
|
9
2
|
import { AuthenticationError, InvalidModelError, ProviderError, RateLimitError, } from "../types/index.js";
|
|
10
3
|
import { logger } from "../utils/logger.js";
|
|
11
4
|
import { createGroqConfig, getProviderModel, validateApiKey, } from "../utils/providerConfig.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
15
|
-
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
-
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
-
import { streamText } from "../utils/generation.js";
|
|
5
|
+
import { TimeoutError } from "../utils/timeout.js";
|
|
6
|
+
import { OpenAIChatCompletionsProvider } from "./openaiChatCompletionsBase.js";
|
|
18
7
|
const GROQ_DEFAULT_BASE_URL = "https://api.groq.com/openai/v1";
|
|
19
8
|
const getGroqApiKey = () => validateApiKey(createGroqConfig());
|
|
20
9
|
const getDefaultGroqModel = () => getProviderModel("GROQ_MODEL", GroqModels.LLAMA_3_3_70B_VERSATILE);
|
|
21
10
|
/**
|
|
22
|
-
* Groq Provider
|
|
11
|
+
* Groq Provider — direct HTTP, no AI SDK.
|
|
23
12
|
*
|
|
24
13
|
* Sub-100ms inference of Llama / Mistral / Gemma at api.groq.com/openai/v1
|
|
25
14
|
* (OpenAI-compatible). Best for low-latency tier; trade-off vs other open
|
|
26
15
|
* model hosts is throughput latency, not quality.
|
|
27
16
|
*
|
|
17
|
+
* All request/stream/tool-loop orchestration lives in
|
|
18
|
+
* `OpenAIChatCompletionsProvider`; this class only declares configuration
|
|
19
|
+
* and provider-specific error mapping.
|
|
20
|
+
*
|
|
28
21
|
* @see https://console.groq.com/docs/quickstart
|
|
29
22
|
*/
|
|
30
|
-
export class GroqProvider extends
|
|
31
|
-
model;
|
|
32
|
-
apiKey;
|
|
33
|
-
baseURL;
|
|
23
|
+
export class GroqProvider extends OpenAIChatCompletionsProvider {
|
|
34
24
|
constructor(modelName, sdk, _region, credentials) {
|
|
35
|
-
const validatedNeurolink = isNeuroLink(sdk) ? sdk : undefined;
|
|
36
|
-
super(modelName, "groq", validatedNeurolink);
|
|
37
25
|
const overrideApiKey = credentials?.apiKey?.trim();
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
GROQ_DEFAULT_BASE_URL;
|
|
46
|
-
const groq = createOpenAI({
|
|
47
|
-
apiKey: this.apiKey,
|
|
48
|
-
baseURL: this.baseURL,
|
|
49
|
-
fetch: createLoggingFetch("groq"),
|
|
50
|
-
});
|
|
51
|
-
this.model = groq.chat(this.modelName);
|
|
26
|
+
const apiKey = overrideApiKey && overrideApiKey.length > 0
|
|
27
|
+
? overrideApiKey
|
|
28
|
+
: getGroqApiKey();
|
|
29
|
+
const baseURL = credentials?.baseURL?.trim() ||
|
|
30
|
+
process.env.GROQ_BASE_URL?.trim() ||
|
|
31
|
+
GROQ_DEFAULT_BASE_URL;
|
|
32
|
+
super("groq", modelName, sdk, { baseURL, apiKey });
|
|
52
33
|
logger.debug("Groq Provider initialized", {
|
|
53
34
|
modelName: this.modelName,
|
|
54
35
|
providerName: this.providerName,
|
|
55
|
-
baseURL: this.baseURL,
|
|
36
|
+
baseURL: this.config.baseURL,
|
|
56
37
|
});
|
|
57
38
|
}
|
|
58
|
-
async executeStream(options, _analysisSchema) {
|
|
59
|
-
return withClientStreamSpan({
|
|
60
|
-
name: "neurolink.provider.stream",
|
|
61
|
-
tracer: tracers.provider,
|
|
62
|
-
attributes: {
|
|
63
|
-
[ATTR.GEN_AI_SYSTEM]: "groq",
|
|
64
|
-
[ATTR.GEN_AI_MODEL]: this.modelName,
|
|
65
|
-
[ATTR.GEN_AI_OPERATION]: "stream",
|
|
66
|
-
[ATTR.NL_STREAM_MODE]: true,
|
|
67
|
-
},
|
|
68
|
-
}, async () => this.executeStreamInner(options), (r) => r.stream, (r, wrapped) => ({ ...r, stream: wrapped }));
|
|
69
|
-
}
|
|
70
|
-
async executeStreamInner(options) {
|
|
71
|
-
this.validateStreamOptions(options);
|
|
72
|
-
// Resolve per-call credentials first, then fall back to instance-level.
|
|
73
|
-
const perCallCreds = options.credentials?.groq;
|
|
74
|
-
const effectiveApiKey = perCallCreds?.apiKey?.trim() || this.apiKey;
|
|
75
|
-
const effectiveBaseURL = perCallCreds?.baseURL || this.baseURL;
|
|
76
|
-
const startTime = Date.now();
|
|
77
|
-
const timeout = this.getTimeout(options);
|
|
78
|
-
const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
|
|
79
|
-
try {
|
|
80
|
-
// Use the canonical BaseProvider helper: merges base tools (MCP/built-in)
|
|
81
|
-
// with user-provided tools (RAG, etc.) and applies per-call filtering.
|
|
82
|
-
const shouldUseTools = !options.disableTools && this.supportsTools();
|
|
83
|
-
const tools = await this.getToolsForStream(options);
|
|
84
|
-
const messages = await this.buildMessagesForStream(options);
|
|
85
|
-
// When per-call credentials differ from instance, build a fresh client.
|
|
86
|
-
const hasDifferentCreds = effectiveApiKey !== this.apiKey || effectiveBaseURL !== this.baseURL;
|
|
87
|
-
const model = hasDifferentCreds
|
|
88
|
-
? createOpenAI({
|
|
89
|
-
apiKey: effectiveApiKey,
|
|
90
|
-
baseURL: effectiveBaseURL,
|
|
91
|
-
fetch: createLoggingFetch("groq"),
|
|
92
|
-
}).chat(this.modelName)
|
|
93
|
-
: await this.getAISDKModelWithMiddleware(options);
|
|
94
|
-
const result = await streamText({
|
|
95
|
-
model,
|
|
96
|
-
messages,
|
|
97
|
-
temperature: options.temperature,
|
|
98
|
-
maxOutputTokens: options.maxTokens,
|
|
99
|
-
tools,
|
|
100
|
-
stopWhen: stepCountIs(options.maxSteps || DEFAULT_MAX_STEPS),
|
|
101
|
-
toolChoice: resolveToolChoice(options, tools, shouldUseTools),
|
|
102
|
-
abortSignal: composeAbortSignals(options.abortSignal, timeoutController?.controller.signal),
|
|
103
|
-
experimental_telemetry: this.telemetryHandler.getTelemetryConfig(options),
|
|
104
|
-
experimental_repairToolCall: this.getToolCallRepairFn(options),
|
|
105
|
-
onStepFinish: ({ toolCalls, toolResults }) => {
|
|
106
|
-
emitToolEndFromStepFinish(this.neurolink?.getEventEmitter(), toolResults);
|
|
107
|
-
this.handleToolExecutionStorage(toolCalls, toolResults, options, new Date()).catch((error) => {
|
|
108
|
-
logger.warn("[GroqProvider] Failed to store tool executions", {
|
|
109
|
-
provider: this.providerName,
|
|
110
|
-
error: error instanceof Error ? error.message : String(error),
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
timeoutController?.cleanup();
|
|
116
|
-
const transformedStream = this.createTextStream(result);
|
|
117
|
-
const analyticsPromise = streamAnalyticsCollector.createAnalytics(this.providerName, this.modelName, toAnalyticsStreamResult(result), Date.now() - startTime, {
|
|
118
|
-
requestId: `groq-stream-${Date.now()}`,
|
|
119
|
-
streamingMode: true,
|
|
120
|
-
});
|
|
121
|
-
return {
|
|
122
|
-
stream: transformedStream,
|
|
123
|
-
provider: this.providerName,
|
|
124
|
-
model: this.modelName,
|
|
125
|
-
analytics: analyticsPromise,
|
|
126
|
-
metadata: { startTime, streamId: `groq-${Date.now()}` },
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
timeoutController?.cleanup();
|
|
131
|
-
throw this.handleProviderError(error);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
39
|
getProviderName() {
|
|
135
|
-
return
|
|
40
|
+
return "groq";
|
|
136
41
|
}
|
|
137
42
|
getDefaultModel() {
|
|
138
43
|
return getDefaultGroqModel();
|
|
139
44
|
}
|
|
140
|
-
|
|
141
|
-
return
|
|
45
|
+
getFallbackModelName() {
|
|
46
|
+
return GroqModels.LLAMA_3_1_8B_INSTANT;
|
|
47
|
+
}
|
|
48
|
+
getFallbackModels() {
|
|
49
|
+
return [
|
|
50
|
+
GroqModels.LLAMA_3_3_70B_VERSATILE,
|
|
51
|
+
GroqModels.LLAMA_3_1_8B_INSTANT,
|
|
52
|
+
GroqModels.GEMMA_2_9B_IT,
|
|
53
|
+
GroqModels.MIXTRAL_8X7B_32768,
|
|
54
|
+
GroqModels.LLAMA_3_2_90B_VISION_PREVIEW,
|
|
55
|
+
GroqModels.LLAMA_3_2_11B_VISION_PREVIEW,
|
|
56
|
+
];
|
|
142
57
|
}
|
|
143
58
|
formatProviderError(error) {
|
|
144
59
|
if (error instanceof TimeoutError) {
|
|
@@ -166,17 +81,5 @@ export class GroqProvider extends BaseProvider {
|
|
|
166
81
|
}
|
|
167
82
|
return new ProviderError(`Groq error: ${message}`, "groq");
|
|
168
83
|
}
|
|
169
|
-
async validateConfiguration() {
|
|
170
|
-
return typeof this.apiKey === "string" && this.apiKey.trim().length > 0;
|
|
171
|
-
}
|
|
172
|
-
getConfiguration() {
|
|
173
|
-
return {
|
|
174
|
-
provider: this.providerName,
|
|
175
|
-
model: this.modelName,
|
|
176
|
-
defaultModel: getDefaultGroqModel(),
|
|
177
|
-
baseURL: this.baseURL,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
84
|
}
|
|
181
|
-
export default GroqProvider;
|
|
182
85
|
//# sourceMappingURL=groq.js.map
|
package/dist/providers/groq.d.ts
CHANGED
|
@@ -1,33 +1,24 @@
|
|
|
1
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import type { LanguageModel } from "../types/index.js";
|
|
2
|
+
import type { NeurolinkCredentials } from "../types/index.js";
|
|
3
|
+
import { OpenAIChatCompletionsProvider } from "./openaiChatCompletionsBase.js";
|
|
5
4
|
/**
|
|
6
|
-
* Groq Provider
|
|
5
|
+
* Groq Provider — direct HTTP, no AI SDK.
|
|
7
6
|
*
|
|
8
7
|
* Sub-100ms inference of Llama / Mistral / Gemma at api.groq.com/openai/v1
|
|
9
8
|
* (OpenAI-compatible). Best for low-latency tier; trade-off vs other open
|
|
10
9
|
* model hosts is throughput latency, not quality.
|
|
11
10
|
*
|
|
11
|
+
* All request/stream/tool-loop orchestration lives in
|
|
12
|
+
* `OpenAIChatCompletionsProvider`; this class only declares configuration
|
|
13
|
+
* and provider-specific error mapping.
|
|
14
|
+
*
|
|
12
15
|
* @see https://console.groq.com/docs/quickstart
|
|
13
16
|
*/
|
|
14
|
-
export declare class GroqProvider extends
|
|
15
|
-
private model;
|
|
16
|
-
private apiKey;
|
|
17
|
-
private baseURL;
|
|
17
|
+
export declare class GroqProvider extends OpenAIChatCompletionsProvider {
|
|
18
18
|
constructor(modelName?: string, sdk?: unknown, _region?: string, credentials?: NeurolinkCredentials["groq"]);
|
|
19
|
-
protected executeStream(options: StreamOptions, _analysisSchema?: ValidationSchema): Promise<StreamResult>;
|
|
20
|
-
private executeStreamInner;
|
|
21
19
|
protected getProviderName(): AIProviderName;
|
|
22
20
|
protected getDefaultModel(): string;
|
|
23
|
-
protected
|
|
21
|
+
protected getFallbackModelName(): string;
|
|
22
|
+
protected getFallbackModels(): string[];
|
|
24
23
|
protected formatProviderError(error: unknown): Error;
|
|
25
|
-
validateConfiguration(): Promise<boolean>;
|
|
26
|
-
getConfiguration(): {
|
|
27
|
-
provider: AIProviderName;
|
|
28
|
-
model: string;
|
|
29
|
-
defaultModel: string;
|
|
30
|
-
baseURL: string;
|
|
31
|
-
};
|
|
32
24
|
}
|
|
33
|
-
export default GroqProvider;
|
package/dist/providers/groq.js
CHANGED
|
@@ -1,144 +1,59 @@
|
|
|
1
|
-
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
1
|
import { GroqModels } from "../constants/enums.js";
|
|
3
|
-
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
|
-
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
5
|
-
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
6
|
-
import { isNeuroLink } from "../neurolink.js";
|
|
7
|
-
import { createLoggingFetch } from "../utils/loggingFetch.js";
|
|
8
|
-
import { tracers, ATTR, withClientStreamSpan } from "../telemetry/index.js";
|
|
9
2
|
import { AuthenticationError, InvalidModelError, ProviderError, RateLimitError, } from "../types/index.js";
|
|
10
3
|
import { logger } from "../utils/logger.js";
|
|
11
4
|
import { createGroqConfig, getProviderModel, validateApiKey, } from "../utils/providerConfig.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
15
|
-
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
-
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
-
import { streamText } from "../utils/generation.js";
|
|
5
|
+
import { TimeoutError } from "../utils/timeout.js";
|
|
6
|
+
import { OpenAIChatCompletionsProvider } from "./openaiChatCompletionsBase.js";
|
|
18
7
|
const GROQ_DEFAULT_BASE_URL = "https://api.groq.com/openai/v1";
|
|
19
8
|
const getGroqApiKey = () => validateApiKey(createGroqConfig());
|
|
20
9
|
const getDefaultGroqModel = () => getProviderModel("GROQ_MODEL", GroqModels.LLAMA_3_3_70B_VERSATILE);
|
|
21
10
|
/**
|
|
22
|
-
* Groq Provider
|
|
11
|
+
* Groq Provider — direct HTTP, no AI SDK.
|
|
23
12
|
*
|
|
24
13
|
* Sub-100ms inference of Llama / Mistral / Gemma at api.groq.com/openai/v1
|
|
25
14
|
* (OpenAI-compatible). Best for low-latency tier; trade-off vs other open
|
|
26
15
|
* model hosts is throughput latency, not quality.
|
|
27
16
|
*
|
|
17
|
+
* All request/stream/tool-loop orchestration lives in
|
|
18
|
+
* `OpenAIChatCompletionsProvider`; this class only declares configuration
|
|
19
|
+
* and provider-specific error mapping.
|
|
20
|
+
*
|
|
28
21
|
* @see https://console.groq.com/docs/quickstart
|
|
29
22
|
*/
|
|
30
|
-
export class GroqProvider extends
|
|
31
|
-
model;
|
|
32
|
-
apiKey;
|
|
33
|
-
baseURL;
|
|
23
|
+
export class GroqProvider extends OpenAIChatCompletionsProvider {
|
|
34
24
|
constructor(modelName, sdk, _region, credentials) {
|
|
35
|
-
const validatedNeurolink = isNeuroLink(sdk) ? sdk : undefined;
|
|
36
|
-
super(modelName, "groq", validatedNeurolink);
|
|
37
25
|
const overrideApiKey = credentials?.apiKey?.trim();
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
GROQ_DEFAULT_BASE_URL;
|
|
46
|
-
const groq = createOpenAI({
|
|
47
|
-
apiKey: this.apiKey,
|
|
48
|
-
baseURL: this.baseURL,
|
|
49
|
-
fetch: createLoggingFetch("groq"),
|
|
50
|
-
});
|
|
51
|
-
this.model = groq.chat(this.modelName);
|
|
26
|
+
const apiKey = overrideApiKey && overrideApiKey.length > 0
|
|
27
|
+
? overrideApiKey
|
|
28
|
+
: getGroqApiKey();
|
|
29
|
+
const baseURL = credentials?.baseURL?.trim() ||
|
|
30
|
+
process.env.GROQ_BASE_URL?.trim() ||
|
|
31
|
+
GROQ_DEFAULT_BASE_URL;
|
|
32
|
+
super("groq", modelName, sdk, { baseURL, apiKey });
|
|
52
33
|
logger.debug("Groq Provider initialized", {
|
|
53
34
|
modelName: this.modelName,
|
|
54
35
|
providerName: this.providerName,
|
|
55
|
-
baseURL: this.baseURL,
|
|
36
|
+
baseURL: this.config.baseURL,
|
|
56
37
|
});
|
|
57
38
|
}
|
|
58
|
-
async executeStream(options, _analysisSchema) {
|
|
59
|
-
return withClientStreamSpan({
|
|
60
|
-
name: "neurolink.provider.stream",
|
|
61
|
-
tracer: tracers.provider,
|
|
62
|
-
attributes: {
|
|
63
|
-
[ATTR.GEN_AI_SYSTEM]: "groq",
|
|
64
|
-
[ATTR.GEN_AI_MODEL]: this.modelName,
|
|
65
|
-
[ATTR.GEN_AI_OPERATION]: "stream",
|
|
66
|
-
[ATTR.NL_STREAM_MODE]: true,
|
|
67
|
-
},
|
|
68
|
-
}, async () => this.executeStreamInner(options), (r) => r.stream, (r, wrapped) => ({ ...r, stream: wrapped }));
|
|
69
|
-
}
|
|
70
|
-
async executeStreamInner(options) {
|
|
71
|
-
this.validateStreamOptions(options);
|
|
72
|
-
// Resolve per-call credentials first, then fall back to instance-level.
|
|
73
|
-
const perCallCreds = options.credentials?.groq;
|
|
74
|
-
const effectiveApiKey = perCallCreds?.apiKey?.trim() || this.apiKey;
|
|
75
|
-
const effectiveBaseURL = perCallCreds?.baseURL || this.baseURL;
|
|
76
|
-
const startTime = Date.now();
|
|
77
|
-
const timeout = this.getTimeout(options);
|
|
78
|
-
const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
|
|
79
|
-
try {
|
|
80
|
-
// Use the canonical BaseProvider helper: merges base tools (MCP/built-in)
|
|
81
|
-
// with user-provided tools (RAG, etc.) and applies per-call filtering.
|
|
82
|
-
const shouldUseTools = !options.disableTools && this.supportsTools();
|
|
83
|
-
const tools = await this.getToolsForStream(options);
|
|
84
|
-
const messages = await this.buildMessagesForStream(options);
|
|
85
|
-
// When per-call credentials differ from instance, build a fresh client.
|
|
86
|
-
const hasDifferentCreds = effectiveApiKey !== this.apiKey || effectiveBaseURL !== this.baseURL;
|
|
87
|
-
const model = hasDifferentCreds
|
|
88
|
-
? createOpenAI({
|
|
89
|
-
apiKey: effectiveApiKey,
|
|
90
|
-
baseURL: effectiveBaseURL,
|
|
91
|
-
fetch: createLoggingFetch("groq"),
|
|
92
|
-
}).chat(this.modelName)
|
|
93
|
-
: await this.getAISDKModelWithMiddleware(options);
|
|
94
|
-
const result = await streamText({
|
|
95
|
-
model,
|
|
96
|
-
messages,
|
|
97
|
-
temperature: options.temperature,
|
|
98
|
-
maxOutputTokens: options.maxTokens,
|
|
99
|
-
tools,
|
|
100
|
-
stopWhen: stepCountIs(options.maxSteps || DEFAULT_MAX_STEPS),
|
|
101
|
-
toolChoice: resolveToolChoice(options, tools, shouldUseTools),
|
|
102
|
-
abortSignal: composeAbortSignals(options.abortSignal, timeoutController?.controller.signal),
|
|
103
|
-
experimental_telemetry: this.telemetryHandler.getTelemetryConfig(options),
|
|
104
|
-
experimental_repairToolCall: this.getToolCallRepairFn(options),
|
|
105
|
-
onStepFinish: ({ toolCalls, toolResults }) => {
|
|
106
|
-
emitToolEndFromStepFinish(this.neurolink?.getEventEmitter(), toolResults);
|
|
107
|
-
this.handleToolExecutionStorage(toolCalls, toolResults, options, new Date()).catch((error) => {
|
|
108
|
-
logger.warn("[GroqProvider] Failed to store tool executions", {
|
|
109
|
-
provider: this.providerName,
|
|
110
|
-
error: error instanceof Error ? error.message : String(error),
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
timeoutController?.cleanup();
|
|
116
|
-
const transformedStream = this.createTextStream(result);
|
|
117
|
-
const analyticsPromise = streamAnalyticsCollector.createAnalytics(this.providerName, this.modelName, toAnalyticsStreamResult(result), Date.now() - startTime, {
|
|
118
|
-
requestId: `groq-stream-${Date.now()}`,
|
|
119
|
-
streamingMode: true,
|
|
120
|
-
});
|
|
121
|
-
return {
|
|
122
|
-
stream: transformedStream,
|
|
123
|
-
provider: this.providerName,
|
|
124
|
-
model: this.modelName,
|
|
125
|
-
analytics: analyticsPromise,
|
|
126
|
-
metadata: { startTime, streamId: `groq-${Date.now()}` },
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
timeoutController?.cleanup();
|
|
131
|
-
throw this.handleProviderError(error);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
39
|
getProviderName() {
|
|
135
|
-
return
|
|
40
|
+
return "groq";
|
|
136
41
|
}
|
|
137
42
|
getDefaultModel() {
|
|
138
43
|
return getDefaultGroqModel();
|
|
139
44
|
}
|
|
140
|
-
|
|
141
|
-
return
|
|
45
|
+
getFallbackModelName() {
|
|
46
|
+
return GroqModels.LLAMA_3_1_8B_INSTANT;
|
|
47
|
+
}
|
|
48
|
+
getFallbackModels() {
|
|
49
|
+
return [
|
|
50
|
+
GroqModels.LLAMA_3_3_70B_VERSATILE,
|
|
51
|
+
GroqModels.LLAMA_3_1_8B_INSTANT,
|
|
52
|
+
GroqModels.GEMMA_2_9B_IT,
|
|
53
|
+
GroqModels.MIXTRAL_8X7B_32768,
|
|
54
|
+
GroqModels.LLAMA_3_2_90B_VISION_PREVIEW,
|
|
55
|
+
GroqModels.LLAMA_3_2_11B_VISION_PREVIEW,
|
|
56
|
+
];
|
|
142
57
|
}
|
|
143
58
|
formatProviderError(error) {
|
|
144
59
|
if (error instanceof TimeoutError) {
|
|
@@ -166,16 +81,4 @@ export class GroqProvider extends BaseProvider {
|
|
|
166
81
|
}
|
|
167
82
|
return new ProviderError(`Groq error: ${message}`, "groq");
|
|
168
83
|
}
|
|
169
|
-
async validateConfiguration() {
|
|
170
|
-
return typeof this.apiKey === "string" && this.apiKey.trim().length > 0;
|
|
171
|
-
}
|
|
172
|
-
getConfiguration() {
|
|
173
|
-
return {
|
|
174
|
-
provider: this.providerName,
|
|
175
|
-
model: this.modelName,
|
|
176
|
-
defaultModel: getDefaultGroqModel(),
|
|
177
|
-
baseURL: this.baseURL,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
84
|
}
|
|
181
|
-
export default GroqProvider;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "9.68.
|
|
3
|
+
"version": "9.68.15",
|
|
4
4
|
"packageManager": "pnpm@10.15.1",
|
|
5
5
|
"description": "Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applications with 21+ providers: OpenAI, Anthropic, Google AI Studio, Google Vertex, AWS Bedrock, Azure OpenAI, Mistral, LiteLLM, SageMaker, Hugging Face, Ollama, OpenAI-compatible, OpenRouter, DeepSeek, NVIDIA NIM, LM Studio, llama.cpp, plus voice (OpenAI TTS, ElevenLabs, Deepgram, Azure Speech).",
|
|
6
6
|
"author": {
|