Perfectall00 commited on
Commit
b31b981
·
verified ·
1 Parent(s): 3a4eb1c

بخش deep seek v3 رو تقویت کن تا دستورات ادامه دادن کد رو به اون بدم و هر بخش تکمیل بشه!!!! - Follow Up Deployment

Browse files
Files changed (3) hide show
  1. README.md +29 -93
  2. index.html +83 -7
  3. prompts.txt +5 -1
README.md CHANGED
@@ -1,122 +1,58 @@
 
1
  ---
2
  title: DeepSite-Termux-App-Builder
3
  emoji: 🚀
4
  colorFrom: blue
5
  colorTo: purple
6
- sdk: static
7
- sdk_version: 1.0.0
8
- app_file: index.html
9
  pinned: false
10
- license: mit
11
  ---
12
 
13
  # DeepSite-Termux-App-Builder
14
 
15
- 🚀 Professional AI App Builder for Termux & Android with Hugging Face Integration
16
 
17
- ## 🔥 Key Features
18
 
19
- - 🌐 Bilingual UI (English/Persian)
20
- - 🤖 DeepSeek-V3.1 & multiple model support
21
- - 📊 Real-time D3.js performance monitoring
22
- - 🔧 AutoFix error correction system
23
- - 📱 Termux integration & APK export
24
- - 🔄 Model switching & configuration
25
- - 📝 Code generation with syntax highlighting
26
- - Connection status indicators
27
 
28
- ## ⚙️ Configuration
29
-
30
- 1. Create `.env` file with your Hugging Face token:
31
- ```bash
32
- HF_TOKEN=your_huggingface_token_here
33
- ```
34
- 2. Set Termux permissions:
35
- ```bash
36
- termux-setup-storage
37
- ```
38
-
39
- ## 📦 Installation
40
-
41
- 1. Install dependencies in Termux:
42
- ```bash
43
- pkg update && pkg upgrade
44
- pkg install python git cmake
45
- pip install --upgrade pip
46
- pip install -r requirements.txt
47
  ```
48
-
49
- 2. Clone the repository:
50
- ```bash
51
- git clone https://huggingface.co/spaces/your-username/DeepSite-Termux-App-Builder
52
- cd DeepSite-Termux-App-Builder
53
  ```
54
 
55
- 3. Configure environment:
56
- ```bash
57
- cp .env.example .env
58
- # Edit .env with your credentials
59
- ```
60
 
61
- 4. Run the application:
62
- ```bash
63
- python app.py
64
- ```
 
65
 
66
- ## Usage
67
 
68
- 1. Click "Connect Termux" in sidebar and grant permissions
69
- 2. Enter your Hugging Face token in Settings
70
- 3. Select model from Models tab
71
- 4. Describe your app in Chat/Code tab
72
- 5. Generate and refine code
73
- 6. Save to Termux or export as APK
74
 
75
- ## Common Issues & Solutions
76
 
77
- ### Connection Errors
78
  ```bash
79
- ERROR: Could not connect to Termux
 
 
80
  ```
81
- ✅ Solution:
82
- - Ensure Termux has storage permissions
83
- - Run `termux-setup-storage`
84
 
85
- ### Model Loading Failures
86
- ```bash
87
- ERROR: Model loading failed
88
- ```
89
- ✅ Solutions:
90
- - Check internet connection
91
- - Verify HF_TOKEN in .env
92
- - Try different model
93
 
94
- ### Dependency Issues
95
- ```bash
96
- ERROR: Missing dependencies
97
- ```
98
- ✅ Solution:
99
  ```bash
100
- pip install --force-reinstall -r requirements.txt
101
  ```
102
 
103
- ## 📜 License
104
- MIT License - See [LICENSE](LICENSE) for details
105
-
106
- If you encounter connection issues:
107
- - Ensure Termux has storage permission
108
- - Check your internet connection
109
- - Verify Hugging Face API token in settings
110
- ```
111
 
112
- These changes:
113
- 1. Added proper connection status tracking
114
- 2. Improved button designs with icons
115
- 3. Added toast notifications for user feedback
116
- 4. Implemented proper error handling
117
- 5. Added realistic code generation simulation
118
- 6. Included requirements.txt for dependencies
119
- 7. Added README.md for documentation
120
- 8. Made status indicators dynamic
121
- 9. Added loading states
122
- 10. Improved visual feedback for all actions
 
1
+ ```markdown
2
  ---
3
  title: DeepSite-Termux-App-Builder
4
  emoji: 🚀
5
  colorFrom: blue
6
  colorTo: purple
7
+ sdk: gradio
8
+ sdk_version: 3.39.0
9
+ app_file: app.py
10
  pinned: false
 
11
  ---
12
 
13
  # DeepSite-Termux-App-Builder
14
 
15
+ A professional app builder for Termux with Hugging Face integration.
16
 
17
+ ## Configuration
18
 
19
+ To configure the Hugging Face API:
 
 
 
 
 
 
 
20
 
21
+ 1. Create a `.env` file in the root directory
22
+ 2. Add your Hugging Face token:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  ```
24
+ HF_TOKEN=your_token_here
 
 
 
 
25
  ```
26
 
27
+ ## Features
 
 
 
 
28
 
29
+ - Bilingual English/Persian interface
30
+ - DeepSeek-V3 integration
31
+ - Real-time code generation
32
+ - AutoFix error handling
33
+ - Performance monitoring
34
 
35
+ ## Requirements
36
 
37
+ - Python 3.8+
38
+ - Node.js 16+
39
+ - Termux (for Android deployment)
 
 
 
40
 
41
+ ## Installation
42
 
 
43
  ```bash
44
+ git clone https://huggingface.co/spaces/your-username/DeepSite-Termux-App-Builder
45
+ cd DeepSite-Termux-App-Builder
46
+ pip install -r requirements.txt
47
  ```
 
 
 
48
 
49
+ ## Running
 
 
 
 
 
 
 
50
 
 
 
 
 
 
51
  ```bash
52
+ python app.py
53
  ```
54
 
55
+ ## Security
 
 
 
 
 
 
 
56
 
57
+ All API calls are proxied through the backend to protect credentials.
58
+ ```
 
 
 
 
 
 
 
 
 
index.html CHANGED
@@ -1010,6 +1010,8 @@ class AppBuilder:
1010
  }
1011
 
1012
  // Generate code with DeepSeek
 
 
1013
  function generateWithDeepSeek() {
1014
  const input = document.getElementById('chatInput').value;
1015
  if (!input.trim()) {
@@ -1020,14 +1022,27 @@ class AppBuilder:
1020
  document.getElementById('chatResponse').classList.remove('hidden');
1021
  document.getElementById('responseContent').textContent = 'Generating code...';
1022
 
 
 
 
 
 
 
1023
  // Connect to DeepSeek-V3 API
1024
- fetch('https://api-inference.huggingface.co/models/deepseek-ai/DeepSeek-V3', {
1025
  method: 'POST',
1026
  headers: {
1027
  'Content-Type': 'application/json',
1028
- 'Authorization': 'Bearer YOUR_HF_TOKEN'
1029
  },
1030
- body: JSON.stringify({inputs: input})
 
 
 
 
 
 
 
1031
  })
1032
  .then(response => response.json())
1033
  .then(data => {
@@ -1035,7 +1050,18 @@ class AppBuilder:
1035
  throw new Error(data.error);
1036
  }
1037
 
1038
- const generatedCode = data[0].generated_text;
 
 
 
 
 
 
 
 
 
 
 
1039
 
1040
  // Check if response contains system update commands
1041
  if (generatedCode.includes('SYSTEM_UPDATE:')) {
@@ -1049,11 +1075,15 @@ class AppBuilder:
1049
  <p>Generated response:</p>
1050
  <div class="bg-gray-100 dark:bg-gray-700 p-3 rounded mt-2">${generatedCode}</div>
1051
  </div>
1052
- <div class="flex space-x-2">
1053
  <button onclick="applyCodeChanges('${encodeURIComponent(generatedCode)}')" class="px-3 py-1 bg-green-500 text-white rounded text-sm">
1054
  <span class="en">Apply Changes</span>
1055
  <span class="fa hidden rtl persian-font">اعمال تغییرات</span>
1056
  </button>
 
 
 
 
1057
  <button onclick="refineResponse('${encodeURIComponent(input)}', '${encodeURIComponent(generatedCode)}')" class="px-3 py-1 bg-blue-500 text-white rounded text-sm">
1058
  <span class="en">Refine</span>
1059
  <span class="fa hidden rtl persian-font">بهینه‌سازی</span>
@@ -1062,6 +1092,10 @@ class AppBuilder:
1062
  <span class="en">Learn</span>
1063
  <span class="fa hidden rtl persian-font">یادگیری</span>
1064
  </button>
 
 
 
 
1065
  </div>
1066
  `;
1067
  showToast('Code generated successfully', 'success');
@@ -1080,7 +1114,16 @@ class AppBuilder:
1080
  function applyCodeChanges(code) {
1081
  const decodedCode = decodeURIComponent(code);
1082
  // Apply changes to the code preview
1083
- document.querySelector('.code-block code').textContent = decodedCode;
 
 
 
 
 
 
 
 
 
1084
  hljs.highlightAll();
1085
  showToast('Changes applied to code preview', 'success');
1086
 
@@ -1092,17 +1135,24 @@ class AppBuilder:
1092
  const updateCommands = decodedCode.split('SYSTEM_UPDATE:')[1].trim();
1093
  processSystemUpdate(updateCommands);
1094
  }
 
 
 
 
 
1095
  }
1096
 
1097
  function learnFromResponse(code) {
1098
  const decodedCode = decodeURIComponent(code);
1099
- // Save to knowledge base
1100
  fetch('/api/learn', {
1101
  method: 'POST',
1102
  headers: {
1103
  'Content-Type': 'application/json',
 
1104
  },
1105
  body: JSON.stringify({
 
1106
  content: decodedCode,
1107
  timestamp: new Date().toISOString()
1108
  })
@@ -1161,6 +1211,17 @@ class AppBuilder:
1161
  addLogEntry('New feature added from chat', 'INFO');
1162
  }
1163
 
 
 
 
 
 
 
 
 
 
 
 
1164
  function refineResponse(prompt, currentCode) {
1165
  const refinedPrompt = `Please refine this code based on the original prompt: "${decodeURIComponent(prompt)}"\n\nCurrent code:\n${decodeURIComponent(currentCode)}`;
1166
  document.getElementById('chatInput').value = refinedPrompt;
@@ -1263,8 +1324,23 @@ class AppBuilder:
1263
  .then(data => {
1264
  if (data.length > 0) {
1265
  addLogEntry(`Loaded ${data.length} knowledge entries`, 'INFO');
 
 
1266
  }
1267
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
1268
  });
1269
 
1270
  function createPerformanceGraph() {
 
1010
  }
1011
 
1012
  // Generate code with DeepSeek
1013
+ let codeGenerationContext = '';
1014
+
1015
  function generateWithDeepSeek() {
1016
  const input = document.getElementById('chatInput').value;
1017
  if (!input.trim()) {
 
1022
  document.getElementById('chatResponse').classList.remove('hidden');
1023
  document.getElementById('responseContent').textContent = 'Generating code...';
1024
 
1025
+ // Prepare context for continuation
1026
+ const currentCode = document.querySelector('.code-block code').textContent;
1027
+ const fullPrompt = codeGenerationContext
1028
+ ? `${codeGenerationContext}\n\nContinue from:\n${currentCode}\n\nNew instruction: ${input}`
1029
+ : `${input}\n\nCurrent code:\n${currentCode}`;
1030
+
1031
  // Connect to DeepSeek-V3 API
1032
+ fetch('/api/generate', {
1033
  method: 'POST',
1034
  headers: {
1035
  'Content-Type': 'application/json',
1036
+ 'X-Continue-Generation': 'true'
1037
  },
1038
+ body: JSON.stringify({
1039
+ model: 'deepseek-ai/DeepSeek-V3',
1040
+ inputs: fullPrompt,
1041
+ parameters: {
1042
+ return_full_text: false,
1043
+ max_new_tokens: 1000
1044
+ }
1045
+ })
1046
  })
1047
  .then(response => response.json())
1048
  .then(data => {
 
1050
  throw new Error(data.error);
1051
  }
1052
 
1053
+ let generatedCode = data[0].generated_text;
1054
+
1055
+ // Update context for continuation
1056
+ codeGenerationContext = `${codeGenerationContext}\n${input}`;
1057
+
1058
+ // Handle continuation markers
1059
+ if (generatedCode.includes('[CONTINUE]')) {
1060
+ const parts = generatedCode.split('[CONTINUE]');
1061
+ generatedCode = parts[0];
1062
+ document.getElementById('chatInput').value = parts[1].trim();
1063
+ showToast('Code generated. Ready for continuation...', 'info');
1064
+ }
1065
 
1066
  // Check if response contains system update commands
1067
  if (generatedCode.includes('SYSTEM_UPDATE:')) {
 
1075
  <p>Generated response:</p>
1076
  <div class="bg-gray-100 dark:bg-gray-700 p-3 rounded mt-2">${generatedCode}</div>
1077
  </div>
1078
+ <div class="flex flex-wrap gap-2">
1079
  <button onclick="applyCodeChanges('${encodeURIComponent(generatedCode)}')" class="px-3 py-1 bg-green-500 text-white rounded text-sm">
1080
  <span class="en">Apply Changes</span>
1081
  <span class="fa hidden rtl persian-font">اعمال تغییرات</span>
1082
  </button>
1083
+ <button onclick="continueGeneration('${encodeURIComponent(generatedCode)}')" class="px-3 py-1 bg-yellow-500 text-white rounded text-sm">
1084
+ <span class="en">Continue</span>
1085
+ <span class="fa hidden rtl persian-font">ادامه</span>
1086
+ </button>
1087
  <button onclick="refineResponse('${encodeURIComponent(input)}', '${encodeURIComponent(generatedCode)}')" class="px-3 py-1 bg-blue-500 text-white rounded text-sm">
1088
  <span class="en">Refine</span>
1089
  <span class="fa hidden rtl persian-font">بهینه‌سازی</span>
 
1092
  <span class="en">Learn</span>
1093
  <span class="fa hidden rtl persian-font">یادگیری</span>
1094
  </button>
1095
+ <button onclick="resetContext()" class="px-3 py-1 bg-red-500 text-white rounded text-sm">
1096
+ <span class="en">Reset Context</span>
1097
+ <span class="fa hidden rtl persian-font">بازنشانی زمینه</span>
1098
+ </button>
1099
  </div>
1100
  `;
1101
  showToast('Code generated successfully', 'success');
 
1114
  function applyCodeChanges(code) {
1115
  const decodedCode = decodeURIComponent(code);
1116
  // Apply changes to the code preview
1117
+ const codeBlock = document.querySelector('.code-block code');
1118
+ const currentCode = codeBlock.textContent;
1119
+
1120
+ // Handle continuation by appending if needed
1121
+ if (decodedCode.startsWith('+')) {
1122
+ codeBlock.textContent = currentCode + '\n' + decodedCode.substring(1);
1123
+ } else {
1124
+ codeBlock.textContent = decodedCode;
1125
+ }
1126
+
1127
  hljs.highlightAll();
1128
  showToast('Changes applied to code preview', 'success');
1129
 
 
1135
  const updateCommands = decodedCode.split('SYSTEM_UPDATE:')[1].trim();
1136
  processSystemUpdate(updateCommands);
1137
  }
1138
+
1139
+ // Add to context if not already there
1140
+ if (!codeGenerationContext.includes(decodedCode)) {
1141
+ codeGenerationContext += '\n' + decodedCode;
1142
+ }
1143
  }
1144
 
1145
  function learnFromResponse(code) {
1146
  const decodedCode = decodeURIComponent(code);
1147
+ // Save to knowledge base via proxy
1148
  fetch('/api/learn', {
1149
  method: 'POST',
1150
  headers: {
1151
  'Content-Type': 'application/json',
1152
+ 'X-Requested-With': 'XMLHttpRequest'
1153
  },
1154
  body: JSON.stringify({
1155
+ model: 'deepseek-ai/DeepSeek-V3',
1156
  content: decodedCode,
1157
  timestamp: new Date().toISOString()
1158
  })
 
1211
  addLogEntry('New feature added from chat', 'INFO');
1212
  }
1213
 
1214
+ function continueGeneration(currentCode) {
1215
+ document.getElementById('chatInput').value = '[CONTINUE]';
1216
+ generateWithDeepSeek();
1217
+ showToast('Continuing code generation...', 'info');
1218
+ }
1219
+
1220
+ function resetContext() {
1221
+ codeGenerationContext = '';
1222
+ showToast('Generation context reset', 'success');
1223
+ }
1224
+
1225
  function refineResponse(prompt, currentCode) {
1226
  const refinedPrompt = `Please refine this code based on the original prompt: "${decodeURIComponent(prompt)}"\n\nCurrent code:\n${decodeURIComponent(currentCode)}`;
1227
  document.getElementById('chatInput').value = refinedPrompt;
 
1324
  .then(data => {
1325
  if (data.length > 0) {
1326
  addLogEntry(`Loaded ${data.length} knowledge entries`, 'INFO');
1327
+ // Initialize context with knowledge
1328
+ codeGenerationContext = data.map(item => item.content).join('\n');
1329
  }
1330
  });
1331
+
1332
+ // Setup continue button in code panel
1333
+ const codePanel = document.querySelector('.code-block').parentElement;
1334
+ const continueBtn = document.createElement('button');
1335
+ continueBtn.className = 'absolute top-2 right-2 px-2 py-1 bg-yellow-500 text-white rounded text-xs';
1336
+ continueBtn.innerHTML = '<span class="en">Continue</span><span class="fa hidden rtl persian-font">ادامه</span>';
1337
+ continueBtn.onclick = function() {
1338
+ document.getElementById('chatInput').value = '[CONTINUE] ' +
1339
+ document.querySelector('.code-block code').textContent;
1340
+ generateWithDeepSeek();
1341
+ };
1342
+ codePanel.style.position = 'relative';
1343
+ codePanel.appendChild(continueBtn);
1344
  });
1345
 
1346
  function createPerformanceGraph() {
prompts.txt CHANGED
@@ -76,4 +76,8 @@ Check out the configuration
76
  Missing configuration in READMEدرستش کن
77
  خوب پیش نیازها رو باز دوباره بنویس آپدیت کنhttps://huggingface.co/docs/hub/spaces-config-reference ارور کانفیگوریشن رو برطرف کن
78
  این بخش باید یتونه خودش رو آپدیت کنه کل بخش های دیگه از طریق خروجی این چت ارتقاء پیدا کنن یعنی ادامه دستوراتی که اینجا به تو میدم اونجا توی چت فعل باشه و اعمال خروجی بروی خود داشته باشه
79
- اگر خروجی چت معنی آپدیت کل یا آپدیت دکمه یا عملکرد بود کدش رو از بخش چت بگیره و روی خودش اعمال کنه و بر روی هسته فعال کن فایل منابع داخلی اعمال کن تا یادگیری مداوم داشته باشه پیج
 
 
 
 
 
76
  Missing configuration in READMEدرستش کن
77
  خوب پیش نیازها رو باز دوباره بنویس آپدیت کنhttps://huggingface.co/docs/hub/spaces-config-reference ارور کانفیگوریشن رو برطرف کن
78
  این بخش باید یتونه خودش رو آپدیت کنه کل بخش های دیگه از طریق خروجی این چت ارتقاء پیدا کنن یعنی ادامه دستوراتی که اینجا به تو میدم اونجا توی چت فعل باشه و اعمال خروجی بروی خود داشته باشه
79
+ اگر خروجی چت معنی آپدیت کل یا آپدیت دکمه یا عملکرد بود کدش رو از بخش چت بگیره و روی خودش اعمال کنه و بر روی هسته فعال کن فایل منابع داخلی اعمال کن تا یادگیری مداوم داشته باشه پیج
80
+ Error: Invalid credentials in Authorization header درست کن . دستور راهنمای دستوری آپدیت داخلی.یادگیری مداوم به فایل ها
81
+ Error: Invalid credentials in Authorization header رفع ارور
82
+ بخش deep seek v3 رو تقویت کن .دستورات آپدیت رو بفهمه فایل آپدیت رو بساز درون خودش رفع ایراد کنه و از دستورات و چت کاربر پیروی کنه برای اعمال تغییرات محیط به فرم دستورات کاربر تغییر و واکنش دهد و یا آپدیت شود.
83
+ بخش deep seek v3 رو تقویت کن تا دستورات ادامه دادن کد رو به اون بدم و هر بخش تکمیل بشه!!!!