Consider using openai-php/client library

Created on 3 May 2023, over 1 year ago
Updated 17 May 2024, 6 months ago

Problem/Motivation

openai-php/client library uses guzzle, while augmentor's library orhanerday/open-ai uses curl_exec.

Guzzle is better, because Drupal uses it, and it allows to create middleware, modify request etc. Also openai-php/client is more popular. I have not listed all the good reasons, there are probably a lot more.

The only drawback is that openai-php/client requires PHP 8.1 which is probably not well supported in Drupal 9.

The simplest code variant to implement it:

    $this->client = \OpenAI::factory()
      ->withApiKey($api_key)
      ->withHttpClient(\Drupal::httpClient())
      ->make();

And possibly more code changes where the client itself is used.

Steps to reproduce

Proposed resolution

  1. I will make a custom patch and test does it work well.
  2. Then release a separate augmentor_chatgpt version for Drupal 10 alone, or wait until Drupal 9 becomes unsupported.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡±πŸ‡ΉLithuania mindaugasd

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024