#!/usr/bin/env php
<?php

use boru\dhcli\dhCLI;
use boru\dhutils\filesys\BasePath;
use boru\openai\OpenAI;

$cd = getcwd();
if(isset($GLOBALS['_composer_bin_dir'])) {
    $rootDir = realpath($GLOBALS['_composer_bin_dir']."/../../");
} else {
    $dir = __DIR__;
    $myParent = "/vendor/boru/openai/bin";
    if(substr($dir,-strlen($myParent))==$myParent) {
        //included as a dependency
        $rootDir = realpath($dir."/../../../../");
    } else {
        //in the dhfw repository
        $rootDir = realpath($dir."/../");
    }
}
require_once $rootDir."/vendor/autoload.php";
$thisFile = \boru\dhutils\filesys\File::fromInput($argv[0],false);
array_shift($argv);


dhCLI::init(
    "Boru OpenAI CLI","Execute OpenAI API commands",
    [
        \boru\openai\command\ModelCommand::class,
        \boru\openai\command\PdfCommand::class,
        \boru\openai\command\AssistantCommand::class,
    ],
    $argv,
    OpenAI::getRelPath($cd,$thisFile->path())." "
);


