Hello
I am testing chatgpt and would like to integrate it in a CB code autoaction.
It works fine when using the code in a single php file to display the result but I cannot get a code autoaction to work.
I use this :
Code:
include_once(JPATH_ROOT . '/ahatools/activations/assets/OpenAi.php');
include_once(JPATH_ROOT . '/ahatools/activations/assets/Url.php');
use \Orhanerday\OpenAi\OpenAi;
use \Orhanerday\OpenAi\Url;
$open_ai_key = 'xxxxxxxxx';
//in$open_ai_key = getenv('OPENAI_API_KEY');
$open_ai = new OpenAi($open_ai_key);
$prompt = 'Quelle est la capitale de paris ?';
$complete = $open_ai->completion([
'model' => 'text-davinci-003',
'prompt' => $prompt,
'temperature' => 0.9,
'max_tokens' => 200,
'frequency_penalty' => 0,
'presence_penalty' => 0.6,
]);
$responseJson = json_decode($complete, true);
$response = $responseJson['choices'][0]['text'];
Where the API used is this one :
github.com/orhanerday/open-ai
Is there an issue using namespace in code autoactions ?
thanks for your help