style: Pint 포맷팅 적용
This commit is contained in:
@@ -109,7 +109,7 @@ public function processAudio(AiVoiceRecording $recording, string $audioBase64, i
|
||||
Log::info('AiVoiceRecording STT 결과', ['recording_id' => $recording->id, 'transcript_length' => strlen($transcript ?? ''), 'transcript_preview' => mb_substr($transcript ?? '', 0, 100)]);
|
||||
|
||||
if (! $transcript) {
|
||||
throw new \Exception('음성 인식 실패: STT 결과가 비어있습니다 (transcript=' . var_export($transcript, true) . ')');
|
||||
throw new \Exception('음성 인식 실패: STT 결과가 비어있습니다 (transcript='.var_export($transcript, true).')');
|
||||
}
|
||||
|
||||
// STT 토큰 사용량 기록
|
||||
@@ -154,7 +154,7 @@ public function processUploadedFile(AiVoiceRecording $recording, UploadedFile $f
|
||||
|
||||
// 임시 저장
|
||||
$tempPath = $file->store('temp', 'local');
|
||||
$fullPath = storage_path('app/' . $tempPath);
|
||||
$fullPath = storage_path('app/'.$tempPath);
|
||||
|
||||
// 파일 크기로 대략적인 재생 시간 추정 (12KB/초 기준)
|
||||
$fileSize = $file->getSize();
|
||||
@@ -240,6 +240,7 @@ private function analyzeWithGemini(string $transcript): ?string
|
||||
|
||||
if (! $config) {
|
||||
Log::warning('Gemini API 설정이 없습니다.');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -279,19 +280,21 @@ private function callVertexAiApi(AiConfig $config, string $prompt): ?string
|
||||
|
||||
if (! $projectId) {
|
||||
Log::error('Vertex AI 프로젝트 ID가 설정되지 않았습니다.');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$accessToken = $this->getAccessToken($config);
|
||||
if (! $accessToken) {
|
||||
Log::error('Google Cloud 인증 실패');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$url = "https://{$region}-aiplatform.googleapis.com/v1/projects/{$projectId}/locations/{$region}/publishers/google/models/{$model}:generateContent";
|
||||
|
||||
return $this->callGeminiApi($url, $prompt, [
|
||||
'Authorization' => 'Bearer ' . $accessToken,
|
||||
'Authorization' => 'Bearer '.$accessToken,
|
||||
'Content-Type' => 'application/json',
|
||||
], true);
|
||||
}
|
||||
@@ -329,6 +332,7 @@ private function callGeminiApi(string $url, string $prompt, array $headers, bool
|
||||
'status' => $response->status(),
|
||||
'body' => $response->body(),
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -340,6 +344,7 @@ private function callGeminiApi(string $url, string $prompt, array $headers, bool
|
||||
return $result['candidates'][0]['content']['parts'][0]['text'] ?? null;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Gemini API 예외', ['error' => $e->getMessage()]);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -367,12 +372,14 @@ private function getAccessToken(AiConfig $config): ?string
|
||||
|
||||
if (! $serviceAccountPath) {
|
||||
Log::error('Service account file not found', ['tried_paths' => $possiblePaths]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$serviceAccount = json_decode(file_get_contents($serviceAccountPath), true);
|
||||
if (! $serviceAccount) {
|
||||
Log::error('Service account JSON parse failed');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -389,11 +396,12 @@ private function getAccessToken(AiConfig $config): ?string
|
||||
$privateKey = openssl_pkey_get_private($serviceAccount['private_key']);
|
||||
if (! $privateKey) {
|
||||
Log::error('Failed to load private key');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
openssl_sign($jwtHeader . '.' . $jwtClaim, $signature, $privateKey, OPENSSL_ALGO_SHA256);
|
||||
$jwt = $jwtHeader . '.' . $jwtClaim . '.' . $this->base64UrlEncode($signature);
|
||||
openssl_sign($jwtHeader.'.'.$jwtClaim, $signature, $privateKey, OPENSSL_ALGO_SHA256);
|
||||
$jwt = $jwtHeader.'.'.$jwtClaim.'.'.$this->base64UrlEncode($signature);
|
||||
|
||||
try {
|
||||
$response = Http::asForm()->post('https://oauth2.googleapis.com/token', [
|
||||
@@ -409,9 +417,11 @@ private function getAccessToken(AiConfig $config): ?string
|
||||
'status' => $response->status(),
|
||||
'body' => $response->body(),
|
||||
]);
|
||||
|
||||
return null;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('OAuth token request exception', ['error' => $e->getMessage()]);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user