- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
// chatbot/rag/debug_search.php
|
|
require_once __DIR__ . '/search.php';
|
|
require_once dirname(__DIR__) . '/../apikey/google_vertex_api.txt'; // Path verify
|
|
|
|
$apiKeyPath = dirname(__DIR__, 2) . '/apikey/google_vertex_api.txt';
|
|
$apiKey = trim(file_get_contents($apiKeyPath));
|
|
|
|
echo "=== RAG Debug Tool ===\n";
|
|
echo "API Key Path: $apiKeyPath\n";
|
|
echo "API Key Length: " . strlen($apiKey) . "\n";
|
|
|
|
$search = new VectorSearch();
|
|
|
|
// Reflect into the object to check vector count
|
|
$reflection = new ReflectionClass($search);
|
|
$property = $reflection->getProperty('vectors');
|
|
$property->setAccessible(true);
|
|
$vectors = $property->getValue($search);
|
|
|
|
echo "Loaded Vectors Count: " . count($vectors) . "\n";
|
|
|
|
if (empty($vectors)) {
|
|
echo "CRITICAL ERROR: No vectors loaded. Check vectors.json format or path.\n";
|
|
exit;
|
|
}
|
|
|
|
$query = "개발 dump";
|
|
echo "Testing Query: '$query'\n";
|
|
|
|
// Run Search
|
|
try {
|
|
$results = $search->search($query, $apiKey, 3);
|
|
echo "Search Result Count: " . count($results) . "\n";
|
|
print_r($results);
|
|
} catch (Exception $e) {
|
|
echo "Search Error: " . $e->getMessage() . "\n";
|
|
}
|
|
?>
|