Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix plural of chain processor vars #190

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/Chain.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@
/**
* @var InputProcessor[]
*/
private array $inputProcessor;
private array $inputProcessors;

/**
* @var OutputProcessor[]
*/
private array $outputProcessor;
private array $outputProcessors;

/**
* @param InputProcessor[] $inputProcessor
* @param OutputProcessor[] $outputProcessor
* @param InputProcessor[] $inputProcessors
* @param OutputProcessor[] $outputProcessors
*/
public function __construct(
private PlatformInterface $platform,
private LanguageModel $llm,
iterable $inputProcessor = [],
iterable $outputProcessor = [],
iterable $inputProcessors = [],
iterable $outputProcessors = [],
private LoggerInterface $logger = new NullLogger(),
) {
$this->inputProcessor = $this->initializeProcessors($inputProcessor, InputProcessor::class);
$this->outputProcessor = $this->initializeProcessors($outputProcessor, OutputProcessor::class);
$this->inputProcessors = $this->initializeProcessors($inputProcessors, InputProcessor::class);
$this->outputProcessors = $this->initializeProcessors($outputProcessors, OutputProcessor::class);
}

/**
Expand All @@ -54,7 +54,7 @@ public function __construct(
public function call(MessageBagInterface $messages, array $options = []): ResponseInterface
{
$input = new Input($this->llm, $messages, $options);
array_map(fn (InputProcessor $processor) => $processor->processInput($input), $this->inputProcessor);
array_map(fn (InputProcessor $processor) => $processor->processInput($input), $this->inputProcessors);

$llm = $input->llm;
$messages = $input->messages;
Expand Down Expand Up @@ -82,13 +82,14 @@ public function call(MessageBagInterface $messages, array $options = []): Respon
}

$output = new Output($llm, $response, $messages, $options);
array_map(fn (OutputProcessor $processor) => $processor->processOutput($output), $this->outputProcessor);
array_map(fn (OutputProcessor $processor) => $processor->processOutput($output), $this->outputProcessors);

return $output->response;
}

/**
* @param InputProcessor[]|OutputProcessor[] $processors
* @param class-string $interface
*
* @return InputProcessor[]|OutputProcessor[]
*/
Expand Down
Loading