- Rename all tables with 5Why_ prefix for namespace isolation - Update models: User.js, Analysis.js, AuditLog.js - Update routes: llmConfig.js - Update scripts: seed-test-users.js, add-deepseek-config.js, add-ollama-config.js - Add migrate-table-prefix.js script for database migration - Update db_schema.sql with new table names - Update views: 5Why_user_analysis_stats, 5Why_recent_analyses Tables renamed: - users -> 5Why_users - analyses -> 5Why_analyses - analysis_perspectives -> 5Why_analysis_perspectives - analysis_whys -> 5Why_analysis_whys - llm_configs -> 5Why_llm_configs - system_settings -> 5Why_system_settings - audit_logs -> 5Why_audit_logs - sessions -> 5Why_sessions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
89 lines
3.0 KiB
JavaScript
89 lines
3.0 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Add DeepSeek LLM Configuration
|
|
* This script adds a DeepSeek configuration to the llm_configs table
|
|
*/
|
|
|
|
import { pool, query } from '../config.js';
|
|
import dotenv from 'dotenv';
|
|
|
|
dotenv.config();
|
|
|
|
async function addDeepSeekConfig() {
|
|
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
console.log(' Adding DeepSeek LLM Configuration');
|
|
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
|
|
try {
|
|
// Check if DeepSeek config already exists
|
|
const existing = await query(
|
|
`SELECT id FROM 5Why_llm_configs WHERE provider = 'DeepSeek' LIMIT 1`
|
|
);
|
|
|
|
if (existing.length > 0) {
|
|
console.log('✅ DeepSeek configuration already exists (ID:', existing[0].id, ')');
|
|
console.log(' Skipping...\n');
|
|
return;
|
|
}
|
|
|
|
// Get API key from environment or leave empty
|
|
const apiKey = process.env.DEEPSEEK_API_KEY || '';
|
|
|
|
if (!apiKey) {
|
|
console.log('⚠️ Warning: DEEPSEEK_API_KEY not found in .env');
|
|
console.log(' You will need to add the API key in the admin panel\n');
|
|
}
|
|
|
|
// First, deactivate all existing configs
|
|
await query('UPDATE 5Why_llm_configs SET is_active = 0');
|
|
|
|
// Insert DeepSeek configuration
|
|
const result = await query(
|
|
`INSERT INTO 5Why_llm_configs
|
|
(provider, api_url, api_key, model_name, temperature, max_tokens, timeout, is_active)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
[
|
|
'DeepSeek',
|
|
process.env.DEEPSEEK_API_URL || 'https://api.deepseek.com',
|
|
apiKey || null,
|
|
process.env.DEEPSEEK_MODEL || 'deepseek-chat',
|
|
0.7,
|
|
6000,
|
|
120000,
|
|
1 // Set as active
|
|
]
|
|
);
|
|
|
|
console.log('✅ DeepSeek configuration added successfully!');
|
|
console.log(' Config ID:', result.insertId);
|
|
console.log(' Provider: DeepSeek');
|
|
console.log(' Model: deepseek-chat');
|
|
console.log(' Status: Active\n');
|
|
|
|
console.log('📝 Next steps:');
|
|
console.log(' 1. Go to Admin Panel > LLM 配置');
|
|
console.log(' 2. Add your DeepSeek API key if not already set');
|
|
console.log(' 3. Test the connection');
|
|
console.log(' 4. Start using DeepSeek for 5 Why analysis!\n');
|
|
|
|
} catch (error) {
|
|
console.error('❌ Error adding DeepSeek configuration:', error.message);
|
|
process.exit(1);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
}
|
|
|
|
// Run the script
|
|
addDeepSeekConfig()
|
|
.then(() => {
|
|
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
console.log(' Configuration Complete');
|
|
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
process.exit(0);
|
|
})
|
|
.catch((error) => {
|
|
console.error('Fatal error:', error);
|
|
process.exit(1);
|
|
});
|