@umituz/web-ai 1.0.1 → 1.0.3
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/dist/cancellation-error-CKcZRhFg.d.ts +129 -0
- package/dist/cancellation-error-DwHrDKBz.d.cts +129 -0
- package/dist/content/index.cjs +914 -37
- package/dist/content/index.cjs.map +1 -1
- package/dist/content/index.d.cts +1 -1
- package/dist/content/index.d.ts +1 -1
- package/dist/content/index.js +914 -37
- package/dist/content/index.js.map +1 -1
- package/dist/core/index.cjs +10 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +13 -3
- package/dist/core/index.d.ts +13 -3
- package/dist/core/index.js +9 -1
- package/dist/core/index.js.map +1 -1
- package/dist/{create-ai-DXEoke8-.d.ts → create-ai-9PW752z8.d.ts} +11 -1
- package/dist/{create-ai-DOI9jD3v.d.cts → create-ai-CXYKPK6G.d.cts} +11 -1
- package/dist/hooks/index.cjs +1192 -39
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +64 -2
- package/dist/hooks/index.d.ts +64 -2
- package/dist/hooks/index.js +1188 -40
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +1230 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1201 -38
- package/dist/index.js.map +1 -1
- package/dist/providers/index.cjs +1505 -37
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.d.cts +115 -8
- package/dist/providers/index.d.ts +115 -8
- package/dist/providers/index.js +1478 -38
- package/dist/providers/index.js.map +1 -1
- package/package.json +11 -1
|
@@ -2,10 +2,13 @@ import { C as CostEstimateRequest, b as ITextProvider, I as IMediaProvider } fro
|
|
|
2
2
|
export { A as AnyProvider, a as IProviderBase, P as ProviderCapability, c as ProviderFactory, d as ProviderFactoryConfig, i as isMediaProvider, e as isTextProvider } from '../provider.factory-BxsfK4WW.cjs';
|
|
3
3
|
import { P as ProviderHealth, c as TextTier, T as TextRequest, G as GenerationResult, b as StructuredTextRequest, a as StructuredGeneration, S as StreamCallbacks, F as FinishReason, C as ChatMessage, d as TokenUsage } from '../index-fXjxTR5W.cjs';
|
|
4
4
|
import { A as AIError, c as TierModelMap } from '../index-DKHNcMbl.cjs';
|
|
5
|
-
import { h as AnthropicProviderConfig, e as AnthropicEffort,
|
|
6
|
-
export { A as AIProviderConfig, a as ANTHROPIC_API_VERSION, b as ANTHROPIC_DEFAULT_MAX_TOKENS, c as ANTHROPIC_MODELS, d as ANTHROPIC_TIERS, j as AnthropicStreamEvent, G as GroqChatChunk, o as createAI } from '../create-ai-
|
|
5
|
+
import { h as AnthropicProviderConfig, e as AnthropicEffort, x as AnthropicMessage, f as AnthropicMessagesRequest, i as AnthropicStopReason, g as AnthropicMessagesResponse, t as GroqProviderConfig, r as GroqMessage, q as GroqGenerationConfig, k as GroqChatRequest, l as GroqChatResponse, S as StreamRequestOptions$1, s as GroqMessageRole, u as GroqReasoningEffort } from '../create-ai-CXYKPK6G.cjs';
|
|
6
|
+
export { A as AIProviderConfig, a as ANTHROPIC_API_VERSION, b as ANTHROPIC_DEFAULT_MAX_TOKENS, c as ANTHROPIC_MODELS, d as ANTHROPIC_TIERS, j as AnthropicStreamEvent, G as GroqChatChunk, m as GroqChoice, n as GroqChunkChoice, o as GroqConfig, p as GroqErrorResponse, v as GroqUsage, w as createAI } from '../create-ai-CXYKPK6G.cjs';
|
|
7
7
|
import { b as CacheStats } from '../cache-manager-Df9LLYGA.cjs';
|
|
8
8
|
import { b as RetryManager, a as RequestQueue, R as RequestDeduplicator } from '../request-deduplicator.util-NDo0_n1y.cjs';
|
|
9
|
+
import { b as IGroqHttpClient, l as TextGenerationService, a as GenerationStage, f as PrunaModelId, h as PrunaPredictionResponse, n as TextToVideoInput, G as GenerateOptions, j as PrunaResult, e as PrunaInput } from '../cancellation-error-DwHrDKBz.cjs';
|
|
10
|
+
export { C as CancellationError, I as IGroqChatService, c as ImageToImageInput, d as ImageToVideoInput, P as PrunaAspectRatio, g as PrunaOutput, i as PrunaResolution, S as StreamingCallbacks, k as StructuredGenerationOptions, T as TextGenerationOptions, m as TextToImageInput } from '../cancellation-error-DwHrDKBz.cjs';
|
|
11
|
+
import { d as ChatService } from '../chat.service-CL1qtYxe.cjs';
|
|
9
12
|
import { c as GeminiConfig, I as ImageGenerationRequest, G as GeneratedContent, V as VideoGenerationRequest, a as ImageToVideoRequest, b as VideoToVideoRequest, F as FalConfig, P as PrunaConfig } from '../ProviderConfig-DIFa9nmG.cjs';
|
|
10
13
|
|
|
11
14
|
interface BaseProviderConfig {
|
|
@@ -175,6 +178,24 @@ declare const GROQ_MODELS: {
|
|
|
175
178
|
* the heavy lifting. Override per instance via `models` in provider config.
|
|
176
179
|
*/
|
|
177
180
|
declare const GROQ_TIERS: TierModelMap;
|
|
181
|
+
declare const DEFAULT_GENERATION_CONFIG: {
|
|
182
|
+
readonly temperature: 0.7;
|
|
183
|
+
readonly maxTokens: 1024;
|
|
184
|
+
readonly topP: 1;
|
|
185
|
+
};
|
|
186
|
+
declare const DEFAULT_MODELS: {
|
|
187
|
+
readonly TEXT: "llama-3.1-8b-instant";
|
|
188
|
+
readonly FAST: "llama-3.1-8b-instant";
|
|
189
|
+
readonly EXPERIMENTAL: "openai/gpt-oss-20b";
|
|
190
|
+
};
|
|
191
|
+
declare const DEFAULT_BASE_URL: "https://api.groq.com/openai/v1";
|
|
192
|
+
declare const API_ENDPOINTS: {
|
|
193
|
+
readonly CHAT: "/chat/completions";
|
|
194
|
+
};
|
|
195
|
+
declare const TIMEOUTS: {
|
|
196
|
+
readonly DEFAULT: 30000;
|
|
197
|
+
readonly STREAMING: 60000;
|
|
198
|
+
};
|
|
178
199
|
|
|
179
200
|
declare class GroqChatRequestBuilder {
|
|
180
201
|
private readonly model;
|
|
@@ -191,15 +212,26 @@ declare class GroqChatRequestBuilder {
|
|
|
191
212
|
build(): GroqChatRequest;
|
|
192
213
|
}
|
|
193
214
|
|
|
215
|
+
declare class GroqConfigStore {
|
|
216
|
+
private config;
|
|
217
|
+
initialize(config: GroqProviderConfig): GroqProviderConfig;
|
|
218
|
+
get(): GroqProviderConfig;
|
|
219
|
+
getOrNull(): GroqProviderConfig | null;
|
|
220
|
+
isInitialized(): boolean;
|
|
221
|
+
setApiKey(apiKey: string): void;
|
|
222
|
+
reset(): void;
|
|
223
|
+
}
|
|
224
|
+
|
|
194
225
|
/**
|
|
195
226
|
* Raw HTTP transport for Groq's OpenAI-compatible chat/completions endpoint.
|
|
196
227
|
* All failures leave here as core AIError with the right AIErrorType —
|
|
197
228
|
* callers up the stack only ever see the neutral taxonomy.
|
|
198
229
|
*/
|
|
199
230
|
declare class GroqHttpTransport {
|
|
200
|
-
private readonly
|
|
231
|
+
private readonly configSource;
|
|
201
232
|
private readonly pendingAbortControllers;
|
|
202
|
-
constructor(
|
|
233
|
+
constructor(configSource: GroqProviderConfig | GroqConfigStore);
|
|
234
|
+
private getConfig;
|
|
203
235
|
cancelPendingRequests(): void;
|
|
204
236
|
postChatCompletion(request: GroqChatRequest): Promise<GroqChatResponse>;
|
|
205
237
|
streamChatCompletion(request: GroqChatRequest, options?: StreamRequestOptions$1): Promise<ReadableStream<Uint8Array>>;
|
|
@@ -211,6 +243,7 @@ declare class GroqHttpTransport {
|
|
|
211
243
|
}
|
|
212
244
|
|
|
213
245
|
interface GroqHttpClientDeps {
|
|
246
|
+
readonly configStore?: GroqConfigStore;
|
|
214
247
|
readonly transport?: GroqHttpTransport;
|
|
215
248
|
readonly retryManager?: RetryManager;
|
|
216
249
|
readonly queue?: RequestQueue;
|
|
@@ -219,16 +252,24 @@ interface GroqHttpClientDeps {
|
|
|
219
252
|
/**
|
|
220
253
|
* Groq HTTP client with the ported strategy stack: identical concurrent
|
|
221
254
|
* requests are deduplicated, transient failures retried with backoff, and
|
|
222
|
-
* everything is funneled through a priority queue.
|
|
223
|
-
*
|
|
255
|
+
* everything is funneled through a priority queue.
|
|
256
|
+
*
|
|
257
|
+
* Supports both standalone initialization `new GroqHttpClient(config)`
|
|
258
|
+
* and deferred initialization `const c = new GroqHttpClient(); c.initialize(config)`.
|
|
224
259
|
*/
|
|
225
260
|
declare class GroqHttpClient {
|
|
261
|
+
private readonly configStore;
|
|
226
262
|
private readonly transport;
|
|
227
263
|
private readonly executor;
|
|
228
|
-
constructor(
|
|
264
|
+
constructor(configOrDeps?: GroqProviderConfig | GroqHttpClientDeps, maybeDeps?: GroqHttpClientDeps);
|
|
265
|
+
initialize(config: GroqProviderConfig): void;
|
|
266
|
+
isInitialized(): boolean;
|
|
267
|
+
getApiKey(): string;
|
|
268
|
+
setApiKey(apiKey: string): void;
|
|
229
269
|
cancelPendingRequests(): void;
|
|
230
270
|
postChatCompletion(request: GroqChatRequest): Promise<GroqChatResponse>;
|
|
231
271
|
streamChatCompletion(request: GroqChatRequest, options?: StreamRequestOptions$1): Promise<ReadableStream<Uint8Array>>;
|
|
272
|
+
reset(): void;
|
|
232
273
|
}
|
|
233
274
|
|
|
234
275
|
/**
|
|
@@ -250,6 +291,32 @@ interface GroqStreamOutcome {
|
|
|
250
291
|
*/
|
|
251
292
|
declare function consumeGroqStream(stream: ReadableStream<Uint8Array>, callbacks: Pick<StreamCallbacks, "onChunk">): Promise<GroqStreamOutcome>;
|
|
252
293
|
|
|
294
|
+
declare const createUserMessage: (content: string) => GroqMessage;
|
|
295
|
+
declare const createAssistantMessage: (content: string) => GroqMessage;
|
|
296
|
+
declare const createSystemMessage: (content: string) => GroqMessage;
|
|
297
|
+
declare const createMessage: (role: GroqMessageRole, content: string) => GroqMessage;
|
|
298
|
+
declare const promptToMessages: (prompt: string) => GroqMessage[];
|
|
299
|
+
declare const extractTextFromMessages: (messages: ReadonlyArray<GroqMessage>) => string;
|
|
300
|
+
declare const formatMessagesForDisplay: (messages: ReadonlyArray<GroqMessage>) => string;
|
|
301
|
+
|
|
302
|
+
interface StructuredJsonRequest {
|
|
303
|
+
readonly model: string;
|
|
304
|
+
readonly instructions: string;
|
|
305
|
+
readonly maxTokens: number;
|
|
306
|
+
readonly temperature: number;
|
|
307
|
+
readonly reasoningEffort?: GroqReasoningEffort;
|
|
308
|
+
}
|
|
309
|
+
declare function requestStructuredJson(client: Pick<IGroqHttpClient, "postChatCompletion">, request: StructuredJsonRequest): Promise<unknown>;
|
|
310
|
+
|
|
311
|
+
interface AppContainer {
|
|
312
|
+
readonly groqHttpClient: GroqHttpClient;
|
|
313
|
+
readonly textGeneration: TextGenerationService;
|
|
314
|
+
readonly chat: ChatService;
|
|
315
|
+
}
|
|
316
|
+
declare function configureProvider(config: GroqProviderConfig): AppContainer;
|
|
317
|
+
declare function getProvider(): AppContainer | null;
|
|
318
|
+
declare function resetProvider(): void;
|
|
319
|
+
|
|
253
320
|
declare const GEMINI_TIERS: TierModelMap;
|
|
254
321
|
/**
|
|
255
322
|
* Gemini provider — text via generateContent (multi-turn aware, system
|
|
@@ -295,9 +362,49 @@ declare class FalProvider extends BaseProvider implements IMediaProvider {
|
|
|
295
362
|
}
|
|
296
363
|
declare function createFalProvider(config: FalConfig): FalProvider;
|
|
297
364
|
|
|
365
|
+
declare class AuthenticationError extends Error {
|
|
366
|
+
constructor(message?: string);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
declare class TimeoutError extends Error {
|
|
370
|
+
constructor(message?: string);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
interface ValidationErrorContext {
|
|
374
|
+
field: string;
|
|
375
|
+
reason: string;
|
|
376
|
+
receivedValue?: unknown;
|
|
377
|
+
}
|
|
378
|
+
declare class ValidationError extends Error {
|
|
379
|
+
readonly field: string;
|
|
380
|
+
readonly reason: string;
|
|
381
|
+
readonly receivedValue: unknown;
|
|
382
|
+
constructor(context: ValidationErrorContext);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
declare function uploadImage(base64OrUrl: string, apiKey: string, onProgress?: (stage: GenerationStage) => void): Promise<string>;
|
|
386
|
+
declare function submitPrediction(model: PrunaModelId, input: Record<string, unknown>, apiKey: string, signal?: AbortSignal, onProgress?: (stage: GenerationStage) => void): Promise<PrunaPredictionResponse>;
|
|
387
|
+
declare class GenerationFailedError extends Error {
|
|
388
|
+
constructor(message: string);
|
|
389
|
+
}
|
|
390
|
+
declare function pollForResult(pollUrl: string, apiKey: string, maxAttempts?: number, intervalMs?: number, signal?: AbortSignal, onProgress?: (stage: GenerationStage, attempt: number) => void): Promise<string>;
|
|
391
|
+
|
|
392
|
+
declare function generate(apiKey: string, input: PrunaInput, options?: GenerateOptions & {
|
|
393
|
+
useCache?: boolean;
|
|
394
|
+
}): Promise<PrunaResult>;
|
|
395
|
+
declare function generateImageThenVideo(apiKey: string, input: TextToVideoInput, options?: GenerateOptions): Promise<PrunaResult>;
|
|
396
|
+
|
|
298
397
|
interface PrunaRequest {
|
|
299
398
|
model?: string;
|
|
300
399
|
image?: string;
|
|
400
|
+
prompt?: string;
|
|
401
|
+
quality?: string;
|
|
402
|
+
duration?: number;
|
|
403
|
+
aspectRatio?: string;
|
|
404
|
+
aspect_ratio?: string;
|
|
405
|
+
motion?: number | string;
|
|
406
|
+
resolution?: string;
|
|
407
|
+
seed?: number;
|
|
301
408
|
[key: string]: unknown;
|
|
302
409
|
}
|
|
303
410
|
interface PrunaProgressStage {
|
|
@@ -329,4 +436,4 @@ declare class PrunaProvider implements IMediaProvider {
|
|
|
329
436
|
}
|
|
330
437
|
declare function createPrunaProvider(config: PrunaConfig): PrunaProvider;
|
|
331
438
|
|
|
332
|
-
export { AnthropicEffort, AnthropicHttpTransport, AnthropicMessagesRequest, AnthropicMessagesResponse, AnthropicProvider, AnthropicProviderConfig, AnthropicRequestBuilder, AnthropicStopReason, BaseProvider, type BaseProviderConfig, CostEstimateRequest, FalProvider, GEMINI_TIERS, GROQ_MODELS, GROQ_TIERS, GeminiProvider, GroqChatRequest, GroqChatRequestBuilder, GroqChatResponse, GroqHttpClient, GroqHttpTransport, GroqMessage, GroqProvider, GroqProviderConfig, IMediaProvider, ITextProvider, ProviderError, type PrunaProgressStage, PrunaProvider, type PrunaRequest, consumeAnthropicStream, consumeGroqStream, createFalProvider, createGeminiProvider, createPrunaProvider, defaultEffortForModel, extractContentFromSsePayload, generateWithPruna, mapAnthropicStopReason, toGroqMessages };
|
|
439
|
+
export { API_ENDPOINTS, AnthropicEffort, AnthropicHttpTransport, AnthropicMessagesRequest, AnthropicMessagesResponse, AnthropicProvider, AnthropicProviderConfig, AnthropicRequestBuilder, AnthropicStopReason, type AppContainer, AuthenticationError, BaseProvider, type BaseProviderConfig, CostEstimateRequest, DEFAULT_BASE_URL, DEFAULT_GENERATION_CONFIG, DEFAULT_MODELS, FalProvider, GEMINI_TIERS, GROQ_MODELS, GROQ_TIERS, GeminiProvider, GenerateOptions, GenerationFailedError, GenerationStage, GroqChatRequest, GroqChatRequestBuilder, GroqChatResponse, GroqConfigStore, GroqGenerationConfig, GroqHttpClient, type GroqHttpClientDeps, GroqHttpTransport, GroqMessage, GroqMessageRole, GroqProvider, GroqProviderConfig, GroqReasoningEffort, IGroqHttpClient, IMediaProvider, ITextProvider, ProviderError, PrunaInput, PrunaModelId, PrunaPredictionResponse, type PrunaProgressStage, PrunaProvider, type PrunaRequest, PrunaResult, StreamRequestOptions$1 as StreamRequestOptions, type StructuredJsonRequest, TIMEOUTS, TextGenerationService, TextToVideoInput, TimeoutError, ValidationError, configureProvider, consumeAnthropicStream, consumeGroqStream, createAssistantMessage, createFalProvider, createGeminiProvider, createMessage, createPrunaProvider, createSystemMessage, createUserMessage, defaultEffortForModel, extractContentFromSsePayload, extractTextFromMessages, formatMessagesForDisplay, generateImageThenVideo, generate as generatePruna, generateWithPruna, getProvider, mapAnthropicStopReason, pollForResult, promptToMessages, requestStructuredJson, resetProvider, submitPrediction, toGroqMessages, uploadImage };
|
|
@@ -2,10 +2,13 @@ import { C as CostEstimateRequest, b as ITextProvider, I as IMediaProvider } fro
|
|
|
2
2
|
export { A as AnyProvider, a as IProviderBase, P as ProviderCapability, c as ProviderFactory, d as ProviderFactoryConfig, i as isMediaProvider, e as isTextProvider } from '../provider.factory-DfDfk0dK.js';
|
|
3
3
|
import { P as ProviderHealth, c as TextTier, T as TextRequest, G as GenerationResult, b as StructuredTextRequest, a as StructuredGeneration, S as StreamCallbacks, F as FinishReason, C as ChatMessage, d as TokenUsage } from '../index-fXjxTR5W.js';
|
|
4
4
|
import { A as AIError, c as TierModelMap } from '../index-DIHz8_OJ.js';
|
|
5
|
-
import { h as AnthropicProviderConfig, e as AnthropicEffort,
|
|
6
|
-
export { A as AIProviderConfig, a as ANTHROPIC_API_VERSION, b as ANTHROPIC_DEFAULT_MAX_TOKENS, c as ANTHROPIC_MODELS, d as ANTHROPIC_TIERS, j as AnthropicStreamEvent, G as GroqChatChunk, o as createAI } from '../create-ai-
|
|
5
|
+
import { h as AnthropicProviderConfig, e as AnthropicEffort, x as AnthropicMessage, f as AnthropicMessagesRequest, i as AnthropicStopReason, g as AnthropicMessagesResponse, t as GroqProviderConfig, r as GroqMessage, q as GroqGenerationConfig, k as GroqChatRequest, l as GroqChatResponse, S as StreamRequestOptions$1, s as GroqMessageRole, u as GroqReasoningEffort } from '../create-ai-9PW752z8.js';
|
|
6
|
+
export { A as AIProviderConfig, a as ANTHROPIC_API_VERSION, b as ANTHROPIC_DEFAULT_MAX_TOKENS, c as ANTHROPIC_MODELS, d as ANTHROPIC_TIERS, j as AnthropicStreamEvent, G as GroqChatChunk, m as GroqChoice, n as GroqChunkChoice, o as GroqConfig, p as GroqErrorResponse, v as GroqUsage, w as createAI } from '../create-ai-9PW752z8.js';
|
|
7
7
|
import { b as CacheStats } from '../cache-manager-Df9LLYGA.js';
|
|
8
8
|
import { b as RetryManager, a as RequestQueue, R as RequestDeduplicator } from '../request-deduplicator.util-NDo0_n1y.js';
|
|
9
|
+
import { b as IGroqHttpClient, l as TextGenerationService, a as GenerationStage, f as PrunaModelId, h as PrunaPredictionResponse, n as TextToVideoInput, G as GenerateOptions, j as PrunaResult, e as PrunaInput } from '../cancellation-error-CKcZRhFg.js';
|
|
10
|
+
export { C as CancellationError, I as IGroqChatService, c as ImageToImageInput, d as ImageToVideoInput, P as PrunaAspectRatio, g as PrunaOutput, i as PrunaResolution, S as StreamingCallbacks, k as StructuredGenerationOptions, T as TextGenerationOptions, m as TextToImageInput } from '../cancellation-error-CKcZRhFg.js';
|
|
11
|
+
import { d as ChatService } from '../chat.service-q05GnhEm.js';
|
|
9
12
|
import { c as GeminiConfig, I as ImageGenerationRequest, G as GeneratedContent, V as VideoGenerationRequest, a as ImageToVideoRequest, b as VideoToVideoRequest, F as FalConfig, P as PrunaConfig } from '../ProviderConfig-DIFa9nmG.js';
|
|
10
13
|
|
|
11
14
|
interface BaseProviderConfig {
|
|
@@ -175,6 +178,24 @@ declare const GROQ_MODELS: {
|
|
|
175
178
|
* the heavy lifting. Override per instance via `models` in provider config.
|
|
176
179
|
*/
|
|
177
180
|
declare const GROQ_TIERS: TierModelMap;
|
|
181
|
+
declare const DEFAULT_GENERATION_CONFIG: {
|
|
182
|
+
readonly temperature: 0.7;
|
|
183
|
+
readonly maxTokens: 1024;
|
|
184
|
+
readonly topP: 1;
|
|
185
|
+
};
|
|
186
|
+
declare const DEFAULT_MODELS: {
|
|
187
|
+
readonly TEXT: "llama-3.1-8b-instant";
|
|
188
|
+
readonly FAST: "llama-3.1-8b-instant";
|
|
189
|
+
readonly EXPERIMENTAL: "openai/gpt-oss-20b";
|
|
190
|
+
};
|
|
191
|
+
declare const DEFAULT_BASE_URL: "https://api.groq.com/openai/v1";
|
|
192
|
+
declare const API_ENDPOINTS: {
|
|
193
|
+
readonly CHAT: "/chat/completions";
|
|
194
|
+
};
|
|
195
|
+
declare const TIMEOUTS: {
|
|
196
|
+
readonly DEFAULT: 30000;
|
|
197
|
+
readonly STREAMING: 60000;
|
|
198
|
+
};
|
|
178
199
|
|
|
179
200
|
declare class GroqChatRequestBuilder {
|
|
180
201
|
private readonly model;
|
|
@@ -191,15 +212,26 @@ declare class GroqChatRequestBuilder {
|
|
|
191
212
|
build(): GroqChatRequest;
|
|
192
213
|
}
|
|
193
214
|
|
|
215
|
+
declare class GroqConfigStore {
|
|
216
|
+
private config;
|
|
217
|
+
initialize(config: GroqProviderConfig): GroqProviderConfig;
|
|
218
|
+
get(): GroqProviderConfig;
|
|
219
|
+
getOrNull(): GroqProviderConfig | null;
|
|
220
|
+
isInitialized(): boolean;
|
|
221
|
+
setApiKey(apiKey: string): void;
|
|
222
|
+
reset(): void;
|
|
223
|
+
}
|
|
224
|
+
|
|
194
225
|
/**
|
|
195
226
|
* Raw HTTP transport for Groq's OpenAI-compatible chat/completions endpoint.
|
|
196
227
|
* All failures leave here as core AIError with the right AIErrorType —
|
|
197
228
|
* callers up the stack only ever see the neutral taxonomy.
|
|
198
229
|
*/
|
|
199
230
|
declare class GroqHttpTransport {
|
|
200
|
-
private readonly
|
|
231
|
+
private readonly configSource;
|
|
201
232
|
private readonly pendingAbortControllers;
|
|
202
|
-
constructor(
|
|
233
|
+
constructor(configSource: GroqProviderConfig | GroqConfigStore);
|
|
234
|
+
private getConfig;
|
|
203
235
|
cancelPendingRequests(): void;
|
|
204
236
|
postChatCompletion(request: GroqChatRequest): Promise<GroqChatResponse>;
|
|
205
237
|
streamChatCompletion(request: GroqChatRequest, options?: StreamRequestOptions$1): Promise<ReadableStream<Uint8Array>>;
|
|
@@ -211,6 +243,7 @@ declare class GroqHttpTransport {
|
|
|
211
243
|
}
|
|
212
244
|
|
|
213
245
|
interface GroqHttpClientDeps {
|
|
246
|
+
readonly configStore?: GroqConfigStore;
|
|
214
247
|
readonly transport?: GroqHttpTransport;
|
|
215
248
|
readonly retryManager?: RetryManager;
|
|
216
249
|
readonly queue?: RequestQueue;
|
|
@@ -219,16 +252,24 @@ interface GroqHttpClientDeps {
|
|
|
219
252
|
/**
|
|
220
253
|
* Groq HTTP client with the ported strategy stack: identical concurrent
|
|
221
254
|
* requests are deduplicated, transient failures retried with backoff, and
|
|
222
|
-
* everything is funneled through a priority queue.
|
|
223
|
-
*
|
|
255
|
+
* everything is funneled through a priority queue.
|
|
256
|
+
*
|
|
257
|
+
* Supports both standalone initialization `new GroqHttpClient(config)`
|
|
258
|
+
* and deferred initialization `const c = new GroqHttpClient(); c.initialize(config)`.
|
|
224
259
|
*/
|
|
225
260
|
declare class GroqHttpClient {
|
|
261
|
+
private readonly configStore;
|
|
226
262
|
private readonly transport;
|
|
227
263
|
private readonly executor;
|
|
228
|
-
constructor(
|
|
264
|
+
constructor(configOrDeps?: GroqProviderConfig | GroqHttpClientDeps, maybeDeps?: GroqHttpClientDeps);
|
|
265
|
+
initialize(config: GroqProviderConfig): void;
|
|
266
|
+
isInitialized(): boolean;
|
|
267
|
+
getApiKey(): string;
|
|
268
|
+
setApiKey(apiKey: string): void;
|
|
229
269
|
cancelPendingRequests(): void;
|
|
230
270
|
postChatCompletion(request: GroqChatRequest): Promise<GroqChatResponse>;
|
|
231
271
|
streamChatCompletion(request: GroqChatRequest, options?: StreamRequestOptions$1): Promise<ReadableStream<Uint8Array>>;
|
|
272
|
+
reset(): void;
|
|
232
273
|
}
|
|
233
274
|
|
|
234
275
|
/**
|
|
@@ -250,6 +291,32 @@ interface GroqStreamOutcome {
|
|
|
250
291
|
*/
|
|
251
292
|
declare function consumeGroqStream(stream: ReadableStream<Uint8Array>, callbacks: Pick<StreamCallbacks, "onChunk">): Promise<GroqStreamOutcome>;
|
|
252
293
|
|
|
294
|
+
declare const createUserMessage: (content: string) => GroqMessage;
|
|
295
|
+
declare const createAssistantMessage: (content: string) => GroqMessage;
|
|
296
|
+
declare const createSystemMessage: (content: string) => GroqMessage;
|
|
297
|
+
declare const createMessage: (role: GroqMessageRole, content: string) => GroqMessage;
|
|
298
|
+
declare const promptToMessages: (prompt: string) => GroqMessage[];
|
|
299
|
+
declare const extractTextFromMessages: (messages: ReadonlyArray<GroqMessage>) => string;
|
|
300
|
+
declare const formatMessagesForDisplay: (messages: ReadonlyArray<GroqMessage>) => string;
|
|
301
|
+
|
|
302
|
+
interface StructuredJsonRequest {
|
|
303
|
+
readonly model: string;
|
|
304
|
+
readonly instructions: string;
|
|
305
|
+
readonly maxTokens: number;
|
|
306
|
+
readonly temperature: number;
|
|
307
|
+
readonly reasoningEffort?: GroqReasoningEffort;
|
|
308
|
+
}
|
|
309
|
+
declare function requestStructuredJson(client: Pick<IGroqHttpClient, "postChatCompletion">, request: StructuredJsonRequest): Promise<unknown>;
|
|
310
|
+
|
|
311
|
+
interface AppContainer {
|
|
312
|
+
readonly groqHttpClient: GroqHttpClient;
|
|
313
|
+
readonly textGeneration: TextGenerationService;
|
|
314
|
+
readonly chat: ChatService;
|
|
315
|
+
}
|
|
316
|
+
declare function configureProvider(config: GroqProviderConfig): AppContainer;
|
|
317
|
+
declare function getProvider(): AppContainer | null;
|
|
318
|
+
declare function resetProvider(): void;
|
|
319
|
+
|
|
253
320
|
declare const GEMINI_TIERS: TierModelMap;
|
|
254
321
|
/**
|
|
255
322
|
* Gemini provider — text via generateContent (multi-turn aware, system
|
|
@@ -295,9 +362,49 @@ declare class FalProvider extends BaseProvider implements IMediaProvider {
|
|
|
295
362
|
}
|
|
296
363
|
declare function createFalProvider(config: FalConfig): FalProvider;
|
|
297
364
|
|
|
365
|
+
declare class AuthenticationError extends Error {
|
|
366
|
+
constructor(message?: string);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
declare class TimeoutError extends Error {
|
|
370
|
+
constructor(message?: string);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
interface ValidationErrorContext {
|
|
374
|
+
field: string;
|
|
375
|
+
reason: string;
|
|
376
|
+
receivedValue?: unknown;
|
|
377
|
+
}
|
|
378
|
+
declare class ValidationError extends Error {
|
|
379
|
+
readonly field: string;
|
|
380
|
+
readonly reason: string;
|
|
381
|
+
readonly receivedValue: unknown;
|
|
382
|
+
constructor(context: ValidationErrorContext);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
declare function uploadImage(base64OrUrl: string, apiKey: string, onProgress?: (stage: GenerationStage) => void): Promise<string>;
|
|
386
|
+
declare function submitPrediction(model: PrunaModelId, input: Record<string, unknown>, apiKey: string, signal?: AbortSignal, onProgress?: (stage: GenerationStage) => void): Promise<PrunaPredictionResponse>;
|
|
387
|
+
declare class GenerationFailedError extends Error {
|
|
388
|
+
constructor(message: string);
|
|
389
|
+
}
|
|
390
|
+
declare function pollForResult(pollUrl: string, apiKey: string, maxAttempts?: number, intervalMs?: number, signal?: AbortSignal, onProgress?: (stage: GenerationStage, attempt: number) => void): Promise<string>;
|
|
391
|
+
|
|
392
|
+
declare function generate(apiKey: string, input: PrunaInput, options?: GenerateOptions & {
|
|
393
|
+
useCache?: boolean;
|
|
394
|
+
}): Promise<PrunaResult>;
|
|
395
|
+
declare function generateImageThenVideo(apiKey: string, input: TextToVideoInput, options?: GenerateOptions): Promise<PrunaResult>;
|
|
396
|
+
|
|
298
397
|
interface PrunaRequest {
|
|
299
398
|
model?: string;
|
|
300
399
|
image?: string;
|
|
400
|
+
prompt?: string;
|
|
401
|
+
quality?: string;
|
|
402
|
+
duration?: number;
|
|
403
|
+
aspectRatio?: string;
|
|
404
|
+
aspect_ratio?: string;
|
|
405
|
+
motion?: number | string;
|
|
406
|
+
resolution?: string;
|
|
407
|
+
seed?: number;
|
|
301
408
|
[key: string]: unknown;
|
|
302
409
|
}
|
|
303
410
|
interface PrunaProgressStage {
|
|
@@ -329,4 +436,4 @@ declare class PrunaProvider implements IMediaProvider {
|
|
|
329
436
|
}
|
|
330
437
|
declare function createPrunaProvider(config: PrunaConfig): PrunaProvider;
|
|
331
438
|
|
|
332
|
-
export { AnthropicEffort, AnthropicHttpTransport, AnthropicMessagesRequest, AnthropicMessagesResponse, AnthropicProvider, AnthropicProviderConfig, AnthropicRequestBuilder, AnthropicStopReason, BaseProvider, type BaseProviderConfig, CostEstimateRequest, FalProvider, GEMINI_TIERS, GROQ_MODELS, GROQ_TIERS, GeminiProvider, GroqChatRequest, GroqChatRequestBuilder, GroqChatResponse, GroqHttpClient, GroqHttpTransport, GroqMessage, GroqProvider, GroqProviderConfig, IMediaProvider, ITextProvider, ProviderError, type PrunaProgressStage, PrunaProvider, type PrunaRequest, consumeAnthropicStream, consumeGroqStream, createFalProvider, createGeminiProvider, createPrunaProvider, defaultEffortForModel, extractContentFromSsePayload, generateWithPruna, mapAnthropicStopReason, toGroqMessages };
|
|
439
|
+
export { API_ENDPOINTS, AnthropicEffort, AnthropicHttpTransport, AnthropicMessagesRequest, AnthropicMessagesResponse, AnthropicProvider, AnthropicProviderConfig, AnthropicRequestBuilder, AnthropicStopReason, type AppContainer, AuthenticationError, BaseProvider, type BaseProviderConfig, CostEstimateRequest, DEFAULT_BASE_URL, DEFAULT_GENERATION_CONFIG, DEFAULT_MODELS, FalProvider, GEMINI_TIERS, GROQ_MODELS, GROQ_TIERS, GeminiProvider, GenerateOptions, GenerationFailedError, GenerationStage, GroqChatRequest, GroqChatRequestBuilder, GroqChatResponse, GroqConfigStore, GroqGenerationConfig, GroqHttpClient, type GroqHttpClientDeps, GroqHttpTransport, GroqMessage, GroqMessageRole, GroqProvider, GroqProviderConfig, GroqReasoningEffort, IGroqHttpClient, IMediaProvider, ITextProvider, ProviderError, PrunaInput, PrunaModelId, PrunaPredictionResponse, type PrunaProgressStage, PrunaProvider, type PrunaRequest, PrunaResult, StreamRequestOptions$1 as StreamRequestOptions, type StructuredJsonRequest, TIMEOUTS, TextGenerationService, TextToVideoInput, TimeoutError, ValidationError, configureProvider, consumeAnthropicStream, consumeGroqStream, createAssistantMessage, createFalProvider, createGeminiProvider, createMessage, createPrunaProvider, createSystemMessage, createUserMessage, defaultEffortForModel, extractContentFromSsePayload, extractTextFromMessages, formatMessagesForDisplay, generateImageThenVideo, generate as generatePruna, generateWithPruna, getProvider, mapAnthropicStopReason, pollForResult, promptToMessages, requestStructuredJson, resetProvider, submitPrediction, toGroqMessages, uploadImage };
|