Skip to content

Commit

Permalink
refactor: demo bootstrap to use specific llm
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienbrault committed Apr 22, 2024
1 parent 1239f35 commit c1fca9d
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions demo/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function createConsoleLogger(OutputInterface $output): LoggerInterface
]);
}

return function (callable $do) {
return function (callable $do, ?ProviderModel $llm = null) {
$inputDefinition = new InputDefinition([
new InputArgument('context', InputArgument::OPTIONAL),
new InputOption('verbose', 'v'),
Expand All @@ -42,24 +42,30 @@ function createConsoleLogger(OutputInterface $output): LoggerInterface

$logger = createConsoleLogger($output);

$providerModels = reindex(
InstructriceFactory::createAvailableProviderModels(),
fn (ProviderModel $providerModel) => $providerModel->getLabel(),
);
if ($llm === null) {
$providerModels = reindex(
InstructriceFactory::createAvailableProviderModels(),
fn (ProviderModel $providerModel) => $providerModel->getLabel(),
);

$questionSection = $output->section();
$questionHelper = new QuestionHelper();
$llmToUse = $questionHelper->ask($input, $questionSection, new ChoiceQuestion(
'Which LLM do you want to use?',
array_keys($providerModels),
0,
));
$questionSection->clear();
$llm = $providerModels[$llmToUse];
} else {
$llmToUse = $llm->getLabel();
}

$questionSection = $output->section();
$questionHelper = new QuestionHelper();
$llmToUse = $questionHelper->ask($input, $questionSection, new ChoiceQuestion(
'Which LLM do you want to use?',
array_keys($providerModels),
0,
));
$questionSection->clear();
$output->writeln(sprintf('Using LLM: <info>%s</info>', $llmToUse));
$output->writeln('');

$instructrice = InstructriceFactory::create(
llm: $providerModels[$llmToUse],
llm: $llm,
logger: $logger,
);

Expand Down

0 comments on commit c1fca9d

Please sign in to comment.