PHP code example of samuele-martini / module-openai-gpt

1. Go to this page and download the library: Download samuele-martini/module-openai-gpt library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

samuele-martini / module-openai-gpt example snippets


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);
    ...
    ...
    ...

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);
    ...
    ...
    ...