@webiny/ai-powerups 6.4.12-beta.5 → 6.5.0-beta.0
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/admin/Extension.js +7 -1
- package/admin/Extension.js.map +1 -1
- package/admin/domain/modelRoles.d.ts +17 -0
- package/admin/domain/modelRoles.js +8 -0
- package/admin/domain/modelRoles.js.map +1 -0
- package/admin/features/compareEntryRevisions/CompareEntryRevisionsGateway.d.ts +12 -0
- package/admin/features/compareEntryRevisions/CompareEntryRevisionsGateway.js +46 -0
- package/admin/features/compareEntryRevisions/CompareEntryRevisionsGateway.js.map +1 -0
- package/admin/features/compareEntryRevisions/CompareEntryRevisionsRepository.d.ts +11 -0
- package/admin/features/compareEntryRevisions/CompareEntryRevisionsRepository.js +18 -0
- package/admin/features/compareEntryRevisions/CompareEntryRevisionsRepository.js.map +1 -0
- package/admin/features/compareEntryRevisions/CompareEntryRevisionsUseCase.d.ts +11 -0
- package/admin/features/compareEntryRevisions/CompareEntryRevisionsUseCase.js +18 -0
- package/admin/features/compareEntryRevisions/CompareEntryRevisionsUseCase.js.map +1 -0
- package/admin/features/compareEntryRevisions/abstractions.d.ts +32 -0
- package/admin/features/compareEntryRevisions/abstractions.js +7 -0
- package/admin/features/compareEntryRevisions/abstractions.js.map +1 -0
- package/admin/features/compareEntryRevisions/feature.d.ts +1 -0
- package/admin/features/compareEntryRevisions/feature.js +15 -0
- package/admin/features/compareEntryRevisions/feature.js.map +1 -0
- package/admin/features/compareEntryRevisions/index.d.ts +2 -0
- package/admin/features/compareEntryRevisions/index.js +2 -0
- package/admin/features/feature.js +4 -0
- package/admin/features/feature.js.map +1 -1
- package/admin/features/generateEntryContent/GenerateEntryContentGateway.d.ts +12 -0
- package/admin/features/generateEntryContent/GenerateEntryContentGateway.js +45 -0
- package/admin/features/generateEntryContent/GenerateEntryContentGateway.js.map +1 -0
- package/admin/features/generateEntryContent/GenerateEntryContentUseCase.d.ts +11 -0
- package/admin/features/generateEntryContent/GenerateEntryContentUseCase.js +18 -0
- package/admin/features/generateEntryContent/GenerateEntryContentUseCase.js.map +1 -0
- package/admin/features/generateEntryContent/abstractions.d.ts +24 -0
- package/admin/features/generateEntryContent/abstractions.js +6 -0
- package/admin/features/generateEntryContent/abstractions.js.map +1 -0
- package/admin/features/generateEntryContent/feature.d.ts +1 -0
- package/admin/features/generateEntryContent/feature.js +13 -0
- package/admin/features/generateEntryContent/feature.js.map +1 -0
- package/admin/features/generateEntryContent/index.d.ts +3 -0
- package/admin/features/generateEntryContent/index.js +2 -0
- package/admin/features/generatePageContent/GeneratePageContentGateway.js +2 -0
- package/admin/features/generatePageContent/GeneratePageContentGateway.js.map +1 -1
- package/admin/features/generatePageContent/abstractions.d.ts +1 -0
- package/admin/features/generatePageContent/abstractions.js.map +1 -1
- package/admin/features/listCapabilities/ListCapabilitiesGateway.d.ts +12 -0
- package/admin/features/listCapabilities/ListCapabilitiesGateway.js +34 -0
- package/admin/features/listCapabilities/ListCapabilitiesGateway.js.map +1 -0
- package/admin/features/listCapabilities/ListCapabilitiesRepository.d.ts +13 -0
- package/admin/features/listCapabilities/ListCapabilitiesRepository.js +27 -0
- package/admin/features/listCapabilities/ListCapabilitiesRepository.js.map +1 -0
- package/admin/features/listCapabilities/ListCapabilitiesUseCase.d.ts +10 -0
- package/admin/features/listCapabilities/ListCapabilitiesUseCase.js +18 -0
- package/admin/features/listCapabilities/ListCapabilitiesUseCase.js.map +1 -0
- package/admin/features/listCapabilities/abstractions.d.ts +28 -0
- package/admin/features/listCapabilities/abstractions.js +7 -0
- package/admin/features/listCapabilities/abstractions.js.map +1 -0
- package/admin/features/listCapabilities/feature.d.ts +3 -0
- package/admin/features/listCapabilities/feature.js +21 -0
- package/admin/features/listCapabilities/feature.js.map +1 -0
- package/admin/features/listCapabilities/index.d.ts +3 -0
- package/admin/features/listCapabilities/index.js +2 -0
- package/admin/features/listModels/ListModelsGateway.js +18 -1
- package/admin/features/listModels/ListModelsGateway.js.map +1 -1
- package/admin/features/listModels/abstractions.d.ts +2 -0
- package/admin/features/listModels/abstractions.js.map +1 -1
- package/admin/features/settings/shared/abstractions.d.ts +58 -25
- package/admin/features/settings/shared/abstractions.js.map +1 -1
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPage.d.ts +2 -2
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPage.js +3 -4
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPage.js.map +1 -1
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPresenter.js +13 -1
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPresenter.js.map +1 -1
- package/admin/presentation/AiPowerUpsSettings/feature.js +6 -2
- package/admin/presentation/AiPowerUpsSettings/feature.js.map +1 -1
- package/admin/presentation/AiPowerUpsSettings/hasUsableModel.d.ts +13 -0
- package/admin/presentation/AiPowerUpsSettings/hasUsableModel.js +9 -0
- package/admin/presentation/AiPowerUpsSettings/hasUsableModel.js.map +1 -0
- package/admin/presentation/AiPowerUpsSettings/index.d.ts +1 -0
- package/admin/presentation/AiPowerUpsSettings/index.js +1 -0
- package/admin/presentation/AiPowerUpsSettings/settingsGroup.d.ts +6 -0
- package/admin/presentation/AiPowerUpsSettings/settingsGroup.js.map +1 -1
- package/admin/presentation/AiPromptFormFactory/AiPromptFormFactory.d.ts +20 -0
- package/admin/presentation/AiPromptFormFactory/AiPromptFormFactory.js +108 -0
- package/admin/presentation/AiPromptFormFactory/AiPromptFormFactory.js.map +1 -0
- package/admin/presentation/AiPromptFormFactory/abstractions.d.ts +14 -0
- package/admin/presentation/AiPromptFormFactory/abstractions.js +5 -0
- package/admin/presentation/AiPromptFormFactory/abstractions.js.map +1 -0
- package/admin/presentation/AiPromptFormFactory/feature.d.ts +1 -0
- package/admin/presentation/AiPromptFormFactory/feature.js +11 -0
- package/admin/presentation/AiPromptFormFactory/feature.js.map +1 -0
- package/admin/presentation/CapabilitiesSettings.d.ts +39 -0
- package/admin/presentation/CapabilitiesSettings.js +104 -0
- package/admin/presentation/CapabilitiesSettings.js.map +1 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsDialog.d.ts +9 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsDialog.js +118 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsDialog.js.map +1 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsDrawer.d.ts +9 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsDrawer.js +72 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsDrawer.js.map +1 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsMenuItem.d.ts +4 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsMenuItem.js +21 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsMenuItem.js.map +1 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsOverlays.d.ts +2 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsOverlays.js +17 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsOverlays.js.map +1 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsPresenter.d.ts +25 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsPresenter.js +90 -0
- package/admin/presentation/CmsCompareEntryRevisions/CmsCompareEntryRevisionsPresenter.js.map +1 -0
- package/admin/presentation/CmsCompareEntryRevisions/Extension.d.ts +2 -0
- package/admin/presentation/CmsCompareEntryRevisions/Extension.js +16 -0
- package/admin/presentation/CmsCompareEntryRevisions/Extension.js.map +1 -0
- package/admin/presentation/CmsCompareEntryRevisions/abstractions.d.ts +29 -0
- package/admin/presentation/CmsCompareEntryRevisions/abstractions.js +5 -0
- package/admin/presentation/CmsCompareEntryRevisions/abstractions.js.map +1 -0
- package/admin/presentation/CmsCompareEntryRevisions/feature.d.ts +3 -0
- package/admin/presentation/CmsCompareEntryRevisions/feature.js +17 -0
- package/admin/presentation/CmsCompareEntryRevisions/feature.js.map +1 -0
- package/admin/presentation/CmsContentGeneration/CmsGenerateContentButton.d.ts +4 -0
- package/admin/presentation/CmsContentGeneration/CmsGenerateContentButton.js +27 -0
- package/admin/presentation/CmsContentGeneration/CmsGenerateContentButton.js.map +1 -0
- package/admin/presentation/CmsContentGeneration/CmsGenerateContentDialog.d.ts +5 -0
- package/admin/presentation/CmsContentGeneration/CmsGenerateContentDialog.js +106 -0
- package/admin/presentation/CmsContentGeneration/CmsGenerateContentDialog.js.map +1 -0
- package/admin/presentation/CmsContentGeneration/CmsGenerateContentPresenter.d.ts +29 -0
- package/admin/presentation/CmsContentGeneration/CmsGenerateContentPresenter.js +120 -0
- package/admin/presentation/CmsContentGeneration/CmsGenerateContentPresenter.js.map +1 -0
- package/admin/presentation/CmsContentGeneration/Extension.d.ts +2 -0
- package/admin/presentation/CmsContentGeneration/Extension.js +27 -0
- package/admin/presentation/CmsContentGeneration/Extension.js.map +1 -0
- package/admin/presentation/CmsContentGeneration/abstractions.d.ts +20 -0
- package/admin/presentation/CmsContentGeneration/abstractions.js +5 -0
- package/admin/presentation/CmsContentGeneration/abstractions.js.map +1 -0
- package/admin/presentation/CmsContentGeneration/feature.d.ts +3 -0
- package/admin/presentation/CmsContentGeneration/feature.js +17 -0
- package/admin/presentation/CmsContentGeneration/feature.js.map +1 -0
- package/admin/presentation/CmsEntryWizard/CmsEntryWizard.d.ts +4 -0
- package/admin/presentation/CmsEntryWizard/CmsEntryWizard.js +113 -0
- package/admin/presentation/CmsEntryWizard/CmsEntryWizard.js.map +1 -0
- package/admin/presentation/CmsEntryWizard/CmsEntryWizardGate.d.ts +4 -0
- package/admin/presentation/CmsEntryWizard/CmsEntryWizardGate.js +19 -0
- package/admin/presentation/CmsEntryWizard/CmsEntryWizardGate.js.map +1 -0
- package/admin/presentation/CmsEntryWizard/Extension.d.ts +2 -0
- package/admin/presentation/CmsEntryWizard/Extension.js +10 -0
- package/admin/presentation/CmsEntryWizard/Extension.js.map +1 -0
- package/admin/presentation/ConnectionsSettings.d.ts +25 -0
- package/admin/presentation/ConnectionsSettings.js +52 -0
- package/admin/presentation/ConnectionsSettings.js.map +1 -0
- package/admin/presentation/ModelRolesSettings.d.ts +29 -0
- package/admin/presentation/ModelRolesSettings.js +67 -0
- package/admin/presentation/ModelRolesSettings.js.map +1 -0
- package/admin/presentation/ProjectsSettings.js +4 -4
- package/admin/presentation/ProjectsSettings.js.map +1 -1
- package/admin/presentation/ProvidersSettings.js +1 -1
- package/admin/presentation/ProvidersSettings.js.map +1 -1
- package/admin/presentation/WbContentGeneration/GenerateContentButton.js +2 -2
- package/admin/presentation/WbContentGeneration/GenerateContentButton.js.map +1 -1
- package/admin/presentation/WbContentGeneration/GenerateContentDialog.d.ts +2 -2
- package/admin/presentation/WbContentGeneration/GenerateContentDialog.js +2 -2
- package/admin/presentation/WbContentGeneration/GenerateContentDialog.js.map +1 -1
- package/admin/presentation/WbContentGeneration/GenerateContentPresenter.d.ts +4 -12
- package/admin/presentation/WbContentGeneration/GenerateContentPresenter.js +12 -94
- package/admin/presentation/WbContentGeneration/GenerateContentPresenter.js.map +1 -1
- package/admin/presentation/modelRoles.d.ts +10 -0
- package/admin/presentation/modelRoles.js +23 -0
- package/admin/presentation/modelRoles.js.map +1 -0
- package/api/Extension.js +16 -0
- package/api/Extension.js.map +1 -1
- package/api/features/AiImageEnrichment/AiImageEnrichmentTask.d.ts +10 -8
- package/api/features/AiImageEnrichment/AiImageEnrichmentTask.js +37 -42
- package/api/features/AiImageEnrichment/AiImageEnrichmentTask.js.map +1 -1
- package/api/features/AiImageEnrichment/capability.d.ts +13 -0
- package/api/features/AiImageEnrichment/capability.js +19 -0
- package/api/features/AiImageEnrichment/capability.js.map +1 -0
- package/api/features/AiImageEnrichment/feature.js +2 -0
- package/api/features/AiImageEnrichment/feature.js.map +1 -1
- package/api/features/AiPromptContext/AiPromptContextBuilder.d.ts +8 -1
- package/api/features/AiPromptContext/AiPromptContextBuilder.js +46 -2
- package/api/features/AiPromptContext/AiPromptContextBuilder.js.map +1 -1
- package/api/features/AiPromptContext/abstractions.d.ts +3 -0
- package/api/features/AiPromptContext/abstractions.js +9 -1
- package/api/features/AiPromptContext/abstractions.js.map +1 -1
- package/api/features/AiPromptContext/index.d.ts +1 -1
- package/api/features/AiPromptContext/index.js +1 -1
- package/api/features/Capabilities/CapabilitiesHandler.d.ts +28 -0
- package/api/features/Capabilities/CapabilitiesHandler.js +56 -0
- package/api/features/Capabilities/CapabilitiesHandler.js.map +1 -0
- package/api/features/Capabilities/ListAiCapabilitiesUseCase.d.ts +18 -0
- package/api/features/Capabilities/ListAiCapabilitiesUseCase.js +28 -0
- package/api/features/Capabilities/ListAiCapabilitiesUseCase.js.map +1 -0
- package/api/features/Capabilities/ResolveAiCapabilityUseCase.d.ts +30 -0
- package/api/features/Capabilities/ResolveAiCapabilityUseCase.js +88 -0
- package/api/features/Capabilities/ResolveAiCapabilityUseCase.js.map +1 -0
- package/api/features/Capabilities/abstractions.d.ts +77 -0
- package/api/features/Capabilities/abstractions.js +7 -0
- package/api/features/Capabilities/abstractions.js.map +1 -0
- package/api/features/Capabilities/composeSystemPrompt.d.ts +14 -0
- package/api/features/Capabilities/composeSystemPrompt.js +13 -0
- package/api/features/Capabilities/composeSystemPrompt.js.map +1 -0
- package/api/features/Capabilities/feature.d.ts +4 -0
- package/api/features/Capabilities/feature.js +15 -0
- package/api/features/Capabilities/feature.js.map +1 -0
- package/api/features/Capabilities/index.d.ts +5 -0
- package/api/features/Capabilities/index.js +3 -0
- package/api/features/Capabilities/types.d.ts +86 -0
- package/api/features/Capabilities/types.js +4 -0
- package/api/features/Capabilities/types.js.map +1 -0
- package/api/features/CmsCompareEntryRevisions/CmsCompareEntryRevisionsUseCase.d.ts +20 -0
- package/api/features/CmsCompareEntryRevisions/CmsCompareEntryRevisionsUseCase.js +82 -0
- package/api/features/CmsCompareEntryRevisions/CmsCompareEntryRevisionsUseCase.js.map +1 -0
- package/api/features/CmsCompareEntryRevisions/abstractions.d.ts +18 -0
- package/api/features/CmsCompareEntryRevisions/abstractions.js +5 -0
- package/api/features/CmsCompareEntryRevisions/abstractions.js.map +1 -0
- package/api/features/CmsCompareEntryRevisions/capability.d.ts +13 -0
- package/api/features/CmsCompareEntryRevisions/capability.js +64 -0
- package/api/features/CmsCompareEntryRevisions/capability.js.map +1 -0
- package/api/features/CmsCompareEntryRevisions/feature.d.ts +4 -0
- package/api/features/CmsCompareEntryRevisions/feature.js +13 -0
- package/api/features/CmsCompareEntryRevisions/feature.js.map +1 -0
- package/api/features/CmsCompareEntryRevisions/index.d.ts +2 -0
- package/api/features/CmsCompareEntryRevisions/index.js +2 -0
- package/api/features/CmsGenerateEntryContent/CmsGenerateEntryContentTask.d.ts +33 -0
- package/api/features/CmsGenerateEntryContent/CmsGenerateEntryContentTask.js +84 -0
- package/api/features/CmsGenerateEntryContent/CmsGenerateEntryContentTask.js.map +1 -0
- package/api/features/CmsGenerateEntryContent/CmsGenerateEntryContentUseCase.d.ts +27 -0
- package/api/features/CmsGenerateEntryContent/CmsGenerateEntryContentUseCase.js +133 -0
- package/api/features/CmsGenerateEntryContent/CmsGenerateEntryContentUseCase.js.map +1 -0
- package/api/features/CmsGenerateEntryContent/abstractions.d.ts +36 -0
- package/api/features/CmsGenerateEntryContent/abstractions.js +5 -0
- package/api/features/CmsGenerateEntryContent/abstractions.js.map +1 -0
- package/api/features/CmsGenerateEntryContent/buildPrompt.d.ts +2 -0
- package/api/features/CmsGenerateEntryContent/buildPrompt.js +61 -0
- package/api/features/CmsGenerateEntryContent/buildPrompt.js.map +1 -0
- package/api/features/CmsGenerateEntryContent/capability.d.ts +17 -0
- package/api/features/CmsGenerateEntryContent/capability.js +17 -0
- package/api/features/CmsGenerateEntryContent/capability.js.map +1 -0
- package/api/features/CmsGenerateEntryContent/feature.d.ts +4 -0
- package/api/features/CmsGenerateEntryContent/feature.js +15 -0
- package/api/features/CmsGenerateEntryContent/feature.js.map +1 -0
- package/api/features/CmsGenerateEntryContent/index.d.ts +1 -0
- package/api/features/CmsGenerateEntryContent/index.js +1 -0
- package/api/features/CmsGenerateEntryContent/injectDynamicZoneTypenames.d.ts +2 -0
- package/api/features/CmsGenerateEntryContent/injectDynamicZoneTypenames.js +30 -0
- package/api/features/CmsGenerateEntryContent/injectDynamicZoneTypenames.js.map +1 -0
- package/api/features/CmsResolveImageTool/CmsResolveImageTool.d.ts +14 -0
- package/api/features/CmsResolveImageTool/CmsResolveImageTool.js +27 -0
- package/api/features/CmsResolveImageTool/CmsResolveImageTool.js.map +1 -0
- package/api/features/CmsResolveImageTool/feature.d.ts +4 -0
- package/api/features/CmsResolveImageTool/feature.js +11 -0
- package/api/features/CmsResolveImageTool/feature.js.map +1 -0
- package/api/features/Connections/ConnectionsGraphQLMapper.d.ts +20 -0
- package/api/features/Connections/ConnectionsGraphQLMapper.js +37 -0
- package/api/features/Connections/ConnectionsGraphQLMapper.js.map +1 -0
- package/api/features/Connections/ConnectionsHandler.d.ts +25 -0
- package/api/features/Connections/ConnectionsHandler.js +84 -0
- package/api/features/Connections/ConnectionsHandler.js.map +1 -0
- package/api/features/Connections/feature.d.ts +4 -0
- package/api/features/Connections/feature.js +13 -0
- package/api/features/Connections/feature.js.map +1 -0
- package/api/features/Connections/index.d.ts +2 -0
- package/api/features/Connections/index.js +1 -0
- package/api/features/Connections/legacyProviders.d.ts +26 -0
- package/api/features/Connections/legacyProviders.js +9 -0
- package/api/features/Connections/legacyProviders.js.map +1 -0
- package/api/features/Connections/types.d.ts +36 -0
- package/api/features/Connections/types.js +0 -0
- package/api/features/GetSettings/GetSettingsRepository.js +1 -1
- package/api/features/GetSettings/GetSettingsRepository.js.map +1 -1
- package/api/features/GetSettings/index.d.ts +1 -0
- package/api/features/GetSettings/index.js +1 -0
- package/api/features/ModelRoles/ModelRolesHandler.d.ts +15 -0
- package/api/features/ModelRoles/ModelRolesHandler.js +68 -0
- package/api/features/ModelRoles/ModelRolesHandler.js.map +1 -0
- package/api/features/ModelRoles/feature.d.ts +4 -0
- package/api/features/ModelRoles/feature.js +11 -0
- package/api/features/ModelRoles/feature.js.map +1 -0
- package/api/features/ModelRoles/index.d.ts +4 -0
- package/api/features/ModelRoles/index.js +2 -0
- package/api/features/ModelRoles/roles.d.ts +16 -0
- package/api/features/ModelRoles/roles.js +9 -0
- package/api/features/ModelRoles/roles.js.map +1 -0
- package/api/features/ModelRoles/types.d.ts +21 -0
- package/api/features/ModelRoles/types.js +7 -0
- package/api/features/ModelRoles/types.js.map +1 -0
- package/api/features/Providers/ProvidersHandler.js.map +1 -1
- package/api/features/Providers/types.d.ts +2 -2
- package/api/features/UpdateSettings/UpdateSettingsRepository.js +2 -2
- package/api/features/UpdateSettings/UpdateSettingsRepository.js.map +1 -1
- package/api/features/WbGeneratePageContent/WbGeneratePageContentTask.d.ts +4 -3
- package/api/features/WbGeneratePageContent/WbGeneratePageContentTask.js +25 -15
- package/api/features/WbGeneratePageContent/WbGeneratePageContentTask.js.map +1 -1
- package/api/features/WbGeneratePageContent/WbGeneratePageContentUseCase.d.ts +3 -5
- package/api/features/WbGeneratePageContent/WbGeneratePageContentUseCase.js +16 -23
- package/api/features/WbGeneratePageContent/WbGeneratePageContentUseCase.js.map +1 -1
- package/api/features/WbGeneratePageContent/abstractions.d.ts +1 -0
- package/api/features/WbGeneratePageContent/abstractions.js.map +1 -1
- package/api/features/WbGeneratePageContent/capability.d.ts +16 -0
- package/api/features/WbGeneratePageContent/capability.js +17 -0
- package/api/features/WbGeneratePageContent/capability.js.map +1 -0
- package/api/features/WbGeneratePageContent/feature.js +2 -0
- package/api/features/WbGeneratePageContent/feature.js.map +1 -1
- package/api/features/WbTranslatePage/LexicalParser.d.ts +10 -0
- package/api/features/WbTranslatePage/LexicalParser.js +37 -0
- package/api/features/WbTranslatePage/LexicalParser.js.map +1 -0
- package/api/features/WbTranslatePage/WbTranslatePageDecorator.d.ts +29 -0
- package/api/features/WbTranslatePage/WbTranslatePageDecorator.js +143 -0
- package/api/features/WbTranslatePage/WbTranslatePageDecorator.js.map +1 -0
- package/api/features/WbTranslatePage/abstractions/LexicalParser.d.ts +7 -0
- package/api/features/WbTranslatePage/abstractions/LexicalParser.js +5 -0
- package/api/features/WbTranslatePage/abstractions/LexicalParser.js.map +1 -0
- package/api/features/WbTranslatePage/capability.d.ts +13 -0
- package/api/features/WbTranslatePage/capability.js +19 -0
- package/api/features/WbTranslatePage/capability.js.map +1 -0
- package/api/features/WbTranslatePage/feature.d.ts +4 -0
- package/api/features/WbTranslatePage/feature.js +15 -0
- package/api/features/WbTranslatePage/feature.js.map +1 -0
- package/api/features/WbTranslatePage/index.d.ts +2 -0
- package/api/features/WbTranslatePage/index.js +2 -0
- package/api/features/shared/abstractions.d.ts +6 -1
- package/api/features/shared/abstractions.js.map +1 -1
- package/api/features/shared/modelId.d.ts +11 -0
- package/api/features/shared/modelId.js +4 -0
- package/api/features/shared/modelId.js.map +1 -0
- package/api/graphql/BaseGraphQLSchema.js +58 -1
- package/api/graphql/BaseGraphQLSchema.js.map +1 -1
- package/api/graphql/CmsCompareEntryRevisionsSchema.d.ts +8 -0
- package/api/graphql/CmsCompareEntryRevisionsSchema.js +68 -0
- package/api/graphql/CmsCompareEntryRevisionsSchema.js.map +1 -0
- package/api/types.d.ts +3 -0
- package/api/types.js +3 -0
- package/{api/features/WbGeneratePageContent → domain}/LlmJsonResponse.d.ts +1 -0
- package/{api/features/WbGeneratePageContent → domain}/LlmJsonResponse.js +3 -0
- package/domain/LlmJsonResponse.js.map +1 -0
- package/exports/admin/ai-powerups.d.ts +1 -0
- package/exports/admin/ai-powerups.js +1 -0
- package/exports/api/ai-powerups.d.ts +2 -0
- package/exports/api/ai-powerups.js +2 -0
- package/package.json +33 -26
- package/api/features/WbGeneratePageContent/LlmJsonResponse.js.map +0 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { computed, makeAutoObservable, runInAction } from "mobx";
|
|
2
|
+
import { ToolPipelineRunner } from "@webiny/app-admin";
|
|
3
|
+
import { CmsGenerateContentPresenter } from "./abstractions.js";
|
|
4
|
+
import { GenerateEntryContentUseCase } from "../../features/generateEntryContent/index.js";
|
|
5
|
+
import { AiPromptFormFactory } from "../AiPromptFormFactory/abstractions.js";
|
|
6
|
+
const SUBMIT_TIMEOUT_MS = 300000;
|
|
7
|
+
class CmsGenerateContentPresenterImpl {
|
|
8
|
+
constructor(pipelineRunner, generateEntryContent, formFactory){
|
|
9
|
+
this.pipelineRunner = pipelineRunner;
|
|
10
|
+
this.generateEntryContent = generateEntryContent;
|
|
11
|
+
this.formFactory = formFactory;
|
|
12
|
+
this._loading = false;
|
|
13
|
+
this._submitting = false;
|
|
14
|
+
this._timedOut = false;
|
|
15
|
+
this._form = null;
|
|
16
|
+
this._timeoutId = null;
|
|
17
|
+
this._intervalId = null;
|
|
18
|
+
this._elapsedSeconds = 0;
|
|
19
|
+
makeAutoObservable(this, {
|
|
20
|
+
vm: computed
|
|
21
|
+
}, {
|
|
22
|
+
autoBind: true
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
get vm() {
|
|
26
|
+
return {
|
|
27
|
+
form: this._form ? this._form.vm : null,
|
|
28
|
+
loading: this._loading,
|
|
29
|
+
submitting: this._submitting,
|
|
30
|
+
timedOut: this._timedOut,
|
|
31
|
+
elapsedSeconds: this._elapsedSeconds
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async init() {
|
|
35
|
+
this._form = this.formFactory.createForm({
|
|
36
|
+
promptDescription: "Describe the content you want to generate for this entry."
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async submit(modelId) {
|
|
40
|
+
if (!this._form) return;
|
|
41
|
+
const data = await this._form.submit();
|
|
42
|
+
if (!data) return;
|
|
43
|
+
runInAction(()=>{
|
|
44
|
+
this._submitting = true;
|
|
45
|
+
this._timedOut = false;
|
|
46
|
+
});
|
|
47
|
+
this.startTimeout();
|
|
48
|
+
try {
|
|
49
|
+
const excludedFileIds = this.formFactory.computeExcludedFileIds(this._form);
|
|
50
|
+
const additionalFileIds = data.additionalFiles?.map((f)=>f.id) ?? null;
|
|
51
|
+
await this.generateEntryContent.execute({
|
|
52
|
+
prompt: data.prompt,
|
|
53
|
+
modelId,
|
|
54
|
+
projectId: data.project || null,
|
|
55
|
+
excludedFileIds,
|
|
56
|
+
readerPersonaId: data.readerPersona || null,
|
|
57
|
+
writerPersonaId: data.writerPersona || null,
|
|
58
|
+
additionalFileIds
|
|
59
|
+
});
|
|
60
|
+
} catch {
|
|
61
|
+
this.clearTimeout();
|
|
62
|
+
runInAction(()=>{
|
|
63
|
+
this._submitting = false;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async processAiResponse(responseText) {
|
|
68
|
+
this.clearTimeout();
|
|
69
|
+
runInAction(()=>{
|
|
70
|
+
this._submitting = false;
|
|
71
|
+
});
|
|
72
|
+
const aiResponseJson = JSON.parse(responseText);
|
|
73
|
+
const resolved = await this.pipelineRunner.resolve(aiResponseJson);
|
|
74
|
+
return resolved;
|
|
75
|
+
}
|
|
76
|
+
cancelPrompt() {
|
|
77
|
+
this.clearTimeout();
|
|
78
|
+
this._submitting = false;
|
|
79
|
+
}
|
|
80
|
+
startTimeout() {
|
|
81
|
+
this.clearTimeout();
|
|
82
|
+
this._elapsedSeconds = 0;
|
|
83
|
+
this._intervalId = setInterval(()=>{
|
|
84
|
+
runInAction(()=>{
|
|
85
|
+
this._elapsedSeconds++;
|
|
86
|
+
});
|
|
87
|
+
}, 1000);
|
|
88
|
+
this._timeoutId = setTimeout(()=>{
|
|
89
|
+
runInAction(()=>{
|
|
90
|
+
this._submitting = false;
|
|
91
|
+
this._timedOut = true;
|
|
92
|
+
});
|
|
93
|
+
this.clearInterval();
|
|
94
|
+
}, SUBMIT_TIMEOUT_MS);
|
|
95
|
+
}
|
|
96
|
+
clearTimeout() {
|
|
97
|
+
if (null !== this._timeoutId) {
|
|
98
|
+
clearTimeout(this._timeoutId);
|
|
99
|
+
this._timeoutId = null;
|
|
100
|
+
}
|
|
101
|
+
this.clearInterval();
|
|
102
|
+
}
|
|
103
|
+
clearInterval() {
|
|
104
|
+
if (null !== this._intervalId) {
|
|
105
|
+
clearInterval(this._intervalId);
|
|
106
|
+
this._intervalId = null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const CmsGenerateContentPresenter_CmsGenerateContentPresenter = CmsGenerateContentPresenter.createImplementation({
|
|
111
|
+
implementation: CmsGenerateContentPresenterImpl,
|
|
112
|
+
dependencies: [
|
|
113
|
+
ToolPipelineRunner,
|
|
114
|
+
GenerateEntryContentUseCase,
|
|
115
|
+
AiPromptFormFactory
|
|
116
|
+
]
|
|
117
|
+
});
|
|
118
|
+
export { CmsGenerateContentPresenter_CmsGenerateContentPresenter as CmsGenerateContentPresenter };
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=CmsGenerateContentPresenter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/presentation/CmsContentGeneration/CmsGenerateContentPresenter.js","sources":["../../../../src/admin/presentation/CmsContentGeneration/CmsGenerateContentPresenter.ts"],"sourcesContent":["import { makeAutoObservable, computed, runInAction } from \"mobx\";\nimport { ToolPipelineRunner } from \"@webiny/app-admin\";\nimport type { FormModel } from \"@webiny/app-admin\";\nimport type { FileValue } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { CmsGenerateContentPresenter as Abstraction } from \"./abstractions.js\";\nimport { GenerateEntryContentUseCase } from \"~/admin/features/generateEntryContent/index.js\";\nimport { AiPromptFormFactory } from \"~/admin/presentation/AiPromptFormFactory/abstractions.js\";\n\nconst SUBMIT_TIMEOUT_MS = 300_000;\n\nclass CmsGenerateContentPresenterImpl implements Abstraction.Interface {\n private _loading = false;\n private _submitting = false;\n private _timedOut = false;\n private _form: FormModel.Interface | null = null;\n private _timeoutId: ReturnType<typeof setTimeout> | null = null;\n private _intervalId: ReturnType<typeof setInterval> | null = null;\n private _elapsedSeconds = 0;\n\n constructor(\n private pipelineRunner: ToolPipelineRunner.Interface,\n private generateEntryContent: GenerateEntryContentUseCase.Interface,\n private formFactory: AiPromptFormFactory.Interface\n ) {\n makeAutoObservable(this, { vm: computed }, { autoBind: true });\n }\n\n get vm(): Abstraction.ViewModel {\n return {\n form: this._form ? this._form.vm : null,\n loading: this._loading,\n submitting: this._submitting,\n timedOut: this._timedOut,\n elapsedSeconds: this._elapsedSeconds\n };\n }\n\n async init(): Promise<void> {\n this._form = this.formFactory.createForm({\n promptDescription: \"Describe the content you want to generate for this entry.\"\n });\n }\n\n async submit(modelId: string): Promise<void> {\n if (!this._form) {\n return;\n }\n\n const data = await this._form.submit<{\n prompt: string;\n project?: string;\n includedFiles?: string[];\n readerPersona?: string;\n writerPersona?: string;\n additionalFiles?: FileValue[];\n }>();\n\n if (!data) {\n return;\n }\n\n runInAction(() => {\n this._submitting = true;\n this._timedOut = false;\n });\n\n this.startTimeout();\n\n try {\n const excludedFileIds = this.formFactory.computeExcludedFileIds(this._form);\n const additionalFileIds = data.additionalFiles?.map(f => f.id) ?? null;\n\n await this.generateEntryContent.execute({\n prompt: data.prompt,\n modelId,\n projectId: data.project || null,\n excludedFileIds,\n readerPersonaId: data.readerPersona || null,\n writerPersonaId: data.writerPersona || null,\n additionalFileIds\n });\n } catch {\n this.clearTimeout();\n runInAction(() => {\n this._submitting = false;\n });\n }\n }\n\n async processAiResponse(responseText: string): Promise<Record<string, unknown>> {\n this.clearTimeout();\n runInAction(() => {\n this._submitting = false;\n });\n\n const aiResponseJson = JSON.parse(responseText);\n const resolved = await this.pipelineRunner.resolve(aiResponseJson);\n return resolved as Record<string, unknown>;\n }\n\n cancelPrompt(): void {\n this.clearTimeout();\n this._submitting = false;\n }\n\n private startTimeout(): void {\n this.clearTimeout();\n this._elapsedSeconds = 0;\n this._intervalId = setInterval(() => {\n runInAction(() => {\n this._elapsedSeconds++;\n });\n }, 1000);\n this._timeoutId = setTimeout(() => {\n runInAction(() => {\n this._submitting = false;\n this._timedOut = true;\n });\n this.clearInterval();\n }, SUBMIT_TIMEOUT_MS);\n }\n\n private clearTimeout(): void {\n if (this._timeoutId !== null) {\n clearTimeout(this._timeoutId);\n this._timeoutId = null;\n }\n this.clearInterval();\n }\n\n private clearInterval(): void {\n if (this._intervalId !== null) {\n clearInterval(this._intervalId);\n this._intervalId = null;\n }\n }\n}\n\nexport const CmsGenerateContentPresenter = Abstraction.createImplementation({\n implementation: CmsGenerateContentPresenterImpl,\n dependencies: [ToolPipelineRunner, GenerateEntryContentUseCase, AiPromptFormFactory]\n});\n"],"names":["SUBMIT_TIMEOUT_MS","CmsGenerateContentPresenterImpl","pipelineRunner","generateEntryContent","formFactory","makeAutoObservable","computed","modelId","data","runInAction","excludedFileIds","additionalFileIds","f","responseText","aiResponseJson","JSON","resolved","setInterval","setTimeout","clearTimeout","clearInterval","CmsGenerateContentPresenter","Abstraction","ToolPipelineRunner","GenerateEntryContentUseCase","AiPromptFormFactory"],"mappings":"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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { AdminConfig, RegisterFeature, useWcp } from "@webiny/app-admin";
|
|
3
|
+
import { InternalContentEntryEditorConfig } from "@webiny/app-headless-cms/admin/config/contentEntries/index.js";
|
|
4
|
+
import { CmsGenerateContentButton } from "./CmsGenerateContentButton.js";
|
|
5
|
+
import { CMS_GENERATE_CONTENT_DIALOG, CmsGenerateContentDialog } from "./CmsGenerateContentDialog.js";
|
|
6
|
+
import { CmsGenerateContentFeature } from "./feature.js";
|
|
7
|
+
import { GenerateEntryContentFeature } from "../../features/generateEntryContent/index.js";
|
|
8
|
+
const { Actions: Actions } = InternalContentEntryEditorConfig;
|
|
9
|
+
const CmsContentGeneration = ()=>{
|
|
10
|
+
const wcp = useWcp();
|
|
11
|
+
if (!wcp.canUseAiEntryGeneration()) return null;
|
|
12
|
+
return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
13
|
+
feature: CmsGenerateContentFeature
|
|
14
|
+
}), /*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
15
|
+
feature: GenerateEntryContentFeature
|
|
16
|
+
}), /*#__PURE__*/ react.createElement(AdminConfig, null, /*#__PURE__*/ react.createElement(AdminConfig.Dialog, {
|
|
17
|
+
name: CMS_GENERATE_CONTENT_DIALOG,
|
|
18
|
+
element: /*#__PURE__*/ react.createElement(CmsGenerateContentDialog, null)
|
|
19
|
+
})), /*#__PURE__*/ react.createElement(InternalContentEntryEditorConfig, null, /*#__PURE__*/ react.createElement(Actions.ButtonAction, {
|
|
20
|
+
name: "generateEntryContent",
|
|
21
|
+
before: "save",
|
|
22
|
+
element: /*#__PURE__*/ react.createElement(CmsGenerateContentButton, null)
|
|
23
|
+
})));
|
|
24
|
+
};
|
|
25
|
+
export { CmsContentGeneration };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=Extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/presentation/CmsContentGeneration/Extension.js","sources":["../../../../src/admin/presentation/CmsContentGeneration/Extension.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdminConfig, RegisterFeature, useWcp } from \"@webiny/app-admin\";\nimport { InternalContentEntryEditorConfig } from \"@webiny/app-headless-cms/admin/config/contentEntries/index.js\";\nimport { CmsGenerateContentButton } from \"~/admin/presentation/CmsContentGeneration/CmsGenerateContentButton.js\";\nimport {\n CmsGenerateContentDialog,\n CMS_GENERATE_CONTENT_DIALOG\n} from \"~/admin/presentation/CmsContentGeneration/CmsGenerateContentDialog.js\";\nimport { CmsGenerateContentFeature } from \"~/admin/presentation/CmsContentGeneration/feature.js\";\nimport { GenerateEntryContentFeature } from \"~/admin/features/generateEntryContent/index.js\";\n\nconst { Actions } = InternalContentEntryEditorConfig;\n\nexport const CmsContentGeneration = () => {\n const wcp = useWcp();\n\n if (!wcp.canUseAiEntryGeneration()) {\n return null;\n }\n\n return (\n <>\n <RegisterFeature feature={CmsGenerateContentFeature} />\n <RegisterFeature feature={GenerateEntryContentFeature} />\n <AdminConfig>\n <AdminConfig.Dialog\n name={CMS_GENERATE_CONTENT_DIALOG}\n element={<CmsGenerateContentDialog />}\n />\n </AdminConfig>\n <InternalContentEntryEditorConfig>\n <Actions.ButtonAction\n name={\"generateEntryContent\"}\n before={\"save\"}\n element={<CmsGenerateContentButton />}\n />\n </InternalContentEntryEditorConfig>\n </>\n );\n};\n"],"names":["Actions","InternalContentEntryEditorConfig","CmsContentGeneration","wcp","useWcp","RegisterFeature","CmsGenerateContentFeature","GenerateEntryContentFeature","AdminConfig","CMS_GENERATE_CONTENT_DIALOG","CmsGenerateContentDialog","CmsGenerateContentButton"],"mappings":";;;;;;;AAWA,MAAM,EAAEA,SAAAA,OAAO,EAAE,GAAGC;AAEb,MAAMC,uBAAuB;IAChC,MAAMC,MAAMC;IAEZ,IAAI,CAACD,IAAI,uBAAuB,IAC5B,OAAO;IAGX,OAAO,WAAP,GACI,wDACI,oBAACE,iBAAeA;QAAC,SAASC;sBAC1B,oBAACD,iBAAeA;QAAC,SAASE;sBAC1B,oBAACC,aAAWA,MAAAA,WAAAA,GACR,oBAACA,YAAY,MAAM;QACf,MAAMC;QACN,uBAAS,oBAACC,0BAAwBA;uBAG1C,oBAACT,kCAAgCA,MAAAA,WAAAA,GAC7B,oBAACD,QAAQ,YAAY;QACjB,MAAM;QACN,QAAQ;QACR,uBAAS,oBAACW,0BAAwBA;;AAKtD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IFormVM } from "@webiny/app-admin/features/formModel/abstractions.js";
|
|
2
|
+
export interface ICmsGenerateContentVm {
|
|
3
|
+
form: IFormVM | null;
|
|
4
|
+
loading: boolean;
|
|
5
|
+
submitting: boolean;
|
|
6
|
+
timedOut: boolean;
|
|
7
|
+
elapsedSeconds: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ICmsGenerateContentPresenter {
|
|
10
|
+
readonly vm: ICmsGenerateContentVm;
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
submit(modelId: string): Promise<void>;
|
|
13
|
+
cancelPrompt(): void;
|
|
14
|
+
processAiResponse(responseText: string): Promise<Record<string, unknown>>;
|
|
15
|
+
}
|
|
16
|
+
export declare const CmsGenerateContentPresenter: import("@webiny/di").Abstraction<ICmsGenerateContentPresenter>;
|
|
17
|
+
export declare namespace CmsGenerateContentPresenter {
|
|
18
|
+
type Interface = ICmsGenerateContentPresenter;
|
|
19
|
+
type ViewModel = ICmsGenerateContentVm;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/presentation/CmsContentGeneration/abstractions.js","sources":["../../../../src/admin/presentation/CmsContentGeneration/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { IFormVM } from \"@webiny/app-admin/features/formModel/abstractions.js\";\n\nexport interface ICmsGenerateContentVm {\n form: IFormVM | null;\n loading: boolean;\n submitting: boolean;\n timedOut: boolean;\n elapsedSeconds: number;\n}\n\nexport interface ICmsGenerateContentPresenter {\n readonly vm: ICmsGenerateContentVm;\n init(): Promise<void>;\n submit(modelId: string): Promise<void>;\n cancelPrompt(): void;\n processAiResponse(responseText: string): Promise<Record<string, unknown>>;\n}\n\nexport const CmsGenerateContentPresenter = createAbstraction<ICmsGenerateContentPresenter>(\n \"CmsContentGeneration/Presenter\"\n);\n\nexport namespace CmsGenerateContentPresenter {\n export type Interface = ICmsGenerateContentPresenter;\n export type ViewModel = ICmsGenerateContentVm;\n}\n"],"names":["CmsGenerateContentPresenter","createAbstraction"],"mappings":";AAmBO,MAAMA,8BAA8BC,kBACvC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/admin";
|
|
2
|
+
import { CmsGenerateContentPresenter } from "./abstractions.js";
|
|
3
|
+
import { CmsGenerateContentPresenter as external_CmsGenerateContentPresenter_js_CmsGenerateContentPresenter } from "./CmsGenerateContentPresenter.js";
|
|
4
|
+
const CmsGenerateContentFeature = createFeature({
|
|
5
|
+
name: "CmsContentGeneration/Presenter",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(external_CmsGenerateContentPresenter_js_CmsGenerateContentPresenter);
|
|
8
|
+
},
|
|
9
|
+
resolve (container) {
|
|
10
|
+
return {
|
|
11
|
+
presenter: container.resolve(CmsGenerateContentPresenter)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export { CmsGenerateContentFeature };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/presentation/CmsContentGeneration/feature.js","sources":["../../../../src/admin/presentation/CmsContentGeneration/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { CmsGenerateContentPresenter as Abstraction } from \"./abstractions.js\";\nimport { CmsGenerateContentPresenter } from \"./CmsGenerateContentPresenter.js\";\n\nexport const CmsGenerateContentFeature = createFeature({\n name: \"CmsContentGeneration/Presenter\",\n register(container) {\n container.register(CmsGenerateContentPresenter);\n },\n resolve(container) {\n return {\n presenter: container.resolve(Abstraction)\n };\n }\n});\n"],"names":["CmsGenerateContentFeature","createFeature","container","CmsGenerateContentPresenter","Abstraction"],"mappings":";;;AAIO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;IACA,SAAQD,SAAS;QACb,OAAO;YACH,WAAWA,UAAU,OAAO,CAACE;QACjC;IACJ;AACJ"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import react, { useEffect, useRef } from "react";
|
|
2
|
+
import { observer } from "mobx-react-lite";
|
|
3
|
+
import { FormView } from "@webiny/app-admin";
|
|
4
|
+
import { BetaBadge, Button, Heading, OverlayLoader, useToast } from "@webiny/admin-ui";
|
|
5
|
+
import { useFeature } from "@webiny/app";
|
|
6
|
+
import { useWebsockets } from "@webiny/app-websockets";
|
|
7
|
+
import { useModel } from "@webiny/app-headless-cms/admin/components/ModelProvider/useModel.js";
|
|
8
|
+
import { useContentEntryFormPresenter } from "@webiny/app-headless-cms/exports/admin/cms/entry/editor.js";
|
|
9
|
+
import { CmsGenerateContentFeature } from "../CmsContentGeneration/feature.js";
|
|
10
|
+
import { decompressGzipBase64 } from "../WbContentGeneration/decompressGzipBase64.js";
|
|
11
|
+
function formatElapsed(totalSeconds) {
|
|
12
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
13
|
+
const seconds = totalSeconds % 60;
|
|
14
|
+
return `${minutes}:${seconds.toString().padStart(2, "0")}`;
|
|
15
|
+
}
|
|
16
|
+
const WS_ACTION_CONTENT = "aiPowerUps.generateEntryContent.content";
|
|
17
|
+
const WS_ACTION_ERROR = "aiPowerUps.generateEntryContent.error";
|
|
18
|
+
const CmsEntryWizard = observer(()=>{
|
|
19
|
+
const { presenter } = useFeature(CmsGenerateContentFeature);
|
|
20
|
+
const formPresenter = useContentEntryFormPresenter();
|
|
21
|
+
const { model } = useModel();
|
|
22
|
+
const vm = presenter.vm;
|
|
23
|
+
const wasSubmitting = useRef(false);
|
|
24
|
+
const websockets = useWebsockets();
|
|
25
|
+
const toast = useToast();
|
|
26
|
+
useEffect(()=>{
|
|
27
|
+
presenter.init().catch((err)=>{
|
|
28
|
+
console.error("Failed to initialize AI entry wizard", err);
|
|
29
|
+
});
|
|
30
|
+
}, []);
|
|
31
|
+
useEffect(()=>{
|
|
32
|
+
const contentSubscription = websockets.onMessage(WS_ACTION_CONTENT, async (message)=>{
|
|
33
|
+
const responseText = await decompressGzipBase64(message.data.value);
|
|
34
|
+
try {
|
|
35
|
+
const entryValues = await presenter.processAiResponse(responseText);
|
|
36
|
+
formPresenter.newEntry(entryValues);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.error("Failed to process AI response", e);
|
|
39
|
+
toast.showWarningToast({
|
|
40
|
+
title: "Failed to process AI response",
|
|
41
|
+
description: "Open the console for more details."
|
|
42
|
+
});
|
|
43
|
+
presenter.cancelPrompt();
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const errorSubscription = websockets.onMessage(WS_ACTION_ERROR, async (message)=>{
|
|
47
|
+
toast.showWarningToast({
|
|
48
|
+
title: "Failed to generate content",
|
|
49
|
+
description: message.data.message
|
|
50
|
+
});
|
|
51
|
+
presenter.cancelPrompt();
|
|
52
|
+
});
|
|
53
|
+
return ()=>{
|
|
54
|
+
contentSubscription.off();
|
|
55
|
+
errorSubscription.off();
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
useEffect(()=>{
|
|
59
|
+
wasSubmitting.current && !vm.submitting && vm.timedOut;
|
|
60
|
+
wasSubmitting.current = vm.submitting;
|
|
61
|
+
}, [
|
|
62
|
+
vm.submitting
|
|
63
|
+
]);
|
|
64
|
+
useEffect(()=>{
|
|
65
|
+
if (vm.timedOut) toast.showWarningToast({
|
|
66
|
+
title: "Request timed out",
|
|
67
|
+
description: "The AI generation took too long. Please try again."
|
|
68
|
+
});
|
|
69
|
+
}, [
|
|
70
|
+
vm.timedOut
|
|
71
|
+
]);
|
|
72
|
+
const handleSubmit = async ()=>{
|
|
73
|
+
await presenter.submit(model.modelId);
|
|
74
|
+
};
|
|
75
|
+
const handleSkip = ()=>{
|
|
76
|
+
formPresenter.newEntry();
|
|
77
|
+
};
|
|
78
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
79
|
+
className: "flex justify-center pt-xl"
|
|
80
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
81
|
+
className: "bg-neutral-base rounded-lg p-lg flex flex-col gap-md",
|
|
82
|
+
style: {
|
|
83
|
+
width: 600
|
|
84
|
+
}
|
|
85
|
+
}, /*#__PURE__*/ react.createElement(Heading, {
|
|
86
|
+
level: 4,
|
|
87
|
+
className: "flex items-center gap-sm"
|
|
88
|
+
}, "Generate Entry Content ", /*#__PURE__*/ react.createElement(BetaBadge, null)), /*#__PURE__*/ react.createElement("p", {
|
|
89
|
+
className: "text-neutral-muted"
|
|
90
|
+
}, "Use AI to generate content for this entry. Configure the prompt and click Generate, or skip to create an empty entry."), vm.loading ? /*#__PURE__*/ react.createElement(OverlayLoader, {
|
|
91
|
+
text: "Loading..."
|
|
92
|
+
}) : null, vm.submitting ? /*#__PURE__*/ react.createElement(OverlayLoader, {
|
|
93
|
+
className: "bg-neutral-base/90",
|
|
94
|
+
text: /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement("div", null, "Generating content... ", formatElapsed(vm.elapsedSeconds)), /*#__PURE__*/ react.createElement("div", {
|
|
95
|
+
className: "text-sm text-neutral-muted pt-xs"
|
|
96
|
+
}, "Content generation can take a few minutes, depending on the model you're using."))
|
|
97
|
+
}) : null, vm.form ? /*#__PURE__*/ react.createElement(FormView, {
|
|
98
|
+
name: "CmsEntryWizard",
|
|
99
|
+
form: vm.form
|
|
100
|
+
}) : null, /*#__PURE__*/ react.createElement("div", {
|
|
101
|
+
className: "flex justify-end gap-sm"
|
|
102
|
+
}, /*#__PURE__*/ react.createElement(Button, {
|
|
103
|
+
variant: "secondary",
|
|
104
|
+
onClick: handleSkip
|
|
105
|
+
}, "Skip"), /*#__PURE__*/ react.createElement(Button, {
|
|
106
|
+
variant: "primary",
|
|
107
|
+
onClick: handleSubmit,
|
|
108
|
+
disabled: vm.loading || vm.submitting
|
|
109
|
+
}, "Generate"))));
|
|
110
|
+
});
|
|
111
|
+
export { CmsEntryWizard };
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=CmsEntryWizard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/presentation/CmsEntryWizard/CmsEntryWizard.js","sources":["../../../../src/admin/presentation/CmsEntryWizard/CmsEntryWizard.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { FormView } from \"@webiny/app-admin\";\nimport { BetaBadge } from \"@webiny/admin-ui\";\nimport { Button, Heading, OverlayLoader, useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport type { IncomingGenericData } from \"@webiny/app-websockets\";\nimport { useWebsockets } from \"@webiny/app-websockets\";\nimport { useModel } from \"@webiny/app-headless-cms/admin/components/ModelProvider/useModel.js\";\nimport { useContentEntryFormPresenter } from \"@webiny/app-headless-cms/exports/admin/cms/entry/editor.js\";\nimport { CmsGenerateContentFeature } from \"~/admin/presentation/CmsContentGeneration/feature.js\";\nimport { decompressGzipBase64 } from \"~/admin/presentation/WbContentGeneration/decompressGzipBase64.js\";\n\nfunction formatElapsed(totalSeconds: number): string {\n const minutes = Math.floor(totalSeconds / 60);\n const seconds = totalSeconds % 60;\n return `${minutes}:${seconds.toString().padStart(2, \"0\")}`;\n}\n\nconst WS_ACTION_CONTENT = \"aiPowerUps.generateEntryContent.content\";\nconst WS_ACTION_ERROR = \"aiPowerUps.generateEntryContent.error\";\n\ninterface GenerateEntryContentMessage extends IncomingGenericData {\n action: typeof WS_ACTION_CONTENT;\n data: {\n compression: \"gzip\";\n value: string;\n };\n}\n\ninterface GenerateEntryContentErrorMessage extends IncomingGenericData {\n action: typeof WS_ACTION_ERROR;\n data: {\n message: string;\n };\n}\n\nexport const CmsEntryWizard = observer(() => {\n const { presenter } = useFeature(CmsGenerateContentFeature);\n const formPresenter = useContentEntryFormPresenter();\n const { model } = useModel();\n const vm = presenter.vm;\n const wasSubmitting = useRef(false);\n const websockets = useWebsockets();\n const toast = useToast();\n\n useEffect(() => {\n presenter.init().catch(err => {\n console.error(\"Failed to initialize AI entry wizard\", err);\n });\n }, []);\n\n useEffect(() => {\n const contentSubscription = websockets.onMessage<GenerateEntryContentMessage>(\n WS_ACTION_CONTENT,\n async message => {\n const responseText = await decompressGzipBase64(message.data.value);\n try {\n const entryValues = await presenter.processAiResponse(responseText);\n formPresenter.newEntry(entryValues);\n } catch (e) {\n console.error(\"Failed to process AI response\", e);\n toast.showWarningToast({\n title: \"Failed to process AI response\",\n description: \"Open the console for more details.\"\n });\n presenter.cancelPrompt();\n }\n }\n );\n\n const errorSubscription = websockets.onMessage<GenerateEntryContentErrorMessage>(\n WS_ACTION_ERROR,\n async message => {\n toast.showWarningToast({\n title: \"Failed to generate content\",\n description: message.data.message\n });\n presenter.cancelPrompt();\n }\n );\n\n return () => {\n contentSubscription.off();\n errorSubscription.off();\n };\n }, []);\n\n useEffect(() => {\n if (wasSubmitting.current && !vm.submitting && !vm.timedOut) {\n // Generation completed successfully — form was created via newEntry()\n }\n wasSubmitting.current = vm.submitting;\n }, [vm.submitting]);\n\n useEffect(() => {\n if (vm.timedOut) {\n toast.showWarningToast({\n title: \"Request timed out\",\n description: \"The AI generation took too long. Please try again.\"\n });\n }\n }, [vm.timedOut]);\n\n const handleSubmit = async () => {\n await presenter.submit(model.modelId);\n };\n\n const handleSkip = () => {\n formPresenter.newEntry();\n };\n\n return (\n <div className=\"flex justify-center pt-xl\">\n <div\n className=\"bg-neutral-base rounded-lg p-lg flex flex-col gap-md\"\n style={{ width: 600 }}\n >\n <Heading level={4} className=\"flex items-center gap-sm\">\n Generate Entry Content <BetaBadge />\n </Heading>\n <p className=\"text-neutral-muted\">\n Use AI to generate content for this entry. Configure the prompt and click\n Generate, or skip to create an empty entry.\n </p>\n {vm.loading ? <OverlayLoader text={\"Loading...\"} /> : null}\n {vm.submitting ? (\n <OverlayLoader\n className={\"bg-neutral-base/90\"}\n text={\n <>\n <div>Generating content... {formatElapsed(vm.elapsedSeconds)}</div>\n <div className=\"text-sm text-neutral-muted pt-xs\">\n Content generation can take a few minutes, depending on the\n model you're using.\n </div>\n </>\n }\n />\n ) : null}\n {vm.form ? <FormView name=\"CmsEntryWizard\" form={vm.form} /> : null}\n <div className=\"flex justify-end gap-sm\">\n <Button variant=\"secondary\" onClick={handleSkip}>\n Skip\n </Button>\n <Button\n variant=\"primary\"\n onClick={handleSubmit}\n disabled={vm.loading || vm.submitting}\n >\n Generate\n </Button>\n </div>\n </div>\n </div>\n );\n});\n"],"names":["formatElapsed","totalSeconds","minutes","Math","seconds","WS_ACTION_CONTENT","WS_ACTION_ERROR","CmsEntryWizard","observer","presenter","useFeature","CmsGenerateContentFeature","formPresenter","useContentEntryFormPresenter","model","useModel","vm","wasSubmitting","useRef","websockets","useWebsockets","toast","useToast","useEffect","err","console","contentSubscription","message","responseText","decompressGzipBase64","entryValues","e","errorSubscription","handleSubmit","handleSkip","Heading","BetaBadge","OverlayLoader","FormView","Button"],"mappings":";;;;;;;;;;AAaA,SAASA,cAAcC,YAAoB;IACvC,MAAMC,UAAUC,KAAK,KAAK,CAACF,eAAe;IAC1C,MAAMG,UAAUH,eAAe;IAC/B,OAAO,GAAGC,QAAQ,CAAC,EAAEE,QAAQ,QAAQ,GAAG,QAAQ,CAAC,GAAG,MAAM;AAC9D;AAEA,MAAMC,oBAAoB;AAC1B,MAAMC,kBAAkB;AAiBjB,MAAMC,iBAAiBC,SAAS;IACnC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAMC,gBAAgBC;IACtB,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAClB,MAAMC,KAAKP,UAAU,EAAE;IACvB,MAAMQ,gBAAgBC,OAAO;IAC7B,MAAMC,aAAaC;IACnB,MAAMC,QAAQC;IAEdC,UAAU;QACNd,UAAU,IAAI,GAAG,KAAK,CAACe,CAAAA;YACnBC,QAAQ,KAAK,CAAC,wCAAwCD;QAC1D;IACJ,GAAG,EAAE;IAELD,UAAU;QACN,MAAMG,sBAAsBP,WAAW,SAAS,CAC5Cd,mBACA,OAAMsB;YACF,MAAMC,eAAe,MAAMC,qBAAqBF,QAAQ,IAAI,CAAC,KAAK;YAClE,IAAI;gBACA,MAAMG,cAAc,MAAMrB,UAAU,iBAAiB,CAACmB;gBACtDhB,cAAc,QAAQ,CAACkB;YAC3B,EAAE,OAAOC,GAAG;gBACRN,QAAQ,KAAK,CAAC,iCAAiCM;gBAC/CV,MAAM,gBAAgB,CAAC;oBACnB,OAAO;oBACP,aAAa;gBACjB;gBACAZ,UAAU,YAAY;YAC1B;QACJ;QAGJ,MAAMuB,oBAAoBb,WAAW,SAAS,CAC1Cb,iBACA,OAAMqB;YACFN,MAAM,gBAAgB,CAAC;gBACnB,OAAO;gBACP,aAAaM,QAAQ,IAAI,CAAC,OAAO;YACrC;YACAlB,UAAU,YAAY;QAC1B;QAGJ,OAAO;YACHiB,oBAAoB,GAAG;YACvBM,kBAAkB,GAAG;QACzB;IACJ,GAAG,EAAE;IAELT,UAAU;QACFN,cAAc,OAAO,IAAI,CAACD,GAAG,UAAU,IAAKA,GAAG,QAAQ;QAG3DC,cAAc,OAAO,GAAGD,GAAG,UAAU;IACzC,GAAG;QAACA,GAAG,UAAU;KAAC;IAElBO,UAAU;QACN,IAAIP,GAAG,QAAQ,EACXK,MAAM,gBAAgB,CAAC;YACnB,OAAO;YACP,aAAa;QACjB;IAER,GAAG;QAACL,GAAG,QAAQ;KAAC;IAEhB,MAAMiB,eAAe;QACjB,MAAMxB,UAAU,MAAM,CAACK,MAAM,OAAO;IACxC;IAEA,MAAMoB,aAAa;QACftB,cAAc,QAAQ;IAC1B;IAEA,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAAC;QACG,WAAU;QACV,OAAO;YAAE,OAAO;QAAI;qBAEpB,oBAACuB,SAAOA;QAAC,OAAO;QAAG,WAAU;OAA2B,yCAC7B,oBAACC,WAASA,QAAAA,WAAAA,GAErC,oBAAC;QAAE,WAAU;OAAqB,0HAIjCpB,GAAG,OAAO,GAAG,WAAH,GAAG,oBAACqB,eAAaA;QAAC,MAAM;SAAmB,MACrDrB,GAAG,UAAU,GAAG,WAAH,GACV,oBAACqB,eAAaA;QACV,WAAW;QACX,oBACI,wDACI,oBAAC,aAAI,0BAAuBrC,cAAcgB,GAAG,cAAc,kBAC3D,oBAAC;YAAI,WAAU;WAAmC;SAO9D,MACHA,GAAG,IAAI,GAAG,WAAH,GAAG,oBAACsB,UAAQA;QAAC,MAAK;QAAiB,MAAMtB,GAAG,IAAI;SAAO,oBAC/D,oBAAC;QAAI,WAAU;qBACX,oBAACuB,QAAMA;QAAC,SAAQ;QAAY,SAASL;OAAY,uBAGjD,oBAACK,QAAMA;QACH,SAAQ;QACR,SAASN;QACT,UAAUjB,GAAG,OAAO,IAAIA,GAAG,UAAU;OACxC;AAOrB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import react, { useEffect } from "react";
|
|
2
|
+
import { observer } from "mobx-react-lite";
|
|
3
|
+
import { useModel } from "@webiny/app-headless-cms/admin/components/ModelProvider/useModel.js";
|
|
4
|
+
import { useContentEntryFormPresenter } from "@webiny/app-headless-cms/exports/admin/cms/entry/editor.js";
|
|
5
|
+
import { CmsEntryWizard } from "./CmsEntryWizard.js";
|
|
6
|
+
const CmsEntryWizardGate = observer(()=>{
|
|
7
|
+
const { model } = useModel();
|
|
8
|
+
const formPresenter = useContentEntryFormPresenter();
|
|
9
|
+
const showWizard = model.settings?.aiEntryWizard === true;
|
|
10
|
+
useEffect(()=>{
|
|
11
|
+
if (!showWizard) formPresenter.newEntry();
|
|
12
|
+
}, [
|
|
13
|
+
showWizard
|
|
14
|
+
]);
|
|
15
|
+
return /*#__PURE__*/ react.createElement(CmsEntryWizard, null);
|
|
16
|
+
});
|
|
17
|
+
export { CmsEntryWizardGate };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=CmsEntryWizardGate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/presentation/CmsEntryWizard/CmsEntryWizardGate.js","sources":["../../../../src/admin/presentation/CmsEntryWizard/CmsEntryWizardGate.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useModel } from \"@webiny/app-headless-cms/admin/components/ModelProvider/useModel.js\";\nimport { useContentEntryFormPresenter } from \"@webiny/app-headless-cms/exports/admin/cms/entry/editor.js\";\nimport { CmsEntryWizard } from \"./CmsEntryWizard.js\";\n\nexport const CmsEntryWizardGate = observer(() => {\n const { model } = useModel();\n const formPresenter = useContentEntryFormPresenter();\n\n const showWizard = model.settings?.aiEntryWizard === true;\n\n useEffect(() => {\n if (!showWizard) {\n formPresenter.newEntry();\n }\n }, [showWizard]);\n\n return <CmsEntryWizard />;\n});\n"],"names":["CmsEntryWizardGate","observer","model","useModel","formPresenter","useContentEntryFormPresenter","showWizard","useEffect","CmsEntryWizard"],"mappings":";;;;;AAMO,MAAMA,qBAAqBC,SAAS;IACvC,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAClB,MAAMC,gBAAgBC;IAEtB,MAAMC,aAAaJ,MAAM,QAAQ,EAAE,kBAAkB;IAErDK,UAAU;QACN,IAAI,CAACD,YACDF,cAAc,QAAQ;IAE9B,GAAG;QAACE;KAAW;IAEf,OAAO,WAAP,GAAO,oBAACE,gBAAcA;AAC1B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { InternalContentEntryEditorConfig } from "@webiny/app-headless-cms/admin/config/contentEntries/index.js";
|
|
3
|
+
import { CmsEntryWizardGate } from "./CmsEntryWizardGate.js";
|
|
4
|
+
const CmsEntryWizardExtension = ()=>/*#__PURE__*/ react.createElement(InternalContentEntryEditorConfig, null, /*#__PURE__*/ react.createElement(InternalContentEntryEditorConfig.NewEntryWizard, {
|
|
5
|
+
name: "aiEntryWizard",
|
|
6
|
+
element: /*#__PURE__*/ react.createElement(CmsEntryWizardGate, null)
|
|
7
|
+
}));
|
|
8
|
+
export { CmsEntryWizardExtension };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=Extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/presentation/CmsEntryWizard/Extension.js","sources":["../../../../src/admin/presentation/CmsEntryWizard/Extension.tsx"],"sourcesContent":["import React from \"react\";\nimport { InternalContentEntryEditorConfig } from \"@webiny/app-headless-cms/admin/config/contentEntries/index.js\";\nimport { CmsEntryWizardGate } from \"./CmsEntryWizardGate.js\";\n\nexport const CmsEntryWizardExtension = () => {\n return (\n <InternalContentEntryEditorConfig>\n <InternalContentEntryEditorConfig.NewEntryWizard\n name={\"aiEntryWizard\"}\n element={<CmsEntryWizardGate />}\n />\n </InternalContentEntryEditorConfig>\n );\n};\n"],"names":["CmsEntryWizardExtension","InternalContentEntryEditorConfig","CmsEntryWizardGate"],"mappings":";;;AAIO,MAAMA,0BAA0B,IAC5B,WAAP,GACI,oBAACC,kCAAgCA,MAAAA,WAAAA,GAC7B,oBAACA,iCAAiC,cAAc;QAC5C,MAAM;QACN,uBAAS,oBAACC,oBAAkBA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AiPowerUpsSettingsGroup } from "./AiPowerUpsSettings/settingsGroup.js";
|
|
2
|
+
import { ListModelsUseCase, ListModelsRepository } from "../../admin/features/listModels/abstractions.js";
|
|
3
|
+
/**
|
|
4
|
+
* One row per API key. The model select moved to Model roles, so adding a second Anthropic model no
|
|
5
|
+
* longer means pasting the same key twice.
|
|
6
|
+
*/
|
|
7
|
+
declare class ConnectionsSettingsImpl implements AiPowerUpsSettingsGroup.Interface {
|
|
8
|
+
private useCase;
|
|
9
|
+
private repository;
|
|
10
|
+
name: string;
|
|
11
|
+
label: string;
|
|
12
|
+
description: string;
|
|
13
|
+
constructor(useCase: ListModelsUseCase.Interface, repository: ListModelsRepository.Interface);
|
|
14
|
+
init(): Promise<void>;
|
|
15
|
+
buildForm(form: AiPowerUpsSettingsGroup.FormBuilder): void;
|
|
16
|
+
/**
|
|
17
|
+
* Derived from the registered SDK factories rather than hardcoded, so a project that registers
|
|
18
|
+
* its own `AiSdkFactory` shows up here without a change to this file.
|
|
19
|
+
*/
|
|
20
|
+
private getVendorOptions;
|
|
21
|
+
}
|
|
22
|
+
export declare const ConnectionsSettings: typeof ConnectionsSettingsImpl & {
|
|
23
|
+
__abstraction: import("@webiny/di").Abstraction<import("./AiPowerUpsSettings/settingsGroup.js").IAiPowerUpsSettingsGroup>;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { generateAlphaNumericId } from "@webiny/utils";
|
|
2
|
+
import { AiPowerUpsSettingsGroup } from "./AiPowerUpsSettings/settingsGroup.js";
|
|
3
|
+
import { ListModelsRepository, ListModelsUseCase } from "../features/listModels/abstractions.js";
|
|
4
|
+
class ConnectionsSettingsImpl {
|
|
5
|
+
constructor(useCase, repository){
|
|
6
|
+
this.useCase = useCase;
|
|
7
|
+
this.repository = repository;
|
|
8
|
+
this.name = "connections";
|
|
9
|
+
this.label = "Connections";
|
|
10
|
+
this.description = "API keys for the AI vendors this project uses.";
|
|
11
|
+
}
|
|
12
|
+
async init() {
|
|
13
|
+
await this.useCase.execute();
|
|
14
|
+
}
|
|
15
|
+
buildForm(form) {
|
|
16
|
+
form.fields((fields)=>({
|
|
17
|
+
presets: fields.object().label("Connections").renderer("objectAccordionMultiple", {
|
|
18
|
+
container: false,
|
|
19
|
+
addItemLabel: "Add connection",
|
|
20
|
+
itemTitle: (data, index)=>String(data.name || `Connection #${index + 1}`)
|
|
21
|
+
}).fields((f)=>({
|
|
22
|
+
id: f.text().hidden().defaultValue(()=>generateAlphaNumericId(10)),
|
|
23
|
+
name: f.text().label("Name").required("Name is required").description("How this connection appears when picking a model. Name it after the key, not the vendor, so two keys for the same vendor stay distinguishable."),
|
|
24
|
+
sdkName: f.text().label("Vendor").required("Vendor is required").description("Which provider this key belongs to.").options(()=>this.getVendorOptions()).renderer("select"),
|
|
25
|
+
apiKey: f.text().label("API Key").required("API Key is required").description("Encrypted at rest. Only the last few characters are shown after saving.")
|
|
26
|
+
})).list()
|
|
27
|
+
}));
|
|
28
|
+
form.layout((layout)=>[
|
|
29
|
+
layout.row("presets")
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
getVendorOptions() {
|
|
33
|
+
const seen = new Map();
|
|
34
|
+
for (const model of this.repository.getModels())seen.set(model.providerId, model.providerName);
|
|
35
|
+
return [
|
|
36
|
+
...seen.entries()
|
|
37
|
+
].map(([value, label])=>({
|
|
38
|
+
label,
|
|
39
|
+
value
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const ConnectionsSettings = AiPowerUpsSettingsGroup.createImplementation({
|
|
44
|
+
implementation: ConnectionsSettingsImpl,
|
|
45
|
+
dependencies: [
|
|
46
|
+
ListModelsUseCase,
|
|
47
|
+
ListModelsRepository
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
export { ConnectionsSettings };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=ConnectionsSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/presentation/ConnectionsSettings.js","sources":["../../../src/admin/presentation/ConnectionsSettings.ts"],"sourcesContent":["import { generateAlphaNumericId } from \"@webiny/utils\";\nimport { AiPowerUpsSettingsGroup } from \"./AiPowerUpsSettings/settingsGroup.js\";\nimport {\n ListModelsUseCase,\n ListModelsRepository\n} from \"~/admin/features/listModels/abstractions.js\";\n\n/**\n * One row per API key. The model select moved to Model roles, so adding a second Anthropic model no\n * longer means pasting the same key twice.\n */\nclass ConnectionsSettingsImpl implements AiPowerUpsSettingsGroup.Interface {\n name = \"connections\";\n label = \"Connections\";\n description = \"API keys for the AI vendors this project uses.\";\n\n constructor(\n private useCase: ListModelsUseCase.Interface,\n private repository: ListModelsRepository.Interface\n ) {}\n\n async init(): Promise<void> {\n await this.useCase.execute();\n }\n\n buildForm(form: AiPowerUpsSettingsGroup.FormBuilder): void {\n form.fields(fields => ({\n presets: fields\n .object()\n .label(\"Connections\")\n .renderer(\"objectAccordionMultiple\", {\n container: false,\n addItemLabel: \"Add connection\",\n itemTitle: (data, index) => String(data.name || `Connection #${index + 1}`)\n })\n .fields(f => ({\n id: f\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericId(10)),\n name: f\n .text()\n .label(\"Name\")\n .required(\"Name is required\")\n .description(\n \"How this connection appears when picking a model. Name it after the key, not the vendor, so two keys for the same vendor stay distinguishable.\"\n ),\n sdkName: f\n .text()\n .label(\"Vendor\")\n .required(\"Vendor is required\")\n .description(\"Which provider this key belongs to.\")\n .options(() => this.getVendorOptions())\n .renderer(\"select\"),\n apiKey: f\n .text()\n .label(\"API Key\")\n .required(\"API Key is required\")\n .description(\n \"Encrypted at rest. Only the last few characters are shown after saving.\"\n )\n }))\n .list()\n }));\n\n form.layout(layout => [layout.row(\"presets\")]);\n }\n\n /**\n * Derived from the registered SDK factories rather than hardcoded, so a project that registers\n * its own `AiSdkFactory` shows up here without a change to this file.\n */\n private getVendorOptions() {\n const seen = new Map<string, string>();\n\n for (const model of this.repository.getModels()) {\n seen.set(model.providerId, model.providerName);\n }\n\n return [...seen.entries()].map(([value, label]) => ({ label, value }));\n }\n}\n\nexport const ConnectionsSettings = AiPowerUpsSettingsGroup.createImplementation({\n implementation: ConnectionsSettingsImpl,\n dependencies: [ListModelsUseCase, ListModelsRepository]\n});\n"],"names":["ConnectionsSettingsImpl","useCase","repository","form","fields","data","index","String","f","generateAlphaNumericId","layout","seen","Map","model","value","label","ConnectionsSettings","AiPowerUpsSettingsGroup","ListModelsUseCase","ListModelsRepository"],"mappings":";;;AAWA,MAAMA;IAKF,YACYC,OAAoC,EACpCC,UAA0C,CACpD;aAFUD,OAAO,GAAPA;aACAC,UAAU,GAAVA;aANZ,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAAG;IAKX;IAEH,MAAM,OAAsB;QACxB,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO;IAC9B;IAEA,UAAUC,IAAyC,EAAQ;QACvDA,KAAK,MAAM,CAACC,CAAAA,SAAW;gBACnB,SAASA,OACJ,MAAM,GACN,KAAK,CAAC,eACN,QAAQ,CAAC,2BAA2B;oBACjC,WAAW;oBACX,cAAc;oBACd,WAAW,CAACC,MAAMC,QAAUC,OAAOF,KAAK,IAAI,IAAI,CAAC,YAAY,EAAEC,QAAQ,GAAG;gBAC9E,GACC,MAAM,CAACE,CAAAA,IAAM;wBACV,IAAIA,EACC,IAAI,GACJ,MAAM,GACN,YAAY,CAAC,IAAMC,uBAAuB;wBAC/C,MAAMD,EACD,IAAI,GACJ,KAAK,CAAC,QACN,QAAQ,CAAC,oBACT,WAAW,CACR;wBAER,SAASA,EACJ,IAAI,GACJ,KAAK,CAAC,UACN,QAAQ,CAAC,sBACT,WAAW,CAAC,uCACZ,OAAO,CAAC,IAAM,IAAI,CAAC,gBAAgB,IACnC,QAAQ,CAAC;wBACd,QAAQA,EACH,IAAI,GACJ,KAAK,CAAC,WACN,QAAQ,CAAC,uBACT,WAAW,CACR;oBAEZ,IACC,IAAI;YACb;QAEAL,KAAK,MAAM,CAACO,CAAAA,SAAU;gBAACA,OAAO,GAAG,CAAC;aAAW;IACjD;IAMQ,mBAAmB;QACvB,MAAMC,OAAO,IAAIC;QAEjB,KAAK,MAAMC,SAAS,IAAI,CAAC,UAAU,CAAC,SAAS,GACzCF,KAAK,GAAG,CAACE,MAAM,UAAU,EAAEA,MAAM,YAAY;QAGjD,OAAO;eAAIF,KAAK,OAAO;SAAG,CAAC,GAAG,CAAC,CAAC,CAACG,OAAOC,MAAM,GAAM;gBAAEA;gBAAOD;YAAM;IACvE;AACJ;AAEO,MAAME,sBAAsBC,wBAAwB,oBAAoB,CAAC;IAC5E,gBAAgBjB;IAChB,cAAc;QAACkB;QAAmBC;KAAqB;AAC3D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AiPowerUpsSettingsGroup } from "./AiPowerUpsSettings/settingsGroup.js";
|
|
2
|
+
import { ListModelsUseCase, ListModelsRepository } from "../../admin/features/listModels/abstractions.js";
|
|
3
|
+
/**
|
|
4
|
+
* Three selects, and for most projects this is the whole AI configuration: one connection, one
|
|
5
|
+
* model per role. Everything else in these settings is opt-in.
|
|
6
|
+
*/
|
|
7
|
+
declare class ModelRolesSettingsImpl implements AiPowerUpsSettingsGroup.Interface {
|
|
8
|
+
private useCase;
|
|
9
|
+
private repository;
|
|
10
|
+
name: string;
|
|
11
|
+
label: string;
|
|
12
|
+
description: string;
|
|
13
|
+
constructor(useCase: ListModelsUseCase.Interface, repository: ListModelsRepository.Interface);
|
|
14
|
+
init(): Promise<void>;
|
|
15
|
+
buildForm(form: AiPowerUpsSettingsGroup.FormBuilder): void;
|
|
16
|
+
private getConnections;
|
|
17
|
+
private getConnectionOptions;
|
|
18
|
+
private getSelectedConnection;
|
|
19
|
+
/**
|
|
20
|
+
* Filtered by the chosen connection's vendor. Listing every model regardless would let someone
|
|
21
|
+
* pair an OpenAI model with an Anthropic key, which then fails at request time with a provider
|
|
22
|
+
* auth error that says nothing about the real mistake.
|
|
23
|
+
*/
|
|
24
|
+
private getModelOptions;
|
|
25
|
+
}
|
|
26
|
+
export declare const ModelRolesSettings: typeof ModelRolesSettingsImpl & {
|
|
27
|
+
__abstraction: import("@webiny/di").Abstraction<import("./AiPowerUpsSettings/settingsGroup.js").IAiPowerUpsSettingsGroup>;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { AiPowerUpsSettingsGroup } from "./AiPowerUpsSettings/settingsGroup.js";
|
|
2
|
+
import { ListModelsRepository, ListModelsUseCase } from "../features/listModels/abstractions.js";
|
|
3
|
+
import { AI_MODEL_ROLE_DISPLAY } from "./modelRoles.js";
|
|
4
|
+
class ModelRolesSettingsImpl {
|
|
5
|
+
constructor(useCase, repository){
|
|
6
|
+
this.useCase = useCase;
|
|
7
|
+
this.repository = repository;
|
|
8
|
+
this.name = "modelRoles";
|
|
9
|
+
this.label = "Model roles";
|
|
10
|
+
this.description = "Which model does the cheap work, the main work, and the image work.";
|
|
11
|
+
}
|
|
12
|
+
async init() {
|
|
13
|
+
await this.useCase.execute();
|
|
14
|
+
}
|
|
15
|
+
buildForm(form) {
|
|
16
|
+
form.fields((fields)=>({
|
|
17
|
+
roles: fields.object().label("Roles").renderer("passthrough").fields((f)=>Object.fromEntries(AI_MODEL_ROLE_DISPLAY.map((role)=>[
|
|
18
|
+
role.id,
|
|
19
|
+
f.object().label(role.label).renderer("objectAccordionSingle", {
|
|
20
|
+
itemTitle: ()=>role.label,
|
|
21
|
+
itemDescription: ()=>role.description,
|
|
22
|
+
open: true
|
|
23
|
+
}).fields((rf)=>({
|
|
24
|
+
connectionId: rf.text().label("Connection").description("Which API key runs this role.").options(({ form })=>this.getConnectionOptions(form)),
|
|
25
|
+
model: rf.text().label("Model").description("Only models from the selected connection's vendor are listed.").disabledWhen(({ form })=>!this.getSelectedConnection(form, role.id)).options(({ form })=>this.getModelOptions(form, role.id))
|
|
26
|
+
}))
|
|
27
|
+
])))
|
|
28
|
+
}));
|
|
29
|
+
form.layout((layout)=>[
|
|
30
|
+
layout.row("roles")
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
getConnections(form) {
|
|
34
|
+
const data = form.getData();
|
|
35
|
+
return data.connections?.presets ?? [];
|
|
36
|
+
}
|
|
37
|
+
getConnectionOptions(form) {
|
|
38
|
+
return this.getConnections(form).filter((c)=>c.id && c.name).map((c)=>({
|
|
39
|
+
label: c.name,
|
|
40
|
+
value: c.id
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
getSelectedConnection(form, roleId) {
|
|
44
|
+
const data = form.getData();
|
|
45
|
+
const connectionId = data.modelRoles?.roles?.[roleId]?.connectionId;
|
|
46
|
+
if (!connectionId) return;
|
|
47
|
+
return this.getConnections(form).find((c)=>c.id === connectionId);
|
|
48
|
+
}
|
|
49
|
+
getModelOptions(form, roleId) {
|
|
50
|
+
const connection = this.getSelectedConnection(form, roleId);
|
|
51
|
+
if (!connection) return [];
|
|
52
|
+
return this.repository.getModels().filter((model)=>model.providerId === connection.sdkName).map((model)=>({
|
|
53
|
+
label: model.modelName,
|
|
54
|
+
value: `${model.providerId}/${model.modelId}`
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const ModelRolesSettings = AiPowerUpsSettingsGroup.createImplementation({
|
|
59
|
+
implementation: ModelRolesSettingsImpl,
|
|
60
|
+
dependencies: [
|
|
61
|
+
ListModelsUseCase,
|
|
62
|
+
ListModelsRepository
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
export { ModelRolesSettings };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=ModelRolesSettings.js.map
|