1. Go to this page and download the library: Download gtstudio/module-aiconnector library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gtstudio / module-aiconnector example snippets
class CustomProviderPlugin
{
public function aroundResolveProvider(NeuronClient $subject, callable $proceed, $request = null)
{
if (strtolower($subject->getConfig()->getProvider()) === 'myprovider') {
return new MyCustomProvider(...);
}
return $proceed($request);
}
}
use Gtstudio\AiConnector\Model\Client\NeuronClient;
use NeuronAI\Chat\Messages\UserMessage;
class MyService
{
public function __construct(private readonly NeuronClient $client) {}
public function ask(string $question): string
{
$provider = $this->client->resolveProvider();
$response = $provider->chat(new UserMessage($question));
return (string) $response->getContent();
}
}