feat:AI 설정에 Vertex AI 서비스 계정 인증 방식 추가

- AiConfig 모델에 Vertex AI 헬퍼 메소드 추가
- AI 설정 UI에 인증 방식 선택 (API 키 / Vertex AI)
- Vertex AI 선택 시 프로젝트 ID, 리전, 서비스 계정 경로 입력
- BusinessCardOcrService가 DB 설정 기반으로 동작
- Google AI Studio와 Vertex AI 모두 지원

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
pro
2026-01-28 08:08:30 +09:00
parent d1660aa9fe
commit d824b45fc0
4 changed files with 262 additions and 43 deletions

View File

@@ -36,13 +36,27 @@ public function store(Request $request): JsonResponse
$validated = $request->validate([
'name' => 'required|string|max:50',
'provider' => 'required|string|in:gemini,claude,openai',
'api_key' => 'required|string|max:255',
'api_key' => 'nullable|string|max:255',
'model' => 'required|string|max:100',
'base_url' => 'nullable|string|max:255|url',
'base_url' => 'nullable|string|max:255',
'description' => 'nullable|string',
'is_active' => 'boolean',
'options' => 'nullable|array',
'options.auth_type' => 'nullable|string|in:api_key,vertex_ai',
'options.project_id' => 'nullable|string|max:100',
'options.region' => 'nullable|string|max:50',
'options.service_account_path' => 'nullable|string|max:500',
]);
// Vertex AI가 아닌 경우 API 키 필수
$authType = $validated['options']['auth_type'] ?? 'api_key';
if ($authType !== 'vertex_ai' && empty($validated['api_key'])) {
return response()->json([
'ok' => false,
'message' => 'API 키를 입력해주세요.',
], 422);
}
// 활성화 시 동일 provider의 다른 설정 비활성화
if ($validated['is_active'] ?? false) {
AiConfig::where('provider', $validated['provider'])
@@ -68,13 +82,27 @@ public function update(Request $request, int $id): JsonResponse
$validated = $request->validate([
'name' => 'required|string|max:50',
'provider' => 'required|string|in:gemini,claude,openai',
'api_key' => 'required|string|max:255',
'api_key' => 'nullable|string|max:255',
'model' => 'required|string|max:100',
'base_url' => 'nullable|string|max:255',
'description' => 'nullable|string',
'is_active' => 'boolean',
'options' => 'nullable|array',
'options.auth_type' => 'nullable|string|in:api_key,vertex_ai',
'options.project_id' => 'nullable|string|max:100',
'options.region' => 'nullable|string|max:50',
'options.service_account_path' => 'nullable|string|max:500',
]);
// Vertex AI가 아닌 경우 API 키 필수
$authType = $validated['options']['auth_type'] ?? 'api_key';
if ($authType !== 'vertex_ai' && empty($validated['api_key'])) {
return response()->json([
'ok' => false,
'message' => 'API 키를 입력해주세요.',
], 422);
}
// 활성화 시 동일 provider의 다른 설정 비활성화
if ($validated['is_active'] ?? false) {
AiConfig::where('provider', $validated['provider'])