### ----------------------------------------------------
### -- LLM::DWIM
### -- Licenses: MIT
### -- Authors: Brian Duggan
### -- File: t/01-dwim.rakutest
### ----------------------------------------------------
use Test;
use LLM::DWIM;
use LLM::Functions;

plan 8;

my $called = 0;
my $arg = Nil;

&llm-function.wrap: -> |args { $called++; sub ($str) { $arg = $str } }

dwim "hello";

ok $called, "called llm-function";
is $arg, 'hello', 'sent args to function';

dwim "world";

is $called, 1, 'cached evaluator function';
is $arg, 'world', 'sent different args';

$called = 0;
$arg = Nil;
&llm-chat.wrap: -> |args {
    $called++;
    $arg = args<prompt>;
}

dwim-chat "hello";

ok $called, "called llm-chat-function";
is $arg, 'hello', 'sent args to chat function';

dwim-chat "world";

is $called, 2, 'called chat function again';
is $arg, 'world', 'sent different args to chat function';


