norbek/aivent

Universal AI Suite for Laravel β€” connect OpenAI, DeepSeek, Gemini, and Ollama with one clean API.

Installs: 56

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/norbek/aivent

v1.0.6 2025-10-22 14:47 UTC

This package is auto-updated.

Last update: 2025-12-25 11:53:00 UTC


README

One elegant API for OpenAI, DeepSeek, Gemini, and Ollama.

Aivent provides a clean, unified AI layer for Laravel. Connect to OpenAI, DeepSeek, Gemini, and Ollama with a single API and effortless provider switching, caching, and logging.

  • Simple methods: chat(), summarize(), translate()
  • Automatic provider fallback and switching
  • Cache and log out of the box
  • Facade and helper functions
  • CLI tools for diagnostics and maintenance

πŸš€ Features

  • Multiple AI providers: OpenAI, DeepSeek, Gemini, Ollama
  • Facade and helpers (Aivent::chat(), aivent_chat())
  • Automatic provider switching (fallback sequence)
  • Caching of repeated prompts
  • Logging with latency tracking (ms)
  • Artisan CLI: aivent:ping, aivent:log, aivent:log:clear, aivent:cache:clear
  • Laravel 10, 11, 12+ support
  • MIT Licensed

πŸ“¦ Installation

Install via Composer:

composer require norbek/aivent

Publish configuration:

php artisan vendor:publish --tag=aivent-config

Set your environment variables for the providers you plan to use:

# General
AI_PROVIDER={openai, deepseek, gemini, ollama}

# OpenAI
OPENAI_API_KEY=your-openai-key
OPENAI_BASE=https://api.openai.com/v1
OPENAI_MODEL=gpt-4o-mini

# DeepSeek
DEEPSEEK_API_KEY=your-deepseek-key
DEEPSEEK_BASE=https://api.deepseek.com/v1/chat/completions
DEEPSEEK_MODEL=deepseek-chat

# Gemini
GEMINI_API_KEY=your-gemini-key
GEMINI_BASE=https://generativelanguage.googleapis.com/v1beta
GEMINI_MODEL=gemini-1.5-flash

# Ollama (local)
OLLAMA_BASE=http://127.0.0.1:11434
OLLAMA_MODEL=llama3.1

#Example

    'default' => env('AI_PROVIDER', 'deepseek'),

    'providers' => [
        'openai' => [
            'api_key' => env('OPENAI_API_KEY'),
            'base_url' => env('OPENAI_BASE', 'https://api.openai.com/v1'),
            'model' => env('OPENAI_MODEL', 'gpt-4o-mini'),
        ],
        'deepseek' => [
            'api_key' => env('DEEPSEEK_API_KEY'),
            'base_url' => env('DEEPSEEK_BASE', 'https://api.deepseek.com/v1/chat/completions'),
            'model' => env('DEEPSEEK_MODEL', 'deepseek-chat'),
        ],
        'gemini' => [
            'api_key' => env('GEMINI_API_KEY'),
            'base_url' => env('GEMINI_BASE', 'https://generativelanguage.googleapis.com/v1beta'),
            'model' => env('GEMINI_MODEL', 'gemini-1.5-flash'),
        ],
        'ollama' => [
            'base_url' => env('OLLAMA_BASE', 'http://127.0.0.1:11434'),
            'model' => env('OLLAMA_MODEL', 'llama3.1'),
        ],
    ],
];

βš™οΈ Configuration

🏁 Quick Start

use Norbek\Aivent\Facades\Aivent;

// Simple chat
$response = Aivent::chat('Write a short haiku about Laravel.');

// Summarize
$summary = Aivent::summarize($longText);

// Translate to English
$en = Aivent::translate('Bonjour tout le monde', 'en');

Helper functions:

$text = aivent_chat('Tell me a joke.');
$sum  = aivent_summarize($article);
$tr   = aivent_translate('Hola', 'en');

πŸ’¬ Usage

Facade

$summary = Aivent::summarize($veryLongText, [
    'model' => 'gemini-1.5-flash',
    'max_tokens' => 512,
]);
$it = Aivent::translate('Good morning', 'it', [
    'temperature' => 0.1,
]);

Helper functions

$result = aivent_chat('What is the capital of Uzbekistan?');

Force a specific provider

use Norbek\Aivent\Facades\Aivent;

$out = Aivent::withProvider('deepseek')
    ->chat('Give me 3 refactoring tips for Laravel controllers.');

Provider names: openai, deepseek, gemini, ollama.

πŸ›  Console Commands

  • Ping all providers and show status + latency:
php artisan aivent:ping
  • Show recent Aivent logs:
php artisan aivent:log --lines=100
  • Clear Aivent logs:
php artisan aivent:log:clear
  • Clear Aivent cached prompts:
php artisan aivent:cache:clear

Each command uses friendly tables or output for quick diagnostics.

Feature β€” Analyser: validation date of any documents / Anlyser: hujjatdagi sanani tekshirish

Aivent includes an "Analyser" feature that extracts text from certificates/documents (OCR) and validates issue/expiry dates. Below is a ready-to-paste README section you can insert into the Features area of your repository.

Overview / Umumiy ma'lumot

This feature uses Tesseract OCR + Imagick to extract text from PDFs and images, then validates dates (issued_at / expires_at) and other fields. It is meant for certificate verification workflows (e.g., IELTS, CEFR, etc.).

Ushbu bo'lim Tesseract OCR va Imagick dan foydalanib hujjatlardan matn olib, sanalarni tekshiradi (berilgan va muddati tugash sanalari).

3️⃣ β€” Install required system packages (OCR dependencies) / OCR uchun tizim paketlarini o'rnatish

Aivent sertifikatdan matn olish uchun Tesseract OCR va Imagick dan foydalanadi.

🧠 Step A: Install Tesseract

sudo apt update
sudo apt install tesseract-ocr -y

πŸ‡ΊπŸ‡Έ Step B: English and Uzbek OCR languages

sudo apt install tesseract-ocr-eng -y
sudo apt install tesseract-ocr-uzb -y
# yoki to'liq:
sudo apt install tesseract-ocr-all -y

Check available languages:

tesseract --list-langs

Expected result: eng and uzb should appear.

πŸ–Ό Step C: PDF Support (Imagick)

sudo apt install php-imagick -y
# restart PHP-FPM if needed, example for PHP 8.4:
sudo service php8.4-fpm restart

Verify Imagick:

php -m | grep imagick

If imagick is shown, it's ready.

4️⃣ β€” Configure cache (for AI responses) / Kesh konfiguratsiyasi

Aivent AI javoblarni kechiktirmaslik uchun cache ishlatadi. .env faylingizga quyidagilarni qo'shing:

CACHE_DRIVER=file
AIVENT_CACHE_ENABLED=true
AIVENT_CACHE_TTL=21600

Bu shuni anglatadi: AI javoblar storage/framework/cache/data papkada 6 soat (21600 soniya) saqlanadi.

5️⃣ β€” Place your certificate files / Sertifikat fayllarini joylashtirish

Masalan:

  • public papkada:
    • /public/certificates/ielts.pdf
    • /public/certificates/cefr.jpg

yoki storage ichida:

  • /storage/app/public/certificates/ielts.pdf

Make sure files are accessible by your app (symlink storage: php artisan storage:link if using storage/public).

6️⃣ β€” Use Aivent in your code / Kodda foydalanish

Example #1: Quick test route

use Norbek\Aivent\Facades\Aivent;

Route::get('/check-certificate', function () {
    $result = Aivent::validateCertificate('certificates/ielts.pdf');
    return response()->json($result->toArray());
});

Example #2: In a Controller

use Norbek\Aivent\Facades\Aivent;

class CertificateController extends Controller
{
    public function verify()
    {
        $result = Aivent::validateCertificate('certificates/cefr.pdf', 'public');

        if (! $result->isValid()) {
            return response()->json([
                'status' => 'failed',
                'errors' => $result->errors,
            ]);
        }

        return response()->json([
            'status' => 'success',
            'data' => $result->toArray(),
        ]);
    }
}
  • validateCertificate accepts a path (relative to disk root) and optional disk (e.g., 'public').
  • The returned object includes boolean isValid(), errors array, recognized ocr_text, and parsed dates.

7️⃣ β€” Example Output / Misol chiqishi

{
  "valid": true,
  "name": "HOMIDOV NORGE",
  "issued_at": "2023-11-25",
  "expires_at": "2025-11-25",
  "errors": [],
  "ocr_text": "Test Report Form ACADEMIC ... (OCR text)"
}

Notes / Eslatma

  • Ensure provider keys and cache are configured before running heavy OCR+AI jobs.
  • If OCR fails to detect certain languages, verify Tesseract language packs and try improving image quality (dpi, contrast).
  • Consider rate-limiting and queueing long-running certificate verifications (use Laravel queues).

Paste this section into the "Features" area of your README where you keep descriptive feature blocks. If you want, I can:

  • integrate this exactly into your repository README and open a PR, or
  • replace any function/class placeholders (like validateCertificate) with exact names from your code after I inspect the repo.

🀝 Contributing

Contributions are welcome! Please:

  • Fork the repo
  • Create a feature branch
  • Add tests when possible
  • Open a pull request with a clear description and screenshots/logs if relevant

πŸ”’ Security

If you discover a security vulnerability, please email the maintainer privately instead of using the issue tracker.

  • Never commit API keys or secrets.
  • Rotate and scope provider keys appropriately.

πŸ“„ License

MIT License. See the LICENSE file for details.

πŸ™ Credits

  • Built and maintained by @hamidovnorbek
  • Inspired by the clean package design culture of the Laravel and Spatie ecosystems

Happy building! πŸš€