@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.cjs
CHANGED
|
@@ -4654,7 +4654,48 @@ function toAIProviderConfig(config) {
|
|
|
4654
4654
|
...pruna ? { pruna } : {}
|
|
4655
4655
|
};
|
|
4656
4656
|
}
|
|
4657
|
-
var buildServices = (configOrGenerator) => {
|
|
4657
|
+
var buildServices = (configOrGenerator, model, customGenerator) => {
|
|
4658
|
+
if (customGenerator) {
|
|
4659
|
+
const executor2 = new GenerationExecutor(customGenerator);
|
|
4660
|
+
const emptyFactory = new ProviderFactory({
|
|
4661
|
+
priority: [],
|
|
4662
|
+
fallbackEnabled: false
|
|
4663
|
+
});
|
|
4664
|
+
return {
|
|
4665
|
+
providerFactory: emptyFactory,
|
|
4666
|
+
blogService: new BlogService(executor2),
|
|
4667
|
+
socialService: new SocialService(executor2),
|
|
4668
|
+
videoScriptService: new VideoScriptService(executor2),
|
|
4669
|
+
analysisService: new AnalysisService(executor2),
|
|
4670
|
+
seoService: new SeoService(executor2),
|
|
4671
|
+
abTestService: new ABTestService(executor2),
|
|
4672
|
+
imagePromptService: new ImagePromptService(executor2),
|
|
4673
|
+
contentCalendarService: new ContentCalendarService(executor2),
|
|
4674
|
+
mediaGenerationService: new MediaGenerationService(emptyFactory)
|
|
4675
|
+
};
|
|
4676
|
+
}
|
|
4677
|
+
if (typeof configOrGenerator === "string") {
|
|
4678
|
+
const aiConfig = {
|
|
4679
|
+
anthropic: {
|
|
4680
|
+
apiKey: configOrGenerator,
|
|
4681
|
+
...model ? { models: { balanced: model } } : {}
|
|
4682
|
+
}
|
|
4683
|
+
};
|
|
4684
|
+
const factory2 = createAI(aiConfig);
|
|
4685
|
+
const executor2 = new GenerationExecutor(factory2);
|
|
4686
|
+
return {
|
|
4687
|
+
providerFactory: factory2,
|
|
4688
|
+
blogService: new BlogService(executor2),
|
|
4689
|
+
socialService: new SocialService(executor2),
|
|
4690
|
+
videoScriptService: new VideoScriptService(executor2),
|
|
4691
|
+
analysisService: new AnalysisService(executor2),
|
|
4692
|
+
seoService: new SeoService(executor2),
|
|
4693
|
+
abTestService: new ABTestService(executor2),
|
|
4694
|
+
imagePromptService: new ImagePromptService(executor2),
|
|
4695
|
+
contentCalendarService: new ContentCalendarService(executor2),
|
|
4696
|
+
mediaGenerationService: new MediaGenerationService(factory2)
|
|
4697
|
+
};
|
|
4698
|
+
}
|
|
4658
4699
|
if (isTextGenerator(configOrGenerator)) {
|
|
4659
4700
|
const executor2 = new GenerationExecutor(configOrGenerator);
|
|
4660
4701
|
const emptyFactory = new ProviderFactory({
|
|
@@ -4700,8 +4741,8 @@ var AIContentService = class {
|
|
|
4700
4741
|
imagePromptService;
|
|
4701
4742
|
contentCalendarService;
|
|
4702
4743
|
mediaGenerationService;
|
|
4703
|
-
constructor(configOrGenerator) {
|
|
4704
|
-
const bundle = buildServices(configOrGenerator);
|
|
4744
|
+
constructor(configOrGenerator, model, textGenerator) {
|
|
4745
|
+
const bundle = buildServices(configOrGenerator, model, textGenerator);
|
|
4705
4746
|
this.providerFactory = bundle.providerFactory;
|
|
4706
4747
|
this.blogService = bundle.blogService;
|
|
4707
4748
|
this.socialService = bundle.socialService;
|
|
@@ -4784,7 +4825,7 @@ var AIContentService = class {
|
|
|
4784
4825
|
|
|
4785
4826
|
// src/hooks/internal/useAIContentContext.ts
|
|
4786
4827
|
function useAIContentContext(options) {
|
|
4787
|
-
const { config, callbacks } = options;
|
|
4828
|
+
const { config, providers, apiKey, model, callbacks } = options;
|
|
4788
4829
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
4789
4830
|
const [progress, setProgress] = react.useState(0);
|
|
4790
4831
|
const [error, setError] = react.useState(null);
|
|
@@ -4806,8 +4847,14 @@ function useAIContentContext(options) {
|
|
|
4806
4847
|
if (config) {
|
|
4807
4848
|
return new AIContentService(config);
|
|
4808
4849
|
}
|
|
4809
|
-
|
|
4810
|
-
|
|
4850
|
+
if (providers) {
|
|
4851
|
+
return new AIContentService(providers);
|
|
4852
|
+
}
|
|
4853
|
+
if (apiKey) {
|
|
4854
|
+
return new AIContentService(apiKey, model);
|
|
4855
|
+
}
|
|
4856
|
+
throw new Error("A provider config, providers object, or apiKey must be provided to useAIContent");
|
|
4857
|
+
}, [config, providers, apiKey, model]);
|
|
4811
4858
|
const reportProgress = react.useCallback((value) => {
|
|
4812
4859
|
if (mountedRef.current) setProgress(value);
|
|
4813
4860
|
callbacksRef.current?.onProgress?.(value);
|
|
@@ -4883,6 +4930,9 @@ function useAIContent(options) {
|
|
|
4883
4930
|
const callbacks = react.useMemo(() => stableCallbacks(options), [options.onError, options.onProgress]);
|
|
4884
4931
|
const { service, ctx } = useAIContentContext({
|
|
4885
4932
|
config: options.config,
|
|
4933
|
+
providers: options.providers,
|
|
4934
|
+
apiKey: options.apiKey,
|
|
4935
|
+
model: options.model,
|
|
4886
4936
|
callbacks
|
|
4887
4937
|
});
|
|
4888
4938
|
const generateBlogPost = react.useCallback(
|
|
@@ -5232,7 +5282,10 @@ function useAIGeneration(options) {
|
|
|
5232
5282
|
}
|
|
5233
5283
|
function useBlogGenerator(options) {
|
|
5234
5284
|
const { service, ctx } = useAIContentContext({
|
|
5235
|
-
config: options.config
|
|
5285
|
+
config: options.config,
|
|
5286
|
+
apiKey: options.apiKey,
|
|
5287
|
+
model: options.model,
|
|
5288
|
+
providers: options.providers
|
|
5236
5289
|
});
|
|
5237
5290
|
const [generatedBlog, setGeneratedBlog] = react.useState(null);
|
|
5238
5291
|
const generateBlog = react.useCallback(
|
|
@@ -5259,7 +5312,10 @@ function useBlogGenerator(options) {
|
|
|
5259
5312
|
}
|
|
5260
5313
|
function useSocialContentGenerator(options) {
|
|
5261
5314
|
const { service, ctx } = useAIContentContext({
|
|
5262
|
-
config: options.config
|
|
5315
|
+
config: options.config,
|
|
5316
|
+
apiKey: options.apiKey,
|
|
5317
|
+
model: options.model,
|
|
5318
|
+
providers: options.providers
|
|
5263
5319
|
});
|
|
5264
5320
|
const [generatedContents, setGeneratedContents] = react.useState([]);
|
|
5265
5321
|
const generateForPlatform = react.useCallback(
|