diff --git a/config/field.field.node.action_points.field_ai_brain.yml b/config/field.field.node.action_points.field_ai_brain.yml index 22e0fbc..15e25d7 100644 --- a/config/field.field.node.action_points.field_ai_brain.yml +++ b/config/field.field.node.action_points.field_ai_brain.yml @@ -17,7 +17,7 @@ required: false translatable: false default_value: - - value: azure_trained + value: amazon_titan_premier default_value_callback: '' settings: { } field_type: list_string diff --git a/config/field.field.node.summary.field_ai_brain.yml b/config/field.field.node.summary.field_ai_brain.yml index 15fe75e..9ec457d 100644 --- a/config/field.field.node.summary.field_ai_brain.yml +++ b/config/field.field.node.summary.field_ai_brain.yml @@ -17,7 +17,7 @@ required: false translatable: false default_value: - - value: azure_trained + value: amazon_titan_premier default_value_callback: '' settings: { } field_type: list_string diff --git a/config/field.storage.node.field_ai_brain.yml b/config/field.storage.node.field_ai_brain.yml index 97065bc..4cad6e2 100644 --- a/config/field.storage.node.field_ai_brain.yml +++ b/config/field.storage.node.field_ai_brain.yml @@ -16,13 +16,16 @@ settings: label: 'Open AI (chat-gpt-3.5)' - value: azure_trained - label: 'Trained Azure AI' + label: 'Azure OpenAI 3.5' - value: bedrock label: 'BedRock (Titan)' - value: claude label: Claude + - + value: amazon_titan_premier + label: 'Amazon Titan Text Premier' allowed_values_function: '' module: options locked: false diff --git a/config/monitoring.sensor_config.core_cron_last_run_age.yml b/config/monitoring.sensor_config.core_cron_last_run_age.yml index f648278..f1b0730 100644 --- a/config/monitoring.sensor_config.core_cron_last_run_age.yml +++ b/config/monitoring.sensor_config.core_cron_last_run_age.yml @@ -1,9 +1,7 @@ -uuid: 2eb4fe7f-035b-42b4-9ddf-86030f5c107f +uuid: null langcode: en status: true dependencies: { } -_core: - default_config_hash: 9xaHOMw0Ra9sOuNKGoBqCLFoX2pj_66FbTQPK1CFK1U id: core_cron_last_run_age label: 'Last cron run age' description: 'Time since last cron run' diff --git a/config/monitoring.sensor_config.monitoring_installed_modules.yml b/config/monitoring.sensor_config.monitoring_installed_modules.yml index 6eb267e..01d258a 100644 --- a/config/monitoring.sensor_config.monitoring_installed_modules.yml +++ b/config/monitoring.sensor_config.monitoring_installed_modules.yml @@ -1,9 +1,7 @@ -uuid: aeaaa913-b6f9-4412-b1da-586b728af2fc +uuid: null langcode: en status: true dependencies: { } -_core: - default_config_hash: HaL0P0uZ-Ej7bGqTmmN6ZhrX1cK-IJEWfQv8xDom61A id: monitoring_installed_modules label: 'Installed modules' description: 'Installed only expected modules' @@ -15,89 +13,6 @@ value_type: number caching_time: 3600 settings: allow_additional: false - modules: - admin_denied: admin_denied - allowed_formats: allowed_formats - block: block - breakpoint: breakpoint - ckeditor5: ckeditor5 - comment: comment - components: components - config: config - config_filter: config_filter - config_split: config_split - config_translation: config_translation - content_moderation: content_moderation - csp: csp - ctools: ctools - datetime: datetime - datetime_range: datetime_range - dblog: dblog - devel: devel - dynamic_page_cache: dynamic_page_cache - editor: editor - entity_reference_revisions: entity_reference_revisions - environment_indicator: environment_indicator - environment_indicator_ui: environment_indicator_ui - field: field - field_ui: field_ui - file: file - file_mdm: file_mdm - filter: filter - image: image - imageapi_optimize: imageapi_optimize - imageapi_optimize_binaries: imageapi_optimize_binaries - imagemagick: imagemagick - inline_form_errors: inline_form_errors - language: language - layout_discovery: layout_discovery - layout_paragraphs: layout_paragraphs - link: link - locale: locale - maintenance200: maintenance200 - media: media - media_library: media_library - memcache: memcache - memcache_admin: memcache_admin - menu_link_content: menu_link_content - menu_ui: menu_ui - monitoring: monitoring - mysql: mysql - node: node - node_view_permissions: node_view_permissions - ocha_ai_summarize: ocha_ai_summarize - ocha_monitoring: ocha_monitoring - options: options - page_cache: page_cache - path: path - path_alias: path_alias - private_content: private_content - queue_ui: queue_ui - redirect: redirect - responsive_image: responsive_image - social_api: social_api - social_auth: social_auth - social_auth_hid: social_auth_hid - sophron: sophron - syslog: syslog - system: system - taxonomy: taxonomy - text: text - token: token - toolbar: toolbar - update: update - user: user - user_display_name: user_display_name - user_expire: user_expire - username_enumeration_prevention: username_enumeration_prevention - views_ui: views_ui - workflows: workflows - xmlsitemap_engines: xmlsitemap_engines - pathauto: pathauto - xmlsitemap: xmlsitemap - content_translation: content_translation - views: views - paragraphs: paragraphs - minimal: minimal + modules: { } thresholds: type: none diff --git a/config/monitoring.sensor_config.ocha_admin_paths.yml b/config/monitoring.sensor_config.ocha_admin_paths.yml new file mode 100644 index 0000000..f69e901 --- /dev/null +++ b/config/monitoring.sensor_config.ocha_admin_paths.yml @@ -0,0 +1,18 @@ +uuid: null +langcode: en +status: true +dependencies: + module: + - ocha_monitoring +id: ocha_admin_paths +label: 'UN admin paths' +description: 'UN admin paths' +category: OCHA +plugin_id: ocha_admin_paths +result_class: null +value_label: Version +value_type: string +caching_time: 86400 +settings: { } +thresholds: + type: none diff --git a/config/monitoring.sensor_config.ocha_common_design.yml b/config/monitoring.sensor_config.ocha_common_design.yml index 9495bd6..2b9ce4a 100644 --- a/config/monitoring.sensor_config.ocha_common_design.yml +++ b/config/monitoring.sensor_config.ocha_common_design.yml @@ -1,4 +1,4 @@ -uuid: af6d384e-d4e8-4b80-a516-cdb4a3fa95eb +uuid: null langcode: en status: true dependencies: diff --git a/config/monitoring.sensor_config.ocha_current_composer_version.yml b/config/monitoring.sensor_config.ocha_current_composer_version.yml index 7e5876e..f776f88 100644 --- a/config/monitoring.sensor_config.ocha_current_composer_version.yml +++ b/config/monitoring.sensor_config.ocha_current_composer_version.yml @@ -1,4 +1,4 @@ -uuid: 070d4341-af5c-4263-8624-b1b735443810 +uuid: null langcode: en status: true dependencies: diff --git a/config/monitoring.sensor_config.ocha_current_drupal_version.yml b/config/monitoring.sensor_config.ocha_current_drupal_version.yml index 20de999..8752fe8 100644 --- a/config/monitoring.sensor_config.ocha_current_drupal_version.yml +++ b/config/monitoring.sensor_config.ocha_current_drupal_version.yml @@ -1,4 +1,4 @@ -uuid: 9757d8fb-4b8b-4e4e-8870-76f918c5155f +uuid: null langcode: en status: true dependencies: diff --git a/config/monitoring.sensor_config.ocha_current_php_version.yml b/config/monitoring.sensor_config.ocha_current_php_version.yml index 5dfc688..562d7a1 100644 --- a/config/monitoring.sensor_config.ocha_current_php_version.yml +++ b/config/monitoring.sensor_config.ocha_current_php_version.yml @@ -1,4 +1,4 @@ -uuid: 4bedc27b-9886-4fd8-aa7a-5ae0d337c59d +uuid: null langcode: en status: true dependencies: diff --git a/config/monitoring.sensor_config.ocha_current_release.yml b/config/monitoring.sensor_config.ocha_current_release.yml index a0556c4..9718893 100644 --- a/config/monitoring.sensor_config.ocha_current_release.yml +++ b/config/monitoring.sensor_config.ocha_current_release.yml @@ -1,4 +1,4 @@ -uuid: 3e0c8eab-7b26-46cf-ae6a-0142fd29fd8e +uuid: null langcode: en status: true dependencies: diff --git a/config/monitoring.sensor_config.ocha_deployment_identifier.yml b/config/monitoring.sensor_config.ocha_deployment_identifier.yml index 763de1a..177806b 100644 --- a/config/monitoring.sensor_config.ocha_deployment_identifier.yml +++ b/config/monitoring.sensor_config.ocha_deployment_identifier.yml @@ -1,4 +1,4 @@ -uuid: fefbe8a3-ad5d-4b6b-8ccf-18a3c32be418 +uuid: null langcode: en status: true dependencies: diff --git a/config/monitoring.sensor_config.ocha_env_link_fixer.yml b/config/monitoring.sensor_config.ocha_env_link_fixer.yml index 36bad9f..7061706 100644 --- a/config/monitoring.sensor_config.ocha_env_link_fixer.yml +++ b/config/monitoring.sensor_config.ocha_env_link_fixer.yml @@ -1,4 +1,4 @@ -uuid: b7c1d38c-bf25-45c4-a5d7-664e89a2385b +uuid: null langcode: en status: true dependencies: diff --git a/config/monitoring.sensor_config.ocha_google_tag.yml b/config/monitoring.sensor_config.ocha_google_tag.yml index 13f1d73..d7e1968 100644 --- a/config/monitoring.sensor_config.ocha_google_tag.yml +++ b/config/monitoring.sensor_config.ocha_google_tag.yml @@ -1,6 +1,6 @@ uuid: 4fb9d053-5d3b-4b4d-a27e-2639ddd828ba langcode: en -status: true +status: false dependencies: module: - ocha_monitoring diff --git a/config/monitoring.sensor_config.ocha_gtm_barebones.yml b/config/monitoring.sensor_config.ocha_gtm_barebones.yml index 60dde6c..8cc266f 100644 --- a/config/monitoring.sensor_config.ocha_gtm_barebones.yml +++ b/config/monitoring.sensor_config.ocha_gtm_barebones.yml @@ -1,4 +1,4 @@ -uuid: 6ce278b7-c2da-4db7-9c7a-5e65a6ad8229 +uuid: null langcode: en status: true dependencies: diff --git a/config/monitoring.sensor_config.ocha_ocha_monitoring.yml b/config/monitoring.sensor_config.ocha_ocha_monitoring.yml index 3fcb8e1..072e559 100644 --- a/config/monitoring.sensor_config.ocha_ocha_monitoring.yml +++ b/config/monitoring.sensor_config.ocha_ocha_monitoring.yml @@ -1,4 +1,4 @@ -uuid: 90959c64-378f-4921-b4e5-504fbbc5cb90 +uuid: null langcode: en status: true dependencies: diff --git a/config/monitoring.sensor_config.ocha_un_date.yml b/config/monitoring.sensor_config.ocha_un_date.yml index 59b35a5..cde3f1d 100644 --- a/config/monitoring.sensor_config.ocha_un_date.yml +++ b/config/monitoring.sensor_config.ocha_un_date.yml @@ -1,4 +1,4 @@ -uuid: ba8b97cd-eb0a-4973-ac28-3337d00ea006 +uuid: null langcode: en status: true dependencies: diff --git a/config/monitoring.sensor_config.update_contrib.yml b/config/monitoring.sensor_config.update_contrib.yml index 4c59ef9..f404002 100644 --- a/config/monitoring.sensor_config.update_contrib.yml +++ b/config/monitoring.sensor_config.update_contrib.yml @@ -1,11 +1,9 @@ -uuid: e58eb6c7-f66f-406e-b092-a191c7fc48f7 +uuid: null langcode: en status: true dependencies: module: - update -_core: - default_config_hash: '-re8-AFGO4z0a0i4NeTZV5HlEipd-KC9kkLxzgz1mgs' id: update_contrib label: 'Modules and themes' description: 'Available updates for contrib modules and themes' diff --git a/config/monitoring.sensor_config.update_core.yml b/config/monitoring.sensor_config.update_core.yml index 23460e0..9469a7c 100644 --- a/config/monitoring.sensor_config.update_core.yml +++ b/config/monitoring.sensor_config.update_core.yml @@ -1,11 +1,9 @@ -uuid: aa1a958a-1cc0-4f29-a0a8-3b79d682464e +uuid: null langcode: en status: true dependencies: module: - update -_core: - default_config_hash: FSvo5_4kGyvNZu9RVgfFKnGfbGkIS8EgI46ckVkT6CM id: update_core label: Core description: 'Available updates for Drupal core' diff --git a/html/modules/custom/ocha_ai_summarize/ocha_ai_summarize.module b/html/modules/custom/ocha_ai_summarize/ocha_ai_summarize.module index 6c8783c..e475133 100644 --- a/html/modules/custom/ocha_ai_summarize/ocha_ai_summarize.module +++ b/html/modules/custom/ocha_ai_summarize/ocha_ai_summarize.module @@ -1253,6 +1253,48 @@ function ocha_ai_summarize_http_call_bedrock($prompt) { } } +/** + * Make chat call to Titan Premier. + */ +function ocha_ai_summarize_http_call_titan_premier($prompt) { + $model = 'amazon.titan-text-premier-v1:0'; + $client_options = ocha_ai_summarize_get_aws_client_options(); + + $bedRock = new BedrockRuntimeClient($client_options); + + $payload = [ + 'accept' => 'application/json', + 'body' => json_encode([ + 'inputText' => $prompt, + 'textGenerationConfig' => [ + 'maxTokenCount' => 3000, + 'stopSequences' => [], + 'temperature' => 0.0, + 'topP' => 0.9, + ], + ]), + 'contentType' => 'application/json', + 'modelId' => $model, + ]; + + try { + /** @var \Aws\Result $response */ + $response = $bedRock->invokeModel($payload); + } + catch (\Exception $exception) { + \Drupal::logger('AI - Titan premier')->error($exception->getMessage()); + return ''; + } + + try { + return json_decode($response->get('body')->getContents(), TRUE); + } + catch (\Exception $exception) { + \Drupal::logger('AI - Titan premier')->error($exception->getMessage()); + return ''; + } +} + /** * Make chat call to Claude. */ @@ -1344,6 +1386,11 @@ function ocha_ai_summarize_check_length($text, $bot) { case 'bedrock': $max_tokens = 2 * 42000; break; + + case 'amazon_titan_premier': + $max_tokens = 2 * 3072; + break; + } $max_tokens = round($max_tokens, 0); @@ -1544,13 +1591,37 @@ function ocha_ai_summarize_notify_user(NodeInterface $node) { $ai_models = $node->get('field_ai_brain')->getSettings()['allowed_values']; $ai_model = $ai_models[$node->get('field_ai_brain')->value]; + $sub_title = $node->type->entity->label(); + + $field_name = ''; + $ai_text = ''; + + switch ($node->bundle()) { + case 'summary': + $field_name = 'field_summary'; + $ai_text = $node->get($field_name)->value; + break; - $params['subject'] = t('AI Summarize: your document has been processed.'); - $params['message'] = implode("\r\n\r\n", [ + case 'action_points': + $field_name = 'field_action_points'; + $ai_text = $node->get($field_name)->value; + break; + + } + + $params['subject'] = t('AI Summarize: @title - has been processed.', [ + '@title' => $node->getTitle(), + ]); + $params['message'] = implode("\r\n", [ t('Your document has been processed by @model.', ['@model' => $ai_model]), - t('You can see the result on @link', [ + '', + t('You can always see your results and provide feedback online here: @link', [ '@link' => $node->toUrl()->setAbsolute()->toString(), ]), + '', + $sub_title, + '', + $ai_text, ]); $mail_manager->mail($module, $key, $to, $langcode, $params); @@ -1573,22 +1644,22 @@ function ocha_ai_summarize_log_time(string $action, int $nid, int $ms) : void { /** * Track execution times of text extraction. */ -function ocha_ai_summarize_log_time_extract(int $nid, int $ms) : void { - ocha_ai_summarize_log_time('extract_text', $nid, $ms); +function ocha_ai_summarize_log_time_extract(int $nid, float $ms) : void { + ocha_ai_summarize_log_time('extract_text', $nid, round($ms)); } /** * Track execution times of summarize. */ -function ocha_ai_summarize_log_time_summarize(int $nid, int $ms) : void { - ocha_ai_summarize_log_time('summarize', $nid, $ms); +function ocha_ai_summarize_log_time_summarize(int $nid, float $ms) : void { + ocha_ai_summarize_log_time('summarize', $nid, round($ms)); } /** * Track execution times of action points. */ -function ocha_ai_summarize_log_time_action_points(int $nid, int $ms) : void { - ocha_ai_summarize_log_time('action_point', $nid, $ms); +function ocha_ai_summarize_log_time_action_points(int $nid, float $ms) : void { + ocha_ai_summarize_log_time('action_point', $nid, round($ms)); } /** diff --git a/html/modules/custom/ocha_ai_summarize/src/Plugin/QueueWorker/OchaAiSummarizeActionPoints.php b/html/modules/custom/ocha_ai_summarize/src/Plugin/QueueWorker/OchaAiSummarizeActionPoints.php index 1e31d22..0643d06 100644 --- a/html/modules/custom/ocha_ai_summarize/src/Plugin/QueueWorker/OchaAiSummarizeActionPoints.php +++ b/html/modules/custom/ocha_ai_summarize/src/Plugin/QueueWorker/OchaAiSummarizeActionPoints.php @@ -164,6 +164,10 @@ public function processItem($data) { $results[] = $this->sendToBedRock($prompt . $text); break; + case 'amazon_titan_premier': + $results[] = $this->sendToTitanPremier($prompt . $text); + break; + } } ocha_ai_summarize_log_time_summarize($nid, Timer::read('summarize')); @@ -191,6 +195,11 @@ public function processItem($data) { case 'bedrock': $action_points = $this->sendToBedRock("$prompt:\n\n" . $text); break; + + case 'amazon_titan_premier': + $action_points = $this->sendToTitanPremier($prompt . $text); + break; + } ocha_ai_summarize_log_time_action_points($nid, Timer::read('action_points')); Timer::stop('action_points'); @@ -255,6 +264,15 @@ protected function sendToBedRock($text) : string { return $result['results'][0]['outputText'] ?? ''; } + /** + * Send query to Titan Premier. + */ + protected function sendToTitanPremier($text) : string { + $result = ocha_ai_summarize_http_call_titan_premier($text); + print_r($result); + return $result['results'][0]['outputText'] ?? ''; + } + /** * Send query to Claude AI. */ diff --git a/html/modules/custom/ocha_ai_summarize/src/Plugin/QueueWorker/OchaAiSummarizeSummarize.php b/html/modules/custom/ocha_ai_summarize/src/Plugin/QueueWorker/OchaAiSummarizeSummarize.php index fcfa253..056380f 100644 --- a/html/modules/custom/ocha_ai_summarize/src/Plugin/QueueWorker/OchaAiSummarizeSummarize.php +++ b/html/modules/custom/ocha_ai_summarize/src/Plugin/QueueWorker/OchaAiSummarizeSummarize.php @@ -166,6 +166,10 @@ public function processItem($data) { $results[] = $this->sendToBedRock($prompt . $text); break; + case 'amazon_titan_premier': + $results[] = $this->sendToTitanPremier($prompt . $text); + break; + } } @@ -190,6 +194,11 @@ public function processItem($data) { case 'bedrock': $summary = $this->sendToBedRock($prompt . $text); break; + + case 'amazon_titan_premier': + $summary = $this->sendToTitanPremier($prompt . $text); + break; + } ocha_ai_summarize_log_time_summarize($nid, Timer::read('summarize')); Timer::stop('summarize'); @@ -251,6 +260,15 @@ protected function sendToBedRock($text) : string { return $result['results'][0]['outputText'] ?? ''; } + /** + * Send query to Titan Premier. + */ + protected function sendToTitanPremier($text) : string { + $result = ocha_ai_summarize_http_call_titan_premier($text); + print_r($result); + return $result['results'][0]['outputText'] ?? ''; + } + /** * Send query to Claude AI. */