/ollama-laravel

Ollama-Laravel is a Laravel package providing seamless integration with the Ollama API.

Primary LanguagePHPMIT LicenseMIT

Ollama-Laravel Package

Ollama-Laravel is a Laravel package that provides a seamless integration with the Ollama API. It includes functionalities for model management, prompt generation, format setting, and more. This package is perfect for developers looking to leverage the power of the Ollama API in their Laravel applications.

Installation

composer require cloudstudio/ollama-laravel

Configuration

php artisan vendor:publish --tag="ollama-laravel-config"

Published config file:

return [
    'model' => env('OLLAMA_MODEL', 'llama2'),
    'url' => env('OLLAMA_URL', 'http://127.0.0.1:11434'),
    'default_prompt' => env('OLLAMA_DEFAULT_PROMPT', 'Hello, how can I assist you today?'),
    'connection' => [
        'timeout' => env('OLLAMA_CONNECTION_TIMEOUT', 300),
    ],
];

Usage

Basic Usage

use Cloudstudio\Ollama\Facades\Ollama;

$response = Ollama::prompt('Why is the sky blue?')
    ->model('llama2')
    ->options(['temperature' => 0.8])
    ->stream(false)
    ->ask();

Show Model Information

$response = Ollama::model('Llama2')->show();

Copy a Model

Ollama::model('Llama2')->copy('newDestination');

Delete a Model

Ollama::model('Llama2')->delete();

Generate Embeddings

$embeddings = Ollama::model('Llama2')->embeddings('Your prompt here');

Testing

pest

Changelog, Contributing, and Security

Credits

License

MIT License