1. Go to this page and download the library: Download la-87/aipromptbuilder 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/ */
use LA87\AIPromptBuilder\Services\AIPromptBuilderService;
use LA87\AIPromptBuilder\Enums\AIModelEnum;
use OpenAI\Client;
$client = app(Client::class);
$service = new AIPromptBuilderService($client);
$response = $service->setModel(AIModelEnum::GPT4)
->setPrompt('What is the capital of France?')
->setRole('You are a knowledgeable assistant.')
->ask();
echo $response->completion;
use LA87\AIPromptBuilder\Contracts\AIFunctionInterface;
use stdClass;
class GetWeatherFunction implements AIFunctionInterface
{
public function getName(): string
{
return 'getWeather';
}
public function getDescription(): string
{
return 'Fetches the current weather for a given location.';
}
public function getParametersSchema(): array
{
return [
'type' => 'object',
'properties' => [
'location' => [
'type' => 'string',
'description' => 'The location to get the weather for.'
]
],
'