Skip to content

Commit

Permalink
refactor(GithubModelsCliGenerator): Improve process generation logic
Browse files Browse the repository at this point in the history
- Refactor the `generate` method for clarity and efficiency.
- Introduce `mustRunProcess` to streamline process execution.
- Set process input directly within configuration parameters.
- Enhance maintainability and readability of the code.
  • Loading branch information
ityaozm@gmail.com committed Nov 5, 2024
1 parent f2bbfd3 commit e1c4ad1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/Generators/GithubModelsCliGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ final class GithubModelsCliGenerator extends Generator
{
public function generate(string $prompt): string
{
return resolve(
Process::class,
[
'command' => $this->ensureWithOptions([$this->config['binary'], 'models', 'run', $this->config['model'], $prompt]),
] + $this->config['parameters']
)->mustRun($this->runningCallback())->getOutput();
return $this
->mustRunProcess(
resolve(
Process::class,
[
'command' => $this->ensureWithOptions([$this->config['binary'], 'models', 'run', $this->config['model']]),
] + $this->config['parameters']
)->setInput($prompt)
)
->getOutput();
}
}

0 comments on commit e1c4ad1

Please sign in to comment.