HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/laravel/app/Console/Commands/SendAerodromeDataToRag.php
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class SendAerodromeDataToRag extends Command
{

    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'aerodrome:send-data-to-rag';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Send Aerodromes data to rag';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $counter = 0;

        $data['model'] = 'local'; // To make call to N8N local LLM proxy

        // getfrom file ../docs/aerodromes.csv
        $filePath = storage_path('../../docs/Airports.csv');
        // read csv file line by line
        $aerodromesData = [];
        $handle = fopen($filePath, 'r');
        while (($line = fgetcsv($handle, 0, ';')) !== false) {
            if ($counter == 0) {
                $headers = $line;
                $counter++;
                continue;
            }

            // combine headers and line to associative array

            $lineData = array_combine($headers, $line);
            $lineData = json_encode($lineData);
            $aerodromesData[] = [
                'code' => $line[0],
                'data' => $lineData,
            ];
            $counter++;
        }
        fclose($handle);

        $endpoint = 'aerodromeToRag';
        foreach ($aerodromesData as $aerodrome) {
            $data['input'] = json_encode([
                'code' => $aerodrome['code'],
                'data' => $aerodrome['data'],
            ]);

            $result = callGptProxi($data, $endpoint, 'rag');

            print_r($result);
        }
    }
}