@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 @@
|
|
|
1
|
+
{"version":3,"file":"admin/presentation/ModelRolesSettings.js","sources":["../../../src/admin/presentation/ModelRolesSettings.ts"],"sourcesContent":["import type { IAiPowerUpsConnectionPreset } from \"~/admin/features/settings/shared/abstractions.js\";\nimport { AiPowerUpsSettingsGroup } from \"./AiPowerUpsSettings/settingsGroup.js\";\nimport {\n ListModelsUseCase,\n ListModelsRepository\n} from \"~/admin/features/listModels/abstractions.js\";\nimport { AI_MODEL_ROLE_DISPLAY } from \"./modelRoles.js\";\nimport type { FormModel } from \"@webiny/app-admin\";\n\n/**\n * Three selects, and for most projects this is the whole AI configuration: one connection, one\n * model per role. Everything else in these settings is opt-in.\n */\nclass ModelRolesSettingsImpl implements AiPowerUpsSettingsGroup.Interface {\n name = \"modelRoles\";\n label = \"Model roles\";\n description = \"Which model does the cheap work, the main work, and the image work.\";\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 roles: fields\n .object()\n .label(\"Roles\")\n .renderer(\"passthrough\")\n .fields(f =>\n Object.fromEntries(\n AI_MODEL_ROLE_DISPLAY.map(role => [\n role.id,\n f\n .object()\n .label(role.label)\n /*\n * Both callbacks, not strings. A string here is a *field name* to\n * read the value from, not literal text, so passing prose made the\n * renderer look for a child field called \"Cheap, low-latency\n * work...\" and render no description at all.\n */\n .renderer(\"objectAccordionSingle\", {\n itemTitle: () => role.label,\n itemDescription: () => role.description,\n open: true\n })\n .fields(rf => ({\n connectionId: rf\n .text()\n .label(\"Connection\")\n .description(\"Which API key runs this role.\")\n .options(({ form }) => this.getConnectionOptions(form)),\n model: rf\n .text()\n .label(\"Model\")\n .description(\n \"Only models from the selected connection's vendor are listed.\"\n )\n .disabledWhen(\n ({ form }) => !this.getSelectedConnection(form, role.id)\n )\n .options(({ form }) => this.getModelOptions(form, role.id))\n }))\n ])\n )\n )\n }));\n\n form.layout(layout => [layout.row(\"roles\")]);\n }\n\n private getConnections(form: FormModel.Interface): IAiPowerUpsConnectionPreset[] {\n const data = form.getData() as {\n connections?: { presets?: IAiPowerUpsConnectionPreset[] };\n };\n return data.connections?.presets ?? [];\n }\n\n private getConnectionOptions(form: FormModel.Interface) {\n return this.getConnections(form)\n .filter(c => c.id && c.name)\n .map(c => ({ label: c.name, value: c.id }));\n }\n\n private getSelectedConnection(\n form: FormModel.Interface,\n roleId: string\n ): IAiPowerUpsConnectionPreset | undefined {\n const data = form.getData() as {\n modelRoles?: { roles?: Record<string, { connectionId?: string }> };\n };\n const connectionId = data.modelRoles?.roles?.[roleId]?.connectionId;\n\n if (!connectionId) {\n return undefined;\n }\n\n return this.getConnections(form).find(c => c.id === connectionId);\n }\n\n /**\n * Filtered by the chosen connection's vendor. Listing every model regardless would let someone\n * pair an OpenAI model with an Anthropic key, which then fails at request time with a provider\n * auth error that says nothing about the real mistake.\n */\n private getModelOptions(form: FormModel.Interface, roleId: string) {\n const connection = this.getSelectedConnection(form, roleId);\n\n if (!connection) {\n return [];\n }\n\n return this.repository\n .getModels()\n .filter(model => model.providerId === connection.sdkName)\n .map(model => ({\n label: model.modelName,\n value: `${model.providerId}/${model.modelId}`\n }));\n }\n}\n\nexport const ModelRolesSettings = AiPowerUpsSettingsGroup.createImplementation({\n implementation: ModelRolesSettingsImpl,\n dependencies: [ListModelsUseCase, ListModelsRepository]\n});\n"],"names":["ModelRolesSettingsImpl","useCase","repository","form","fields","f","Object","AI_MODEL_ROLE_DISPLAY","role","rf","layout","data","c","roleId","connectionId","connection","model","ModelRolesSettings","AiPowerUpsSettingsGroup","ListModelsUseCase","ListModelsRepository"],"mappings":";;;AAaA,MAAMA;IAKF,YACYC,OAAoC,EACpCC,UAA0C,CACpD;aAFUD,OAAO,GAAPA;aACAC,UAAU,GAAVA;aANZ,IAAI,GAAG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AAKA,EAAE,EAAE,IAAIA,EAAE,IAAI,EAC1B,GAAG,CAACA,CAAAA,IAAM;gBAAE,OAAOA,EAAE,IAAI;gBAAE,OAAOA,EAAE,EAAE;YAAC;IAChD;IAEQ,sBACJT,IAAyB,EACzBU,MAAc,EACyB;QACvC,MAAMF,OAAOR,KAAK,OAAO;QAGzB,MAAMW,eAAeH,KAAK,UAAU,EAAE,OAAO,CAACE,OAAO,EAAE;QAEvD,IAAI,CAACC,cACD;QAGJ,OAAO,IAAI,CAAC,cAAc,CAACX,MAAM,IAAI,CAACS,CAAAA,IAAKA,EAAE,EAAE,KAAKE;IACxD;IAOQ,gBAAgBX,IAAyB,EAAEU,MAAc,EAAE;QAC/D,MAAME,aAAa,IAAI,CAAC,qBAAqB,CAACZ,MAAMU;QAEpD,IAAI,CAACE,YACD,OAAO,EAAE;QAGb,OAAO,IAAI,CAAC,UAAU,CACjB,SAAS,GACT,MAAM,CAACC,CAAAA,QAASA,MAAM,UAAU,KAAKD,WAAW,OAAO,EACvD,GAAG,CAACC,CAAAA,QAAU;gBACX,OAAOA,MAAM,SAAS;gBACtB,OAAO,GAAGA,MAAM,UAAU,CAAC,CAAC,EAAEA,MAAM,OAAO,EAAE;YACjD;IACR;AACJ;AAEO,MAAMC,qBAAqBC,wBAAwB,oBAAoB,CAAC;IAC3E,gBAAgBlB;IAChB,cAAc;QAACmB;QAAmBC;KAAqB;AAC3D"}
|
|
@@ -16,8 +16,8 @@ class ProjectsSettingsImpl {
|
|
|
16
16
|
instructions: f.text().label("Instructions").description("System-prompt-style guidance that will be sent to the LLM when this project is selected.").renderer("textarea", {
|
|
17
17
|
rows: 6
|
|
18
18
|
}),
|
|
19
|
-
defaultReaderPersonaId: f.text().label("Default Reader Persona").description("Auto-populates the reader persona when this project is selected.").options((
|
|
20
|
-
const data =
|
|
19
|
+
defaultReaderPersonaId: f.text().label("Default Reader Persona").description("Auto-populates the reader persona when this project is selected.").options(({ form })=>{
|
|
20
|
+
const data = form.getData();
|
|
21
21
|
const presets = data?.readerPersonas?.presets;
|
|
22
22
|
if (!presets || 0 === presets.length) return [];
|
|
23
23
|
return presets.map((preset)=>({
|
|
@@ -25,8 +25,8 @@ class ProjectsSettingsImpl {
|
|
|
25
25
|
value: preset.id
|
|
26
26
|
}));
|
|
27
27
|
}),
|
|
28
|
-
defaultWriterPersonaId: f.text().label("Default Writer Persona").description("Auto-populates the writer persona when this project is selected.").options((
|
|
29
|
-
const data =
|
|
28
|
+
defaultWriterPersonaId: f.text().label("Default Writer Persona").description("Auto-populates the writer persona when this project is selected.").options(({ form })=>{
|
|
29
|
+
const data = form.getData();
|
|
30
30
|
const presets = data?.writerPersonas?.presets;
|
|
31
31
|
if (!presets || 0 === presets.length) return [];
|
|
32
32
|
return presets.map((preset)=>({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/ProjectsSettings.js","sources":["../../../src/admin/presentation/ProjectsSettings.ts"],"sourcesContent":["import { generateAlphaNumericId } from \"@webiny/utils\";\nimport
|
|
1
|
+
{"version":3,"file":"admin/presentation/ProjectsSettings.js","sources":["../../../src/admin/presentation/ProjectsSettings.ts"],"sourcesContent":["import { generateAlphaNumericId } from \"@webiny/utils\";\nimport { AiPowerUpsSettingsGroup } from \"./AiPowerUpsSettings/settingsGroup.js\";\n\nclass ProjectsSettingsImpl implements AiPowerUpsSettingsGroup.Interface {\n name = \"projects\";\n label = \"Projects\";\n description = \"Predefined prompting contexts.\";\n\n buildForm(form: AiPowerUpsSettingsGroup.FormBuilder): void {\n form.fields(fields => ({\n presets: fields\n .object()\n .label(\"Presets\")\n .renderer(\"objectAccordionMultiple\", {\n container: false,\n addItemLabel: \"Add project\",\n itemTitle: (data, index) => String(data.name || `Project #${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(\"This name will be used to identify the project in the UI.\"),\n description: f\n .text()\n .label(\"Description\")\n .description(\n \"Human-facing description shown in the project picker. Not sent to the LLM.\"\n )\n .renderer(\"textarea\", { rows: 3 }),\n instructions: f\n .text()\n .label(\"Instructions\")\n .description(\n \"System-prompt-style guidance that will be sent to the LLM when this project is selected.\"\n )\n .renderer(\"textarea\", { rows: 6 }),\n defaultReaderPersonaId: f\n .text()\n .label(\"Default Reader Persona\")\n .description(\n \"Auto-populates the reader persona when this project is selected.\"\n )\n .options(({ form }) => {\n const data = form.getData();\n const presets = data?.readerPersonas?.presets;\n if (!presets || presets.length === 0) {\n return [];\n }\n return presets.map((preset: { id: string; name: string }) => ({\n label: preset.name,\n value: preset.id\n }));\n }),\n defaultWriterPersonaId: f\n .text()\n .label(\"Default Writer Persona\")\n .description(\n \"Auto-populates the writer persona when this project is selected.\"\n )\n .options(({ form }) => {\n const data = form.getData();\n const presets = data?.writerPersonas?.presets;\n if (!presets || presets.length === 0) {\n return [];\n }\n return presets.map((preset: { id: string; name: string }) => ({\n label: preset.name,\n value: preset.id\n }));\n }),\n files: f\n .file()\n .label(\"Files\")\n .list()\n .description(\n \"Add files from the library to include as context for the LLM.\"\n )\n .note(\n \"Only files containing text will be sent to the LLM (.mdx, .md, .html, .json, .csv, .txt, etc.)\"\n )\n }))\n .list()\n }));\n\n form.layout(layout => [layout.row(\"presets\")]);\n }\n}\n\nexport const ProjectsSettings = AiPowerUpsSettingsGroup.createImplementation({\n implementation: ProjectsSettingsImpl,\n dependencies: []\n});\n"],"names":["ProjectsSettingsImpl","form","fields","data","index","String","f","generateAlphaNumericId","presets","preset","layout","ProjectsSettings","AiPowerUpsSettingsGroup"],"mappings":";;AAGA,MAAMA;IAKF,UAAUC,IAAyC,EAAQ;QACvDA,KAAK,MAAM,CAACC,CAAAA,SAAW;gBACnB,SAASA,OACJ,MAAM,GACN,KAAK,CAAC,WACN,QAAQ,CAAC,2BAA2B;oBACjC,WAAW;oBACX,cAAc;oBACd,WAAW,CAACC,MAAMC,QAAUC,OAAOF,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AAI,GACJ,WAAW,CACR,iEAEH,IAAI,CACD;oBAEZ,IACC,IAAI;YACb;QAEAL,KAAK,MAAM,CAACS,CAAAA,SAAU;gBAACA,OAAO,GAAG,CAAC;aAAW;IACjD;;aAvFA,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAAG;;AAsFlB;AAEO,MAAMC,mBAAmBC,wBAAwB,oBAAoB,CAAC;IACzE,gBAAgBZ;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -19,7 +19,7 @@ class ProviderSettingsImpl {
|
|
|
19
19
|
}).fields((f)=>({
|
|
20
20
|
id: f.text().hidden().defaultValue(()=>generateAlphaNumericId(10)),
|
|
21
21
|
name: f.text().label("Name").required("Name is required"),
|
|
22
|
-
model: f.text().label("Model").required("Model is required").options(()=>this.getModelOptions()),
|
|
22
|
+
model: f.text().label("Model").required("Model is required").options(()=>this.getModelOptions()).renderer("autoComplete"),
|
|
23
23
|
apiKey: f.text().label("API Key").required("API Key is required")
|
|
24
24
|
})).list()
|
|
25
25
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/ProvidersSettings.js","sources":["../../../src/admin/presentation/ProvidersSettings.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\nclass ProviderSettingsImpl implements AiPowerUpsSettingsGroup.Interface {\n name = \"providers\";\n label = \"Providers\";\n description = \"Configure AI model providers.\";\n\n constructor(\n private useCase: ListModelsUseCase.Interface,\n private repository: ListModelsRepository.Interface\n ) {}\n\n buildForm(form: AiPowerUpsSettingsGroup.FormBuilder): void {\n void this.useCase.execute();\n\n form.fields(fields => ({\n presets: fields\n .object()\n .label(\"Presets\")\n .renderer(\"objectAccordionMultiple\", {\n container: false,\n addItemLabel: \"Add provider\",\n itemTitle: (data, index) => String(data.name || `Provider #${index + 1}`)\n })\n .fields(f => ({\n id: f\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericId(10)),\n name: f.text().label(\"Name\").required(\"Name is required\"),\n model: f\n .text()\n .label(\"Model\")\n .required(\"Model is required\")\n .options(() => this.getModelOptions()),\n apiKey: f.text().label(\"API Key\").required(\"API Key is required\")\n }))\n .list()\n }));\n\n form.layout(layout => [layout.row(\"presets\")]);\n }\n\n private getModelOptions() {\n return this.repository.getModels().map(model => ({\n label: `${model.modelName} (${model.modelId})`,\n value: `${model.providerId}/${model.modelId}`\n }));\n }\n}\n\nexport const ProviderSettings = AiPowerUpsSettingsGroup.createImplementation({\n implementation: ProviderSettingsImpl,\n dependencies: [ListModelsUseCase, ListModelsRepository]\n});\n"],"names":["ProviderSettingsImpl","useCase","repository","form","fields","data","index","String","f","generateAlphaNumericId","layout","model","ProviderSettings","AiPowerUpsSettingsGroup","ListModelsUseCase","ListModelsRepository"],"mappings":";;;AAOA,MAAMA;IAKF,YACYC,OAAoC,EACpCC,UAA0C,CACpD;aAFUD,OAAO,GAAPA;aACAC,UAAU,GAAVA;aANZ,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAAG;IAKX;IAEH,UAAUC,IAAyC,EAAQ;QAClD,IAAI,CAAC,OAAO,CAAC,OAAO;QAEzBA,KAAK,MAAM,CAACC,CAAAA,SAAW;gBACnB,SAASA,OACJ,MAAM,GACN,KAAK,CAAC,WACN,QAAQ,CAAC,2BAA2B;oBACjC,WAAW;oBACX,cAAc;oBACd,WAAW,CAACC,MAAMC,QAAUC,OAAOF,KAAK,IAAI,IAAI,CAAC,UAAU,EAAEC,QAAQ,GAAG;gBAC5E,GACC,MAAM,CAACE,CAAAA,IAAM;wBACV,IAAIA,EACC,IAAI,GACJ,MAAM,GACN,YAAY,CAAC,IAAMC,uBAAuB;wBAC/C,MAAMD,EAAE,IAAI,GAAG,KAAK,CAAC,QAAQ,QAAQ,CAAC;wBACtC,OAAOA,EACF,IAAI,GACJ,KAAK,CAAC,SACN,QAAQ,CAAC,qBACT,OAAO,CAAC,IAAM,IAAI,CAAC,eAAe;
|
|
1
|
+
{"version":3,"file":"admin/presentation/ProvidersSettings.js","sources":["../../../src/admin/presentation/ProvidersSettings.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\nclass ProviderSettingsImpl implements AiPowerUpsSettingsGroup.Interface {\n name = \"providers\";\n label = \"Providers\";\n description = \"Configure AI model providers.\";\n\n constructor(\n private useCase: ListModelsUseCase.Interface,\n private repository: ListModelsRepository.Interface\n ) {}\n\n buildForm(form: AiPowerUpsSettingsGroup.FormBuilder): void {\n void this.useCase.execute();\n\n form.fields(fields => ({\n presets: fields\n .object()\n .label(\"Presets\")\n .renderer(\"objectAccordionMultiple\", {\n container: false,\n addItemLabel: \"Add provider\",\n itemTitle: (data, index) => String(data.name || `Provider #${index + 1}`)\n })\n .fields(f => ({\n id: f\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericId(10)),\n name: f.text().label(\"Name\").required(\"Name is required\"),\n model: f\n .text()\n .label(\"Model\")\n .required(\"Model is required\")\n .options(() => this.getModelOptions())\n .renderer(\"autoComplete\"),\n apiKey: f.text().label(\"API Key\").required(\"API Key is required\")\n }))\n .list()\n }));\n\n form.layout(layout => [layout.row(\"presets\")]);\n }\n\n private getModelOptions() {\n return this.repository.getModels().map(model => ({\n label: `${model.modelName} (${model.modelId})`,\n value: `${model.providerId}/${model.modelId}`\n }));\n }\n}\n\nexport const ProviderSettings = AiPowerUpsSettingsGroup.createImplementation({\n implementation: ProviderSettingsImpl,\n dependencies: [ListModelsUseCase, ListModelsRepository]\n});\n"],"names":["ProviderSettingsImpl","useCase","repository","form","fields","data","index","String","f","generateAlphaNumericId","layout","model","ProviderSett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BC,wBAAwB,oBAAoB,CAAC;IACzE,gBAAgBb;IAChB,cAAc;QAACc;QAAmBC;KAAqB;AAC3D"}
|
|
@@ -3,11 +3,11 @@ import { IconButton } from "@webiny/admin-ui";
|
|
|
3
3
|
import { ReactComponent } from "@webiny/icons/auto_fix_high.svg";
|
|
4
4
|
import { useOpenDialog } from "@webiny/app-admin";
|
|
5
5
|
import { GENERATE_CONTENT_DIALOG } from "./GenerateContentDialog.js";
|
|
6
|
-
import { useAiPowerUpsSettings } from "../AiPowerUpsSettings/index.js";
|
|
6
|
+
import { hasUsableModel, useAiPowerUpsSettings } from "../AiPowerUpsSettings/index.js";
|
|
7
7
|
const GenerateContentButton = ()=>{
|
|
8
8
|
const { openDialog } = useOpenDialog();
|
|
9
9
|
const { settings } = useAiPowerUpsSettings();
|
|
10
|
-
if (!settings
|
|
10
|
+
if (!hasUsableModel(settings)) return null;
|
|
11
11
|
return /*#__PURE__*/ react.createElement(IconButton, {
|
|
12
12
|
variant: "ghost",
|
|
13
13
|
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WbContentGeneration/GenerateContentButton.js","sources":["../../../../src/admin/presentation/WbContentGeneration/GenerateContentButton.tsx"],"sourcesContent":["import React from \"react\";\nimport { IconButton } from \"@webiny/admin-ui\";\nimport { ReactComponent as ChatIcon } from \"@webiny/icons/auto_fix_high.svg\";\nimport { useOpenDialog } from \"@webiny/app-admin\";\nimport { GENERATE_CONTENT_DIALOG } from \"./GenerateContentDialog.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"admin/presentation/WbContentGeneration/GenerateContentButton.js","sources":["../../../../src/admin/presentation/WbContentGeneration/GenerateContentButton.tsx"],"sourcesContent":["import React from \"react\";\nimport { IconButton } from \"@webiny/admin-ui\";\nimport { ReactComponent as ChatIcon } from \"@webiny/icons/auto_fix_high.svg\";\nimport { useOpenDialog } from \"@webiny/app-admin\";\nimport { GENERATE_CONTENT_DIALOG } from \"./GenerateContentDialog.js\";\nimport {\n hasUsableModel,\n useAiPowerUpsSettings\n} from \"~/admin/presentation/AiPowerUpsSettings/index.js\";\n\nexport const GenerateContentButton = () => {\n const { openDialog } = useOpenDialog();\n const { settings } = useAiPowerUpsSettings();\n\n if (!hasUsableModel(settings)) {\n return null;\n }\n\n return (\n <IconButton\n variant=\"ghost\"\n icon={<ChatIcon />}\n onClick={() => openDialog(GENERATE_CONTENT_DIALOG, {})}\n />\n );\n};\n"],"names":["GenerateContentButton","openDialog","useOpenDialog","settings","useAiPowerUpsSettings","hasUsableModel","IconButton","ChatIcon","GENERATE_CONTENT_DIALOG"],"mappings":";;;;;;AAUO,MAAMA,wBAAwB;IACjC,MAAM,EAAEC,UAAU,EAAE,GAAGC;IACvB,MAAM,EAAEC,QAAQ,EAAE,GAAGC;IAErB,IAAI,CAACC,eAAeF,WAChB,OAAO;IAGX,OAAO,WAAP,GACI,oBAACG,YAAUA;QACP,SAAQ;QACR,oBAAM,oBAACC,gBAAQA;QACf,SAAS,IAAMN,WAAWO,yBAAyB,CAAC;;AAGhE"}
|
|
@@ -16,6 +16,6 @@ export interface GeneratePageContentErrorMessage extends IncomingGenericData {
|
|
|
16
16
|
message: string;
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
export declare const GenerateContentDialog: (() => React.JSX.Element) &
|
|
20
|
-
|
|
19
|
+
export declare const GenerateContentDialog: (() => React.JSX.Element) & {
|
|
20
|
+
displayName: string;
|
|
21
21
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import react, { useCallback, useEffect, useRef } from "react";
|
|
2
2
|
import { observer } from "mobx-react-lite";
|
|
3
3
|
import { FormView, useDialog } from "@webiny/app-admin";
|
|
4
|
-
import { Dialog, OverlayLoader, useToast } from "@webiny/admin-ui";
|
|
4
|
+
import { BetaBadge, Dialog, OverlayLoader, useToast } from "@webiny/admin-ui";
|
|
5
5
|
import { useFeature } from "@webiny/app";
|
|
6
6
|
import { useWebsockets } from "@webiny/app-websockets";
|
|
7
7
|
import { useSelectFromEditor } from "@webiny/app-website-builder/BaseEditor/hooks/useSelectFromEditor.js";
|
|
@@ -96,7 +96,7 @@ const GenerateContentDialog = observer(()=>{
|
|
|
96
96
|
return /*#__PURE__*/ react.createElement(Dialog, {
|
|
97
97
|
open: true,
|
|
98
98
|
onClose: closeDialog,
|
|
99
|
-
title: "Generate Content",
|
|
99
|
+
title: /*#__PURE__*/ react.createElement(react.Fragment, null, "Generate Content ", /*#__PURE__*/ react.createElement(BetaBadge, null)),
|
|
100
100
|
size: "lg",
|
|
101
101
|
actions: /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Dialog.CancelAction, {
|
|
102
102
|
onClick: closeDialog,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WbContentGeneration/GenerateContentDialog.js","sources":["../../../../src/admin/presentation/WbContentGeneration/GenerateContentDialog.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useDialog, FormView } from \"@webiny/app-admin\";\nimport { Dialog, 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 { useSelectFromEditor } from \"@webiny/app-website-builder/BaseEditor/hooks/useSelectFromEditor.js\";\nimport { useCreateElement } from \"@webiny/app-website-builder/BaseEditor/hooks/useCreateElement.js\";\nimport { GenerateContentFeature } from \"./feature.js\";\nimport { decompressGzipBase64 } from \"./decompressGzipBase64.js\";\nimport type { CreateElementParams } from \"./abstractions.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\nexport const GENERATE_CONTENT_DIALOG = \"generate-content\";\n\nexport const WS_ACTION_CONTENT = \"aiPowerUps.generatePageContent.content\";\nexport const WS_ACTION_ERROR = \"aiPowerUps.generatePageContent.error\";\n\nexport interface GeneratePageContentMessage extends IncomingGenericData {\n action: typeof WS_ACTION_CONTENT;\n data: {\n compression: \"gzip\";\n value: string;\n };\n}\n\nexport interface GeneratePageContentErrorMessage extends IncomingGenericData {\n action: typeof WS_ACTION_ERROR;\n data: {\n message: string;\n };\n}\n\nexport const GenerateContentDialog = observer(() => {\n const { closeDialog } = useDialog();\n const { presenter } = useFeature(GenerateContentFeature);\n const vm = presenter.vm;\n const wasSubmitting = useRef(false);\n const websockets = useWebsockets();\n const toast = useToast();\n\n const components = useSelectFromEditor(state => state.components);\n const { createElement } = useCreateElement();\n\n const createElements = useCallback(\n async (elements: CreateElementParams[]) => {\n for (const el of elements) {\n await createElement(el);\n }\n },\n [createElement]\n );\n\n useEffect(() => {\n const aiComponents = Object.values(components)\n .filter(c => c.useInAiContentGeneration !== false)\n .map(c => {\n return {\n name: c.name,\n label: c.label,\n aiContext: c.aiContext,\n inputs: c.inputs.map(input => ({\n type: input.type,\n name: input.name,\n label: input.label,\n description: input.description\n }))\n };\n });\n presenter.init(aiComponents, createElements);\n }, [components, createElements]);\n\n useEffect(() => {\n const contentSubscription = websockets.onMessage<GeneratePageContentMessage>(\n WS_ACTION_CONTENT,\n async message => {\n const responseText = await decompressGzipBase64(message.data.value);\n try {\n await presenter.processAiResponse(responseText);\n } catch (e) {\n console.error(\"Failed to process AI response\", { responseText });\n console.error(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<GeneratePageContentErrorMessage>(\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 closeDialog();\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();\n };\n\n return (\n <Dialog\n open={true}\n onClose={closeDialog}\n title
|
|
1
|
+
{"version":3,"file":"admin/presentation/WbContentGeneration/GenerateContentDialog.js","sources":["../../../../src/admin/presentation/WbContentGeneration/GenerateContentDialog.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useDialog, FormView } from \"@webiny/app-admin\";\nimport { BetaBadge } from \"@webiny/admin-ui\";\nimport { Dialog, 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 { useSelectFromEditor } from \"@webiny/app-website-builder/BaseEditor/hooks/useSelectFromEditor.js\";\nimport { useCreateElement } from \"@webiny/app-website-builder/BaseEditor/hooks/useCreateElement.js\";\nimport { GenerateContentFeature } from \"./feature.js\";\nimport { decompressGzipBase64 } from \"./decompressGzipBase64.js\";\nimport type { CreateElementParams } from \"./abstractions.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\nexport const GENERATE_CONTENT_DIALOG = \"generate-content\";\n\nexport const WS_ACTION_CONTENT = \"aiPowerUps.generatePageContent.content\";\nexport const WS_ACTION_ERROR = \"aiPowerUps.generatePageContent.error\";\n\nexport interface GeneratePageContentMessage extends IncomingGenericData {\n action: typeof WS_ACTION_CONTENT;\n data: {\n compression: \"gzip\";\n value: string;\n };\n}\n\nexport interface GeneratePageContentErrorMessage extends IncomingGenericData {\n action: typeof WS_ACTION_ERROR;\n data: {\n message: string;\n };\n}\n\nexport const GenerateContentDialog = observer(() => {\n const { closeDialog } = useDialog();\n const { presenter } = useFeature(GenerateContentFeature);\n const vm = presenter.vm;\n const wasSubmitting = useRef(false);\n const websockets = useWebsockets();\n const toast = useToast();\n\n const components = useSelectFromEditor(state => state.components);\n const { createElement } = useCreateElement();\n\n const createElements = useCallback(\n async (elements: CreateElementParams[]) => {\n for (const el of elements) {\n await createElement(el);\n }\n },\n [createElement]\n );\n\n useEffect(() => {\n const aiComponents = Object.values(components)\n .filter(c => c.useInAiContentGeneration !== false)\n .map(c => {\n return {\n name: c.name,\n label: c.label,\n aiContext: c.aiContext,\n inputs: c.inputs.map(input => ({\n type: input.type,\n name: input.name,\n label: input.label,\n description: input.description\n }))\n };\n });\n presenter.init(aiComponents, createElements);\n }, [components, createElements]);\n\n useEffect(() => {\n const contentSubscription = websockets.onMessage<GeneratePageContentMessage>(\n WS_ACTION_CONTENT,\n async message => {\n const responseText = await decompressGzipBase64(message.data.value);\n try {\n await presenter.processAiResponse(responseText);\n } catch (e) {\n console.error(\"Failed to process AI response\", { responseText });\n console.error(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<GeneratePageContentErrorMessage>(\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 closeDialog();\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();\n };\n\n return (\n <Dialog\n open={true}\n onClose={closeDialog}\n title={\n <>\n Generate Content <BetaBadge />\n </>\n }\n size={\"lg\"}\n actions={\n <>\n <Dialog.CancelAction onClick={closeDialog} text=\"Cancel\" />\n <Dialog.ConfirmAction\n onClick={handleSubmit}\n text=\"Generate\"\n disabled={vm.loading || vm.submitting}\n />\n </>\n }\n >\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 model\n you're using.\n </div>\n </>\n }\n />\n ) : null}\n {vm.processing ? <OverlayLoader text={\"Processing content...\"} /> : null}\n {vm.form ? <FormView name=\"GenerateContent\" form={vm.form} /> : null}\n </Dialog>\n );\n});\n"],"names":["formatElapsed","totalSeconds","minutes","Math","seconds","GENERATE_CONTENT_DIALOG","WS_ACTION_CONTENT","WS_ACTION_ERROR","GenerateContentDialog","observer","closeDialog","useDialog","presenter","useFeature","GenerateContentFeature","vm","wasSubmitting","useRef","websockets","useWebsockets","toast","useToast","components","useSelectFromEditor","state","createElement","useCreateElement","createElements","useCallback","elements","el","useEffect","aiComponents","Object","c","input","contentSubscription","message","responseText","decompressGzipBase64","e","console","errorSubscription","handleSubmit","Dialog","BetaBadge","OverlayLoader","FormView"],"mappings":";;;;;;;;;;AAcA,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;AAEO,MAAMC,0BAA0B;AAEhC,MAAMC,oBAAoB;AAC1B,MAAMC,kBAAkB;AAiBxB,MAAMC,w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I,GAAG,WAAH,GAAG,oBAACgC,UAAQA;QAAC,MAAK;QAAkB,MAAMhC,GAAG,IAAI;SAAO;AAG5E"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ToolRegistry, ToolPipelineRunner } from "@webiny/app-admin";
|
|
2
2
|
import { GenerateContentPresenter, type CreateElementsFn } from "./abstractions.js";
|
|
3
3
|
import { GeneratePageContentUseCase } from "../../../admin/features/generatePageContent/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { AiPromptFormFactory } from "../../../admin/presentation/AiPromptFormFactory/abstractions.js";
|
|
5
5
|
declare class GenerateContentPresenterImpl implements GenerateContentPresenter.Interface {
|
|
6
6
|
private toolRegistry;
|
|
7
7
|
private pipelineRunner;
|
|
8
8
|
private generatePageContent;
|
|
9
|
-
private
|
|
10
|
-
private getSettings;
|
|
9
|
+
private formFactory;
|
|
11
10
|
private _loading;
|
|
12
11
|
private _submitting;
|
|
13
12
|
private _processing;
|
|
@@ -15,11 +14,10 @@ declare class GenerateContentPresenterImpl implements GenerateContentPresenter.I
|
|
|
15
14
|
private _components;
|
|
16
15
|
private _createElements;
|
|
17
16
|
private _form;
|
|
18
|
-
private _settings;
|
|
19
17
|
private _timeoutId;
|
|
20
18
|
private _intervalId;
|
|
21
19
|
private _elapsedSeconds;
|
|
22
|
-
constructor(toolRegistry: ToolRegistry.Interface, pipelineRunner: ToolPipelineRunner.Interface, generatePageContent: GeneratePageContentUseCase.Interface,
|
|
20
|
+
constructor(toolRegistry: ToolRegistry.Interface, pipelineRunner: ToolPipelineRunner.Interface, generatePageContent: GeneratePageContentUseCase.Interface, formFactory: AiPromptFormFactory.Interface);
|
|
23
21
|
get vm(): GenerateContentPresenter.ViewModel;
|
|
24
22
|
init(components: Record<string, any>[], createElements: CreateElementsFn): Promise<void>;
|
|
25
23
|
submit(): Promise<void>;
|
|
@@ -28,12 +26,6 @@ declare class GenerateContentPresenterImpl implements GenerateContentPresenter.I
|
|
|
28
26
|
private startTimeout;
|
|
29
27
|
private clearTimeout;
|
|
30
28
|
private clearInterval;
|
|
31
|
-
private buildForm;
|
|
32
|
-
private getSelectedProject;
|
|
33
|
-
private getProjectFileOptions;
|
|
34
|
-
private computeExcludedFileIds;
|
|
35
|
-
private getProjectOptions;
|
|
36
|
-
private getPersonaOptions;
|
|
37
29
|
}
|
|
38
30
|
export declare const GenerateContentPresenterRegistration: typeof GenerateContentPresenterImpl & {
|
|
39
31
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGenerateContentPresenter>;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { computed, makeAutoObservable, runInAction, toJS } from "mobx";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import pick from "lodash/pick.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ToolPipelineRunner, ToolRegistry } from "@webiny/app-admin";
|
|
5
5
|
import { GenerateContentPresenter } from "./abstractions.js";
|
|
6
6
|
import { GeneratePageContentUseCase } from "../../features/generatePageContent/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { AiPromptFormFactory } from "../AiPromptFormFactory/abstractions.js";
|
|
8
8
|
const SUBMIT_TIMEOUT_MS = 300000;
|
|
9
9
|
class GenerateContentPresenterImpl {
|
|
10
|
-
constructor(toolRegistry, pipelineRunner, generatePageContent,
|
|
10
|
+
constructor(toolRegistry, pipelineRunner, generatePageContent, formFactory){
|
|
11
11
|
this.toolRegistry = toolRegistry;
|
|
12
12
|
this.pipelineRunner = pipelineRunner;
|
|
13
13
|
this.generatePageContent = generatePageContent;
|
|
14
|
-
this.
|
|
15
|
-
this.getSettings = getSettings;
|
|
14
|
+
this.formFactory = formFactory;
|
|
16
15
|
this._loading = false;
|
|
17
16
|
this._submitting = false;
|
|
18
17
|
this._processing = false;
|
|
@@ -20,7 +19,6 @@ class GenerateContentPresenterImpl {
|
|
|
20
19
|
this._components = [];
|
|
21
20
|
this._createElements = ()=>{};
|
|
22
21
|
this._form = null;
|
|
23
|
-
this._settings = null;
|
|
24
22
|
this._timeoutId = null;
|
|
25
23
|
this._intervalId = null;
|
|
26
24
|
this._elapsedSeconds = 0;
|
|
@@ -43,18 +41,9 @@ class GenerateContentPresenterImpl {
|
|
|
43
41
|
async init(components, createElements) {
|
|
44
42
|
this._components = components;
|
|
45
43
|
this._createElements = createElements;
|
|
46
|
-
this.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
runInAction(()=>{
|
|
50
|
-
this._settings = settings;
|
|
51
|
-
this._form = this.buildForm();
|
|
52
|
-
});
|
|
53
|
-
} finally{
|
|
54
|
-
runInAction(()=>{
|
|
55
|
-
this._loading = false;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
44
|
+
this._form = this.formFactory.createForm({
|
|
45
|
+
promptDescription: "Describe the page content you want to generate."
|
|
46
|
+
});
|
|
58
47
|
}
|
|
59
48
|
async submit() {
|
|
60
49
|
if (!this._form) return;
|
|
@@ -78,7 +67,8 @@ class GenerateContentPresenterImpl {
|
|
|
78
67
|
"type"
|
|
79
68
|
])
|
|
80
69
|
}));
|
|
81
|
-
const excludedFileIds = this.computeExcludedFileIds(
|
|
70
|
+
const excludedFileIds = this.formFactory.computeExcludedFileIds(this._form);
|
|
71
|
+
const additionalFileIds = data.additionalFiles?.map((f)=>f.id) ?? null;
|
|
82
72
|
await this.generatePageContent.execute({
|
|
83
73
|
prompt: data.prompt,
|
|
84
74
|
components: toJS(this._components),
|
|
@@ -86,7 +76,8 @@ class GenerateContentPresenterImpl {
|
|
|
86
76
|
projectId: data.project || null,
|
|
87
77
|
excludedFileIds,
|
|
88
78
|
readerPersonaId: data.readerPersona || null,
|
|
89
|
-
writerPersonaId: data.writerPersona || null
|
|
79
|
+
writerPersonaId: data.writerPersona || null,
|
|
80
|
+
additionalFileIds
|
|
90
81
|
});
|
|
91
82
|
} catch {
|
|
92
83
|
this.clearTimeout();
|
|
@@ -155,78 +146,6 @@ class GenerateContentPresenterImpl {
|
|
|
155
146
|
this._intervalId = null;
|
|
156
147
|
}
|
|
157
148
|
}
|
|
158
|
-
buildForm() {
|
|
159
|
-
return this.formModelFactory.create({
|
|
160
|
-
fields: (fields)=>({
|
|
161
|
-
project: fields.text().label("Project").description("Select a predefined context to attach.").options(()=>this.getProjectOptions()).afterChange((value, form)=>{
|
|
162
|
-
const projectId = value;
|
|
163
|
-
const project = projectId ? this._settings?.projects?.presets?.find((p)=>p.id === projectId) : void 0;
|
|
164
|
-
if (project?.defaultReaderPersonaId) form.field("readerPersona").setValue(project.defaultReaderPersonaId);
|
|
165
|
-
if (project?.defaultWriterPersonaId) form.field("writerPersona").setValue(project.defaultWriterPersonaId);
|
|
166
|
-
const fileIds = (project?.files ?? []).map((f)=>f.id);
|
|
167
|
-
form.field("includedFiles").setValue(fileIds);
|
|
168
|
-
}),
|
|
169
|
-
includedFiles: fields.text().label("Files included").description("Uncheck files to exclude them from this generation only.").options(()=>this.getProjectFileOptions()).renderer("checkboxes").list().hiddenWhen((form)=>{
|
|
170
|
-
const projectId = form.field("project").as("text").getValue();
|
|
171
|
-
if (!projectId) return true;
|
|
172
|
-
const project = this._settings?.projects?.presets?.find((p)=>p.id === projectId);
|
|
173
|
-
return !project?.files || 0 === project.files.length;
|
|
174
|
-
}),
|
|
175
|
-
readerPersona: fields.text().label("Reader Persona").description("Select the target audience for the generated content.").options(()=>this.getPersonaOptions("reader")),
|
|
176
|
-
writerPersona: fields.text().label("Writer Persona").description("Select the writing style for the generated content.").options(()=>this.getPersonaOptions("writer")),
|
|
177
|
-
prompt: fields.text().label("Prompt").description("Describe the page content you want to generate.").required("Prompt is required").renderer("textarea", {
|
|
178
|
-
rows: 6
|
|
179
|
-
})
|
|
180
|
-
}),
|
|
181
|
-
layout: (layout)=>[
|
|
182
|
-
layout.row("project"),
|
|
183
|
-
layout.row("includedFiles"),
|
|
184
|
-
layout.row("readerPersona"),
|
|
185
|
-
layout.row("writerPersona"),
|
|
186
|
-
layout.row("prompt")
|
|
187
|
-
]
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
getSelectedProject() {
|
|
191
|
-
if (!this._form || !this._settings) return;
|
|
192
|
-
const projectId = this._form.field("project").getValue();
|
|
193
|
-
if (!projectId) return;
|
|
194
|
-
return this._settings.projects?.presets?.find((p)=>p.id === projectId);
|
|
195
|
-
}
|
|
196
|
-
getProjectFileOptions() {
|
|
197
|
-
const project = this.getSelectedProject();
|
|
198
|
-
const files = project?.files;
|
|
199
|
-
if (!files || 0 === files.length) return [];
|
|
200
|
-
return files.map((f)=>({
|
|
201
|
-
label: f.name,
|
|
202
|
-
value: f.id
|
|
203
|
-
}));
|
|
204
|
-
}
|
|
205
|
-
computeExcludedFileIds(projectId, includedFiles) {
|
|
206
|
-
if (!projectId) return null;
|
|
207
|
-
const project = this._settings?.projects?.presets?.find((p)=>p.id === projectId);
|
|
208
|
-
const allFileIds = (project?.files ?? []).map((f)=>f.id);
|
|
209
|
-
if (0 === allFileIds.length) return null;
|
|
210
|
-
const included = new Set(includedFiles ?? []);
|
|
211
|
-
const excluded = allFileIds.filter((id)=>!included.has(id));
|
|
212
|
-
return excluded.length > 0 ? excluded : null;
|
|
213
|
-
}
|
|
214
|
-
getProjectOptions() {
|
|
215
|
-
const presets = this._settings?.projects?.presets;
|
|
216
|
-
if (!presets || 0 === presets.length) return [];
|
|
217
|
-
return presets.map((preset)=>({
|
|
218
|
-
label: preset.name,
|
|
219
|
-
value: preset.id
|
|
220
|
-
}));
|
|
221
|
-
}
|
|
222
|
-
getPersonaOptions(type) {
|
|
223
|
-
const presets = "reader" === type ? this._settings?.readerPersonas?.presets : this._settings?.writerPersonas?.presets;
|
|
224
|
-
if (!presets || 0 === presets.length) return [];
|
|
225
|
-
return presets.map((preset)=>({
|
|
226
|
-
label: preset.name,
|
|
227
|
-
value: preset.id
|
|
228
|
-
}));
|
|
229
|
-
}
|
|
230
149
|
}
|
|
231
150
|
const GenerateContentPresenterRegistration = GenerateContentPresenter.createImplementation({
|
|
232
151
|
implementation: GenerateContentPresenterImpl,
|
|
@@ -234,8 +153,7 @@ const GenerateContentPresenterRegistration = GenerateContentPresenter.createImpl
|
|
|
234
153
|
ToolRegistry,
|
|
235
154
|
ToolPipelineRunner,
|
|
236
155
|
GeneratePageContentUseCase,
|
|
237
|
-
|
|
238
|
-
GetSettingsUseCase
|
|
156
|
+
AiPromptFormFactory
|
|
239
157
|
]
|
|
240
158
|
});
|
|
241
159
|
export { GenerateContentPresenterRegistration };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WbContentGeneration/GenerateContentPresenter.js","sources":["../../../../src/admin/presentation/WbContentGeneration/GenerateContentPresenter.ts"],"sourcesContent":["import { makeAutoObservable, computed, toJS, runInAction } from \"mobx\";\nimport { z } from \"zod\";\nimport pick from \"lodash/pick.js\";\nimport { FormModelFactory, FormModel, ToolRegistry, ToolPipelineRunner } from \"@webiny/app-admin\";\nimport { GenerateContentPresenter, type CreateElementsFn } from \"./abstractions.js\";\nimport { GeneratePageContentUseCase } from \"~/admin/features/generatePageContent/index.js\";\nimport { GetSettingsUseCase } from \"~/admin/features/settings/getSettings/abstractions.js\";\nimport type { IAiPowerUpsSettings } from \"~/admin/features/settings/shared/abstractions.js\";\n\nconst SUBMIT_TIMEOUT_MS = 300_000;\n\nclass GenerateContentPresenterImpl implements GenerateContentPresenter.Interface {\n private _loading = false;\n private _submitting = false;\n private _processing = false;\n private _timedOut = false;\n private _components: Record<string, any>[] = [];\n private _createElements: CreateElementsFn = () => {};\n private _form: FormModel.Interface | null = null;\n private _settings: IAiPowerUpsSettings | 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 toolRegistry: ToolRegistry.Interface,\n private pipelineRunner: ToolPipelineRunner.Interface,\n private generatePageContent: GeneratePageContentUseCase.Interface,\n private formModelFactory: FormModelFactory.Interface,\n private getSettings: GetSettingsUseCase.Interface\n ) {\n makeAutoObservable(this, { vm: computed }, { autoBind: true });\n }\n\n get vm(): GenerateContentPresenter.ViewModel {\n return {\n form: this._form ? this._form.vm : null,\n loading: this._loading,\n submitting: this._submitting,\n processing: this._processing,\n timedOut: this._timedOut,\n elapsedSeconds: this._elapsedSeconds\n };\n }\n\n async init(components: Record<string, any>[], createElements: CreateElementsFn): Promise<void> {\n this._components = components;\n this._createElements = createElements;\n\n this._loading = true;\n\n try {\n const settings = await this.getSettings.execute();\n runInAction(() => {\n this._settings = settings;\n this._form = this.buildForm();\n });\n } finally {\n runInAction(() => {\n this._loading = false;\n });\n }\n }\n\n async submit(): 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 }>();\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 tools = this.toolRegistry.getTools().map(tool => ({\n name: tool.name,\n description: tool.description,\n inputSchema: pick(z.toJSONSchema(tool.inputSchema), [\"properties\", \"type\"]),\n outputSchema: pick(z.toJSONSchema(tool.outputSchema), [\"properties\", \"type\"])\n }));\n\n const excludedFileIds = this.computeExcludedFileIds(data.project, data.includedFiles);\n\n await this.generatePageContent.execute({\n prompt: data.prompt,\n components: toJS(this._components),\n tools,\n projectId: data.project || null,\n excludedFileIds,\n readerPersonaId: data.readerPersona || null,\n writerPersonaId: data.writerPersona || null\n });\n } catch {\n this.clearTimeout();\n runInAction(() => {\n this._submitting = false;\n });\n }\n }\n\n async processAiResponse(responseText: string): Promise<void> {\n this.clearTimeout();\n runInAction(() => {\n this._processing = true;\n this._submitting = false;\n });\n\n try {\n const aiResponseJson = JSON.parse(responseText);\n const resolved = await this.pipelineRunner.resolve(aiResponseJson);\n const items = Array.isArray(resolved) ? resolved : [resolved];\n\n await this._createElements(\n items.map((element: { component: string; inputs: Record<string, unknown> }) => ({\n componentName: element.component,\n parentId: \"root\",\n slot: \"children\",\n bindings: { inputs: element.inputs }\n }))\n );\n } finally {\n runInAction(() => {\n this._processing = false;\n });\n }\n }\n\n cancelPrompt(): void {\n this.clearTimeout();\n this._processing = false;\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 private buildForm() {\n return this.formModelFactory.create({\n fields: fields => ({\n project: fields\n .text()\n .label(\"Project\")\n .description(\"Select a predefined context to attach.\")\n .options(() => this.getProjectOptions())\n .afterChange((value, form) => {\n const projectId = value as string | undefined;\n const project = projectId\n ? this._settings?.projects?.presets?.find(p => p.id === projectId)\n : undefined;\n\n if (project?.defaultReaderPersonaId) {\n form.field(\"readerPersona\").setValue(project.defaultReaderPersonaId);\n }\n if (project?.defaultWriterPersonaId) {\n form.field(\"writerPersona\").setValue(project.defaultWriterPersonaId);\n }\n\n const fileIds = (project?.files ?? []).map(f => f.id);\n form.field(\"includedFiles\").setValue(fileIds);\n }),\n includedFiles: fields\n .text()\n .label(\"Files included\")\n .description(\"Uncheck files to exclude them from this generation only.\")\n .options(() => this.getProjectFileOptions())\n .renderer(\"checkboxes\")\n .list()\n .hiddenWhen(form => {\n const projectId = form.field(\"project\").as(\"text\").getValue();\n if (!projectId) {\n return true;\n }\n const project = this._settings?.projects?.presets?.find(\n p => p.id === projectId\n );\n return !project?.files || project.files.length === 0;\n }),\n readerPersona: fields\n .text()\n .label(\"Reader Persona\")\n .description(\"Select the target audience for the generated content.\")\n .options(() => this.getPersonaOptions(\"reader\")),\n writerPersona: fields\n .text()\n .label(\"Writer Persona\")\n .description(\"Select the writing style for the generated content.\")\n .options(() => this.getPersonaOptions(\"writer\")),\n prompt: fields\n .text()\n .label(\"Prompt\")\n .description(\"Describe the page content you want to generate.\")\n .required(\"Prompt is required\")\n .renderer(\"textarea\", { rows: 6 })\n }),\n layout: layout => [\n layout.row(\"project\"),\n layout.row(\"includedFiles\"),\n layout.row(\"readerPersona\"),\n layout.row(\"writerPersona\"),\n layout.row(\"prompt\")\n ]\n });\n }\n\n private getSelectedProject() {\n if (!this._form || !this._settings) {\n return undefined;\n }\n const projectId = this._form.field(\"project\").getValue<string>();\n if (!projectId) {\n return undefined;\n }\n return this._settings.projects?.presets?.find(p => p.id === projectId);\n }\n\n private getProjectFileOptions() {\n const project = this.getSelectedProject();\n const files = project?.files;\n if (!files || files.length === 0) {\n return [];\n }\n return files.map(f => ({\n label: f.name,\n value: f.id\n }));\n }\n\n private computeExcludedFileIds(projectId?: string, includedFiles?: string[]): string[] | null {\n if (!projectId) {\n return null;\n }\n const project = this._settings?.projects?.presets?.find(p => p.id === projectId);\n const allFileIds = (project?.files ?? []).map(f => f.id);\n if (allFileIds.length === 0) {\n return null;\n }\n const included = new Set(includedFiles ?? []);\n const excluded = allFileIds.filter(id => !included.has(id));\n return excluded.length > 0 ? excluded : null;\n }\n\n private getProjectOptions() {\n const presets = this._settings?.projects?.presets;\n if (!presets || presets.length === 0) {\n return [];\n }\n return presets.map(preset => ({\n label: preset.name,\n value: preset.id\n }));\n }\n\n private getPersonaOptions(type: \"reader\" | \"writer\") {\n const presets =\n type === \"reader\"\n ? this._settings?.readerPersonas?.presets\n : this._settings?.writerPersonas?.presets;\n\n if (!presets || presets.length === 0) {\n return [];\n }\n\n return presets.map(preset => ({\n label: preset.name,\n value: preset.id\n }));\n }\n}\n\nexport const GenerateContentPresenterRegistration = GenerateContentPresenter.createImplementation({\n implementation: GenerateContentPresenterImpl,\n dependencies: [\n ToolRegistry,\n ToolPipelineRunner,\n GeneratePageContentUseCase,\n FormModelFactory,\n GetSettingsUseCase\n ]\n});\n"],"names":["SUBMIT_TIMEOUT_MS","GenerateContentPresenterImpl","toolRegistry","pipelineRunner","generatePageContent","formModelFactory","getSettings","makeAutoObservable","computed","components","createElements","settings","runInAction","data","tools","tool","pick","z","excludedFileIds","toJS","responseText","aiResponseJson","JSON","resolved","items","Array","element","setInterval","setTimeout","clearTimeout","clearInterval","fields","value","form","projectId","project","p","undefined","fileIds","f","layout","files","includedFiles","allFileIds","included","Set","excluded","id","presets","preset","type","GenerateContentPresenterRegistration","GenerateContentPresenter","ToolRegistry","ToolPipelineRunner","GeneratePageContentUseCase","FormModelFactory","GetSettingsUseCase"],"mappings":";;;;;;;AASA,MAAMA,oBAAoB;AAE1B,MAAMC;IAaF,YACYC,YAAoC,EACpCC,cAA4C,EAC5CC,mBAAyD,EACzDC,gBAA4C,EAC5CC,WAAyC,CACnD;aALUJ,YAAY,GAAZA;aACAC,cAAc,GAAdA;aACAC,mBAAmB,GAAnBA;aACAC,gBAAgB,GAAhBA;aACAC,WAAW,GAAXA;aAjBJ,QAAQ,GAAG;aACX,WAAW,GAAG;aACd,WAAW,GAAG;aACd,SAAS,GAAG;aACZ,WAAW,GAA0B,EAAE;aACvC,eAAe,GAAqB,KAAO;aAC3C,KAAK,GAA+B;aACpC,SAAS,GAA+B;aACxC,UAAU,GAAyC;aACnD,WAAW,GAA0C;aACrD,eAAe,GAAG;QAStBC,mBAAmB,IAAI,EAAE;YAAE,IAAIC;QAAS,GAAG;YAAE,UAAU;QAAK;IAChE;IAEA,IAAI,KAAyC;QACzC,OAAO;YACH,MAAM,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG;YACnC,SAAS,IAAI,CAAC,QAAQ;YACtB,YAAY,IAAI,CAAC,WAAW;YAC5B,YAAY,IAAI,CAAC,WAAW;YAC5B,UAAU,IAAI,CAAC,SA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GenerateContentPresenter.js","sources":["../../../../src/admin/presentation/WbContentGeneration/GenerateContentPresenter.ts"],"sourcesContent":["import { makeAutoObservable, computed, toJS, runInAction } from \"mobx\";\nimport { z } from \"zod\";\nimport pick from \"lodash/pick.js\";\nimport { ToolRegistry, ToolPipelineRunner } from \"@webiny/app-admin\";\nimport type { FormModel } from \"@webiny/app-admin\";\nimport type { FileValue } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { GenerateContentPresenter, type CreateElementsFn } from \"./abstractions.js\";\nimport { GeneratePageContentUseCase } from \"~/admin/features/generatePageContent/index.js\";\nimport { AiPromptFormFactory } from \"~/admin/presentation/AiPromptFormFactory/abstractions.js\";\n\nconst SUBMIT_TIMEOUT_MS = 300_000;\n\nclass GenerateContentPresenterImpl implements GenerateContentPresenter.Interface {\n private _loading = false;\n private _submitting = false;\n private _processing = false;\n private _timedOut = false;\n private _components: Record<string, any>[] = [];\n private _createElements: CreateElementsFn = () => {};\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 toolRegistry: ToolRegistry.Interface,\n private pipelineRunner: ToolPipelineRunner.Interface,\n private generatePageContent: GeneratePageContentUseCase.Interface,\n private formFactory: AiPromptFormFactory.Interface\n ) {\n makeAutoObservable(this, { vm: computed }, { autoBind: true });\n }\n\n get vm(): GenerateContentPresenter.ViewModel {\n return {\n form: this._form ? this._form.vm : null,\n loading: this._loading,\n submitting: this._submitting,\n processing: this._processing,\n timedOut: this._timedOut,\n elapsedSeconds: this._elapsedSeconds\n };\n }\n\n async init(components: Record<string, any>[], createElements: CreateElementsFn): Promise<void> {\n this._components = components;\n this._createElements = createElements;\n\n this._form = this.formFactory.createForm({\n promptDescription: \"Describe the page content you want to generate.\"\n });\n }\n\n async submit(): 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 tools = this.toolRegistry.getTools().map(tool => ({\n name: tool.name,\n description: tool.description,\n inputSchema: pick(z.toJSONSchema(tool.inputSchema), [\"properties\", \"type\"]),\n outputSchema: pick(z.toJSONSchema(tool.outputSchema), [\"properties\", \"type\"])\n }));\n\n const excludedFileIds = this.formFactory.computeExcludedFileIds(this._form);\n const additionalFileIds = data.additionalFiles?.map(f => f.id) ?? null;\n\n await this.generatePageContent.execute({\n prompt: data.prompt,\n components: toJS(this._components),\n tools,\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<void> {\n this.clearTimeout();\n runInAction(() => {\n this._processing = true;\n this._submitting = false;\n });\n\n try {\n const aiResponseJson = JSON.parse(responseText);\n const resolved = await this.pipelineRunner.resolve(aiResponseJson);\n const items = Array.isArray(resolved) ? resolved : [resolved];\n\n await this._createElements(\n items.map((element: { component: string; inputs: Record<string, unknown> }) => ({\n componentName: element.component,\n parentId: \"root\",\n slot: \"children\",\n bindings: { inputs: element.inputs }\n }))\n );\n } finally {\n runInAction(() => {\n this._processing = false;\n });\n }\n }\n\n cancelPrompt(): void {\n this.clearTimeout();\n this._processing = false;\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 GenerateContentPresenterRegistration = GenerateContentPresenter.createImplementation({\n implementation: GenerateContentPresenterImpl,\n dependencies: [\n ToolRegistry,\n ToolPipelineRunner,\n GeneratePageContentUseCase,\n AiPromptFormFactory\n ]\n});\n"],"names":["SUBMIT_TIMEOUT_MS","GenerateContentPresenterImpl","toolRegistry","pipelineRunner","generatePageContent","formFactory","makeAutoObservable","computed","components","createElements","data","runInAction","tools","tool","pick","z","excludedFileIds","additionalFileIds","f","toJS","responseText","aiResponseJson","JSON","resolved","items","Array","element","setInterval","setTimeout","clearTimeout","clearInterval","GenerateContentPresenterRegistration","GenerateContentPresenter","ToolRegistry","ToolPipelineRunner","GeneratePageContentUseCase","AiPromptFormFactory"],"mappings":";;;;;;;AAUA,MAAMA,oBAAoB;AAE1B,MAAMC;IAYF,YACYC,YAAoC,EACpCC,cAA4C,EAC5CC,mBAAyD,EACzDC,WAA0C,CACpD;aAJUH,YAAY,GAAZA;aACAC,cAAc,GAAdA;aACAC,mBAAmB,GAAnBA;aACAC,WAAW,GAAXA;aAfJ,QAAQ,GAAG;aACX,WAAW,GAAG;aACd,WAAW,GAAG;aACd,SAAS,GAAG;aACZ,WAAW,GAA0B,EAAE;aACvC,eAAe,GAAqB,KAAO;aAC3C,KAAK,GAA+B;aACpC,UAAU,GAAyC;aACnD,WAAW,GAA0C;aACrD,eAAe,GAAG;QAQtBC,mBAAmB,IAAI,EAAE;YAAE,IAAIC;QAAS,GAAG;YAAE,UAAU;QAAK;IAChE;IAEA,IAAI,KAAyC;QACzC,OAAO;YACH,MAAM,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG;YACnC,SAAS,IAAI,CAAC,QAAQ;YACtB,YAAY,IAAI,CAAC,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AAI,CAAC,UAAU;YAC5B,IAAI,CAAC,UAAU,GAAG;QACtB;QACA,IAAI,CAAC,aAAa;IACtB;IAEQ,gBAAsB;QAC1B,IAAI,AAAqB,SAArB,IAAI,CAAC,WAAW,EAAW;YAC3BC,cAAc,IAAI,CAAC,WAAW;YAC9B,IAAI,CAAC,WAAW,GAAG;QACvB;IACJ;AACJ;AAEO,MAAMC,uCAAuCC,yBAAyB,oBAAoB,CAAC;IAC9F,gBAAgB/B;IAChB,cAAc;QACVgC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AI_MODEL_ROLE_IDS } from "../../admin/domain/modelRoles.js";
|
|
2
|
+
import type { AiModelRoleId } from "../../admin/domain/modelRoles.js";
|
|
3
|
+
export { AI_MODEL_ROLE_IDS };
|
|
4
|
+
export type { AiModelRoleId };
|
|
5
|
+
export declare const AI_MODEL_ROLE_DISPLAY: {
|
|
6
|
+
label: string;
|
|
7
|
+
description: string;
|
|
8
|
+
id: "fast" | "standard" | "vision";
|
|
9
|
+
}[];
|
|
10
|
+
export declare const roleLabel: (id: string) => string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AI_MODEL_ROLE_IDS } from "../domain/modelRoles.js";
|
|
2
|
+
const ROLE_TEXT = {
|
|
3
|
+
fast: {
|
|
4
|
+
label: "Fast",
|
|
5
|
+
description: "Cheap, low-latency work where a smaller model is good enough: summarising, classifying, comparing."
|
|
6
|
+
},
|
|
7
|
+
standard: {
|
|
8
|
+
label: "Standard",
|
|
9
|
+
description: "The workhorse. Anything that writes content a person will read, or has to follow a schema and call tools. Every other role falls back to this one when left empty."
|
|
10
|
+
},
|
|
11
|
+
vision: {
|
|
12
|
+
label: "Vision",
|
|
13
|
+
description: "Work that reads images. Pick a model that accepts image input. Left empty, image features fall back to Standard and only work there if Standard is multimodal too."
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const AI_MODEL_ROLE_DISPLAY = AI_MODEL_ROLE_IDS.map((id)=>({
|
|
17
|
+
id,
|
|
18
|
+
...ROLE_TEXT[id]
|
|
19
|
+
}));
|
|
20
|
+
const roleLabel = (id)=>id in ROLE_TEXT ? ROLE_TEXT[id].label : id;
|
|
21
|
+
export { AI_MODEL_ROLE_DISPLAY, AI_MODEL_ROLE_IDS, roleLabel };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=modelRoles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/presentation/modelRoles.js","sources":["../../../src/admin/presentation/modelRoles.ts"],"sourcesContent":["import { AI_MODEL_ROLE_IDS } from \"~/admin/domain/modelRoles.js\";\nimport type { AiModelRoleId } from \"~/admin/domain/modelRoles.js\";\n\n/**\n * The model roles, as the settings screen presents them. The ids live in\n * `~/admin/domain/modelRoles.js`; this owns the words.\n *\n * Typed as a full record, so adding a role id without a label is a compile error.\n */\nconst ROLE_TEXT: Record<AiModelRoleId, { label: string; description: string }> = {\n fast: {\n label: \"Fast\",\n description:\n \"Cheap, low-latency work where a smaller model is good enough: summarising, classifying, comparing.\"\n },\n standard: {\n label: \"Standard\",\n description:\n \"The workhorse. Anything that writes content a person will read, or has to follow a schema and call tools. Every other role falls back to this one when left empty.\"\n },\n vision: {\n label: \"Vision\",\n description:\n \"Work that reads images. Pick a model that accepts image input. Left empty, image features fall back to Standard and only work there if Standard is multimodal too.\"\n }\n};\n\nexport { AI_MODEL_ROLE_IDS };\nexport type { AiModelRoleId };\n\nexport const AI_MODEL_ROLE_DISPLAY = AI_MODEL_ROLE_IDS.map(id => ({ id, ...ROLE_TEXT[id] }));\n\nexport const roleLabel = (id: string): string =>\n id in ROLE_TEXT ? ROLE_TEXT[id as AiModelRoleId].label : id;\n"],"names":["ROLE_TEXT","AI_MODEL_ROLE_DISPLAY","AI_MODEL_ROLE_IDS","id","roleLabel"],"mappings":";AASA,MAAMA,YAA2E;IAC7E,MAAM;QACF,OAAO;QACP,aACI;IACR;IACA,UAAU;QACN,OAAO;QACP,aACI;IACR;IACA,QAAQ;QACJ,OAAO;QACP,aACI;IACR;AACJ;AAKO,MAAMC,wBAAwBC,kBAAkB,GAAG,CAACC,CAAAA,KAAO;QAAEA;QAAI,GAAGH,SAAS,CAACG,GAAG;IAAC;AAElF,MAAMC,YAAY,CAACD,KACtBA,MAAMH,YAAYA,SAAS,CAACG,GAAoB,CAAC,KAAK,GAAGA"}
|
package/api/Extension.js
CHANGED
|
@@ -7,12 +7,20 @@ import { GetSettingsFeature } from "./features/GetSettings/feature.js";
|
|
|
7
7
|
import { UpdateSettingsFeature } from "./features/UpdateSettings/feature.js";
|
|
8
8
|
import { WbGeneratePageContentFeature } from "./features/WbGeneratePageContent/feature.js";
|
|
9
9
|
import { ProvidersFeature } from "./features/Providers/feature.js";
|
|
10
|
+
import { ConnectionsFeature } from "./features/Connections/feature.js";
|
|
11
|
+
import { ModelRolesFeature } from "./features/ModelRoles/feature.js";
|
|
12
|
+
import { CapabilitiesFeature } from "./features/Capabilities/feature.js";
|
|
10
13
|
import { ReaderPersonasFeature } from "./features/ReaderPersonas/feature.js";
|
|
11
14
|
import { WriterPersonasFeature } from "./features/WriterPersonas/feature.js";
|
|
12
15
|
import { ProjectsFeature } from "./features/Projects/feature.js";
|
|
13
16
|
import { AiPromptContextFeature } from "./features/AiPromptContext/feature.js";
|
|
14
17
|
import { AiImageEnrichmentFeature } from "./features/AiImageEnrichment/feature.js";
|
|
15
18
|
import { ExtractFrontmatterFeature } from "./features/ExtractFrontmatter/feature.js";
|
|
19
|
+
import { CmsGenerateEntryContentFeature } from "./features/CmsGenerateEntryContent/feature.js";
|
|
20
|
+
import { CmsResolveImageToolFeature } from "./features/CmsResolveImageTool/feature.js";
|
|
21
|
+
import { CmsCompareEntryRevisionsFeature } from "./features/CmsCompareEntryRevisions/feature.js";
|
|
22
|
+
import { WbTranslatePageFeature } from "./features/WbTranslatePage/feature.js";
|
|
23
|
+
import { CmsCompareEntryRevisionsSchema } from "./graphql/CmsCompareEntryRevisionsSchema.js";
|
|
16
24
|
const Extension = createFeature({
|
|
17
25
|
name: "AiPowerUps",
|
|
18
26
|
register (container) {
|
|
@@ -20,16 +28,24 @@ const Extension = createFeature({
|
|
|
20
28
|
GetSettingsFeature.register(container);
|
|
21
29
|
UpdateSettingsFeature.register(container);
|
|
22
30
|
ProvidersFeature.register(container);
|
|
31
|
+
ConnectionsFeature.register(container);
|
|
32
|
+
ModelRolesFeature.register(container);
|
|
33
|
+
CapabilitiesFeature.register(container);
|
|
23
34
|
ReaderPersonasFeature.register(container);
|
|
24
35
|
WriterPersonasFeature.register(container);
|
|
25
36
|
ProjectsFeature.register(container);
|
|
26
37
|
AiPromptContextFeature.register(container);
|
|
27
38
|
WbGeneratePageContentFeature.register(container);
|
|
39
|
+
CmsGenerateEntryContentFeature.register(container);
|
|
40
|
+
CmsResolveImageToolFeature.register(container);
|
|
28
41
|
ExtractFrontmatterFeature.register(container);
|
|
29
42
|
const wcp = container.resolve(WcpContext);
|
|
30
43
|
if (wcp.canUseAiImageEnrichment()) AiImageEnrichmentFeature.register(container);
|
|
44
|
+
CmsCompareEntryRevisionsFeature.register(container);
|
|
45
|
+
WbTranslatePageFeature.register(container);
|
|
31
46
|
container.register(AiPowerUpsSettingsGraphQLMapper).inSingletonScope();
|
|
32
47
|
container.register(BaseGraphQLSchema);
|
|
48
|
+
container.register(CmsCompareEntryRevisionsSchema);
|
|
33
49
|
}
|
|
34
50
|
});
|
|
35
51
|
export { Extension };
|