PHP code example of futuremeng / ragflow-laravel

1. Go to this page and download the library: Download futuremeng/ragflow-laravel 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/ */

    

futuremeng / ragflow-laravel example snippets


use RAGFlow\Laravel\Facades\RAGFlow;

$result = RAGFlow::chat()->create([
    'message' =>'Hello!',
]);

echo $result->completion->content; // Hello! How can I assist you today?

use RAGFlow\Laravel\Facades\RAGFlow;
use RAGFlow\Responses\Completions\CreateResponse;

RAGFlow::fake([
    CreateResponse::fake([
        'choices' => [
            [
                'text' => 'awesome!',
            ],
        ],
    ]),
]);

$completion = RAGFlow::completions()->create([
    'model' => 'gpt-3.5-turbo-instruct',
    'prompt' => 'PHP is ',
]);

expect($completion['choices'][0]['text'])->toBe('awesome!');

// assert completion create request was sent
RAGFlow::assertSent(Completions::class, function (string $method, array $parameters): bool {
    return $method === 'create' &&
        $parameters['model'] === 'gpt-3.5-turbo-instruct' &&
        $parameters['prompt'] === 'PHP is ';
});
bash
php artisan ragflow:install