초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
61
ocr/test_models.php
Normal file
61
ocr/test_models.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
// Claude API 모델 테스트
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
if ($level > 5) {
|
||||
die(json_encode(['error' => '접근 권한이 없습니다.']));
|
||||
}
|
||||
|
||||
// API 키 읽기
|
||||
$apiKeyFile = $_SERVER['DOCUMENT_ROOT'] . '/apikey/claude_api.txt';
|
||||
$apiKey = trim(file_get_contents($apiKeyFile));
|
||||
|
||||
// 테스트할 모델들
|
||||
$models = [
|
||||
'claude-3-5-sonnet-20241022',
|
||||
'claude-3-5-sonnet-20240620',
|
||||
'claude-3-opus-20240229',
|
||||
'claude-3-sonnet-20240229',
|
||||
'claude-3-haiku-20240307'
|
||||
];
|
||||
|
||||
$results = [];
|
||||
|
||||
foreach ($models as $model) {
|
||||
$requestBody = [
|
||||
'model' => $model,
|
||||
'max_tokens' => 100,
|
||||
'messages' => [
|
||||
[
|
||||
'role' => 'user',
|
||||
'content' => 'Hello, just testing. Reply with OK.'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$ch = curl_init('https://api.anthropic.com/v1/messages');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'x-api-key: ' . $apiKey,
|
||||
'anthropic-version: 2023-06-01'
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestBody));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
$responseData = json_decode($response, true);
|
||||
|
||||
$results[$model] = [
|
||||
'status' => $httpCode,
|
||||
'success' => ($httpCode === 200),
|
||||
'error' => isset($responseData['error']) ? $responseData['error']['message'] : null,
|
||||
'response' => $httpCode === 200 ? 'OK' : null
|
||||
];
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($results, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||
Reference in New Issue
Block a user