@umituz/web-ai 1.0.0 → 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/{ABTesting-DDqNhHtP.d.ts → AIErrors-B2ogd1PB.d.ts} +14 -1
- package/dist/{ABTesting-DWBtKTMQ.d.cts → AIErrors-C5EasV_c.d.cts} +14 -1
- package/dist/{ProviderConfig-a55tLhWT.d.cts → ProviderConfig-DIFa9nmG.d.cts} +10 -1
- package/dist/{ProviderConfig-a55tLhWT.d.ts → ProviderConfig-DIFa9nmG.d.ts} +10 -1
- package/dist/chat/index.cjs +114 -23
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +4 -4
- package/dist/chat/index.d.ts +4 -4
- package/dist/chat/index.js +114 -23
- package/dist/chat/index.js.map +1 -1
- package/dist/{chat.service-DBKq9I2c.d.cts → chat.service-CL1qtYxe.d.cts} +7 -7
- package/dist/{chat.service-RQn8UTXD.d.ts → chat.service-q05GnhEm.d.ts} +7 -7
- package/dist/content/index.cjs +506 -193
- package/dist/content/index.cjs.map +1 -1
- package/dist/content/index.d.cts +7 -8
- package/dist/content/index.d.ts +7 -8
- package/dist/content/index.js +506 -193
- package/dist/content/index.js.map +1 -1
- package/dist/core/index.cjs +122 -15
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +13 -31
- package/dist/core/index.d.ts +13 -31
- package/dist/core/index.js +119 -16
- package/dist/core/index.js.map +1 -1
- package/dist/{create-ai-BhNaz86i.d.ts → create-ai-9PW752z8.d.ts} +14 -21
- package/dist/{create-ai-DGZFBOA1.d.cts → create-ai-CXYKPK6G.d.cts} +14 -21
- package/dist/hooks/index.cjs +631 -179
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +33 -7
- package/dist/hooks/index.d.ts +33 -7
- package/dist/hooks/index.js +631 -180
- package/dist/hooks/index.js.map +1 -1
- package/dist/index-DIHz8_OJ.d.ts +48 -0
- package/dist/index-DKHNcMbl.d.cts +48 -0
- package/dist/index.cjs +666 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +645 -105
- package/dist/index.js.map +1 -1
- package/dist/{provider.factory-COsnprLH.d.cts → provider.factory-BxsfK4WW.d.cts} +1 -1
- package/dist/{provider.factory-CpWFyjbw.d.ts → provider.factory-DfDfk0dK.d.ts} +1 -1
- package/dist/providers/index.cjs +973 -130
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.d.cts +84 -18
- package/dist/providers/index.d.ts +84 -18
- package/dist/providers/index.js +956 -131
- 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/dist/wizard/index.d.cts +1 -1
- package/dist/wizard/index.d.ts +1 -1
- package/package.json +9 -1
- package/dist/index-DjX9ZKuM.d.cts +0 -14
- package/dist/index-DxLvE588.d.ts +0 -14
|
@@ -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/dist/wizard/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { B as BlogGenerationRequest, b as SocialContentRequest, V as VideoScriptRequest } from '../ContentGeneration-B6iK2B33.cjs';
|
|
2
|
-
import { I as ImageGenerationRequest, V as VideoGenerationRequest, a as ImageToVideoRequest, b as VideoToVideoRequest } from '../ProviderConfig-
|
|
2
|
+
import { I as ImageGenerationRequest, V as VideoGenerationRequest, a as ImageToVideoRequest, b as VideoToVideoRequest } from '../ProviderConfig-DIFa9nmG.cjs';
|
|
3
3
|
|
|
4
4
|
interface WizardStep<T extends string = string> {
|
|
5
5
|
id: T;
|
package/dist/wizard/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { B as BlogGenerationRequest, b as SocialContentRequest, V as VideoScriptRequest } from '../ContentGeneration-B6iK2B33.js';
|
|
2
|
-
import { I as ImageGenerationRequest, V as VideoGenerationRequest, a as ImageToVideoRequest, b as VideoToVideoRequest } from '../ProviderConfig-
|
|
2
|
+
import { I as ImageGenerationRequest, V as VideoGenerationRequest, a as ImageToVideoRequest, b as VideoToVideoRequest } from '../ProviderConfig-DIFa9nmG.js';
|
|
3
3
|
|
|
4
4
|
interface WizardStep<T extends string = string> {
|
|
5
5
|
id: T;
|
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",
|
|
@@ -94,9 +99,12 @@
|
|
|
94
99
|
"@eslint/js": "^9.32.0",
|
|
95
100
|
"@types/node": "^20.0.0",
|
|
96
101
|
"@types/react": "^18.2.0",
|
|
102
|
+
"@types/react-dom": "^18.3.7",
|
|
97
103
|
"@umituz/pruna-provider": "^1.0.9",
|
|
98
104
|
"eslint": "^9.32.0",
|
|
105
|
+
"happy-dom": "^21.0.4",
|
|
99
106
|
"react": "18.3.1",
|
|
107
|
+
"react-dom": "^18.3.1",
|
|
100
108
|
"tsup": "^8.0.0",
|
|
101
109
|
"typescript": "~5.9.2",
|
|
102
110
|
"typescript-eslint": "^8.38.0",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { c as TextTier } from './index-fXjxTR5W.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Per-provider default model per tier. Config can override any slot; an
|
|
5
|
-
* explicit `model` on a request overrides everything. This table is the knob
|
|
6
|
-
* that turns "switch from Claude to Groq" into a config edit.
|
|
7
|
-
*/
|
|
8
|
-
type TierModelMap = Readonly<Partial<Record<TextTier, string>>>;
|
|
9
|
-
declare const TEXT_TIERS: ReadonlyArray<TextTier>;
|
|
10
|
-
declare function isTextTier(value: unknown): value is TextTier;
|
|
11
|
-
declare function resolveModel(tiers: TierModelMap, tier: TextTier, providerId: string): string;
|
|
12
|
-
declare function mergeTierOverrides(defaults: TierModelMap, overrides?: TierModelMap): TierModelMap;
|
|
13
|
-
|
|
14
|
-
export { TEXT_TIERS as T, type TierModelMap as a, isTextTier as i, mergeTierOverrides as m, resolveModel as r };
|
package/dist/index-DxLvE588.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { c as TextTier } from './index-fXjxTR5W.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Per-provider default model per tier. Config can override any slot; an
|
|
5
|
-
* explicit `model` on a request overrides everything. This table is the knob
|
|
6
|
-
* that turns "switch from Claude to Groq" into a config edit.
|
|
7
|
-
*/
|
|
8
|
-
type TierModelMap = Readonly<Partial<Record<TextTier, string>>>;
|
|
9
|
-
declare const TEXT_TIERS: ReadonlyArray<TextTier>;
|
|
10
|
-
declare function isTextTier(value: unknown): value is TextTier;
|
|
11
|
-
declare function resolveModel(tiers: TierModelMap, tier: TextTier, providerId: string): string;
|
|
12
|
-
declare function mergeTierOverrides(defaults: TierModelMap, overrides?: TierModelMap): TierModelMap;
|
|
13
|
-
|
|
14
|
-
export { TEXT_TIERS as T, type TierModelMap as a, isTextTier as i, mergeTierOverrides as m, resolveModel as r };
|