diff --git a/src/SolutionProviders/Laravel/OpenAiSolutionProvider.php b/src/SolutionProviders/Laravel/OpenAiSolutionProvider.php index 09e9d86..67d4a14 100644 --- a/src/SolutionProviders/Laravel/OpenAiSolutionProvider.php +++ b/src/SolutionProviders/Laravel/OpenAiSolutionProvider.php @@ -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); diff --git a/src/Solutions/OpenAi/OpenAiSolution.php b/src/Solutions/OpenAi/OpenAiSolution.php index 4b69f6d..0fc6cc4 100644 --- a/src/Solutions/OpenAi/OpenAiSolution.php +++ b/src/Solutions/OpenAi/OpenAiSolution.php @@ -28,6 +28,7 @@ public function __construct( protected int|null $cacheTtlInSeconds = 60, protected string|null $applicationType = null, protected string|null $applicationPath = null, + protected string $openAiModel, ) { $this->prompt = $this->generatePrompt(); @@ -60,7 +61,7 @@ public function getAiSolution(): ?OpenAiSolutionResponse $solutionText = OpenAI::client($this->openAiKey) ->chat() ->create([ - 'model' => $this->getModel(), + 'model' => $this->openAiModel(), 'messages' => [['role' => 'user', 'content' => $this->prompt]], 'max_tokens' => 1000, 'temperature' => 0, @@ -97,11 +98,6 @@ protected function generatePrompt(): string ); } - protected function getModel(): string - { - return 'gpt-3.5-turbo'; - } - protected function getApplicationFrame(Throwable $throwable): ?Frame { $backtrace = Backtrace::createForThrowable($throwable); diff --git a/src/Solutions/OpenAi/OpenAiSolutionProvider.php b/src/Solutions/OpenAi/OpenAiSolutionProvider.php index ecd6d9f..d754790 100644 --- a/src/Solutions/OpenAi/OpenAiSolutionProvider.php +++ b/src/Solutions/OpenAi/OpenAiSolutionProvider.php @@ -14,6 +14,7 @@ public function __construct( 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(); } @@ -33,6 +34,7 @@ public function getSolutions(Throwable $throwable): array $this->cacheTtlInSeconds, $this->applicationType, $this->applicationPath, + $this->openAiModel ), ]; }