این بخش باید یتونه خودش رو آپدیت کنه کل بخش های دیگه از طریق خروجی این چت ارتقاء پیدا کنن یعنی ادامه دستوراتی که اینجا به تو میدم اونجا توی چت فعل باشه و اعمال خروجی بروی خود داشته باشه - Follow Up Deployment
Browse files- index.html +146 -35
- prompts.txt +2 -1
index.html
CHANGED
|
@@ -1020,49 +1020,160 @@ class AppBuilder:
|
|
| 1020 |
document.getElementById('chatResponse').classList.remove('hidden');
|
| 1021 |
document.getElementById('responseContent').textContent = 'Generating code...';
|
| 1022 |
|
| 1023 |
-
//
|
| 1024 |
-
|
| 1025 |
-
|
| 1026 |
-
|
| 1027 |
-
|
| 1028 |
-
|
| 1029 |
-
|
| 1030 |
-
|
| 1031 |
-
|
| 1032 |
-
|
| 1033 |
-
|
| 1034 |
-
|
| 1035 |
-
|
| 1036 |
-
`;
|
| 1037 |
-
showToast('Code generation failed', 'error');
|
| 1038 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1039 |
hljs.highlightAll();
|
| 1040 |
-
}
|
| 1041 |
}
|
| 1042 |
|
| 1043 |
-
|
| 1044 |
-
|
| 1045 |
-
|
| 1046 |
-
|
| 1047 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1048 |
|
| 1049 |
-
|
| 1050 |
-
|
| 1051 |
-
|
| 1052 |
-
|
| 1053 |
-
|
| 1054 |
-
|
| 1055 |
-
|
| 1056 |
-
|
| 1057 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1058 |
|
| 1059 |
-
|
| 1060 |
-
|
| 1061 |
-
|
| 1062 |
-
|
| 1063 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1064 |
}
|
| 1065 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1066 |
function createPerformanceGraph() {
|
| 1067 |
const data = Array.from({length: 15}, (_, i) => ({
|
| 1068 |
time: i,
|
|
|
|
| 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 => {
|
| 1034 |
+
if (data.error) {
|
| 1035 |
+
throw new Error(data.error);
|
|
|
|
|
|
|
| 1036 |
}
|
| 1037 |
+
|
| 1038 |
+
const generatedCode = data[0].generated_text;
|
| 1039 |
+
document.getElementById('responseContent').innerHTML = `
|
| 1040 |
+
<div class="mb-4">
|
| 1041 |
+
<p>Generated response:</p>
|
| 1042 |
+
<div class="bg-gray-100 dark:bg-gray-700 p-3 rounded mt-2">${generatedCode}</div>
|
| 1043 |
+
</div>
|
| 1044 |
+
<div class="flex space-x-2">
|
| 1045 |
+
<button onclick="applyCodeChanges('${encodeURIComponent(generatedCode)}')" class="px-3 py-1 bg-green-500 text-white rounded text-sm">
|
| 1046 |
+
<span class="en">Apply Changes</span>
|
| 1047 |
+
<span class="fa hidden rtl persian-font">اعمال تغییرات</span>
|
| 1048 |
+
</button>
|
| 1049 |
+
<button onclick="refineResponse('${encodeURIComponent(input)}', '${encodeURIComponent(generatedCode)}')" class="px-3 py-1 bg-blue-500 text-white rounded text-sm">
|
| 1050 |
+
<span class="en">Refine</span>
|
| 1051 |
+
<span class="fa hidden rtl persian-font">بهینهسازی</span>
|
| 1052 |
+
</button>
|
| 1053 |
+
</div>
|
| 1054 |
+
`;
|
| 1055 |
+
showToast('Code generated successfully', 'success');
|
| 1056 |
+
})
|
| 1057 |
+
.catch(error => {
|
| 1058 |
+
document.getElementById('responseContent').innerHTML = `
|
| 1059 |
+
<p class="text-red-500">Error: ${error.message}</p>
|
| 1060 |
+
`;
|
| 1061 |
+
showToast('Code generation failed', 'error');
|
| 1062 |
+
})
|
| 1063 |
+
.finally(() => {
|
| 1064 |
hljs.highlightAll();
|
| 1065 |
+
});
|
| 1066 |
}
|
| 1067 |
|
| 1068 |
+
function applyCodeChanges(code) {
|
| 1069 |
+
const decodedCode = decodeURIComponent(code);
|
| 1070 |
+
// Apply changes to the code preview
|
| 1071 |
+
document.querySelector('.code-block code').textContent = decodedCode;
|
| 1072 |
+
hljs.highlightAll();
|
| 1073 |
+
showToast('Changes applied to code preview', 'success');
|
| 1074 |
+
|
| 1075 |
+
// Auto-update related components
|
| 1076 |
+
updateRelatedComponents(decodedCode);
|
| 1077 |
+
}
|
| 1078 |
|
| 1079 |
+
function refineResponse(prompt, currentCode) {
|
| 1080 |
+
const refinedPrompt = `Please refine this code based on the original prompt: "${decodeURIComponent(prompt)}"\n\nCurrent code:\n${decodeURIComponent(currentCode)}`;
|
| 1081 |
+
document.getElementById('chatInput').value = refinedPrompt;
|
| 1082 |
+
generateWithDeepSeek();
|
| 1083 |
+
showToast('Refinement request sent', 'info');
|
| 1084 |
+
}
|
| 1085 |
+
|
| 1086 |
+
function updateRelatedComponents(code) {
|
| 1087 |
+
// Auto-update requirements if needed
|
| 1088 |
+
if (code.includes('import transformers')) {
|
| 1089 |
+
updateLibraryVersion('transformers', '4.30.0');
|
| 1090 |
+
}
|
| 1091 |
+
if (code.includes('import torch')) {
|
| 1092 |
+
updateLibraryVersion('torch', '2.0.1');
|
| 1093 |
+
}
|
| 1094 |
+
|
| 1095 |
+
// Add to logs
|
| 1096 |
+
addLogEntry('Code changes applied', 'INFO');
|
| 1097 |
+
|
| 1098 |
+
// Update performance graphs if needed
|
| 1099 |
+
if (code.includes('GPU') || code.includes('CUDA')) {
|
| 1100 |
+
updatePerformanceGraphs();
|
| 1101 |
+
}
|
| 1102 |
+
}
|
| 1103 |
+
|
| 1104 |
+
function updateLibraryVersion(libName, version) {
|
| 1105 |
+
const libElements = document.querySelectorAll('.text-sm.font-medium');
|
| 1106 |
+
libElements.forEach(el => {
|
| 1107 |
+
if (el.textContent.includes(libName)) {
|
| 1108 |
+
const versionSpan = el.nextElementSibling;
|
| 1109 |
+
versionSpan.textContent = `v${version}`;
|
| 1110 |
+
versionSpan.className = 'text-xs bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200 px-2 py-1 rounded';
|
| 1111 |
+
}
|
| 1112 |
+
});
|
| 1113 |
+
}
|
| 1114 |
+
|
| 1115 |
+
function addLogEntry(message, type) {
|
| 1116 |
+
const logsContainer = document.querySelector('.space-y-3.max-h-96');
|
| 1117 |
+
const newLog = document.createElement('div');
|
| 1118 |
+
newLog.className = `log-entry p-3 bg-gray-50 dark:bg-gray-800 rounded`;
|
| 1119 |
|
| 1120 |
+
const typeClass = type === 'ERROR' ? 'bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-200' :
|
| 1121 |
+
type === 'INFO' ? 'bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200' :
|
| 1122 |
+
'bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200';
|
| 1123 |
+
|
| 1124 |
+
newLog.innerHTML = `
|
| 1125 |
+
<div class="flex justify-between items-start">
|
| 1126 |
+
<div>
|
| 1127 |
+
<span class="text-sm font-medium en">${message}</span>
|
| 1128 |
+
<span class="text-sm font-medium fa hidden rtl persian-font">${message}</span>
|
| 1129 |
+
<p class="text-xs text-gray-500 dark:text-gray-400">Just now</p>
|
| 1130 |
+
</div>
|
| 1131 |
+
<span class="text-xs ${typeClass} px-2 py-1 rounded">${type}</span>
|
| 1132 |
+
</div>
|
| 1133 |
+
`;
|
| 1134 |
+
logsContainer.prepend(newLog);
|
| 1135 |
}
|
| 1136 |
|
| 1137 |
+
function updatePerformanceGraphs() {
|
| 1138 |
+
// Force re-render graphs with updated data
|
| 1139 |
+
d3.select("#performanceGraph").select("svg").remove();
|
| 1140 |
+
createPerformanceGraph();
|
| 1141 |
+
showToast('Performance graphs updated', 'info');
|
| 1142 |
+
}
|
| 1143 |
+
|
| 1144 |
+
// Initialize real-time chat updates
|
| 1145 |
+
function initChatUpdates() {
|
| 1146 |
+
// Check for updates every 5 seconds
|
| 1147 |
+
setInterval(() => {
|
| 1148 |
+
const lastMessage = document.querySelector('#chatResponse .bg-gray-100')?.textContent;
|
| 1149 |
+
if (lastMessage) {
|
| 1150 |
+
fetchChatUpdates(lastMessage)
|
| 1151 |
+
.then(updates => {
|
| 1152 |
+
if (updates.length > 0) {
|
| 1153 |
+
applyCodeChanges(updates[0].content);
|
| 1154 |
+
showToast('Auto-applied code improvements', 'info');
|
| 1155 |
+
}
|
| 1156 |
+
});
|
| 1157 |
+
}
|
| 1158 |
+
}, 5000);
|
| 1159 |
+
}
|
| 1160 |
+
|
| 1161 |
+
function fetchChatUpdates(lastKnownMessage) {
|
| 1162 |
+
// Simulate API call to check for updates
|
| 1163 |
+
return new Promise(resolve => {
|
| 1164 |
+
setTimeout(() => {
|
| 1165 |
+
// In a real implementation, this would query an API endpoint
|
| 1166 |
+
// that tracks conversation updates
|
| 1167 |
+
resolve([]); // Return empty array for demo
|
| 1168 |
+
}, 1000);
|
| 1169 |
+
});
|
| 1170 |
+
}
|
| 1171 |
+
|
| 1172 |
+
// Initialize on load
|
| 1173 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 1174 |
+
initChatUpdates();
|
| 1175 |
+
});
|
| 1176 |
+
|
| 1177 |
function createPerformanceGraph() {
|
| 1178 |
const data = Array.from({length: 15}, (_, i) => ({
|
| 1179 |
time: i,
|
prompts.txt
CHANGED
|
@@ -74,4 +74,5 @@ pinned: false
|
|
| 74 |
Check out the configuration
|
| 75 |
ارو میاد روی فضای برنامه.configuration error
|
| 76 |
Missing configuration in READMEدرستش کن
|
| 77 |
-
خوب پیش نیازها رو باز دوباره بنویس آپدیت کنhttps://huggingface.co/docs/hub/spaces-config-reference ارور کانفیگوریشن رو برطرف کن
|
|
|
|
|
|
| 74 |
Check out the configuration
|
| 75 |
ارو میاد روی فضای برنامه.configuration error
|
| 76 |
Missing configuration in READMEدرستش کن
|
| 77 |
+
خوب پیش نیازها رو باز دوباره بنویس آپدیت کنhttps://huggingface.co/docs/hub/spaces-config-reference ارور کانفیگوریشن رو برطرف کن
|
| 78 |
+
این بخش باید یتونه خودش رو آپدیت کنه کل بخش های دیگه از طریق خروجی این چت ارتقاء پیدا کنن یعنی ادامه دستوراتی که اینجا به تو میدم اونجا توی چت فعل باشه و اعمال خروجی بروی خود داشته باشه
|