@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
package/dist/hooks/index.d.cts
CHANGED
|
@@ -18,6 +18,10 @@ type ContentServiceConfig = AIProviderConfig | ProviderConfig | ITextGenerator;
|
|
|
18
18
|
interface UseAIContentOptions {
|
|
19
19
|
/** Provider config (AIProviderConfig or legacy ProviderConfig) or a custom ITextGenerator. */
|
|
20
20
|
config?: ContentServiceConfig;
|
|
21
|
+
/** Legacy alias for config */
|
|
22
|
+
providers?: ProviderConfig;
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
model?: string;
|
|
21
25
|
onError?: (error: Error) => void;
|
|
22
26
|
onProgress?: (progress: number) => void;
|
|
23
27
|
}
|
|
@@ -75,7 +79,10 @@ interface UseAIGenerationReturn {
|
|
|
75
79
|
declare function useAIGeneration(options: UseAIGenerationOptions): UseAIGenerationReturn;
|
|
76
80
|
|
|
77
81
|
interface UseBlogGeneratorOptions {
|
|
78
|
-
config
|
|
82
|
+
config?: ContentServiceConfig;
|
|
83
|
+
apiKey?: string;
|
|
84
|
+
model?: string;
|
|
85
|
+
providers?: ProviderConfig;
|
|
79
86
|
}
|
|
80
87
|
interface UseBlogGeneratorReturn {
|
|
81
88
|
isGenerating: boolean;
|
|
@@ -87,7 +94,10 @@ interface UseBlogGeneratorReturn {
|
|
|
87
94
|
declare function useBlogGenerator(options: UseBlogGeneratorOptions): UseBlogGeneratorReturn;
|
|
88
95
|
|
|
89
96
|
interface UseSocialContentGeneratorOptions {
|
|
90
|
-
config
|
|
97
|
+
config?: ContentServiceConfig;
|
|
98
|
+
apiKey?: string;
|
|
99
|
+
model?: string;
|
|
100
|
+
providers?: ProviderConfig;
|
|
91
101
|
}
|
|
92
102
|
interface UseSocialContentGeneratorReturn {
|
|
93
103
|
isGenerating: boolean;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -18,6 +18,10 @@ type ContentServiceConfig = AIProviderConfig | ProviderConfig | ITextGenerator;
|
|
|
18
18
|
interface UseAIContentOptions {
|
|
19
19
|
/** Provider config (AIProviderConfig or legacy ProviderConfig) or a custom ITextGenerator. */
|
|
20
20
|
config?: ContentServiceConfig;
|
|
21
|
+
/** Legacy alias for config */
|
|
22
|
+
providers?: ProviderConfig;
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
model?: string;
|
|
21
25
|
onError?: (error: Error) => void;
|
|
22
26
|
onProgress?: (progress: number) => void;
|
|
23
27
|
}
|
|
@@ -75,7 +79,10 @@ interface UseAIGenerationReturn {
|
|
|
75
79
|
declare function useAIGeneration(options: UseAIGenerationOptions): UseAIGenerationReturn;
|
|
76
80
|
|
|
77
81
|
interface UseBlogGeneratorOptions {
|
|
78
|
-
config
|
|
82
|
+
config?: ContentServiceConfig;
|
|
83
|
+
apiKey?: string;
|
|
84
|
+
model?: string;
|
|
85
|
+
providers?: ProviderConfig;
|
|
79
86
|
}
|
|
80
87
|
interface UseBlogGeneratorReturn {
|
|
81
88
|
isGenerating: boolean;
|
|
@@ -87,7 +94,10 @@ interface UseBlogGeneratorReturn {
|
|
|
87
94
|
declare function useBlogGenerator(options: UseBlogGeneratorOptions): UseBlogGeneratorReturn;
|
|
88
95
|
|
|
89
96
|
interface UseSocialContentGeneratorOptions {
|
|
90
|
-
config
|
|
97
|
+
config?: ContentServiceConfig;
|
|
98
|
+
apiKey?: string;
|
|
99
|
+
model?: string;
|
|
100
|
+
providers?: ProviderConfig;
|
|
91
101
|
}
|
|
92
102
|
interface UseSocialContentGeneratorReturn {
|
|
93
103
|
isGenerating: boolean;
|
package/dist/hooks/index.js
CHANGED
|
@@ -4652,7 +4652,48 @@ function toAIProviderConfig(config) {
|
|
|
4652
4652
|
...pruna ? { pruna } : {}
|
|
4653
4653
|
};
|
|
4654
4654
|
}
|
|
4655
|
-
var buildServices = (configOrGenerator) => {
|
|
4655
|
+
var buildServices = (configOrGenerator, model, customGenerator) => {
|
|
4656
|
+
if (customGenerator) {
|
|
4657
|
+
const executor2 = new GenerationExecutor(customGenerator);
|
|
4658
|
+
const emptyFactory = new ProviderFactory({
|
|
4659
|
+
priority: [],
|
|
4660
|
+
fallbackEnabled: false
|
|
4661
|
+
});
|
|
4662
|
+
return {
|
|
4663
|
+
providerFactory: emptyFactory,
|
|
4664
|
+
blogService: new BlogService(executor2),
|
|
4665
|
+
socialService: new SocialService(executor2),
|
|
4666
|
+
videoScriptService: new VideoScriptService(executor2),
|
|
4667
|
+
analysisService: new AnalysisService(executor2),
|
|
4668
|
+
seoService: new SeoService(executor2),
|
|
4669
|
+
abTestService: new ABTestService(executor2),
|
|
4670
|
+
imagePromptService: new ImagePromptService(executor2),
|
|
4671
|
+
contentCalendarService: new ContentCalendarService(executor2),
|
|
4672
|
+
mediaGenerationService: new MediaGenerationService(emptyFactory)
|
|
4673
|
+
};
|
|
4674
|
+
}
|
|
4675
|
+
if (typeof configOrGenerator === "string") {
|
|
4676
|
+
const aiConfig = {
|
|
4677
|
+
anthropic: {
|
|
4678
|
+
apiKey: configOrGenerator,
|
|
4679
|
+
...model ? { models: { balanced: model } } : {}
|
|
4680
|
+
}
|
|
4681
|
+
};
|
|
4682
|
+
const factory2 = createAI(aiConfig);
|
|
4683
|
+
const executor2 = new GenerationExecutor(factory2);
|
|
4684
|
+
return {
|
|
4685
|
+
providerFactory: factory2,
|
|
4686
|
+
blogService: new BlogService(executor2),
|
|
4687
|
+
socialService: new SocialService(executor2),
|
|
4688
|
+
videoScriptService: new VideoScriptService(executor2),
|
|
4689
|
+
analysisService: new AnalysisService(executor2),
|
|
4690
|
+
seoService: new SeoService(executor2),
|
|
4691
|
+
abTestService: new ABTestService(executor2),
|
|
4692
|
+
imagePromptService: new ImagePromptService(executor2),
|
|
4693
|
+
contentCalendarService: new ContentCalendarService(executor2),
|
|
4694
|
+
mediaGenerationService: new MediaGenerationService(factory2)
|
|
4695
|
+
};
|
|
4696
|
+
}
|
|
4656
4697
|
if (isTextGenerator(configOrGenerator)) {
|
|
4657
4698
|
const executor2 = new GenerationExecutor(configOrGenerator);
|
|
4658
4699
|
const emptyFactory = new ProviderFactory({
|
|
@@ -4698,8 +4739,8 @@ var AIContentService = class {
|
|
|
4698
4739
|
imagePromptService;
|
|
4699
4740
|
contentCalendarService;
|
|
4700
4741
|
mediaGenerationService;
|
|
4701
|
-
constructor(configOrGenerator) {
|
|
4702
|
-
const bundle = buildServices(configOrGenerator);
|
|
4742
|
+
constructor(configOrGenerator, model, textGenerator) {
|
|
4743
|
+
const bundle = buildServices(configOrGenerator, model, textGenerator);
|
|
4703
4744
|
this.providerFactory = bundle.providerFactory;
|
|
4704
4745
|
this.blogService = bundle.blogService;
|
|
4705
4746
|
this.socialService = bundle.socialService;
|
|
@@ -4782,7 +4823,7 @@ var AIContentService = class {
|
|
|
4782
4823
|
|
|
4783
4824
|
// src/hooks/internal/useAIContentContext.ts
|
|
4784
4825
|
function useAIContentContext(options) {
|
|
4785
|
-
const { config, callbacks } = options;
|
|
4826
|
+
const { config, providers, apiKey, model, callbacks } = options;
|
|
4786
4827
|
const [isLoading, setIsLoading] = useState(false);
|
|
4787
4828
|
const [progress, setProgress] = useState(0);
|
|
4788
4829
|
const [error, setError] = useState(null);
|
|
@@ -4804,8 +4845,14 @@ function useAIContentContext(options) {
|
|
|
4804
4845
|
if (config) {
|
|
4805
4846
|
return new AIContentService(config);
|
|
4806
4847
|
}
|
|
4807
|
-
|
|
4808
|
-
|
|
4848
|
+
if (providers) {
|
|
4849
|
+
return new AIContentService(providers);
|
|
4850
|
+
}
|
|
4851
|
+
if (apiKey) {
|
|
4852
|
+
return new AIContentService(apiKey, model);
|
|
4853
|
+
}
|
|
4854
|
+
throw new Error("A provider config, providers object, or apiKey must be provided to useAIContent");
|
|
4855
|
+
}, [config, providers, apiKey, model]);
|
|
4809
4856
|
const reportProgress = useCallback((value) => {
|
|
4810
4857
|
if (mountedRef.current) setProgress(value);
|
|
4811
4858
|
callbacksRef.current?.onProgress?.(value);
|
|
@@ -4881,6 +4928,9 @@ function useAIContent(options) {
|
|
|
4881
4928
|
const callbacks = useMemo(() => stableCallbacks(options), [options.onError, options.onProgress]);
|
|
4882
4929
|
const { service, ctx } = useAIContentContext({
|
|
4883
4930
|
config: options.config,
|
|
4931
|
+
providers: options.providers,
|
|
4932
|
+
apiKey: options.apiKey,
|
|
4933
|
+
model: options.model,
|
|
4884
4934
|
callbacks
|
|
4885
4935
|
});
|
|
4886
4936
|
const generateBlogPost = useCallback(
|
|
@@ -5230,7 +5280,10 @@ function useAIGeneration(options) {
|
|
|
5230
5280
|
}
|
|
5231
5281
|
function useBlogGenerator(options) {
|
|
5232
5282
|
const { service, ctx } = useAIContentContext({
|
|
5233
|
-
config: options.config
|
|
5283
|
+
config: options.config,
|
|
5284
|
+
apiKey: options.apiKey,
|
|
5285
|
+
model: options.model,
|
|
5286
|
+
providers: options.providers
|
|
5234
5287
|
});
|
|
5235
5288
|
const [generatedBlog, setGeneratedBlog] = useState(null);
|
|
5236
5289
|
const generateBlog = useCallback(
|
|
@@ -5257,7 +5310,10 @@ function useBlogGenerator(options) {
|
|
|
5257
5310
|
}
|
|
5258
5311
|
function useSocialContentGenerator(options) {
|
|
5259
5312
|
const { service, ctx } = useAIContentContext({
|
|
5260
|
-
config: options.config
|
|
5313
|
+
config: options.config,
|
|
5314
|
+
apiKey: options.apiKey,
|
|
5315
|
+
model: options.model,
|
|
5316
|
+
providers: options.providers
|
|
5261
5317
|
});
|
|
5262
5318
|
const [generatedContents, setGeneratedContents] = useState([]);
|
|
5263
5319
|
const generateForPlatform = useCallback(
|