1. Go to this page and download the library: Download genaker/agento-ai 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/ */
// Basic image recognition
$imageData = $openAiService->recognizeImage(
'/path/to/image.jpg',
$googleAccessToken
);
// Extract text from documents (OCR)
$textData = $openAiService->extractTextFromImage(
'/path/to/document.jpg',
$googleAccessToken
);
// AI analysis of image content
$analysis = $openAiService->recognizeImageWithAiAnalysis(
'/path/to/image.jpg',
$googleAccessToken,
$openAiApiKey,
'Describe what you see in this image. Labels detected: {{LABELS}}. Text found: {{TEXT}}.'
);
// Upload a single file
$fileData = $openAiService->uploadFile(
'/path/to/document.pdf',
'assistants',
$openAiApiKey
);
// Upload multiple files in batch
$batchResults = $openAiService->batchUploadFiles(
['/path/to/doc1.pdf', '/path/to/doc2.pdf'],
'assistants',
$openAiApiKey
);
// Ask questions about a file
$answer = $openAiService->getFileAnswers(
'What is the main topic discussed in this document?',
$fileData['id'],
$openAiApiKey
);
// Compare information across multiple files
$comparison = $openAiService->getFileAnswers(
'What are the key differences between these documents?',
[$fileId1, $fileId2, $fileId3],
$openAiApiKey
);
// Extract text from image and use it with file reference
$textData = $openAiService->extractTextFromImage('/path/to/image.jpg', $googleAccessToken);
$messages = [
['role' => 'system', 'content' => 'Compare the text from this image with the uploaded document.'],
['role' => 'user', 'content' => 'Image text: ' . $textData['text']]
];
$comparison = $openAiService->sendFileReferenceChatRequest($messages, $fileId, 'gpt-4', $openAiApiKey);
// Convert speech to text and then analyze with AI
$transcript = $openAiService->speechToText('/path/to/audio.mp3', $googleAccessToken);
$messages = [
['role' => 'system', 'content' => 'You are an expert content analyzer.'],
['role' => 'user', 'content' => 'Analyze this transcript: ' . $transcript['transcript']]
];
$analysis = $openAiService->sendChatRequest($messages, 'gpt-3.5-turbo', $openAiApiKey);
// Example code to get Google access token
$accessToken = $googleAuthService->getAccessToken($serviceAccountKeyFile);
sql
GRANT SELECT ON magento_db.* TO 'username'@'localhost';
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.