@umituz/web-ai 1.0.1 → 1.0.2
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/content/index.cjs +116 -10
- 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 +116 -10
- 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 +272 -10
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +28 -2
- package/dist/hooks/index.d.ts +28 -2
- package/dist/hooks/index.js +272 -11
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +421 -10
- 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 +402 -11
- package/dist/index.js.map +1 -1
- package/dist/providers/index.cjs +696 -10
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.d.cts +75 -8
- package/dist/providers/index.d.ts +75 -8
- package/dist/providers/index.js +679 -11
- package/dist/providers/index.js.map +1 -1
- package/dist/text-generation.service-BQO3Tvz2.d.cts +66 -0
- package/dist/text-generation.service-CcYQM6Ch.d.ts +66 -0
- package/package.json +6 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { q as GroqGenerationConfig, r as GroqMessage, k as GroqChatRequest, l as GroqChatResponse, S as StreamRequestOptions, t as GroqProviderConfig } from './create-ai-CXYKPK6G.cjs';
|
|
2
|
+
import { C as CacheManager } from './cache-manager-Df9LLYGA.cjs';
|
|
3
|
+
import { b as ITextProvider, P as ProviderCapability, C as CostEstimateRequest } from './provider.factory-BxsfK4WW.cjs';
|
|
4
|
+
import { b as StructuredTextRequest, a as StructuredGeneration, c as TextTier, T as TextRequest, G as GenerationResult, S as StreamCallbacks, P as ProviderHealth } from './index-fXjxTR5W.cjs';
|
|
5
|
+
|
|
6
|
+
interface TextGenerationOptions {
|
|
7
|
+
readonly model?: string;
|
|
8
|
+
readonly generationConfig?: GroqGenerationConfig;
|
|
9
|
+
readonly signal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
interface StreamingCallbacks {
|
|
12
|
+
readonly onChunk?: (chunk: string) => void;
|
|
13
|
+
readonly onComplete?: (fullText: string) => void;
|
|
14
|
+
readonly onError?: (error: Error) => void;
|
|
15
|
+
}
|
|
16
|
+
interface StructuredGenerationOptions {
|
|
17
|
+
readonly model?: string;
|
|
18
|
+
readonly generationConfig?: GroqGenerationConfig;
|
|
19
|
+
readonly schema?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
interface IGroqChatService {
|
|
22
|
+
generateCompletion(prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
23
|
+
generateChatCompletion(messages: ReadonlyArray<GroqMessage>, options?: TextGenerationOptions): Promise<string>;
|
|
24
|
+
generateStructured<T>(prompt: string, options?: StructuredGenerationOptions): Promise<T>;
|
|
25
|
+
streamCompletion(prompt: string, callbacks: StreamingCallbacks, options?: TextGenerationOptions): Promise<string>;
|
|
26
|
+
streamChatCompletion(messages: ReadonlyArray<GroqMessage>, callbacks: StreamingCallbacks, options?: TextGenerationOptions): Promise<string>;
|
|
27
|
+
clearCache(): void;
|
|
28
|
+
}
|
|
29
|
+
interface IGroqHttpClient {
|
|
30
|
+
postChatCompletion(request: GroqChatRequest): Promise<GroqChatResponse>;
|
|
31
|
+
streamChatCompletion(request: GroqChatRequest, options?: StreamRequestOptions): Promise<ReadableStream<Uint8Array>>;
|
|
32
|
+
getApiKey(): string;
|
|
33
|
+
setApiKey(apiKey: string): void;
|
|
34
|
+
initialize(config: GroqProviderConfig): void;
|
|
35
|
+
isInitialized(): boolean;
|
|
36
|
+
cancelPendingRequests(): void;
|
|
37
|
+
reset(): void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare class TextGenerationService implements IGroqChatService, ITextProvider {
|
|
41
|
+
private readonly httpClient;
|
|
42
|
+
private readonly cache;
|
|
43
|
+
private readonly defaultModel;
|
|
44
|
+
readonly id = "groq-text-generation";
|
|
45
|
+
readonly name = "Groq Text Generation";
|
|
46
|
+
readonly capabilities: ReadonlyArray<ProviderCapability>;
|
|
47
|
+
private readonly jsonParser;
|
|
48
|
+
constructor(httpClient: IGroqHttpClient, cache?: CacheManager, defaultModel?: string);
|
|
49
|
+
generateCompletion(prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
50
|
+
generateChatCompletion(messages: ReadonlyArray<GroqMessage>, options?: TextGenerationOptions): Promise<string>;
|
|
51
|
+
generateStructured<T>(prompt: string, options?: StructuredGenerationOptions): Promise<T>;
|
|
52
|
+
generateStructured<T>(request: StructuredTextRequest): Promise<StructuredGeneration<T>>;
|
|
53
|
+
streamCompletion(prompt: string, callbacks: StreamingCallbacks, options?: TextGenerationOptions): Promise<string>;
|
|
54
|
+
streamChatCompletion(messages: ReadonlyArray<GroqMessage>, callbacks: StreamingCallbacks, options?: TextGenerationOptions): Promise<string>;
|
|
55
|
+
clearCache(): void;
|
|
56
|
+
resolveModel(tier: TextTier): string;
|
|
57
|
+
generate(request: TextRequest): Promise<GenerationResult>;
|
|
58
|
+
stream(request: TextRequest, callbacks: StreamCallbacks): Promise<GenerationResult>;
|
|
59
|
+
countTokens(text: string): Promise<number>;
|
|
60
|
+
estimateCost(_request: CostEstimateRequest): Promise<number>;
|
|
61
|
+
healthCheck(): Promise<ProviderHealth>;
|
|
62
|
+
private executeWithCache;
|
|
63
|
+
private extractContent;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { type IGroqChatService as I, type StreamingCallbacks as S, type TextGenerationOptions as T, type IGroqHttpClient as a, type StructuredGenerationOptions as b, TextGenerationService as c };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { q as GroqGenerationConfig, r as GroqMessage, k as GroqChatRequest, l as GroqChatResponse, S as StreamRequestOptions, t as GroqProviderConfig } from './create-ai-9PW752z8.js';
|
|
2
|
+
import { C as CacheManager } from './cache-manager-Df9LLYGA.js';
|
|
3
|
+
import { b as ITextProvider, P as ProviderCapability, C as CostEstimateRequest } from './provider.factory-DfDfk0dK.js';
|
|
4
|
+
import { b as StructuredTextRequest, a as StructuredGeneration, c as TextTier, T as TextRequest, G as GenerationResult, S as StreamCallbacks, P as ProviderHealth } from './index-fXjxTR5W.js';
|
|
5
|
+
|
|
6
|
+
interface TextGenerationOptions {
|
|
7
|
+
readonly model?: string;
|
|
8
|
+
readonly generationConfig?: GroqGenerationConfig;
|
|
9
|
+
readonly signal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
interface StreamingCallbacks {
|
|
12
|
+
readonly onChunk?: (chunk: string) => void;
|
|
13
|
+
readonly onComplete?: (fullText: string) => void;
|
|
14
|
+
readonly onError?: (error: Error) => void;
|
|
15
|
+
}
|
|
16
|
+
interface StructuredGenerationOptions {
|
|
17
|
+
readonly model?: string;
|
|
18
|
+
readonly generationConfig?: GroqGenerationConfig;
|
|
19
|
+
readonly schema?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
interface IGroqChatService {
|
|
22
|
+
generateCompletion(prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
23
|
+
generateChatCompletion(messages: ReadonlyArray<GroqMessage>, options?: TextGenerationOptions): Promise<string>;
|
|
24
|
+
generateStructured<T>(prompt: string, options?: StructuredGenerationOptions): Promise<T>;
|
|
25
|
+
streamCompletion(prompt: string, callbacks: StreamingCallbacks, options?: TextGenerationOptions): Promise<string>;
|
|
26
|
+
streamChatCompletion(messages: ReadonlyArray<GroqMessage>, callbacks: StreamingCallbacks, options?: TextGenerationOptions): Promise<string>;
|
|
27
|
+
clearCache(): void;
|
|
28
|
+
}
|
|
29
|
+
interface IGroqHttpClient {
|
|
30
|
+
postChatCompletion(request: GroqChatRequest): Promise<GroqChatResponse>;
|
|
31
|
+
streamChatCompletion(request: GroqChatRequest, options?: StreamRequestOptions): Promise<ReadableStream<Uint8Array>>;
|
|
32
|
+
getApiKey(): string;
|
|
33
|
+
setApiKey(apiKey: string): void;
|
|
34
|
+
initialize(config: GroqProviderConfig): void;
|
|
35
|
+
isInitialized(): boolean;
|
|
36
|
+
cancelPendingRequests(): void;
|
|
37
|
+
reset(): void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare class TextGenerationService implements IGroqChatService, ITextProvider {
|
|
41
|
+
private readonly httpClient;
|
|
42
|
+
private readonly cache;
|
|
43
|
+
private readonly defaultModel;
|
|
44
|
+
readonly id = "groq-text-generation";
|
|
45
|
+
readonly name = "Groq Text Generation";
|
|
46
|
+
readonly capabilities: ReadonlyArray<ProviderCapability>;
|
|
47
|
+
private readonly jsonParser;
|
|
48
|
+
constructor(httpClient: IGroqHttpClient, cache?: CacheManager, defaultModel?: string);
|
|
49
|
+
generateCompletion(prompt: string, options?: TextGenerationOptions): Promise<string>;
|
|
50
|
+
generateChatCompletion(messages: ReadonlyArray<GroqMessage>, options?: TextGenerationOptions): Promise<string>;
|
|
51
|
+
generateStructured<T>(prompt: string, options?: StructuredGenerationOptions): Promise<T>;
|
|
52
|
+
generateStructured<T>(request: StructuredTextRequest): Promise<StructuredGeneration<T>>;
|
|
53
|
+
streamCompletion(prompt: string, callbacks: StreamingCallbacks, options?: TextGenerationOptions): Promise<string>;
|
|
54
|
+
streamChatCompletion(messages: ReadonlyArray<GroqMessage>, callbacks: StreamingCallbacks, options?: TextGenerationOptions): Promise<string>;
|
|
55
|
+
clearCache(): void;
|
|
56
|
+
resolveModel(tier: TextTier): string;
|
|
57
|
+
generate(request: TextRequest): Promise<GenerationResult>;
|
|
58
|
+
stream(request: TextRequest, callbacks: StreamCallbacks): Promise<GenerationResult>;
|
|
59
|
+
countTokens(text: string): Promise<number>;
|
|
60
|
+
estimateCost(_request: CostEstimateRequest): Promise<number>;
|
|
61
|
+
healthCheck(): Promise<ProviderHealth>;
|
|
62
|
+
private executeWithCache;
|
|
63
|
+
private extractContent;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { type IGroqChatService as I, type StreamingCallbacks as S, type TextGenerationOptions as T, type IGroqHttpClient as a, type StructuredGenerationOptions as b, TextGenerationService as c };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-ai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Provider-agnostic AI engine for web and edge — text, chat, structured output and streaming over swappable providers (Anthropic, Groq, Gemini, fal, Pruna), plus a content generation suite",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
"import": "./dist/providers/index.js",
|
|
23
23
|
"require": "./dist/providers/index.cjs"
|
|
24
24
|
},
|
|
25
|
+
"./groq": {
|
|
26
|
+
"types": "./dist/providers/index.d.ts",
|
|
27
|
+
"import": "./dist/providers/index.js",
|
|
28
|
+
"require": "./dist/providers/index.cjs"
|
|
29
|
+
},
|
|
25
30
|
"./chat": {
|
|
26
31
|
"types": "./dist/chat/index.d.ts",
|
|
27
32
|
"import": "./dist/chat/index.js",
|