ayacoo/news-tldr

Creates a short summary for news via ChatGPT

Installs: 54

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:typo3-cms-extension

1.0.1 2023-05-28 16:31 UTC

This package is auto-updated.

Last update: 2024-04-14 19:41:01 UTC


README

1 Features

The extension makes it possible to create short news summaries using ChatGPT.

2 Hints

  • The code can be used and further developed as desired, e.g. for a backport to version 11
  • Only the field bodytext is read. Other linked content elements must be read and manipulated via an event.

3 Usage

3.1 Prerequisites

To use this extension, you need the following requirements:

  • PHP version 8.1 or higher
  • TYPO3 version 12
  • News Extension 11 or higher
  • ChatGPT API Token (Please note the number of tokens and costs)

3.2 Installation

Installation using Composer

The recommended way to install the extension is using Composer.

Run the following command within your Composer based TYPO3 project:

composer require ayacoo/news-tldr

3.3 Event / EventListener

To modify the ChatGPT request, e.g. to change the payload, there is an event: ModifyChatGptContentEvent.

EventListener registration

services:
  Vendor\Ext\Listener\ContentListener:
    tags:
      - name: event.listener
        identifier: 'news-tldr/content'
        method: 'setContent'
        event: Ayacoo\NewsTldr\Event\ModifyChatGptContentEvent

EventListener

<?php
declare(strict_types=1);

namespace Vendor\Ext\Listener;

use Ayacoo\NewsTldr\Event\ModifyChatGptContentEvent;

class ContentListener
{
    public function setContent(ModifyChatGptContentEvent $event): ModifyChatGptContentEvent
    {
        $row = $event->getRow()
        $text = strip_tags($row['bodytext'] ?? '');

        $content = 'Fasse mir diesen Text in 100 Zeichen zusammen: ' . $text;
        $event->setContent($content);

        return $event;
    }
}

4 Support

If you are happy with the extension and would like to support it in any way, I would appreciate the support of social institutions.