Add (inspector)
Add (openai): debugging points for inspector
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
@@ -20,11 +22,54 @@ class Handler extends ExceptionHandler
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(): void
|
||||
public function register()
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
$this->reportable(function (Throwable $exception) {
|
||||
//
|
||||
|
||||
});
|
||||
|
||||
$this->renderable(function (NotFoundHttpException $e, $request) {
|
||||
|
||||
|
||||
if ($request->is('api/*')) {
|
||||
return response()->json([
|
||||
'status' => -1,
|
||||
], 404);
|
||||
} else {
|
||||
return redirect()->route('front.home');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Throwable $exception)
|
||||
{
|
||||
|
||||
if ($exception instanceof NotFoundHttpException)
|
||||
{
|
||||
|
||||
}
|
||||
else if ($exception instanceof AuthenticationException)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
inspector()->reportException($exception);
|
||||
}
|
||||
|
||||
//default laravel response
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,15 +94,21 @@ public static function suggestArticleTitles($current_title, $supporting_data, $s
|
||||
|
||||
public static function chatCompletion($system_prompt, $user_prompt, $model)
|
||||
{
|
||||
dump($system_prompt);
|
||||
dump($user_prompt);
|
||||
|
||||
$response = Http::timeout(800)->withToken(config('platform.ai.openai.api_key'))
|
||||
->post('https://api.openai.com/v1/chat/completions', [
|
||||
'model' => $model,
|
||||
'max_tokens' => 2500,
|
||||
'messages' => [
|
||||
['role' => 'user', 'content' => $system_prompt.' '.$user_prompt],
|
||||
['role' => 'system', 'content' => $system_prompt],
|
||||
['role' => 'user', 'content' => $user_prompt],
|
||||
],
|
||||
]);
|
||||
|
||||
dump($response->body);
|
||||
|
||||
$json_response = json_decode($response->body());
|
||||
|
||||
$reply = $json_response?->choices[0]?->message?->content;
|
||||
|
||||
Reference in New Issue
Block a user