1. Go to this page and download the library: Download endritvs/laravel-ai-toolkit 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 Endritvs\LaravelAIToolkit\Models\Prompt;
$prompt = new Prompt();
$prompt->addContent('What is the capital of France?')
->setModel('gpt-4o-mini')
->setMaxTokens(50);
$response = $prompt->execute();
echo $response; // Output will be the AI's response.
use Endritvs\LaravelAIToolkit\Models\Prompt;
$response = Prompt::query()
->setModel('anthropic.claude-v2')
->setMaxTokens(100)
->addContent('Tell me a joke')
->execute();
echo $response; // Output will be the AI's response.
use Endritvs\LaravelAIToolkit\Models\Prompt;
// Using GPT model
$gptPrompt = new Prompt();
$gptPrompt->addContent('Explain quantum computing in simple terms.')
->setModel('gpt-4o-mini')
->setMaxTokens(150);
$gptResponse = $gptPrompt->execute();
echo 'GPT Response: ' . $gptResponse . PHP_EOL;
// Using Claude model
$claudePrompt = new Prompt();
$claudePrompt->addContent('What are the latest trends in web development?')
->setModel('anthropic.claude-v2')
->setMaxTokens(150);
$claudeResponse = $claudePrompt->execute();
echo 'Claude Response: ' . $claudeResponse . PHP_EOL;
use Endritvs\LaravelAIToolkit\Models\Prompt;
$prompt = new Prompt();
$prompt->addContent('Summarize the latest news on AI technology.')
->setProvider('gpt')
->setModel('gpt-4o-mini')
->setMaxTokens(150)
->fallback('claude'); // Claude will be used if GPT fails
$response = $prompt->execute();
echo $response;
use Endritvs\LaravelAIToolkit\Models\Prompt;
$prompt = new Prompt();
$prompt->setProvider('claude') // Set a different provider
->addContent('Describe the principles of machine learning.')
->setModel('claude-v2')
->setMaxTokens(150);
$response = $prompt->execute();
echo $response; // The response from the specified provider.
use Endritvs\LaravelAIToolkit\Models\Prompt;
$response = Prompt::query()
->setModel('gpt-4o-mini')
->addContent('What are the implications of quantum computing?')
->setMaxTokens(200)
->execute();
echo $response; // Outputs the result based on the complex query.
use Endritvs\LaravelAIToolkit\Models\Prompt;
// Example using GPT-4
$prompt = new Prompt();
$prompt->addContent('Give a summary of the latest advancements in technology.')
->setModel('gpt-4')
->setMaxTokens(300)
->fallback('claude'); // Fallback to Claude if GPT-4 fails
$response = $prompt->execute();
echo $response; // Outputs the result from GPT-4 or Claude if GPT-4 fails.
// Example using Claude
$claudePrompt = new Prompt();
$claudePrompt->addContent('Discuss the impact of recent technological innovations on society.')
->setModel('claude-v2')
->setMaxTokens(300);
$claudeResponse = $claudePrompt->execute();
echo 'Claude Response: ' . $claudeResponse . PHP_EOL;
// Example using Query Builder
$response = Prompt::query()
->setModel('gpt-4o-mini')
->addContent('What is the future of artificial intelligence?')
->setMaxTokens(150)
->execute();
echo $response; // Outputs the result based on the complex query and fallback.