Files
OpenCode 68a9071cf1 feat: reconcile local master with origin (exa/hot-platform hunters, leaks ledger, latest results)
Local branch had diverged from origin/master (sibling commits on the same base). Rewrote local history linearly on top of origin/master, folding in all local content: exa/hot-platform discovery hunters, leaks ledger, nightly sweep orchestrator, updated .gitignore and skill docs, plus the latest hunt output and vault state. Remote-only files (vault keys, channel scripts) were restored rather than dropped, so the resulting tree is a full union of both sides.
2026-08-07 12:53:47 +08:00

1 line
5.5 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"repo": "ansh2006-dev/resqconnect", "files": {"backend/test-deepseek-connection.js": {"8e5287f5c6055d0904ca86e22eb1f7191d0bcc30": {"t": 1786068272.5417671, "n": 5248, "h": "654563cbb175d4fb", "c": "/**\n * Test utility for DeepSeek API connection\n * \n * Run with: node test-deepseek-connection.js\n */\n\nrequire('dotenv').config();\nconst axios = require('axios');\n\nasync function testDeepSeekConnection() {\n console.log('\\n🔍 TESTING DEEPSEEK API CONNECTION\\n');\n \n // Check environment variables\n const apiKey = process.env.DEEPSEEK_API_KEY;\n const apiUrl = process.env.DEEPSEEK_API_URL || 'https://api.deepseek.ai/v1';\n const useMockData = process.env.USE_MOCK_DATA === 'true';\n \n console.log('Environment Configuration:');\n console.log('------------------------');\n console.log(`API URL: ${apiUrl}`);\n console.log(`API Key configured: ${!!apiKey}`);\n if (apiKey) {\n console.log(`API Key first/last chars: ${apiKey.substring(0, 4)}...${apiKey.substring(apiKey.length - 4)}`);\n } else {\n console.log('⚠️ API Key is not set in .env file');\n }\n console.log(`Using mock data: ${useMockData}`);\n console.log('------------------------\\n');\n \n // Ensure proper endpoint handling\n let baseUrl = apiUrl;\n let endpointPrefix = '';\n \n // Check if the API URL already contains /v1\n if (!apiUrl.includes('/v1')) {\n baseUrl = apiUrl;\n endpointPrefix = '/v1';\n console.log(`Adding /v1 prefix to endpoints since it's not in the base URL`);\n } else {\n console.log(`Using endpoints without /v1 prefix since it's already in the base URL`);\n }\n \n console.log(`Base URL: ${baseUrl}`);\n console.log(`Endpoint prefix: ${endpointPrefix || '(none)'}`);\n console.log('------------------------\\n');\n \n if (useMockData) {\n console.log('ℹ️ Mock data is enabled, skipping actual API connection test');\n console.log('To test the actual API connection, set USE_MOCK_DATA=false in .env\\n');\n return;\n }\n \n if (!apiKey || apiKey === 'your_deepseek_api_key_here') {\n console.log('❌ No valid API key found. Please set DEEPSEEK_API_KEY in your .env file');\n return;\n }\n \n // Create axios client for DeepSeek\n const client = axios.create({\n baseURL: baseUrl,\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${apiKey}`\n },\n timeout: 15000 // 15 second timeout\n });\n \n // Test endpoint access\n console.log('Testing connection to DeepSeek API...');\n \n try {\n console.log(`GET ${baseUrl}/models`);\n const response = await client.get('/models');\n \n console.log('✅ Connection successful!');\n console.log('Status:', response.status);\n console.log('\\nAvailable models:');\n \n if (response.data.data && Array.isArray(response.data.data)) {\n // OpenAI-compatible format\n response.data.data.forEach(model => {\n console.log(`- ${model.id}`);\n });\n } else {\n // Just display the raw data\n console.log(JSON.stringify(response.data, null, 2));\n }\n \n // Test a simple completion\n console.log('\\nTesting a simple completion...');\n \n const completionResponse = await client.post('/chat/completions', {\n model: 'deepseek-chat',\n messages: [\n { role: 'system', content: 'You are a helpful assistant.' },\n { role: 'user', content: 'Say hello!' }\n ],\n max_tokens: 100\n });\n \n console.log('\\n✅ Chat completion successful!');\n console.log('Response:');\n if (completionResponse.data.choices && completionResponse.data.choices[0].message) {\n console.log(completionResponse.data.choices[0].message.content);\n } else {\n console.log(JSON.stringify(completionResponse.data, null, 2));\n }\n \n } catch (error) {\n console.log('❌ Connection failed');\n console.error('Error details:');\n \n if (error.response) {\n // The request was made and the server responded with a status code\n console.error('Status:', error.response.status);\n console.error('Response:', JSON.stringify(error.response.data, null, 2));\n \n if (error.response.status === 401) {\n console.error('\\n⚠️ Authentication error: Your API key appears to be invalid.');\n console.error('Please check your DEEPSEEK_API_KEY in the .env file.');\n } else if (error.response.status === 404) {\n console.error('\\n⚠️ Endpoint not found: The API endpoint may have changed.');\n console.error('Please check your DEEPSEEK_API_URL in the .env file.');\n }\n } else if (error.request) {\n // The request was made but no response was received\n console.error('No response received. The service may be down or network issues.');\n console.error('Request details:', error.request._currentUrl);\n } else {\n // Something happened in setting up the request\n console.error('Error setting up request:', error.message);\n }\n \n console.error('\\nTroubleshooting tips:');\n console.error('1. Verify your API key is correct and active');\n console.error('2. Check if the DeepSeek API is experiencing outages');\n console.error('3. Ensure your network can reach the DeepSeek API');\n console.error('4. Check if you have proper firewall/proxy settings');\n }\n}\n\n// Run the test\ntestDeepSeekConnection()\n .then(() => {\n console.log('\\nTest completed. Exit with Ctrl+C if the process doesn\\'t terminate automatically.');\n })\n .catch(err => {\n console.error('Unhandled error during test:', err);\n }); "}}}}