Home

Awesome

SamueleMartini_GPT module

<font color='red'>The following module integrates some OpenAI GPT model language features into Magento: </font>

Install

composer require samuele-martini/module-openai-gpt

Admin panel usage

The main feature is the ability to automatically generate product and category descriptions from the admin panel. Simply enter the modification page of a product or category and click on the appropriate button. The description is generated via GPT model language starting from the product or category name, directly translated into the same language as the selected store view. The generated description is only a preview, it needs to be revised and the product or category needs to be saved to consolidate it. img_1.png img_2.png

Configurations

For the module working, you need to properly configure the parameters from the administration panel: img.png

For developers

Some notes of interest for developers

Provided Magento Model

The module provides 3 Magento Models:

Provided Service

The module provides 2 Service:

A Service has not been created for the images. Due to the complexity and precision required in the instructions for generating consistent images, it is not possible to generate them starting from the simple product or category name. You can use the Magento Model directly by providing precise instructions.

Implementations and developments

Both the Magento Models and the Services provided by module are totally transparent with the other functionalities, therefore they are usable in third-party modules or developments via dependency injection, for other uses.

For example, the Services and the image Model can be used in the development of a systems integration, during the catalog import phase, to automatically generate images and starting descriptions in products and categories, if the master data in the ERP does not have them .

Another example: the provided Magento Models can be used to develop the automatic generation of texts also for CMS pages, or blog articles if a module is installed to manage it.

public function __construct(
        ...
        \SamueleMartini\GPT\Api\GenerateProductDescriptionInterface $generateProductDescription,
        ...
    ) {
        ...
        $this->generateProductDescription = $generateProductDescription;
        ...
    }

    ...
    ...
    ...
    $description = $this->generateProductDescription->getProductDescription($productName, $language);   
    $description = $this->generateProductDescription->getProductDescriptionBySku($sku, $storeId);
    $description = $this->generateProductDescription->getProductDescriptionById($productId, $storeId);
    ...
    ...
    ...
    $product->setDescription($description);
    $this->productRepository->save($product);
    ...
    ...
    ...

Console Command

Some console commands have been made available, executable from the CLI. They are only useful for testing the functions, the generated texts and images are not assigned to products and categories and do not determine their real modification.


SamueleMartini_GPT module

<font color='red'>Il seguente modulo integra in Magento alcune funzionalità del modello linguistico GPT di OpenAI: </font>

Install

composer require samuele-martini/module-openai-gpt

Utilizzo da pannello di amministrazione

La funzionalità principale è la possibilità di generare automaticamente la descrizione di prodotti e categorie dal pannello di amministrazione. È sufficiente entrare nella pagina di modifica di un prodotto o di una categoria e cliccare nell'apposito pulsante. La descrizione viene generata tramite il modello linguistico GPT a partire dal nome del prodotto o della categoria, direttamente tradotta nella stessa lingua della store view selezionata. La descrizione generata è solo un'aneprima, deve essere revisionata ed il prodotto o la categoria devono essere salvati per consolidarla. img_1.png img_2.png

Configurazioni

Affinché il modulo funzioni, occorre configurare opportunamente i parametri dal pannello di amministrazione: img.png

Per gli sviluppatori

Alcune note di interesse per gli sviluppatori

Magento Model messi a disposizione

Il modulo mette a disposizione 3 Magento Model:

Service messi a disposizione

Il modulo mette a disposizione 2 Service:

Per le immagini non è stato creato un service. A causa della complessità e della precisione necessarie nelle istruzioni per la generazione di immagini coerenti, non è possibile generarle partendo dal semplice nome del prodotto o della categoria. Si può utilizzare direttamente il Magento Model fornendo delle istruzioni precise.

Implementazioni e sviluppi

Sia i Magento Model che i Service messi a disposizione sono totalmente trasparenti rispetto alle altre funzionalità, quindi utilizzabili in moduli o sviluppi terzi tramite dependency injection, per altri utilizzi.

Ad esempio i Service ed il Magento Model delle immagini sono utilizzabili nello sviluppo di un'integrazione sistemi, durante la fase di importazione del catalogo, per generare automaticamente immagini e descrizioni di partenza in prodotti e categorie, qualora le anagrafiche nell'ERP ne siano sprovviste.

Un altro esempio: i Magento Model messi a disposizione possono essere usati per sviluppare la generazione automatica dei testi anche per le CMS page, o gli articoli del blog se installato un modulo per gestirlo.

public function __construct(
        ...
        \SamueleMartini\GPT\Api\GenerateProductDescriptionInterface $generateProductDescription,
        ...
    ) {
        ...
        $this->generateProductDescription = $generateProductDescription;
        ...
    }

    ...
    ...
    ...
    $description = $this->generateProductDescription->getProductDescription($productName, $language);   
    $description = $this->generateProductDescription->getProductDescriptionBySku($sku, $storeId);
    $description = $this->generateProductDescription->getProductDescriptionById($productId, $storeId);
    ...
    ...
    ...
    $product->setDescription($description);
    $this->productRepository->save($product);
    ...
    ...
    ...

Console Command

Sono stati messi a disposizione alcuni console command, eseguibili da CLI. Questi servono solo per testare le funzionalità, i testi e le immagini generati non vengono assegnati a prodotti e categorie e non ne determinano la modifica reale.