Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/avvy-lavoienne_sellica-golang.json

1 line
13 KiB
JSON

{"repo": "avvy-lavoienne/sellica-golang", "files": {"frontend/scripts/test-enhanced-response.js": {"249e00cbe37dccd2ae0d923433675d070cff6c94": {"t": 1785745537.8494375, "n": 6181, "h": "f1a019bfa5a2cc7f", "c": "/**\n * Test Script for Enhanced Response System\n * Run this to verify the DeepSeek enhancement integration\n */\n\n// This script can be run in the browser console or Node.js environment\n\nasync function testEnhancedResponse() {\n console.log('🧪 Testing Enhanced Response System...');\n \n try {\n // Test basic query\n const testQuery = \"Berapa total pengajuan salah rekam bulan ini?\";\n console.log(`📝 Testing query: \"${testQuery}\"`);\n \n // Make API call to chat endpoint\n const response = await fetch('/api/chat', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n message: testQuery,\n context: {\n userId: 'test-user',\n sessionId: 'test-session'\n }\n })\n });\n \n if (!response.ok) {\n throw new Error(`API call failed: ${response.status} ${response.statusText}`);\n }\n \n const data = await response.json();\n \n console.log('✅ API Response received:');\n console.log('📊 Response Data:', {\n success: data.success,\n type: data.type,\n contentLength: data.response?.length || 0,\n aiProvider: data.metadata?.aiProvider,\n deepSeekEnhanced: data.metadata?.deepSeekEnhanced,\n confidence: data.metadata?.confidence,\n processingTime: data.metadata?.enhancementMetadata?.processingTime\n });\n \n console.log('📝 Response Content:');\n console.log(data.response);\n \n // Check if enhancement worked\n if (data.metadata?.deepSeekEnhanced) {\n console.log('🎯 ✅ DeepSeek enhancement was applied successfully!');\n \n if (data.metadata?.originalContent) {\n console.log('📈 Enhancement Comparison:');\n console.log(` Original length: ${data.metadata.originalContent.length} chars`);\n console.log(` Enhanced length: ${data.response.length} chars`);\n console.log(` Improvement ratio: ${(data.response.length / data.metadata.originalContent.length).toFixed(2)}x`);\n }\n } else {\n console.log('⚠️ DeepSeek enhancement was not applied (fallback used)');\n \n if (data.metadata?.enhancementMetadata?.error) {\n console.log(`❌ Enhancement error: ${data.metadata.enhancementMetadata.error}`);\n }\n }\n \n return {\n success: true,\n enhanced: data.metadata?.deepSeekEnhanced || false,\n response: data.response,\n metadata: data.metadata\n };\n \n } catch (error) {\n console.error('❌ Test failed:', error);\n return {\n success: false,\n error: error.message\n };\n }\n}\n\n// Test multiple queries\nasync function testMultipleQueries() {\n console.log('🧪 Testing Multiple Queries...');\n \n const testQueries = [\n \"Berapa total pengajuan salah rekam bulan ini?\",\n \"Tampilkan statistik pengguna SELLICA\",\n \"Bagaimana cara menggunakan sistem ini?\",\n \"Cari data dengan NIK 1234567890123456\"\n ];\n \n const results = [];\n \n for (let i = 0; i < testQueries.length; i++) {\n const query = testQueries[i];\n console.log(`\\n📝 Test ${i + 1}/${testQueries.length}: \"${query}\"`);\n \n const result = await testSingleQuery(query);\n results.push({\n query,\n ...result\n });\n \n // Wait between requests to avoid rate limiting\n await new Promise(resolve => setTimeout(resolve, 1000));\n }\n \n // Summary\n console.log('\\n📊 Test Summary:');\n console.log(`Total queries: ${results.length}`);\n console.log(`Successful: ${results.filter(r => r.success).length}`);\n console.log(`Enhanced: ${results.filter(r => r.enhanced).length}`);\n console.log(`Enhancement rate: ${(results.filter(r => r.enhanced).length / results.length * 100).toFixed(1)}%`);\n \n return results;\n}\n\nasync function testSingleQuery(query) {\n try {\n const response = await fetch('/api/chat', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n message: query,\n context: {\n userId: 'test-user',\n sessionId: 'test-session'\n }\n })\n });\n \n if (!response.ok) {\n throw new Error(`API call failed: ${response.status}`);\n }\n \n const data = await response.json();\n \n const enhanced = data.metadata?.deepSeekEnhanced || false;\n console.log(` ${enhanced ? '🎯' : '⚪'} Enhanced: ${enhanced}`);\n console.log(` 📏 Length: ${data.response?.length || 0} chars`);\n \n return {\n success: true,\n enhanced,\n response: data.response,\n metadata: data.metadata\n };\n \n } catch (error) {\n console.error(` ❌ Error: ${error.message}`);\n return {\n success: false,\n enhanced: false,\n error: error.message\n };\n }\n}\n\n// Configuration test\nasync function testConfiguration() {\n console.log('🔧 Testing Configuration...');\n \n // Check environment variables\n const config = {\n deepSeekEnabled: typeof process !== 'undefined' ? \n process.env?.NEXT_PUBLIC_ENABLE_DEEPSEEK_ENHANCEMENT === 'true' : \n 'Unknown (browser environment)',\n deepSeekApiKey: typeof process !== 'undefined' ? \n !!process.env?.DEEPSEEK_API_KEY : \n 'Unknown (browser environment)',\n huggingFaceEnabled: typeof process !== 'undefined' ? \n process.env?.NEXT_PUBLIC_ENABLE_HUGGINGFACE === 'true' : \n 'Unknown (browser environment)',\n tensorFlowEnabled: typeof process !== 'undefined' ? \n process.env?.NEXT_PUBLIC_ENABLE_TENSORFLOW === 'true' : \n 'Unknown (browser environment)'\n };\n \n console.log('📋 Configuration Status:', config);\n \n return config;\n}\n\n// Export functions for use\nif (typeof window !== 'undefined') {\n // Browser environment\n window.testEnhancedResponse = testEnhancedResponse;\n window.testMultipleQueries = testMultipleQueries;\n window.testConfiguration = testConfiguration;\n \n console.log('🎯 Enhanced Response Test Functions Available:');\n console.log(' - testEnhancedResponse()');\n console.log(' - testMultipleQueries()');\n console.log(' - testConfiguration()');\n} else {\n // Node.js environment\n module.exports = {\n testEnhancedResponse,\n testMultipleQueries,\n testConfiguration\n };\n}\n\n// Auto-run configuration test\ntestConfiguration();\n"}, "9fdba125f922461259d08eb160d49a05e3e9daf1": {"t": 1785754009.607932, "n": 6181, "h": "f1a019bfa5a2cc7f", "c": "/**\n * Test Script for Enhanced Response System\n * Run this to verify the DeepSeek enhancement integration\n */\n\n// This script can be run in the browser console or Node.js environment\n\nasync function testEnhancedResponse() {\n console.log('🧪 Testing Enhanced Response System...');\n \n try {\n // Test basic query\n const testQuery = \"Berapa total pengajuan salah rekam bulan ini?\";\n console.log(`📝 Testing query: \"${testQuery}\"`);\n \n // Make API call to chat endpoint\n const response = await fetch('/api/chat', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n message: testQuery,\n context: {\n userId: 'test-user',\n sessionId: 'test-session'\n }\n })\n });\n \n if (!response.ok) {\n throw new Error(`API call failed: ${response.status} ${response.statusText}`);\n }\n \n const data = await response.json();\n \n console.log('✅ API Response received:');\n console.log('📊 Response Data:', {\n success: data.success,\n type: data.type,\n contentLength: data.response?.length || 0,\n aiProvider: data.metadata?.aiProvider,\n deepSeekEnhanced: data.metadata?.deepSeekEnhanced,\n confidence: data.metadata?.confidence,\n processingTime: data.metadata?.enhancementMetadata?.processingTime\n });\n \n console.log('📝 Response Content:');\n console.log(data.response);\n \n // Check if enhancement worked\n if (data.metadata?.deepSeekEnhanced) {\n console.log('🎯 ✅ DeepSeek enhancement was applied successfully!');\n \n if (data.metadata?.originalContent) {\n console.log('📈 Enhancement Comparison:');\n console.log(` Original length: ${data.metadata.originalContent.length} chars`);\n console.log(` Enhanced length: ${data.response.length} chars`);\n console.log(` Improvement ratio: ${(data.response.length / data.metadata.originalContent.length).toFixed(2)}x`);\n }\n } else {\n console.log('⚠️ DeepSeek enhancement was not applied (fallback used)');\n \n if (data.metadata?.enhancementMetadata?.error) {\n console.log(`❌ Enhancement error: ${data.metadata.enhancementMetadata.error}`);\n }\n }\n \n return {\n success: true,\n enhanced: data.metadata?.deepSeekEnhanced || false,\n response: data.response,\n metadata: data.metadata\n };\n \n } catch (error) {\n console.error('❌ Test failed:', error);\n return {\n success: false,\n error: error.message\n };\n }\n}\n\n// Test multiple queries\nasync function testMultipleQueries() {\n console.log('🧪 Testing Multiple Queries...');\n \n const testQueries = [\n \"Berapa total pengajuan salah rekam bulan ini?\",\n \"Tampilkan statistik pengguna SELLICA\",\n \"Bagaimana cara menggunakan sistem ini?\",\n \"Cari data dengan NIK 1234567890123456\"\n ];\n \n const results = [];\n \n for (let i = 0; i < testQueries.length; i++) {\n const query = testQueries[i];\n console.log(`\\n📝 Test ${i + 1}/${testQueries.length}: \"${query}\"`);\n \n const result = await testSingleQuery(query);\n results.push({\n query,\n ...result\n });\n \n // Wait between requests to avoid rate limiting\n await new Promise(resolve => setTimeout(resolve, 1000));\n }\n \n // Summary\n console.log('\\n📊 Test Summary:');\n console.log(`Total queries: ${results.length}`);\n console.log(`Successful: ${results.filter(r => r.success).length}`);\n console.log(`Enhanced: ${results.filter(r => r.enhanced).length}`);\n console.log(`Enhancement rate: ${(results.filter(r => r.enhanced).length / results.length * 100).toFixed(1)}%`);\n \n return results;\n}\n\nasync function testSingleQuery(query) {\n try {\n const response = await fetch('/api/chat', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n message: query,\n context: {\n userId: 'test-user',\n sessionId: 'test-session'\n }\n })\n });\n \n if (!response.ok) {\n throw new Error(`API call failed: ${response.status}`);\n }\n \n const data = await response.json();\n \n const enhanced = data.metadata?.deepSeekEnhanced || false;\n console.log(` ${enhanced ? '🎯' : '⚪'} Enhanced: ${enhanced}`);\n console.log(` 📏 Length: ${data.response?.length || 0} chars`);\n \n return {\n success: true,\n enhanced,\n response: data.response,\n metadata: data.metadata\n };\n \n } catch (error) {\n console.error(` ❌ Error: ${error.message}`);\n return {\n success: false,\n enhanced: false,\n error: error.message\n };\n }\n}\n\n// Configuration test\nasync function testConfiguration() {\n console.log('🔧 Testing Configuration...');\n \n // Check environment variables\n const config = {\n deepSeekEnabled: typeof process !== 'undefined' ? \n process.env?.NEXT_PUBLIC_ENABLE_DEEPSEEK_ENHANCEMENT === 'true' : \n 'Unknown (browser environment)',\n deepSeekApiKey: typeof process !== 'undefined' ? \n !!process.env?.DEEPSEEK_API_KEY : \n 'Unknown (browser environment)',\n huggingFaceEnabled: typeof process !== 'undefined' ? \n process.env?.NEXT_PUBLIC_ENABLE_HUGGINGFACE === 'true' : \n 'Unknown (browser environment)',\n tensorFlowEnabled: typeof process !== 'undefined' ? \n process.env?.NEXT_PUBLIC_ENABLE_TENSORFLOW === 'true' : \n 'Unknown (browser environment)'\n };\n \n console.log('📋 Configuration Status:', config);\n \n return config;\n}\n\n// Export functions for use\nif (typeof window !== 'undefined') {\n // Browser environment\n window.testEnhancedResponse = testEnhancedResponse;\n window.testMultipleQueries = testMultipleQueries;\n window.testConfiguration = testConfiguration;\n \n console.log('🎯 Enhanced Response Test Functions Available:');\n console.log(' - testEnhancedResponse()');\n console.log(' - testMultipleQueries()');\n console.log(' - testConfiguration()');\n} else {\n // Node.js environment\n module.exports = {\n testEnhancedResponse,\n testMultipleQueries,\n testConfiguration\n };\n}\n\n// Auto-run configuration test\ntestConfiguration();\n"}}}}