feat: [additional] Notion 검색 토큰 사용량 기록 및 비용 안내

- 검색어 정제/AI 답변 시 AiTokenHelper로 토큰 사용량 저장
- 상단 안내에 Gemini API 2회 호출 및 토큰 기록 안내 추가
This commit is contained in:
김보곤
2026-02-22 23:26:33 +09:00
parent c97a21f03d
commit 5810b15940
2 changed files with 13 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Services;
use App\Helpers\AiTokenHelper;
use App\Models\System\AiConfig;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
@@ -151,6 +152,8 @@ public function searchWithAi(string $userMessage, array $history = []): array
];
}
AiTokenHelper::saveGeminiUsage($response->json(), $geminiModel, 'Notion 검색 > AI 답변');
$reply = $response->json('candidates.0.content.parts.0.text')
?? '죄송합니다. 답변을 생성하지 못했습니다.';
@@ -189,6 +192,8 @@ private function refineQuery(string $userMessage, string $historyText, string $b
);
if ($response->successful()) {
AiTokenHelper::saveGeminiUsage($response->json(), $model, 'Notion 검색 > 검색어 정제');
$refined = $response->json('candidates.0.content.parts.0.text');
if ($refined) {
return trim($refined);

View File

@@ -167,9 +167,14 @@ className={`underline font-medium break-all ${isUser ? 'text-blue-200 hover:text
<div className="ns-header">
<h1>Notion 검색</h1>
<p>Notion 문서에서 검색하고 AI가 답변합니다</p>
<div className="mt-2 inline-flex items-center gap-1.5 px-3 py-1 bg-blue-50 border border-blue-200 rounded-full text-xs text-blue-700">
<span className="w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"></span>
실시간 검색 검색할 때마다 Notion API를 직접 호출합니다
<div className="mt-2 flex flex-wrap justify-center gap-2">
<span className="inline-flex items-center gap-1.5 px-3 py-1 bg-blue-50 border border-blue-200 rounded-full text-xs text-blue-700">
<span className="w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"></span>
실시간 검색 검색할 때마다 Notion API를 직접 호출합니다
</span>
<span className="inline-flex items-center gap-1.5 px-3 py-1 bg-amber-50 border border-amber-200 rounded-full text-xs text-amber-700">
검색 1회당 Gemini API 2 호출 (검색어 정제 + AI 답변) · 토큰 사용량 자동 기록
</span>
</div>
</div>