Skip to content
Snippets Groups Projects
Commit 02ab4183 authored by Naveen Valecha's avatar Naveen Valecha
Browse files

Issue #3458696 by naveenvalecha: Drupal 11 compatibility of augmentor_nlpcloud

parent 339e701e
Branches 1.0.x
Tags 1.0.1
1 merge request!7Issue #3458696 by naveenvalecha: Drupal 11 compatibility of augmentor_nlpcloud.
Pipeline #214583 passed with warnings
################
# DrupalCI GitLabCI template
#
# Gitlab-ci.yml to replicate DrupalCI testing for Contrib
#
# With thanks to:
# * The GitLab Acceleration Initiative participants
# * DrupalSpoons
################
################
# Guidelines
#
# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification. It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained.
#
# However, you can modify this template if you have additional needs for your project.
################
################
# Includes
#
# Additional configuration can be provided through includes.
# One advantage of include files is that if they are updated upstream, the changes affect all pipelines using that include.
# One advantage of include files is that if they are updated upstream, the changes affect all pipelines using that include.
#
# Includes can be overridden by re-declaring anything provided in an include, here in gitlab-ci.yml
# https://docs.gitlab.com/ee/ci/yaml/includes.html#override-included-configuration-values
################
include:
include:
################
# DrupalCI includes:
# DrupalCI includes:
# As long as you include this, any future includes added by the Drupal Association will be accessible to your pipelines automatically.
# View these include files at https://git.drupalcode.org/project/gitlab_templates/
################
......@@ -46,52 +28,11 @@ include:
#
# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml
################
# variables:
# SKIP_ESLINT: '1'
###################################################################################
#
# *
# /(
# ((((,
# /(((((((
# ((((((((((*
# ,(((((((((((((((
# ,(((((((((((((((((((
# ((((((((((((((((((((((((*
# *(((((((((((((((((((((((((((((
# ((((((((((((((((((((((((((((((((((*
# *(((((((((((((((((( .((((((((((((((((((
# ((((((((((((((((((. /(((((((((((((((((*
# /((((((((((((((((( .(((((((((((((((((,
# ,(((((((((((((((((( ((((((((((((((((((
# .(((((((((((((((((((( .(((((((((((((((((
# ((((((((((((((((((((((( ((((((((((((((((/
# (((((((((((((((((((((((((((/ ,(((((((((((((((*
# .((((((((((((((/ /(((((((((((((. ,(((((((((((((((
# *(((((((((((((( ,(((((((((((((/ *((((((((((((((.
# ((((((((((((((, /(((((((((((((. ((((((((((((((,
# (((((((((((((/ ,(((((((((((((* ,(((((((((((((,
# *((((((((((((( .((((((((((((((( ,(((((((((((((
# ((((((((((((/ /((((((((((((((((((. ,((((((((((((/
# ((((((((((((( *(((((((((((((((((((((((* *((((((((((((
# ((((((((((((( ,(((((((((((((..((((((((((((( *((((((((((((
# ((((((((((((, /((((((((((((* /((((((((((((/ ((((((((((((
# ((((((((((((( /((((((((((((/ (((((((((((((* ((((((((((((
# (((((((((((((/ /(((((((((((( ,((((((((((((, *((((((((((((
# (((((((((((((( *(((((((((((/ *((((((((((((. ((((((((((((/
# *((((((((((((((((((((((((((, /(((((((((((((((((((((((((
# ((((((((((((((((((((((((( ((((((((((((((((((((((((,
# .(((((((((((((((((((((((/ ,(((((((((((((((((((((((
# ((((((((((((((((((((((/ ,(((((((((((((((((((((/
# *((((((((((((((((((((( (((((((((((((((((((((,
# ,(((((((((((((((((((((, ((((((((((((((((((((/
# ,(((((((((((((((((((((* /((((((((((((((((((((
# ((((((((((((((((((((((, ,/((((((((((((((((((((,
# ,(((((((((((((((((((((((((((((((((((((((((((((((((((
# .(((((((((((((((((((((((((((((((((((((((((((((
# .((((((((((((((((((((((((((((((((((((,.
# .,(((((((((((((((((((((((((.
#
###################################################################################
variables:
_CSPELL_WORDS: 'Acehnese, Adeni, Armn, Asturian, augmentors, Awadhi, Banjar, Bhojpuri, Bokmål, Buginese, chatdolphin, Chhattisgarhi, Chokwe, Dari, Davison, Dyula, Dzongkha, Ethi, Faroese, Finetuned, finetuned, Fulfulde, Geor, Grek, Gujr, Halh, Hebr, Jingpho, Jpan, Kabiyè, Kabuverdianu, Kamba, Kanuri, Keyphrases, keyphrases, Khmr, Kikongo, Kimbundu, Kinyarwanda, Knda, Laoo, Latgalian, Limburgish, Lingala, Luba, Luxembourgish, Magahi, Maithili, Meitei, Michau, Minangkabau, Mizo, Mlym, MNLI, mnli, Morpht, morpht, Mossi, Mymr, Najdi, neox, NLLB, nllb, Nuer, Nyanja, Occitan, Odia, Olck, Orya, Pangasinan, Pisin, Rundi, Sango, Santali, Shona, Sinhala, Sotho, Swati, Tamasheq, Tamazight, Taml, Ta’izzi, Telu, Tfng, Tibt, Tifinagh, Tosk, Tsonga, Tumbuka, Umbundu, Uyghur, Waray, XNLI, xnli'
RUN_JOB_UPGRADE_STATUS: '1'
# Broaden test coverage.
OPT_IN_TEST_PREVIOUS_MINOR: 1
OPT_IN_TEST_NEXT_MINOR: 1
OPT_IN_TEST_MAX_PHP: 1
OPT_IN_TEST_NEXT_MAJOR: 1
......@@ -19,16 +19,16 @@ to interface with NLP Cloud's REST API.
ABOUT NLP CLOUD
---------------
NLP Cloud serves high performance pre-trained or custom models for NER,
sentiment-analysis, classification, summarization, dialogue summarization,
paraphrasing, intent classification, product description and ad generation,
chatbot, grammar and spelling correction, keywords and keyphrases extraction,
text generation, image generation, blog post generation, code generation,
question answering, automatic speech recognition, machine translation,
language detection, semantic search, semantic similarity, tokenization,
NLP Cloud serves high performance pre-trained or custom models for NER,
sentiment-analysis, classification, summarization, dialogue summarization,
paraphrasing, intent classification, product description and ad generation,
chatbot, grammar and spelling correction, keywords and keyphrases extraction,
text generation, image generation, blog post generation, code generation,
question answering, automatic speech recognition, machine translation,
language detection, semantic search, semantic similarity, tokenization,
POS tagging, embeddings, and dependency parsing.
[Official documentation](https://docs.nlpcloud.com)
[Official documentation](https://docs.nlpcloud.com)
REQUIREMENTS
------------
......@@ -53,7 +53,7 @@ CONFIGURATION
- Administer augmentors
Users with this permission will see the webservices > augmentors
Users with this permission will see the web services > augmentors
configuration list page. From here they can add, configure, delete, enable
and disabled augmentors.
......@@ -63,17 +63,7 @@ CONFIGURATION
MAINTAINERS
-----------
Current maintainers:
* Eleo Basili (eleonel) - https://www.drupal.org/u/eleonel
* Naveen Valecha (naveenvalecha) - https://www.drupal.org/u/naveenvalecha
This project has been sponsored by: [Morpht Pty Ltd](https://www.morpht.com)
<img alt="Morpht Logo" src="https://www.morpht.com/sites/default/files/2020-12/
morpht_logo__default.png" height="40px">
-------------
We are a team of dedicated and enthusiastic designers, programmers and site
builders who know how to get the most from Drupal. We work for a variety of
clients in government, education, media and pharmaceutical sectors.
This module is maintained by developers at Morpht. For more information on the
company and our offerings, see [morpht.com](https://www.morpht.com/).
......@@ -2,6 +2,6 @@ name: NLP Cloud Augmentor
type: module
description: Provides integration of Augmentor with the NLP Cloud API.
package: Augmentor
core_version_requirement: ^9.5 || ^10
core_version_requirement: ^10.2 || ^11
dependencies:
- augmentor:augmentor
......@@ -63,7 +63,8 @@ class NLPCloudClassification extends NPLCloudBase {
FileSystemInterface $file_system,
FileRepositoryInterface $file_repository,
EntityTypeBundleInfo $entity_bundle_info,
EntityTypeManagerInterface $entity_type_manager) {
EntityTypeManagerInterface $entity_type_manager,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $logger, $key_repository, $current_user, $file_system, $file_repository);
$this->entityTypeBundleInfo = $entity_bundle_info;
$this->entityTypeManager = $entity_type_manager;
......@@ -72,7 +73,7 @@ class NLPCloudClassification extends NPLCloudBase {
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
......
......@@ -26,8 +26,8 @@ class NLPCloudEntities extends NPLCloudBase {
*/
public function defaultConfiguration() {
return parent::defaultConfiguration() + [
'model' => NULL,
];
'model' => NULL,
];
}
/**
......@@ -56,7 +56,6 @@ class NLPCloudEntities extends NPLCloudBase {
/**
* Extracts entities from the provided input text.
* Limited to 256 tokens in synchronous mode.
*
* @param string $text
* The text you want to extract entities from.
......@@ -69,7 +68,8 @@ class NLPCloudEntities extends NPLCloudBase {
$language = trim($this->configuration['language']);
$model = trim($this->configuration['model']);
$client = $this->getClient($model, self::NLP_CLOUD_GPU, $language);
// @todo: limit to first 1024 chars as approximation of 256 tokens.
// @todo Limit to the first 1024 chars as an approximation of 256 tokens.
// Limited to 256 tokens in synchronous mode.
$text = substr($text, 0, 1024);
$result = $client->entities($text);
return ['default' => json_encode($result->entities)];
......@@ -92,7 +92,7 @@ class NLPCloudEntities extends NPLCloudBase {
*/
private function getSupportedModels(): array {
return [
'en_core_web_lg' => $this->t('spaCy\'s English Large'),
'en_core_web_lg' => $this->t("spaCy's English Large"),
'fast-gpt-j' => $this->t('Fast GPT-J'),
'finetuned-gpt-neox-20b' => $this->t('Finetuned GPT-NeoX 20B'),
];
......
......@@ -46,8 +46,7 @@ class NLPCloudTextGeneration extends NPLCloudBase {
'#default_value' => $this->configuration['model'] ?? 'finetuned-llama-2-70b',
'#description' => $this->t('Specifies the model which you want to use for Blog generation.'),
];
// TODO: Make the max length dynamic,
// so that it is respective to the selected model.
// @todo Make the max length dynamic, which is respective to the selected model.
$form['max_length'] = [
'#type' => 'number',
'#title' => $this->t('Max Length'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment