feat: [additional] Notion 검색 기능 추가
- NotionService: Notion API 검색 + Gemini AI 답변 - AiConfig에 notion provider 추가 - 추가기능 > Notion 검색 채팅 UI
This commit is contained in:
51
app/Http/Controllers/Additional/NotionSearchController.php
Normal file
51
app/Http/Controllers/Additional/NotionSearchController.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Additional;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\NotionService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class NotionSearchController extends Controller
|
||||
{
|
||||
/**
|
||||
* Notion 검색 페이지 (채팅 UI)
|
||||
*/
|
||||
public function index(Request $request): View|Response
|
||||
{
|
||||
if ($request->header('HX-Request')) {
|
||||
return response('', 200)->header('HX-Redirect', route('additional.notion-search.index'));
|
||||
}
|
||||
|
||||
return view('additional.notion-search.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX 검색 API
|
||||
*/
|
||||
public function search(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'message' => 'required|string|max:1000',
|
||||
'history' => 'nullable|array',
|
||||
]);
|
||||
|
||||
try {
|
||||
$service = new NotionService;
|
||||
$result = $service->searchWithAi(
|
||||
$validated['message'],
|
||||
$validated['history'] ?? []
|
||||
);
|
||||
|
||||
return response()->json($result);
|
||||
} catch (\RuntimeException $e) {
|
||||
return response()->json([
|
||||
'reply' => $e->getMessage(),
|
||||
'debug' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user