@umituz/web-ai 1.0.4 → 1.0.5
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 +205 -7
- 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 +199 -8
- package/dist/content/index.js.map +1 -1
- package/dist/hooks/index.cjs +64 -8
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +12 -2
- package/dist/hooks/index.d.ts +12 -2
- package/dist/hooks/index.js +64 -8
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +78 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +73 -6
- package/dist/index.js.map +1 -1
- package/dist/{PromptBuilder-DIUZlfV6.d.cts → requestQueue-CkJ6Xc9K.d.cts} +48 -2
- package/dist/{PromptBuilder-B5Lm1znm.d.ts → requestQueue-CvxWxC-z.d.ts} +48 -2
- package/package.json +1 -1
|
@@ -51,7 +51,7 @@ declare class AIContentService implements IAIContentService {
|
|
|
51
51
|
private readonly imagePromptService;
|
|
52
52
|
private readonly contentCalendarService;
|
|
53
53
|
private readonly mediaGenerationService;
|
|
54
|
-
constructor(configOrGenerator: AIProviderConfig | ProviderConfig | ITextGenerator);
|
|
54
|
+
constructor(configOrGenerator: AIProviderConfig | ProviderConfig | ITextGenerator | string, model?: string, textGenerator?: ITextGenerator);
|
|
55
55
|
/** The composed factory — chat()/chatStream() with usage, health, fallback. */
|
|
56
56
|
get providers(): ProviderFactory;
|
|
57
57
|
generateBlogPost(request: BlogGenerationRequest): Promise<GeneratedBlog>;
|
|
@@ -212,4 +212,50 @@ declare class PromptBuilder {
|
|
|
212
212
|
static maxTokensForDuration(durationSeconds: number): number;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
declare function safeJSONParse<T>(text: string, fallback: T, onError?: (context: string) => void): T;
|
|
216
|
+
declare function extractJSON(text: string): string | null;
|
|
217
|
+
declare function parseAIResponse<T>(response: string, fallback: T, onError?: (context: string) => void): T;
|
|
218
|
+
declare function isValidJSON(text: string): boolean;
|
|
219
|
+
|
|
220
|
+
declare enum RequestPriority {
|
|
221
|
+
LOW = 0,
|
|
222
|
+
NORMAL = 1,
|
|
223
|
+
HIGH = 2,
|
|
224
|
+
URGENT = 3
|
|
225
|
+
}
|
|
226
|
+
interface QueueConfig {
|
|
227
|
+
maxConcurrent: number;
|
|
228
|
+
maxQueueSize: number;
|
|
229
|
+
defaultTimeout: number;
|
|
230
|
+
retryDelay: number;
|
|
231
|
+
enableRateLimit: boolean;
|
|
232
|
+
rateLimitWindow: number;
|
|
233
|
+
rateLimitMaxRequests: number;
|
|
234
|
+
}
|
|
235
|
+
declare class RequestQueue {
|
|
236
|
+
private queue;
|
|
237
|
+
private running;
|
|
238
|
+
private config;
|
|
239
|
+
private requestHistory;
|
|
240
|
+
private isProcessing;
|
|
241
|
+
constructor(config?: Partial<QueueConfig>);
|
|
242
|
+
add<T>(fn: (signal: AbortSignal) => Promise<T>, priority?: RequestPriority, maxRetries?: number): Promise<T>;
|
|
243
|
+
private sortQueue;
|
|
244
|
+
private process;
|
|
245
|
+
private canMakeRequest;
|
|
246
|
+
private executeRequest;
|
|
247
|
+
private withTimeout;
|
|
248
|
+
getStats(): {
|
|
249
|
+
queued: number;
|
|
250
|
+
running: number;
|
|
251
|
+
rateLimitRemaining: number;
|
|
252
|
+
};
|
|
253
|
+
clear(): void;
|
|
254
|
+
drain(): Promise<void>;
|
|
255
|
+
}
|
|
256
|
+
declare function batchRequest<T>(requests: Array<() => Promise<T>>, options?: {
|
|
257
|
+
concurrency?: number;
|
|
258
|
+
stopOnError?: boolean;
|
|
259
|
+
}): Promise<T[]>;
|
|
260
|
+
|
|
261
|
+
export { ABTestService as A, BlogService as B, ContentCalendarService as C, GenerationExecutor as G, type IAIContentService as I, MediaGenerationService as M, PromptBuilder as P, type QueueConfig as Q, RequestPriority as R, SeoService as S, VIDEO_DURATION_OPTIONS as V, AIContentService as a, ASPECT_RATIO_VALUES as b, AnalysisService as c, IMAGE_QUALITY_VALUES as d, ImagePromptService as e, SocialService as f, VIDEO_QUALITY_VALUES as g, VideoScriptService as h, batchRequest as i, extractJSON as j, getDimensionsForAspectRatio as k, getRecommendedQuality as l, isValidJSON as m, RequestQueue as n, resolveDimensionsForAspectRatio as o, parseAIResponse as p, recommendQualityForAspectRatio as r, safeJSONParse as s };
|
|
@@ -51,7 +51,7 @@ declare class AIContentService implements IAIContentService {
|
|
|
51
51
|
private readonly imagePromptService;
|
|
52
52
|
private readonly contentCalendarService;
|
|
53
53
|
private readonly mediaGenerationService;
|
|
54
|
-
constructor(configOrGenerator: AIProviderConfig | ProviderConfig | ITextGenerator);
|
|
54
|
+
constructor(configOrGenerator: AIProviderConfig | ProviderConfig | ITextGenerator | string, model?: string, textGenerator?: ITextGenerator);
|
|
55
55
|
/** The composed factory — chat()/chatStream() with usage, health, fallback. */
|
|
56
56
|
get providers(): ProviderFactory;
|
|
57
57
|
generateBlogPost(request: BlogGenerationRequest): Promise<GeneratedBlog>;
|
|
@@ -212,4 +212,50 @@ declare class PromptBuilder {
|
|
|
212
212
|
static maxTokensForDuration(durationSeconds: number): number;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
declare function safeJSONParse<T>(text: string, fallback: T, onError?: (context: string) => void): T;
|
|
216
|
+
declare function extractJSON(text: string): string | null;
|
|
217
|
+
declare function parseAIResponse<T>(response: string, fallback: T, onError?: (context: string) => void): T;
|
|
218
|
+
declare function isValidJSON(text: string): boolean;
|
|
219
|
+
|
|
220
|
+
declare enum RequestPriority {
|
|
221
|
+
LOW = 0,
|
|
222
|
+
NORMAL = 1,
|
|
223
|
+
HIGH = 2,
|
|
224
|
+
URGENT = 3
|
|
225
|
+
}
|
|
226
|
+
interface QueueConfig {
|
|
227
|
+
maxConcurrent: number;
|
|
228
|
+
maxQueueSize: number;
|
|
229
|
+
defaultTimeout: number;
|
|
230
|
+
retryDelay: number;
|
|
231
|
+
enableRateLimit: boolean;
|
|
232
|
+
rateLimitWindow: number;
|
|
233
|
+
rateLimitMaxRequests: number;
|
|
234
|
+
}
|
|
235
|
+
declare class RequestQueue {
|
|
236
|
+
private queue;
|
|
237
|
+
private running;
|
|
238
|
+
private config;
|
|
239
|
+
private requestHistory;
|
|
240
|
+
private isProcessing;
|
|
241
|
+
constructor(config?: Partial<QueueConfig>);
|
|
242
|
+
add<T>(fn: (signal: AbortSignal) => Promise<T>, priority?: RequestPriority, maxRetries?: number): Promise<T>;
|
|
243
|
+
private sortQueue;
|
|
244
|
+
private process;
|
|
245
|
+
private canMakeRequest;
|
|
246
|
+
private executeRequest;
|
|
247
|
+
private withTimeout;
|
|
248
|
+
getStats(): {
|
|
249
|
+
queued: number;
|
|
250
|
+
running: number;
|
|
251
|
+
rateLimitRemaining: number;
|
|
252
|
+
};
|
|
253
|
+
clear(): void;
|
|
254
|
+
drain(): Promise<void>;
|
|
255
|
+
}
|
|
256
|
+
declare function batchRequest<T>(requests: Array<() => Promise<T>>, options?: {
|
|
257
|
+
concurrency?: number;
|
|
258
|
+
stopOnError?: boolean;
|
|
259
|
+
}): Promise<T[]>;
|
|
260
|
+
|
|
261
|
+
export { ABTestService as A, BlogService as B, ContentCalendarService as C, GenerationExecutor as G, type IAIContentService as I, MediaGenerationService as M, PromptBuilder as P, type QueueConfig as Q, RequestPriority as R, SeoService as S, VIDEO_DURATION_OPTIONS as V, AIContentService as a, ASPECT_RATIO_VALUES as b, AnalysisService as c, IMAGE_QUALITY_VALUES as d, ImagePromptService as e, SocialService as f, VIDEO_QUALITY_VALUES as g, VideoScriptService as h, batchRequest as i, extractJSON as j, getDimensionsForAspectRatio as k, getRecommendedQuality as l, isValidJSON as m, RequestQueue as n, resolveDimensionsForAspectRatio as o, parseAIResponse as p, recommendQualityForAspectRatio as r, safeJSONParse as s };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-ai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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",
|