Skip to content

Commit

Permalink
Merge pull request #7 from arnebr/main
Browse files Browse the repository at this point in the history
Allow to customize OpenAI Model
  • Loading branch information
freekmurze authored Jul 22, 2024
2 parents f139ef7 + 1677ae7 commit a014da1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/SolutionProviders/Laravel/OpenAiSolutionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function getSolutions(Throwable $throwable): array
cacheTtlInSeconds: 60,
applicationType: 'Laravel ' . Str::before(app()->version(), '.'),
applicationPath: base_path(),
openAiModel: config('error-solutions.open_ai_model', 'gpt-3.5-turbo'),
);

return $solutionProvider->getSolutions($throwable);
Expand Down
3 changes: 2 additions & 1 deletion src/Solutions/OpenAi/OpenAiSolution.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function __construct(
protected int|null $cacheTtlInSeconds = 60,
protected string|null $applicationType = null,
protected string|null $applicationPath = null,
protected string|null $openAiModel = null,
) {
$this->prompt = $this->generatePrompt();

Expand Down Expand Up @@ -99,7 +100,7 @@ protected function generatePrompt(): string

protected function getModel(): string
{
return 'gpt-3.5-turbo';
return $this->openAiModel ?? 'gpt-3.5-turbo';
}

protected function getApplicationFrame(Throwable $throwable): ?Frame
Expand Down
12 changes: 7 additions & 5 deletions src/Solutions/OpenAi/OpenAiSolutionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
class OpenAiSolutionProvider implements HasSolutionsForThrowable
{
public function __construct(
protected string $openAiKey,
protected ?CacheInterface $cache = null,
protected int $cacheTtlInSeconds = 60 * 60,
protected string|null $applicationType = null,
protected string|null $applicationPath = null,
protected string $openAiKey,
protected ?CacheInterface $cache = null,
protected int $cacheTtlInSeconds = 60 * 60,
protected string|null $applicationType = null,
protected string|null $applicationPath = null,
protected string $openAiModel = 'gpt-3.5-turbo',
) {
$this->cache ??= new DummyCache();
}
Expand All @@ -33,6 +34,7 @@ public function getSolutions(Throwable $throwable): array
$this->cacheTtlInSeconds,
$this->applicationType,
$this->applicationPath,
$this->openAiModel
),
];
}
Expand Down

0 comments on commit a014da1

Please sign in to comment.