1. Go to this page and download the library: Download evoware/ollama-php 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/ */
evoware / ollama-php example snippets
use GuzzleHttp\Client as HttpClient;
use Evoware\OllamaPHP\OllamaClient;
$ollamaClient = new OllamaClient(new HttpClient());
$response = $ollamaClient->generateCompletion('The capital of France is ', ['model' => 'mistral:7b']);
$completionText = $response->getResponse(); // Returns the generated completion text.
// List all local models
$models = $ollamaClient->model()->list();
// Pull a local model
$result = $ollamaClient->model()->pull('mistral:7b');
// Alternatively, access via the getModelRepository method
$result = $ollamaClient->getModelRepository()->pull('mistral:7b');
// Load a Modelfile
$ollamaClient->fromModelFile('/path/to/modelfile');
$embeddings = $ollamaClient->generateEmbeddings('This is my text to be embedded.', 'nomic-embed-text');
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.