R-Kentaren commited on
Commit
426783d
·
verified ·
1 Parent(s): 380204e

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. code/server/routes.py +3 -1
  2. index.html +39 -21
code/server/routes.py CHANGED
@@ -27,6 +27,7 @@ from gradio import Server
27
 
28
  from code.config.constants import (
29
  APP_TITLE,
 
30
  EXAMPLE_PROMPTS,
31
  LANGUAGE_OPTIONS,
32
  MODEL_CONFIGS,
@@ -82,7 +83,8 @@ async def homepage():
82
 
83
  config = json.dumps({
84
  "app_title": APP_TITLE,
85
- "model_id": MODEL_CONFIGS,
 
86
  "model_url": MODEL_URL,
87
  "languages": LANGUAGE_OPTIONS,
88
  "examples": [
 
27
 
28
  from code.config.constants import (
29
  APP_TITLE,
30
+ DEFAULT_MODEL_KEY,
31
  EXAMPLE_PROMPTS,
32
  LANGUAGE_OPTIONS,
33
  MODEL_CONFIGS,
 
83
 
84
  config = json.dumps({
85
  "app_title": APP_TITLE,
86
+ "model_id": MODEL_CONFIGS[DEFAULT_MODEL_KEY]["id"],
87
+ "model_configs": {k: {"name": v["name"], "type": v["type"], "description": v["description"]} for k, v in MODEL_CONFIGS.items()},
88
  "model_url": MODEL_URL,
89
  "languages": LANGUAGE_OPTIONS,
90
  "examples": [
index.html CHANGED
@@ -1169,13 +1169,14 @@ const state = {
1169
  document.addEventListener('DOMContentLoaded', () => {
1170
  document.title = CONFIG.app_title || 'Fullstack Code Builder';
1171
 
1172
- if (CONFIG.model_url) {
1173
- document.getElementById('model-pill').href = CONFIG.model_url;
1174
- document.getElementById('banner-model-link').href = CONFIG.model_url;
1175
- }
1176
- if (CONFIG.model_id) {
1177
- document.getElementById('model-pill-text').textContent = CONFIG.model_id.split('/').pop();
1178
- }
 
1179
 
1180
  // Populate language/framework selects
1181
  populateLanguageSelects();
@@ -1282,16 +1283,32 @@ async function pollModelStatus() {
1282
  function populateLanguageSelects() {
1283
  const langSelect = document.getElementById('lang-select');
1284
  const fwSelect = document.getElementById('framework-select');
1285
-
1286
- if (CONFIG.languages) {
1287
- CONFIG.languages.forEach(([lang, frameworks]) => {
1288
- const opt = document.createElement('option');
1289
- opt.value = lang;
1290
- opt.textContent = lang;
1291
- if (lang === 'Python') opt.selected = true;
1292
- langSelect.appendChild(opt);
1293
- });
1294
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1295
 
1296
  onLanguageChange();
1297
  }
@@ -1305,15 +1322,16 @@ function onLanguageChange() {
1305
 
1306
  // Update frameworks
1307
  fwSelect.innerHTML = '';
1308
- const frameworks = (CONFIG.languages || []).find(([l]) => l === selectedLang);
1309
- if (frameworks && frameworks[1]) {
1310
- frameworks[1].forEach((fw) => {
 
1311
  const opt = document.createElement('option');
1312
  opt.value = fw;
1313
  opt.textContent = fw;
1314
  fwSelect.appendChild(opt);
1315
  });
1316
- state.targetFramework = frameworks[1][0];
1317
  }
1318
 
1319
  fwSelect.onchange = () => {
 
1169
  document.addEventListener('DOMContentLoaded', () => {
1170
  document.title = CONFIG.app_title || 'Fullstack Code Builder';
1171
 
1172
+ try {
1173
+ if (CONFIG.model_url) {
1174
+ document.getElementById('model-pill').href = CONFIG.model_url;
1175
+ document.getElementById('banner-model-link').href = CONFIG.model_url;
1176
+ }
1177
+ const modelId = typeof CONFIG.model_id === 'string' ? CONFIG.model_id : (CONFIG.model_configs ? Object.values(CONFIG.model_configs)[0]?.name || 'AI Model' : 'AI Model');
1178
+ document.getElementById('model-pill-text').textContent = modelId.split('/').pop();
1179
+ } catch (e) { console.warn('Model pill setup error:', e); }
1180
 
1181
  // Populate language/framework selects
1182
  populateLanguageSelects();
 
1283
  function populateLanguageSelects() {
1284
  const langSelect = document.getElementById('lang-select');
1285
  const fwSelect = document.getElementById('framework-select');
1286
+ if (!langSelect || !fwSelect) return;
1287
+
1288
+ // Fallback languages if CONFIG not loaded
1289
+ const languages = CONFIG.languages || [
1290
+ ["Python", ["Gradio", "Flask", "Django", "FastAPI", "Streamlit", "Plain Python"]],
1291
+ ["JavaScript", ["React", "Vue.js", "Next.js", "Express.js", "Node.js", "Vanilla JS"]],
1292
+ ["TypeScript", ["React", "Next.js", "Express.js", "NestJS"]],
1293
+ ["HTML/CSS/JS", ["Tailwind CSS", "Bootstrap", "Vanilla"]],
1294
+ ["Java", ["Spring Boot", "Maven", "Gradle"]],
1295
+ ["Go", ["Gin", "Fiber", "Echo", "Plain Go"]],
1296
+ ["Rust", ["Actix", "Axum", "Rocket"]],
1297
+ ["PHP", ["Laravel", "Symfony", "Plain PHP"]],
1298
+ ["Ruby", ["Rails", "Sinatra"]],
1299
+ ["C#", ["ASP.NET", "Blazor"]],
1300
+ ["Swift", ["Vapor", "SwiftUI"]],
1301
+ ["Kotlin", ["Ktor", "Spring Boot"]],
1302
+ ];
1303
+
1304
+ languages.forEach((entry) => {
1305
+ const lang = Array.isArray(entry) ? entry[0] : entry;
1306
+ const opt = document.createElement('option');
1307
+ opt.value = lang;
1308
+ opt.textContent = lang;
1309
+ if (lang === 'Python') opt.selected = true;
1310
+ langSelect.appendChild(opt);
1311
+ });
1312
 
1313
  onLanguageChange();
1314
  }
 
1322
 
1323
  // Update frameworks
1324
  fwSelect.innerHTML = '';
1325
+ const languages = CONFIG.languages || [];
1326
+ const entry = languages.find((e) => (Array.isArray(e) ? e[0] : e) === selectedLang);
1327
+ if (entry && Array.isArray(entry) && entry[1]) {
1328
+ entry[1].forEach((fw) => {
1329
  const opt = document.createElement('option');
1330
  opt.value = fw;
1331
  opt.textContent = fw;
1332
  fwSelect.appendChild(opt);
1333
  });
1334
+ state.targetFramework = entry[1][0];
1335
  }
1336
 
1337
  fwSelect.onchange = () => {