Skip to content

Commit

Permalink
Refactor in PromptRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
parsilver committed Jan 16, 2024
1 parent c89c7d8 commit ae169a8
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/Resources/PromptRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@ class PromptRepository implements PromptRepositoryInterface
*/
public function compile(string $name, array $bindings = []): string
{
if (! file_exists(__DIR__."/../../stubs/prompts/{$name}.txt")) {
return str_replace(
array_map(fn ($key) => ":{$key}:", array_keys($bindings)),
array_values($bindings),
$name,
);
}

$content = file_get_contents(__DIR__."/../../stubs/prompts/{$name}.txt");
$content = file_exists(__DIR__."/../../stubs/prompts/{$name}.txt")
? file_get_contents(__DIR__."/../../stubs/prompts/{$name}.txt")
: $name;

return str_replace(
array_map(fn ($key) => ":{$key}:", array_keys($bindings)),
Expand Down

0 comments on commit ae169a8

Please sign in to comment.