<?php



use Idearia\Logger;



class GPTTransport extends BaseTransport {

	private $transport;



	public function __construct($apiKey) {

		$this->transport = OpenAI::client($apiKey);

		// parent::__construct($transport);

	}



	public function chat($text) {

		$data = [

		    'model' => 'gpt-4',

		    'messages' => [

		        ['role' => 'user', 'content' => $text],

		    ],

		];

		$result = $this->transport->chat()->create($data);

		return $result->choices[0]->message->content;

	}



	protected function getResult($result) {

		return $this->objToArray($result);

	}



}

