Consider using openai-php/client library

Created on 16 May 2023, over 1 year ago
Updated 18 July 2024, 2 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_openai_gpt3 version for Drupal 10 alone, or wait until Drupal 9 becomes unsupported.

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇯🇵Japan eleonel Itoshima 🇯🇵

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024