File size: 6,067 Bytes
029739a
 
 
153831b
 
 
 
bed6e0a
153831b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bed6e0a
153831b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bed6e0a
77357c2
153831b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bed6e0a
 
77357c2
153831b
 
 
 
 
 
 
bed6e0a
153831b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bed6e0a
153831b
bed6e0a
153831b
 
 
 
 
 
 
 
 
bed6e0a
153831b
 
 
 
029739a
153831b
 
 
 
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- ... (previous head content remains the same) -->
</head>
<body class="bg-white dark:bg-dark text-gray-900 dark:text-gray-100 min-h-screen">
    <!-- ... (previous body content remains the same until the script section) -->
    <script>
        // ... (previous code remains the same until the generateCode function)

        async function generateCode() {
            try {
                // Show loading state
                appRequirements.classList.add('hidden');
                codeGeneration.classList.remove('hidden');
                generationLoading.classList.remove('hidden');
                generationResults.classList.add('hidden');
                state.currentView = 'code-generation';

                // Build the prompt
                const techList = state.technologies.length > 0 
                    ? `using ${state.technologies.join(', ')}` 
                    : '';
                
                const appTypeText = Array.from(appTypeButtons)
                    .find(btn => btn.getAttribute('data-type') === state.appType)
                    .textContent.trim();
                    
                state.originalPrompt = `
Create a ${appTypeText} application named "${state.appName}" ${techList}. 
Requirements: ${state.appDescription}

Respond with:
1. Complete, ready-to-run code that works in a browser
2. Only use technologies that work in a standard web browser without backend dependencies
3. Make the code visually appealing with good UI/UX
4. Include detailed comments
5. Return ONLY the complete code, no explanations or additional text
`;

                // Get API key from user
                const apiKey = prompt('Please enter your DeepSeek API key:');
                if (!apiKey) return;

                // Make API call to DeepSeek
                const response = await fetch('https://api.boldapps.ai/v1/chat/completions', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': `Bearer ${apiKey}`
                    },
                    body: JSON.stringify({
                        model: 'deepseek-ai/DeepSeek-R1-Distill-Qwen-32B',
                        messages: [{
                            role: 'user',
                            content: state.originalPrompt
                        }],
                        temperature: 0.7,
                        max_tokens: 4096
                    })
                });

                const data = await response.json();
                
                if (data.error) {
                    showError(data.error.message);
                    return;
                }

                const code = data.choices[0].message.content;

                // Display code and preview
                displayGeneratedCode(code);
                
                // Create deployment instructions
                createDeploymentInstructions();
                
                // Show results
                generationLoading.classList.add('hidden');
                generationResults.classList.remove('hidden');
                
                // Try to create a preview
                tryCreatePreview(code);

            } catch (error) {
                showError("An error occurred: " + error.message);
            }
        }

        // Modify submitModification function to use DeepSeek API
        submitModification.addEventListener('click', async () => {
            const modificationRequest = document.getElementById('modification-request').value.trim();
            
            if (!modificationRequest) {
                alert('Please describe the changes you want to make');
                return;
            }
            
            // Show loading
            modificationForm.classList.add('hidden');
            generationResults.classList.add('hidden');
            generationLoading.classList.remove('hidden');
            
            try {
                // Get API key from user
                const apiKey = prompt('Please enter your DeepSeek API key:');
                if (!apiKey) return;

                // Make API call to DeepSeek
                const response = await fetch('https://api.boldapps.ai/v1/chat/completions', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': `Bearer ${apiKey}`
                    },
                    body: JSON.stringify({
                        model: 'deepseek-ai/DeepSeek-R1-Distill-Qwen-32B',
                        messages: [{
                            role: 'user',
                            content: `
I have the following code for a ${state.appType} app named "${state.appName}":

\`\`\`
${state.generatedCode}
\`\`\`

Please modify the code according to this request: "${modificationRequest}"

Return ONLY the complete modified code, no explanations or additional text.
`
                        }],
                        temperature: 0.7,
                        max_tokens: 4096
                    })
                });

                const data = await response.json();
                
                if (data.error) {
                    showError(data.error.message);
                    return;
                }

                const modifiedCode = data.choices[0].message.content;

                // Display code and preview
                displayGeneratedCode(modifiedCode);
                
                // Try to create a preview
                tryCreatePreview(modifiedCode);
                
                // Show results
                generationLoading.classList.add('hidden');
                generationResults.classList.remove('hidden');

            } catch (error) {
                showError("An error occurred: " + error.message);
            }
        });

        // ... (rest of the code remains the same)
    </script>
</body>
</html>