PHP code example of farzai / viola
1. Go to this page and download the library: Download farzai/viola 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/ */
farzai / viola example snippets
use Farzai\Viola\Viola;
// Setup Viola.
$viola = Viola::builder()
->setApiKey(string $key)
->setDatabaseConfig(string $driver, array $databaseConfig)
->setClient(\Psr\Http\Client\ClientInterface $client) // Optional
->setLogger(\Psr\Log\LoggerInterface $logger) // Optional
->build();
// Ask a question to ChatGPT.
$answer = $viola->ask('Show me all books by J. K. Rowling.');
// Get the answer.
echo $answer->getAnswer();
// Or get the answer with the results.
foreach ($answer->getResults() as $row) {
//
}
bash
$ composer global