-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-env.js
More file actions
71 lines (55 loc) · 2.17 KB
/
Copy pathsetup-env.js
File metadata and controls
71 lines (55 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const readline = require('readline');
console.log('🔑 LoanOfficerAI - Environment Setup');
console.log('====================================');
const envPath = path.join(__dirname, 'server', '.env');
const envExamplePath = path.join(__dirname, 'server', 'env.example');
// Check if .env already exists
if (fs.existsSync(envPath)) {
console.log('✅ Environment file already exists at server/.env');
console.log('💡 To update your OpenAI API key, edit server/.env manually');
process.exit(0);
}
// Read the example file
if (!fs.existsSync(envExamplePath)) {
console.error('❌ env.example file not found');
process.exit(1);
}
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
console.log('');
console.log('To enable full chatbot functionality, you need an OpenAI API key.');
console.log('Get one from: https://platform.openai.com/api-keys');
console.log('');
rl.question('Enter your OpenAI API key (or press Enter to use placeholder): ', (apiKey) => {
const finalApiKey = apiKey.trim() || 'sk-proj-enter-your-real-openai-api-key-here';
// Read example file and replace the API key
let envContent = fs.readFileSync(envExamplePath, 'utf8');
envContent = envContent.replace('your_openai_api_key_here', finalApiKey);
// Add database configuration
envContent += `
# Database Configuration (optional - defaults to JSON files)
USE_DATABASE=false
DB_SERVER=localhost
DB_NAME=LoanOfficerAI_MCP_POC
DB_USER=sa
DB_PASSWORD=YourStrong@Passw0rd
DB_PORT=1433`;
// Write the .env file
fs.writeFileSync(envPath, envContent);
console.log('');
console.log('✅ Environment file created successfully!');
console.log('📁 Location: server/.env');
if (finalApiKey === 'sk-proj-enter-your-real-openai-api-key-here') {
console.log('');
console.log('⚠️ Remember to replace the placeholder API key in server/.env');
console.log(' with your real OpenAI API key for full functionality');
}
console.log('');
console.log('🚀 Next step: npm start');
rl.close();
});